Broker APIs

Capital.com API Bot Guide: Sessions, Demo and Common Checks

A technical overview of using Capital.com Public API with demo endpoints, sessions, tokens, rate limits and defensive bot design.

Broker view showing small crypto CFD test positions
Hands-on screenshot: broker state is the source of truth after an order request.

A technical overview of using Capital.com Public API with demo endpoints, sessions, tokens, rate limits and defensive bot design.

Updated 2026-09-06Broker APIsPractical guide2 min read

In plain English

This guide treats the broker as an external API with its own authentication, symbols, limits and failure states. A successful HTTP request is not always the same as a confirmed final action.

authenticationdemorate limitorder confirmation

Start with the demo base URL

Capital.com's current public documentation lists separate live and demo base URLs and uses /api/v1 endpoints. Build the endpoint choice into configuration so live cannot be selected accidentally.

CAPITAL_ENV=demo
CAPITAL_DEMO_BASE=https://demo-api-capital.backend-capital.com
CAPITAL_LIVE_BASE=https://api-capital.backend-capital.com

Sessions are state

The documentation states that a session is launched with POST /api/v1/session. Authenticated requests use session tokens such as CST and X-SECURITY-TOKEN. The docs also currently state that a REST session is active for ten minutes and that the session-creation endpoint is limited to one request per second per API key.

Do not re-login on every price tick. Cache the session, refresh or recreate it when necessary, and serialize session creation so multiple workers do not stampede the login endpoint.

Use a connectivity check

A health routine can distinguish “process is alive” from “broker API is reachable”. Capital.com documents a time endpoint that does not require authentication and a ping endpoint that uses session tokens.

Before placing any order

Practical lesson from real bot debugging: broker-side risk rejections are useful information. Do not “solve” a rejection by blindly retrying with more orders. Log the broker reason, inspect account/market constraints, and change code only when you understand the cause.

Before you rely on this in production

  • Demo/live environments are clearly separated.
  • Authentication renewal is handled.
  • Position/order state is checked before retrying.
  • Rate limits and final confirmations are logged.