TypeScript SDK#
Native fetch. Zero runtime deps. Full type defs. Node 19+ or Bun.
Install#
bun add rustbox
# or: npm install rustbox / pnpm add rustbox
Quickstart#
import { Rustbox } from "rustbox";
const client = new Rustbox(process.env.RUSTBOX_API_KEY!);
const result = await client.run({
language: "python",
code: "print('hello')",
});
console.log(result.verdict, result.stdout); // AC hello
run() submits, waits for sync completion, polls if needed, returns the verdict.
Errors#
import {
RustboxAuthError,
RustboxRateLimitError,
RustboxServerError,
RustboxTimeoutError,
} from "rustbox";
try {
await client.run({ language: "python", code: "..." });
} catch (e) {
if (e instanceof RustboxAuthError) { /* 401/403 - check API key */ }
if (e instanceof RustboxRateLimitError) { /* 429 - back off */ }
if (e instanceof RustboxServerError) { /* 5xx - SDK already retried */ }
if (e instanceof RustboxTimeoutError) { /* exceeded timeoutMs */ }
}
Configuration#
new Rustbox(apiKey, {
baseUrl: "https://rustbox.orkait.com", // default
timeoutMs: 65_000, // default
maxRetries: 2, // default (3 attempts total)
});
Webhooks#
// Configure the webhook endpoint on the project in the dashboard first.
await client.submit({
language: "python",
code: "...",
}, false); // wait=false, returns id immediately
See Webhooks for HMAC verification.