Before you start
- An API key. See Authentication.
curlfor REST requests and any WebSocket client that can send headers, for example websocat.
1. Find a security
Every data request needs anexchange and a symbol. Look them up with search:
exchange and symbol pair you can pass to the other endpoints. Always take the pair from here: exchange codes are TakeProfit’s own, not the MIC of the listing venue, so Apple comes back as exchange=BATS, not XNAS. The same symbol usually trades on several exchanges, so pick the one you want:
2. Load historical candles
Ask for hourly candles from a given timestamp. The range is optional — without it you get the most recent 1000 candles — sofrom, to, period and limit are there to narrow the window. Note that period counts seconds (86400), it is not a timeframe id:
78562 rather than 78562.00. Parse the strings with a decimal type, never a float.
Valid timeframe ids come from GET /api/v1/marketdata/timeframes.
3. Subscribe to live candles
Open a WebSocket connection with the subscription parameters in the query string and the key in the handshake header:"isLast": true — it closes the history the stream starts from. Every later frame for the forming candle arrives with "isLast": false and the same timestamp, so update the candle in place instead of appending it.
Errors
A REST error, or a rejected WebSocket handshake, comes back as an HTTP status with a JSON body:code is stable enough to branch on: invalid_argument for a bad or unknown parameter, unauthenticated for a missing or rejected key, not_found for an exchange or symbol that is not served.
Next steps
- Browse the endpoints in the REST API and WebSocket API groups of this tab.
- Read the Overview for what each group returns and how credits are charged.