- Documentation agents use machine-readable documentation to answer integration questions, generate code, and navigate the API surface.
- Trading agents use a dedicated agent wallet to read market and account state, sign approved actions, and react to real-time WebSocket events without exposing the master account’s private key.
An AI model should never be treated as the final authority for order parameters, balances, or risk limits. Validate generated payloads in code and enforce deterministic checks before signing or submitting any write request.
Recommended architecture
1
Discover the documentation
Start with
/llms.txt to identify the relevant pages and endpoints without loading the entire documentation set.2
Load only the context you need
Fetch individual pages for focused tasks, or use
/llms-full.txt when the agent needs broad API context for code generation or retrieval.3
Read public and account state
Use
POST /info for market configuration, prices, order books, orders, balances, positions, and authorized agent records. Read requests do not require request signing.4
Execute through a controlled signer
Send state-changing operations through
POST /exchange. Keep the master key offline and authorize a separate API wallet with approveAgent for automated execution.5
React to real-time events
Subscribe to the WebSocket API for order-book updates, trades, candles, order changes, open orders, and fills instead of repeatedly polling REST endpoints.
Choose the right integration path
Machine-readable docs
Give coding assistants and custom agents a concise documentation index or the full API reference in Markdown.
Agent wallets
Delegate trading actions to a separate wallet, set an expiry, monitor authorization, and revoke access when needed.
Read API
Retrieve configuration, live market state, account state, and order data without signing.
WebSocket streams
Maintain a synchronized local view of market and account events for low-latency agent workflows.
Agent control loop
A production trading agent should separate reasoning from execution:- Observe — read configuration and current state from REST, then keep it fresh through WebSocket subscriptions.
- Propose — let the model or strategy engine produce a structured intent, such as side, contract, size, price, and risk rationale.
- Validate — enforce deterministic rules for contract IDs, numeric precision, maximum position size, leverage, reduce-only behavior, available margin, and allowed action types.
- Sign — sign only the validated action with the authorized agent wallet and a unique nonce.
- Submit — send the envelope to
POST /exchangeand inspect both transport-level and business-level errors. - Reconcile — confirm the resulting order or fill through
POST /infoand private WebSocket channels.
Starter system prompt
Use the following as a base prompt for an API-aware coding agent:Production checklist
- Pin explicit risk limits outside the model prompt.
- Reject unknown fields and unsupported action types with a strict schema.
- Use a named agent wallet with an expiry for each environment or strategy.
- Maintain a monotonic nonce per signing address.
- Reconcile every submitted action against order and fill updates.
- Add a kill switch that revokes the agent and stops the signer independently of the model.
- Test against non-production infrastructure and small limits before increasing exposure.