WebSocket
AssetPay provides a Socket.IO WebSocket connection for real-time updates. Use it to push trade status changes and price updates to your frontend without polling.Connecting
Connect using Socket.IO with your API key or a client token: With API key (merchant-level access):Socket.IO Client Example
Events
Trade Updates
Fired whenever a trade changes status. This is the most important event for keeping your UI in sync.data.trade object is the same ITrade shape you see in callbacks and API responses.
Trade events are not game-specific. You’ll receive updates for all games (CS2 and Rust) on the same connection.
Crypto Deposit Updates
Fired when a merchant crypto deposit changes state:Crypto Withdrawal Updates
Fired when a merchant crypto withdrawal changes state:WebSocket vs Callbacks
Both WebSocket and callbacks deliver trade updates. They serve different purposes:| WebSocket | Callbacks | |
|---|---|---|
| Direction | Push to your frontend/client | Push to your backend |
| Use for | UI updates, real-time UX | Balance operations, business logic |
| Reliability | Best-effort (can miss events on disconnect) | Guaranteed delivery with retries |
| State | Stateful connection | Stateless HTTP POST |
Connection Notes
- Only the
websockettransport is supported (no HTTP long-polling fallback) - The connection authenticates once on connect. If your token expires, reconnect with a fresh one.
- All events are scoped to your merchant account. You only see your own trades.