Stream Subscription API is a real-time data push service based on the WebSocket protocol. Unlike the request-response model of REST APIs, WebSocket establishes a persistent connection, allowing the server to proactively push data to the client.
| Features | WebSocket | REST API |
|---|---|---|
| Delay | Low | High than websocket |
| Push mode | Server active push | Client polling |
| Connect | Persistent connection | New per request |
Applicable scenarios : real-time market display, order status monitoring, account asset change notification, high-frequency trading data acquisition
Connection address
Public channels (no certification required):
wss://stream-hk.osl.com/ws/v5/publicwss://stream-hk.oslsandbox.com/ws/v5/public
Private channels (authentication required):
wss://stream-hk.osl.com/ws/v5/privatewss://stream-hk.oslsandbox.com/ws/v5/private
Connection parameters :
| Parameter | Explanation |
|---|---|
| Heartbeat interval | 30 seconds (recommended) |
| Connection timed out | 60 seconds no data automatically disconnected |
| Connection restrictions | 100/IP, current active sessions |
| Message size | Up to 64KB |
Heartbeat
Client needs to send a heartbeat every 30 seconds to keep the connection active. If there is no subscription or server does not push data within 60 seconds after connection, the system will automatically disconnect.
Heartbeat request : ping
Heartbeat response : pong
Error code
| Error code | Explanation |
|---|---|
| 30001 | Channel does not exist |
| 30002 | Illegal request |
| 30003 | Invalid op |
| 30004 | User needs to log in |
| 30005 | Login failed |
| 30011 | Invalid ACCESS_KEY |
| 30013 | Invalid ACCESS_TIMESTAMP |
| 30014 | Request timestamp expired |
| 30015 | Invalid signature |
| 30016 | Parameter error |
