Developers

Ten lines of Python get an agent a desktop, work it, and give it back. Watch each line become an HTTP call.

Python clientIllustrative
# illustrative: not run against a live servicefrom deskspawn import Deskspawn ds = Deskspawn(api_key="YOUR_KEY")with ds.computer() as c:    c.click(400, 300)    png = c.screenshot()    c.type("hello")    c.key("Return")    c.scroll(400, 300, "down", 3)    out = c.bash("ls /tmp")    c.save_screenshot("shot.png")
  1. POST/v1/computers

    Needs the fleet key. Hands out a warm desktop with its own bearer token, shown once.

  2. POST/v1/computers/{id}/control/click

    Needs the desktop's token. The fleet's proxy forwards it to that desktop.

  3. GET/v1/computers/{id}/control/screenshot

    Returns the screen as a PNG.

  4. POST/v1/computers/{id}/control/type

    Types the text.

  5. POST/v1/computers/{id}/control/key

    Presses a key.

  6. POST/v1/computers/{id}/control/scroll

    Scrolls at a point on the screen.

  7. POST/v1/computers/{id}/control/bash

    Runs a shell command and returns its exit code, stdout and stderr.

  8. GET/v1/computers/{id}/control/screenshot

    Saves the screen to a file.

  9. DELETE/v1/computers/{id}

    Leaving the with block destroys the desktop. The container is removed, not reused.

The HTTP API

Two kinds of credential. The fleet key opens the fleet. A desktop's own bearer token opens that desktop and nothing else.

Routes and what each one needs
RouteNeedsDoes
GET /healthNothingSays the fleet is up.
GET /v1/poolFleet keyReads the warm pool.
GET, POST /v1/computersFleet keyLists desktops, or hands one out.
GET, DELETE /v1/computers/{id}Desktop tokenReads one desktop, or destroys it.
POST /v1/computers/{id}/pause, /resumeDesktop tokenFreezes a desktop, or wakes it.
POST /v1/computers/{id}/stop, /startDesktop tokenStops a desktop and keeps its home, or starts it again.
ANY /v1/computers/{id}/control/*Desktop tokenThe control verbs: screenshot, click, type, key, scroll and bash.

The same in JavaScript

The JavaScript client has the same shape, with camelCase names and promises.

The Python client uses only the standard library: nothing to install. The Python client also has a command line with pool, new, ls, shot, click, type, key, scroll, bash, pause, resume, rm, vnc and run.

The clients are part of the private prototype and are not published yet. Ask about access.

JavaScript clientIllustrative
// illustrative: not run against a live service
import { Deskspawn } from "./deskspawn.mjs";

const ds = new Deskspawn({ apiKey: "YOUR_KEY" });
await ds.withComputer(async (c) => {
  await c.click(400, 300);
  const png = await c.screenshot();
  await c.type("hello");
  await c.key("Return");
  await c.scroll(400, 300, -3);
  const out = await c.bash("ls /tmp");
  await c.saveScreenshot("shot.png");
});