WebSocket API Basic Usage
Connection
Futures WebSocket API
wss://stream.bittap.com/endpoint?format=JSON
Request Format
All requests sent to the WebSocket API must be in JSON format and include the following fields:
id: A unique identifier for the request, used to match responses with requests.method: The method name to call, SUBSCRIBE/UNSUBSCRIBE.params: (Optional) Method parameters, a JSON array object.
Request Example
#### Request Authentication Types
Each method has an authentication type indicating the required API key permissions, displayed next to the method name (e.g., Place New Order (TRADE)).
If not specified, the authentication type is `NONE`.
Except for `NONE`, all methods with authentication types are considered `SIGNED` requests (i.e., include `signature`), except for `listenKey` management.
Methods with authentication types require a valid API key and verification.
API keys can be created on the API Management page of your BitTap account.
API keys and key pairs are sensitive information. Do not share them with others. If you notice unusual activity in your account, immediately revoke all keys and contact BitTap support.
API keys can be configured to only allow access to certain authentication types.
For example, you can have an API key with `TRADE` permissions for trading, while using another API key with `USER_DATA` permissions to monitor order status.
By default, API keys cannot perform `TRADE`. You need to enable trading permissions in API management first.
#### Common Request Information
##### Test Connectivity
```json
{
"id": "922bcc6e-9de8-440d-9e84-7c80933a8d0d",
"method": "PING"
}Test connectivity to the WebSocket API.
Note: You can also use regular WebSocket ping frames to test connectivity. The WebSocket API will respond with a pong frame as soon as possible. ping requests and time are safe ways to test request-response handling in applications.
Parameters: NONE
Data Source: Cache
Response:
{
"id": "922bcc6e-9de8-440d-9e84-7c80933a8d0d",
"type": "ACK"
}Check Server Time
{
"id": "187d3cb2-942d-484c-8271-4e2141bbadb1",
"method": "time"
}Test connectivity to the WebSocket API and get the current server time.
Parameters: NONE
Data Source: Cache
Response:
{
"id": "187d3cb2-942d-484c-8271-4e2141bbadb1",
"status": 200,
"result": {
"serverTime": 1656400526260
}
}Subscribe to a Stream
Request Example
{
"method": "SUBSCRIBE",
"params": [
"f_trade@BTC-USDT-M",
"f_depth30@BTC-USDT-M_0.1"
],
"id": 1
}Response Example
{
"code": 0, // 0 means success, non-0 means failure
"msg":"", // Failure reason, null on success
"topic": ["", ""] // Topics that failed to subscribe
"id": 1
}Last updated on: