General Info
Connection Management
Private stream and public stream have different subscription path.
Private stream: wss://ws.pionex.com/ws
Public stream: wss://ws.pionex.com/wsPub
Subscribing to the private requires authentication, while public stream does not.
Authentication Information
When subscribing to private stream, you need to send authentication parameters in query string
key
: user's API Keytimestamp
: timestamp in millisecondsignature
: concatenatePATH_URL
and "websocket_auth
" , then use the result to generateHMAC SHA256
code.
Signing
Get current millisecond
timestamp
.Set query parameters as key-value pairs:
key=value
(key
andtimestamp
).Sort the key-value pairs in ascending ASCII order by key and concatenate with & .
Concatenate above result after
PATH
with?
to generatePATH_URL.
Concatenate "
websocket_auth
" after above result.Use
API Secret
and the above result to generateHMAC SHA256
code, then convert it to hexadecimal.Assign the hex result to
signature
, add it to query parameter and send request.
Example
User's API Key / Secret
and timestamp
are:
The base part of request to query the private stream is
Step 1, Get current millisecond timestamp
.
Step 2, Set query parameters as key-value pairs: key=value
.
Step 3, Sort the key-value pairs in ascending ASCII order by key and concatenate with & .
Step 4, Concatenate above result after PATH
with ?
to generate PATH_URL.
Step 5, Concatenate "websocket_auth
" after above result.
Step 6, Use API Secret
and the above result to generate HMAC SHA256
code, then convert it to hexadecimal.
Step 7, Assign the hex result to signature
, add it to query parameter and send request.
Request format
Messages sent to the server should contain the following dictionary items:
op
: The operation you want to run. Should be one ofSUBSCRIBE
to subscribe to a topicUNSUBSCRIBE
to unsubscribe to a topic
topic
: The topic for which your want data. Should be one ofTRADE
: for trade market dataDEPTH
: for depth market dataORDER
: for order account dataFILL
: for fill account data
symbol
: The symbol for which you want data. Example:BTC_USDT
Response format
topic
symbol
op
:PING
orCLOSE
type
: Response ofSUBSCRIBE
andUNSUBSCRIBE
data
: Subscribed messagestimestamp
: The timestamp in millisecondcode
: Error codemessage
: Error message
Subscribe
Send JSON request to subscribe
Response
Unsubscribe
Send JSON request to unsubscribe
Response
HeartBeat
Our server sends 'PING' heartbeat message every 15 seconds
Client sends 'PONG
' heartbeat message as a reply after receiving 'PING
'. The timestamp of 'PONG' does not need to be consistent with or correspond to 'PING
'.
Client have to send latest timestamp to keep persistent connection. If the server does not receive a 'PONG' reply after sending 3 'PING' heartbeat, it will close the connection and send the disconnect message to client at the same time.
Limit
You can create up to 10 connections on the same ip
Error Code
INVALID_OP Invalid op.
INVALID_TOPIC Invalid topic.
INVALID_SYMBOL Invalid symbol.
PARAMETER_ERROR Parameter error.
SUBSCRIBED_TOPICS_EXCEED_LIMIT The number of subscribed topics on single connection exceed the limit.
Last updated