Trade WebSocket
The Trade WebSocket provides authenticated, real-time access to trading operations with lower latency than REST endpoints.
Endpoint
ws.send() wss://api.synthetix.io/v1/ws/tradeFeatures
- Low Latency Trading: Submit orders with minimal delay
- Real-time Updates: Instant order status notifications
- Persistent Connection: Single connection for all operations
- Authenticated Connection: EIP-712 signature-based connection authentication
- Mixed Operations: Read operations use connection auth, write operations use per-request signatures
- Bidirectional: Request-response and server-pushed updates
Connection Flow
- Establish Connection: Connect to WebSocket endpoint
- Authenticate: Send authentication message with signature
- Trade: Send trading commands using
method: "post" - Subscribe: Receive real-time updates
- Maintain: Send heartbeats to keep connection alive
Authentication
Authentication is required immediately after connecting to the Trade WebSocket endpoint. See WebSocket Authentication for complete authentication flow and examples.
Quick Summary:- Connect to
wss://papi.synthetix.io/v1/ws/trade - Send authentication message with EIP-712 signature
- Receive authentication confirmation with
sub_account_id - Begin trading operations
- Uses EIP-712 typed data signing
- Timestamp must be within ±60 seconds of server time
- Authentication establishes which subaccount you're trading with
- Connection remains authenticated until disconnected
Security
- Secure private key storage
- WSS encrypted connections
- Re-authentication on connection drops
- Server response validation
Comparison with REST
| Feature | WebSocket | REST |
|---|---|---|
| Latency | Lower (~10-50ms) | Higher (~50-200ms) |
| Connection | Persistent | Per-request |
| Real-time Updates | Yes | No (polling required) |
| Overhead | Minimal | HTTP headers each request |
| Complexity | Higher | Lower |
| Best For | Active trading | Occasional trades |
Available Methods
Order Management
- Place Orders - Submit new orders
- Modify Order - Modify existing order
- Cancel Orders - Cancel specific orders
Account Management
- Create Subaccount - Create a new subaccount
- Get Subaccount - Get account details
- Update Leverage - Adjust market leverage
- Withdraw Collateral - Withdraw funds to wallet
Delegation
- Add Delegated Signer - Add a delegated signer
- Get Delegated Signers - List delegated signers
- Remove Delegated Signer - Remove a delegated signer
Data Queries
- Get Open Orders - Query active open orders
- Get Order History - Query order history with filters
- Get Positions - Query open and closed positions
- Get Trades - Query trade execution history
- Get Balance Updates - Query deposit/withdrawal history
- Get Funding Payments - Query funding payment history
- Get Performance History - Query performance analytics
Authentication & Setup
- Authentication - WebSocket authentication flow
- Timeouts & Heartbeats - Connection management
Related Resources
- REST Trade API - REST API alternative for trading
- WebSocket Subscriptions - Real-time data streams