subscribe, unsubscribe, or list_subscriptions. Any other first command fails authentication. You do not need to send credentials on later commands.
Authentication lasts for the life of the connection. If the connection drops, reconnect, authenticate again, and resubscribe.
Authentication
Example authenticated first command, using the test values from Signature example:
id, cmd, and params. See Command keys.
Signature
- Concatenate these strings without delimiters:
time + key + "CPM_WEB_MARKETDATA" + passphrase. Use the exacttime,key, andpassphrasevalues you send. - Do not trim or Unicode-normalize the API key or passphrase.
- Encode the concatenated text once as UTF-8.
- Decode your signing secret with standard Base64.
- Compute HMAC-SHA256 over the UTF-8 bytes, keyed with the decoded secret.
- Encode the 32-byte result with standard padded Base64 and send it as
signature.
id, cmd, and params are not signed. The signature authenticates the whole connection.
time must be within 30 seconds of the server’s clock, inclusive, in either direction: server_time - 30 to server_time + 30.Signature example
These are test values only. The signing secreta2V5 is the Base64 encoding of the text key. Use it only to check your signing code, and never share your real secret.
Example in Python:
Authorization
Authentication succeeds when all of the following are true:- The signature is valid for the API key and passphrase.
- The API key exists.
- The API key’s user is active and has the
MARKET_DATApermission. - The user’s Firm or FCM is active.
7 and text Unable to authenticate, then closes the WebSocket with close code 3000 and reason Unauthorized User. Open a new connection with a fresh time and signature to retry. See Errors.
Example authentication failure:
A newly created or rotated API key may take up to 5 seconds to become usable.