Indices WebSocket Documentation
Indices WebSocket Documentation
The iTick.org Indices WebSocket API provides streaming access to the latest data for global indices. You specify the channel to use by sending instructions in the form of actions. When events occur in the channels you subscribe to, our WebSockets emit events to notify you.
Our WebSocket API is based on authorization, which controls which WebSocket clusters you can connect to and what types of data you can access. You can log in to see a sample that includes your API key and is personalized based on your authorization.
Step 1: Connect
With the Premium plan, you will be able to use a single connection to the cluster. If another connection tries to connect to the cluster at the same time, the current connection will be disconnected. If you need more connections to this cluster at the same time, you can contact support.
Connect to the cluster:
wscat -c wss://api.itick.org/iws
Once connected you will receive the following message:
{
"code":1,
"msg": "Connected Successfully"
}
Step 2: Authentication
You must authenticate before you can make any additional requests.
{
"ac":"auth",
"params":"dVEIODs9rmbxOtFJAL_SRvwLXjmddLKg"
}
After successful authentication, you will receive the following message:
{
"code":1,
"resAc":"auth",
"msg": "authenticated"
}
If authentication fails, the connection will be disconnected and the process will terminate
{
"code":0,
"resAc":"auth",
"msg": "auth failed"
}
Step 3: Subscribe
After verifying your identity, you can request a stream. You can request multiple streams in the same request.
{
"ac":"subscribe",
"params":"US100",
"types":"quote"
}
params: target code, supports multiple subscriptions
types: subscription type, depth market, quote, tick
Subscription returns content successfully.
{
"code":1,
"resAc":"subscribe",
"msg": "subscribe Successfully"
}
Subscription returns content failed. As follows: exceeds the maximum number of package plans, subscription parameter error.
{
"code":0,
"resAc":"subscribe",
"msg": "exceeding the maximum subscription limit"
}
{
"code":0,
"resAc":"subscribe",
"msg": "cannot be resolved action"
}
Step 4: Response Content
iTick.org WebSocket clients must be able to handle many incoming messages per second. Due to the nature of the WebSocket protocol, if the client is slow to get messages from the server, iTick.org's server must buffer messages and send them as fast as the client can receive them. If the client consumes messages too slowly for a long time, iTick.org's server-side buffer may become too large. If this happens, iTick.org will terminate the WebSocket connection. If you encounter this situation frequently, please consider subscribing to fewer symbols or channels.
After the subscription is successful, the data is sent as follows.
Trade response content
{
"code": 1,
"data": {
"s": "US100",
"ld": 225.215,
"v": 16742235,
"t": 1731689407000,
"type": "tick"
}
}
Quote response content
{
"code": 1,
"data": {
"s": "US100",
"ld": 225.215,
"o": 226.27,
"h": 226.92,
"l": 224.44,
"t": 1731689407000,
"v": 16742235,
"tu": 3774688301.452,
"ts": 0,
"type": "quote"
}
}
Depth response content
{
"code": 1,
"data": {
"s": "US100",
"a": [
{
"po": 1,
"p": 3034.01,
"v": 10.6023,
"o": 10.6023
},
{
"po": 2,
"p": 3034.03,
"v": 0.0017,
"o": 0.0017
},
{
"po": 3,
"p": 3034.18,
"v": 0.0017,
"o": 0.0017
},
{
"po": 4,
"p": 3034.26,
"v": 0.0018,
"o": 0.0018
},
{
"po": 5,
"p": 3034.27,
"v": 0.21,
"o": 0.21
}
],
"b": [
{
"po": 1,
"p": 3034,
"v": 20.9758,
"o": 20.9758
},
{
"po": 2,
"p": 3033.99,
"v": 1.8408,
"o": 1.8408
},
{
"po": 3,
"p": 3033.98,
"v": 0.003,
"o": 0.003
},
{
"po": 4,
"p": 3033.97,
"v": 0.0065,
"o": 0.0065
},
{
"po": 5,
"p": 3033.94,
"v": 0.003,
"o": 0.003
}
],
"type": "depth"
}
}
K-line response content
{
"code": 0,
"msg": null,
"data": {
"s":"US100",
"t":1,
"k":
{
"tu": 157513,
"c": 3059.39,
"t": 1731660060000,
"v": 28,
"h": 3061.41,
"l": 3055.24,
"o": 3055.36
}
}
}
t K-line cycle: Cycle 1 minute, 2 five minutes, 3 ten minutes, 4 thirty minutes, 5 one hour, 6 two hours, 7 four hours, 8 one day, 9 one week, 10 one month
Step 5: Keep heartbeat
The client sends to the server
{
"ac":"ping",
"params":"1731688569840"
}
The server sends to the client
{
"resAc":"pong",
"data": {"params":"1731688569840"}
}
The timestamps of ping and pong need to be consistent