Skip to content
Docs
Get API Access
Browse the Documentation

API Reference

Streaming

Browser access to the WebSocket stream without an API key in the browser.

Read from the running API at , version 1.0.0, and read again every 5 minutes.

Every endpoint here authenticates with X-API-Key, answers in the standard envelope and fails with the standard error body.

Issue a single-use stream ticket for a browser

POSThttps://api.cantoncap.cc/v1/stream/tickets
createStreamTicket

Call this from your server, never from a browser. The ticket opens one WebSocket stream from one web origin, so a browser can stream without holding your API key. Pass it to the page, which opens wss://api.cantoncap.cc/v1/stream offering the subprotocols cantoncap.v1 and cantoncap.ticket.<ticket>; the gateway answers with cantoncap.v1. Never put a ticket in a URL: a handshake that carries one in its query string is refused and the ticket is used up. A ticket is bound to this key, its account and plan, and the origin given here; it is redeemed once, and expires 30 seconds after issue. Redemption re-checks the account and takes one of its stream connections, and counts toward its minute limit. Plans without streaming are refused with 403 plan_not_authorized. Issuing a ticket counts toward the minute limit.

Credits: 0 credits.

Parameters

This endpoint takes no parameters.

Request Body

application/json
{
  "origin": "https://app.example.com"
}
  • originstring

    The web origin of the page that will open the stream: an https origin, or http on localhost, 127.0.0.1 or [::1], written exactly as a browser sends it in Origin (scheme and host, an optional non-default port, no path or trailing slash).

Request

curl -s -X POST "https://api.cantoncap.cc/v1/stream/tickets" \
  -H "X-API-Key: $CANTONCAP_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"origin":"https://app.example.com"}'

Response

200 A ticket redeemable once, from the given origin, until expires_at.

Example Response
{
  "status": {
    "timestamp": "2026-10-11T14:00:00.000Z",
    "elapsed_ms": 18,
    "error_code": 0,
    "error_message": null,
    "request_id": "req_7Hk2pQ9xLm"
  },
  "data": {
    "ticket": "cst_Xq8vN2cTf0LmZ7rKpA4sWb1hYe9uJd3gQo6iVxC5nRt",
    "origin": "https://app.example.com",
    "expires_at": "2026-10-11T14:00:30.000Z"
  }
}
  • dataobject
    3 child fields
    • ticketstring

      Opaque single-use ticket. Treat it as a secret until it is redeemed.

    • originstring

      The origin the ticket is bound to.

    • expires_atdate-time

      When the ticket stops being redeemable, at most 30 seconds after issue.

Headers

  • X-RateLimit-Limit Maximum requests admitted in the current plan window, which every key of an account shares.
  • X-RateLimit-Remaining Requests remaining in the current plan window, across every key of the account.
  • X-RateLimit-Reset Unix timestamp in seconds when the current plan window resets.
  • Cache-Control private, no-store Prevents every cache, private or shared, from storing the response. Every error response carries it.

Errors

StatusCodeWhenerror_code todayFrom launch
400invalid_requestA parameter, body or cursor is invalid.1000400
401unauthenticatedThe X-API-Key header is missing or empty.10011002
401unauthenticatedThe API key is unknown, malformed or deleted.10011001
402payment_requiredThe account is not activated.4021003
402payment_requiredThe account's paid period has ended unpaid.4021004
403forbiddenThe API key is disabled or does not resolve to an active plan.10021007
403forbiddenThe API key's account is suspended.10021007
403forbiddenThe API key lacks a permission the operation needs.10021006
403plan_not_authorizedThe API plan does not include the operation.4031006
403quota_exceededThe requested history or page size exceeds the API plan.10061006
404not_foundThe resource does not exist or is not published.1003404
429rate_limitedThe account's per-minute request limit is used up.10051008
429credit_limit_reachedThe account's monthly credits are used up.4291010
429ip_rate_limitedToo many requests without a valid API key came from this address.4291011
500internal_errorThe server failed unexpectedly.1009500
503source_unavailableA data or quota store is unavailable, or the service is at capacity.1008503
Esc
navigateopenEscclose