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/quota

GET /api/quota

Check remaining quota before launching jobs

GET/api/quota

Response: Returns total, used, remaining quota and percentage used

curl -H "Authorization: Bearer your-token" https://cloud.bots.win/api/quota

GET /api/usage

Get usage statistics for reporting and cost analysis

GET/api/usage

Response: Returns total sessions, total minutes, and active sessions count

curl -H "Authorization: Bearer your-token" https://cloud.bots.win/api/usage

GET /api/history

Retrieve session history for audit trails

GET/api/history

Parameters: 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/history

POST /api/user-data

Create a new User Data container for persistent browser state (cookies, localStorage, etc.)

POST/api/user-data

Response: Returns the created User Data ID and timestamp

curl -X POST -H "Authorization: Bearer your-token" https://cloud.bots.win/api/user-data

GET /api/user-data

List all User Data containers for the authenticated user

GET/api/user-data

Response: Returns array of User Data objects with quota information

curl -H "Authorization: Bearer your-token" https://cloud.bots.win/api/user-data

DELETE /api/user-data/:id

Delete a User Data container and release quota

DELETE/api/user-data/:id

Response: Returns success status

curl -X DELETE -H "Authorization: Bearer your-token" \
  https://cloud.bots.win/api/user-data/udd_abc123xyz789defg

Framework 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 StatusCause
400The --proxy-server query parameter is missing or malformed
401Token is missing or invalid
401Subscription is not active (no subscription, lapsed, or period expired)
401Trial token has expired or its quota is used up
403Account balance ran out — no remaining subscription hours and balance is zero
429Trial 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.

CodeDescription
socket_closeClient closed the connection (e.g. browser.close() or process exit) — most common, normal completion
idle_timeoutNo activity from the client for an extended period — session ended by the gateway
browser_close_gracefulBrowser closed itself (e.g. window.close() called from within the page)
trial_exhaustedTrial quota was used up during the session
primary_blocked:Insufficient balanceAccount balance ran out mid-session — gateway closed the session
primary_blocked:Subscription lapsed or expiredSubscription expired or became inactive mid-session
browser_disconnectBrowser disconnected from the gateway — safe to retry
browser_crashBrowser process crashed — safe to retry
gateway_crashGateway restarted — your session was terminated, safe to retry
socket_errorNetwork-level error (TCP reset or abnormal close)