WebSocket is an advanced HTML5 protocol enabling full-duplex communication between clients and servers. It simplifies real-time data transfer with a single handshake, allowing servers to push updates based on preset rules. Key advantages include:
- Ultra-light headers: Only 2 bytes per transmission.
- Bi-directional initiation: Clients or servers can trigger data exchanges.
- Resource efficiency: Eliminates repetitive TCP connection overhead, conserving bandwidth and server resources.
Connection Guidelines
Rate Limits:
- Maximum of 3 requests per second (per API KEY).
- Private channels require dedicated service addresses.
Stability Tips:
- Set an N-second timer (where N < 30) upon receiving a message.
- If triggered, send
'ping'and await'pong'. - Reconnect if no response within N seconds.
Request Caps:
- Combined
subscribe/unsubscribe/loginactions limited to 480/hour per connection.
⚠️ Connections auto-terminate after 30 seconds of inactivity or failed subscriptions.
Notification System
WebSocket’s event = notice alerts users about:
- Planned disconnections (e.g., service upgrades).
- Clients receive warnings 30 seconds pre-disconnect to facilitate seamless reconnection.
Response Example:
{
"event": "notice",
"message": "Upgrade scheduled—reconnect to avoid disruption."
}FAQs
Q1: How does WebSocket differ from HTTP polling?
A1: WebSocket maintains a persistent connection, reducing latency and overhead compared to repeated HTTP requests.
Q2: Can I use WebSocket for private DEX API data?
A2: Yes, but configure it with your private service endpoint for secure access.
Q3: What happens if I exceed the request limit?
A3: Further requests are throttled; optimize calls to stay within hourly quotas.
👉 Explore WebSocket API use cases
👉 Optimize your DEX integration today
Tables and detailed code snippets are omitted for brevity. Expand with case studies or data to meet depth requirements.