AI coding agents
Give Claude Code, Cursor, Copilot and other coding agents the docs in a form they read well.
Coding agents write better integrations when they read the real documentation instead of guessing from what they saw in training. These docs are published in formats made for them.
Docs for agents
| URL | What it is |
|---|---|
/llms.txt | An index of every page with a link to its Markdown version, in the llms.txt format |
/llms-full.txt | All of API v2 in one Markdown file — guides plus the full Account API and Trading API reference |
/docs/<page>.mdx | Any page as Markdown: append .mdx to its address, e.g. /docs/quickstart.mdx |
api.api2trade.com/v2/openapi.json | OpenAPI spec of the Account API |
/openapi/trading-api-mt5.json | OpenAPI spec of the Trading API — the same endpoints for MT4 |
Every page also has a Copy Markdown button below its title, and an Open in menu that hands the page to ChatGPT or Claude.
Point your agent at them
Most agents can read a URL. Give yours this one and ask it to read it before writing any code against the API:
https://docs.api2trade.com/llms-full.txtFor agents that take standing instructions from a file in your repository —
AGENTS.md (Codex, Copilot, Cursor and others), CLAUDE.md (Claude Code) or
your editor's rules file — add the brief below.
A brief for your repository
The things agents most often get wrong with this API, in a form you can paste as it is:
## API2Trade (MetaTrader 4/5 API)
Docs: https://docs.api2trade.com/llms-full.txt — read them before writing API code.
- Use API v2 only. API v1 (Legacy: /RegisterAccount, the ?id= query parameter)
is switched off on 31 December 2026.
- Every REST request sends the header `X-API-Key`. Read the key from the
environment variable API2TRADE_API_KEY; never hard-code or log it.
- Connecting an account: POST https://api.api2trade.com/v2/accounts with
accountNumber, name, type ("Metatrader 4" | "Metatrader 5"), accountPassword
and accountServerHost (the server name exactly as the broker writes it).
It returns at once with terminalStatus "provisioning". Poll
GET /v2/accounts/{id} until terminalStatus is "ready" — or "error", where
terminalLastError says why; do not retry the same credentials.
- Each account has its own base URL: https://api.api2trade.com/v2/{account_id}/
(e.g. GET AccountSummary, GET getQuote?symbol=EURUSD, POST OrderSend with a
JSON body). MT4 and MT5 accounts have the same endpoints.
- Before trusting balances or quotes, check GET /status: broker.connected and
account.loggedIn must both be true. An account that has not logged in still
answers 200 — with zeros.
- Live data: one WebSocket per account,
wss://api.api2trade.com/v2/{account_id}/ws?api_key=<key> — the only place the
key goes in a URL. Send {"action":"subscribe","topic":"prices","symbol":"EURUSD"};
topics: prices, bars (with timeframe M1…MN1), account, positions, trades,
orders, terminal. Frames are typed tick, bar, account, positions, trade,
modify, order, terminal; ignore unknown types. Add up `dropped` from "warning"
frames; reconnect with backoff, resubscribing to trades with
"since": <last frame's time> to replay what you missed.
- Errors are JSON {"error": CODE, "message": text}. Branch on `error`, never on
`message`. 401 is a wrong key, 403 means your plan's account limit is
reached, 404 means no such account or no access, 429 means too many different
accounts connected recently. Retry reads on 503 and 504 with backoff.
- Orders: send every POST OrderSend with a unique clientOrderId and reuse it on
retries — a repeat never places a second order (needs bridge.version 0.17.0+
on MT5 / 0.15.0+ on MT4 in GET /status; older versions ignore the id). Never
resend an order after a 504 MRPC_TRADE_OUTCOME_UNKNOWN without that id. A 200
only means the broker answered; check `success` and `retcode`.Keep the brief short
Agents follow a short brief more reliably than a long one. For everything else, let them read the docs — that is what the Markdown versions are for.