The API is described in froog.tech/openapi.json (OpenAPI 3.1). Three dependency-free clients are generated from it, one file each (download again to update):
# Python 3.8+, imported as froogdev
$ curl -fsSL https://froog.tech/sdk/froog.py -o froogdev.py
# TypeScript: Node 18+, Deno, Bun or a browser (also as ../sdk/froog.ts)
$ npm install froogdev
# Go 1.21+, package froog
$ mkdir -p froog && curl -fsSL https://froog.tech/sdk/froog.go -o froog/froog.goFiles: froog.py, froog.ts, froog.go. create waits until the sandbox runs. Leaving the with / await using scope (or Go's Delete) deletes it, unless created with keep=True.
# Python
from froogdev import Froog
froog = Froog() # FROOG_API_KEY from the environment
with froog.sandboxes.create(size="small", env={"TENANT_ID": "42"}) as sb:
sb.files.write("app.py", "print('hi')")
print(sb.exec("python3 app.py", check=True).stdout) # check=True raises CommandError on non-zero exit
for e in sb.exec_stream("make test"):
print(e.get("data", ""), end="")
// TypeScript
import { Froog } from "froogdev";
const froog = new Froog({ apiKey: process.env.FROOG_API_KEY });
await using sb = await froog.sandboxes.create({ size: "small" });
const r = await sb.exec("uname -a", { cwd: "/tmp", timeout: 60 });
for await (const e of sb.execStream("make test")) if (e.type === "stdout") process.stdout.write(e.data);
// Go
c := froog.New("")
sb, err := c.Sandboxes.Create(ctx, froog.CreateSandbox{Size: froog.Ptr(froog.SizeSmall)})
if err != nil { return err }
defer sb.Delete(context.Background())
r, err := sb.Exec(ctx, "uname -a", &froog.ExecOptions{Cwd: "/tmp", Timeout: time.Minute})The sandbox object has:
exec(cmd, cwd=, env=, stdin=, timeout=),exec_stream(...)files.read,read_text,write,list,info,exists,remove,mkdir,move,watch(path)start,stop(both wait),fork(name),deletesnapshot(label),host(port)(the URL),metrics,refreshwait_for_port(port, timeout): up to 600 s, then a408 timeouterror
froog.sandboxes.get(name) and froog.sandboxes.list(label=["team=a", "tier"]) (all labels must match) return sandboxes that are never deleted at block end. Go: c.Sandbox(name) makes a handle without a request.
Background commands run as jobs and survive the connection:
server = sb.spawn("npm run dev", cwd="app", env={"PORT": "3000"})
sb.wait_for_port(3000)
print(sb.host(3000), server.logs())
server.kill()
build = sb.spawn("make build")
for chunk in build.follow(): print(chunk, end="")
print(build.wait()) # exit code
p = sb.process("job_…") # reconnect later
sb.processes() # all, newest first
repl = sb.spawn("python3 -i", stdin_open=True) # TS stdinOpen, Go StdinOpen
repl.write("print(6 * 7)\n")
repl.close_stdin()Python also has AsyncFroog, the same methods as coroutines.
Each client also has one flat method per operationId (create_sandboxes(body, idempotency_key=), wait_until, exec…): path parameters, then body, then query.
Errors raise FroogError (Go: *froog.Error) with the HTTP status, error code, message and request id. TypeScript and Go include types for every request and response.