🔑Authentication
Endpoint
GET /api/v1/ws-token
Description
This endpoint is designed to provide you with a secure method to authenticate WebSocket connections within your application. By following a simple two-step process, you can obtain a temporary token and use it to establish an authenticated WebSocket connection. Below are the steps you need to follow:
Step 1: Obtain a WebSocket Authentication Token
To initiate a WebSocket connection, you first need to obtain an authentication token by making a GET request to the /api/v1/ws-token
endpoint. You must include your API key in the request header as x-api-key
. Here's a sample curl
command to obtain the token:
Upon a successful request, the server will respond with a JSON object containing the token
field. This token is valid for a limited time period (10 minutes) to ensure security.
Step 2: Establish a WebSocket Connection
Once you have obtained the authentication token, you can use it to establish a WebSocket connection. Append the token as a query parameter named token
to your WebSocket URL. This process authenticates the WebSocket session, enabling secure communication.
Here is how you can modify your WebSocket URL:
After establishing the connection, you can use the WebSocket as usual to subscribe to channels.
Reconnecting
In case the WebSocket connection closes and you need to reconnect, ensure to obtain a new authentication token following the same steps above. This practice ensures that each connection is securely authenticated.
Headers
x-api-key (required): A valid API key.
Example
Response
Response Codes
200
: Success. Returns the USD price for the given token.401: Forbidden. The x-api-key header is not provided or is invalid.
Last updated