TypeScript SDK
Use Masko's account and canonical API from Node.js or Electron main on macOS. The SDK runs the Masko runtime for sign-in and requests. It does not display mascots.
Install
npm install @masko/sdk@masko/sdk needs Node.js 20+ and macOS 14+. Install the runtime with the terminal setup, or bundle it with your app.
Use
import { Masko } from '@masko/sdk';
const client = Masko.client(); // Reuses your saved login.
const credits = await client.credits();
const mascots = await client.studio('GET', 'mascots');Upgrading from 0.1.0
Version 0.2.0 removes the on-screen API: Masko.mascot, Masko.connect, Masko.playback, and the mascot methods show, state, play, position and resize. Floating mascots now run in Masko Desktop. Keep using Masko.client() for account and Studio calls, and keep API keys on your server.
Methods
| Call | Result |
|---|---|
Masko.client({ apiURL?, apiKey?, runtimePath? }) | Creates a client. An apiKey stays in memory. |
client.login({ noBrowser?, device?, apiKey? }) | Signs in with a browser or device code, or validates and saves an API key. |
client.logout() | Revokes the saved session. |
client.whoami() | Returns the current account and session. |
client.credits() | Returns the credit balance: total, subscription and top-up. |
client.studio(method, path, body?) | Calls a canonical v1 path with GET, POST, PATCH or DELETE. |
client.assets.show(id) | Returns one asset. |
client.assets.download(id, { output }) | Downloads one asset to output. |
studio() paths are relative to /v1 and must start with mascots, canvases, projects, jobs, assets or upload. Other paths are rejected before any request is sent. Use the migration guide for current route names.
Keys and errors
Use this SDK on a server, or in trusted tooling. Never put an API key in a shipped app or a public repository. The SDK sends an in-memory key to the runtime over stdin, never as a command argument.
Errors are MaskoError objects with code, message and optional details. Account and studio calls need the macOS runtime, so call them from Electron main or Node.js, never from a browser page or renderer.
Next steps
Read the quickstart for the REST calls behind these operations, and the authentication guide for API keys and workspaces.
