Documentation
API Reference
REST API endpoints for quota management, usage tracking, and session history
Quick Start
Connect your existing Puppeteer, Playwright, or CDP automation to BotCloud by swapping your WebSocket endpoint to wss://cloud.bots.win. No code rewrites — just one line change.
import puppeteer from "puppeteer-core";
const params = new URLSearchParams({
token: process.env.BOTCLOUD_TOKEN,
"--proxy-server": process.env.BOTCLOUD_PROXY,
device_type: "mac",
});
const browser = await puppeteer.connect({
browserWSEndpoint: `wss://cloud.bots.win?${params.toString()}`,
});
const page = await browser.newPage();
await page.goto("https://example.com");
await page.screenshot({ path: "screenshot.png" });
await browser.close();Authentication
All API endpoints require Bearer token authentication
# All API endpoints require Bearer token authentication
curl -H "Authorization: Bearer your-user-token-here" \
https://cloud.bots.win/api/quotaGET /api/quota
Check remaining quota before launching jobs
/api/quotaResponse: Returns total, used, remaining quota and percentage used
curl -H "Authorization: Bearer your-token" https://cloud.bots.win/api/quotaGET /api/usage
Get usage statistics for reporting and cost analysis
/api/usageResponse: Returns total sessions, total minutes, and active sessions count
curl -H "Authorization: Bearer your-token" https://cloud.bots.win/api/usageGET /api/history
Retrieve session history for audit trails
/api/historyParameters: Optional start and end query parameters (ISO 8601 timestamps)
Response: Returns array of session objects with duration and disconnect reasons
curl -H "Authorization: Bearer your-token" https://cloud.bots.win/api/historyPOST /api/user-data
Create a new User Data container for persistent browser state (cookies, localStorage, etc.)
/api/user-dataResponse: Returns the created User Data ID and timestamp
curl -X POST -H "Authorization: Bearer your-token" https://cloud.bots.win/api/user-dataGET /api/user-data
List all User Data containers for the authenticated user
/api/user-dataResponse: Returns array of User Data objects with quota information
curl -H "Authorization: Bearer your-token" https://cloud.bots.win/api/user-dataDELETE /api/user-data/:id
Delete a User Data container and release quota
/api/user-data/:idResponse: Returns success status
curl -X DELETE -H "Authorization: Bearer your-token" \
https://cloud.bots.win/api/user-data/udd_abc123xyz789defgFramework Integration
Puppeteer, PuppeteerSharp, Playwright (Node.js / Python / .NET), raw CDP, Go (chromedp / rod), Java (native WebSocket), and Ruby (Ferrum) all work without code rewrites. Swap wss://cloud.bots.win as your endpoint and pass your token, proxy, and device type as query parameters.
import puppeteer from "puppeteer-core";
const params = new URLSearchParams({
token: process.env.BOTCLOUD_TOKEN,
"--proxy-server": process.env.BOTCLOUD_PROXY,
device_type: "mac",
});
const browser = await puppeteer.connect({
browserWSEndpoint: `wss://cloud.bots.win?${params.toString()}`,
});
const page = await browser.newPage();
await page.goto("https://example.com");
await page.screenshot({ path: "screenshot.png" });
await browser.close();Billing Model
Subscription plans include monthly browser hours. Once exhausted, additional usage is billed from your prepaid balance at the plan's overage rate.
Connection Errors
These errors happen during connection setup — the session is never created, so it will not appear in /api/history. Check the HTTP status and the message in the response body to handle them.
| HTTP Status | Cause |
|---|---|
| 400 | The --proxy-server query parameter is missing or malformed |
| 401 | Token is missing or invalid |
| 401 | Subscription is not active (no subscription, lapsed, or period expired) |
| 401 | Trial token has expired or its quota is used up |
| 403 | Account balance ran out — no remaining subscription hours and balance is zero |
| 429 | Trial accounts are limited to 1 active session at a time |
Disconnect Reasons
Once a session has been opened, it will eventually end with one of the reasons below — recorded in /api/history. Use these codes for error handling and audit trails.
| Code | Description |
|---|---|
| socket_close | Client closed the connection (e.g. browser.close() or process exit) — most common, normal completion |
| idle_timeout | No activity from the client for an extended period — session ended by the gateway |
| browser_close_graceful | Browser closed itself (e.g. window.close() called from within the page) |
| trial_exhausted | Trial quota was used up during the session |
| primary_blocked:Insufficient balance | Account balance ran out mid-session — gateway closed the session |
| primary_blocked:Subscription lapsed or expired | Subscription expired or became inactive mid-session |
| browser_disconnect | Browser disconnected from the gateway — safe to retry |
| browser_crash | Browser process crashed — safe to retry |
| gateway_crash | Gateway restarted — your session was terminated, safe to retry |
| socket_error | Network-level error (TCP reset or abnormal close) |