Create a trading key
1
Open token settings
Open takeprofit.com/settings/account, go to Login & Security and scroll to Personal API Tokens. Click Generate New Token.
2
Pick the trading scope
Name the token, for example
grid-bot, and tick TRADING:ACCESS:WRITE. Trading scopes can’t be combined with other scopes, so keep a separate key for market data.3
Set how long it lasts
Under Expires in, pick 7, 30 or 60 days. A trading key always expires, and the default is 30 days. The list shows the date next to the key.
4
Copy the token and the private key
Click Generate Token. Your browser creates the key pair, and the dialog shows the token, the public key and the private key only once. Copy the token and the private key, and save the private key as a file, for example
trading-key.pem. TakeProfit never receives the private key, so a lost one can’t be recovered: create a new key.Sign every request
Send four headers with every REST request and every WebSocket handshake:
The signed message joins the three header values exactly as sent, then the payload. An omitted
X-API-RECV-WINDOW adds nothing. The payload is:
- POST: the raw request body, exactly as sent.
- GET and WebSocket handshake: the raw query string as sent, without
?, or nothing when there is none.
Keep the clock in sync
A request is accepted while its timestamp is at most the receive window behind our server time and at most 1 second ahead of it. Sync your clock with NTP. There is no nonce: within the window, a captured request can be sent again. Keep the window short, and useIdempotency-Key when placing orders so a repeat never places a second one.