WebSocket Connections
Aries provides real-time WebSocket APIs for streaming market data, account updates, and other time-sensitive information.New to WebSockets? Regular REST API calls work like asking a question and waiting for a single answer — you ask, the server responds, then the conversation ends. A WebSocket is more like a phone call: you open one connection and the server keeps pushing updates to you as they happen (prices changing, orders filling, etc.) until you hang up. Use WebSockets whenever you need live, continuously updating data instead of refreshing on a timer.
Available WebSocket Endpoints
Aries provides separate WebSocket endpoints so you can connect only to the streams you actually need:- Market data — live prices and trading activity for stocks, options, and indices.
- Charting — a TradingView-compatible feed for charting widgets.
- Account — your own orders, positions, balances, P&L, watchlists, and news.
Market Endpoint
Market Data WebSocket
Real-time equity quotes, options data, time & sales, level 2 order book, and market status. Authentication required.Endpoint:
wss://api.aries.com/v1/market/wsCharting WebSocket
Real-time quotes and trades for charting (TradingView-compatible). Authentication required (send token via POST /auth after connect).Endpoint:
wss://api.aries.com/v1/charts/wsAccounts Endpoint
Account Updates WebSocket
Orders, positions, balances, P&L candles, watchlist updates, and news. All account-related streams use this endpoint.Endpoint:
wss://api.aries.com/v1/accounts/wsWatchlist WebSocket
Real-time watchlist changes. Connect to the accounts endpoint and subscribe to the watchlist topic.Endpoint:
wss://api.aries.com/v1/accounts/wsWebSocket Features
Real-Time Data Streaming
The connection stays open both ways, so the server can push updates the moment they happen rather than you having to poll. Typical latency is in the low milliseconds.Authentication
Every Aries WebSocket requires authentication before you can subscribe to anything. The flow is:- Open the WebSocket connection.
- Send a request message to POST /auth with your OAuth2 access token. The envelope looks like
type: "request",payload: { method: "post", path: "/auth", body: { action: "auth", token: "<access_token>" } }. - Wait for the server to respond with authSuccess.
- Only after that, send your subscribe messages.
Keep-Alive Support
WebSockets can be dropped silently by network equipment if they go quiet. To prevent that, send a smallping message every 30–60 seconds; the server replies with pong. If you don’t hear back, treat the connection as dead and reconnect.
Selective Subscriptions
Tell the server exactly which symbols and which fields you want. This keeps your bandwidth usage low and your app responsive — you won’t receive data you weren’t going to use anyway.Connection Flow
Establish Connection
Open a secure WebSocket connection (
wss://...) to one of the endpoints listed above.Authenticate
Send a request message containing your OAuth2 access token and wait for the server’s authSuccess response.
Subscribe
Tell the server which symbols or topics you want updates for (e.g. quotes for AAPL, or all orders on a specific account).
Receive Data
Read messages off the connection as the server pushes them and update your UI, store, or strategy logic accordingly.
Best Practices
Connection Management
Handle Reconnections
Handle Reconnections
Implement automatic reconnection logic with exponential backoff when connections drop:
Maintain Keep-Alive
Maintain Keep-Alive
Send ping messages regularly (recommended every 30-60 seconds) to maintain the connection:
Handle Errors Gracefully
Handle Errors Gracefully
Implement proper error handling for connection failures, authentication errors, and data parsing issues:
Clean Up Resources
Clean Up Resources
Always close WebSocket connections and clear intervals when they’re no longer needed:
Performance Optimization
Selective Subscriptions
Only subscribe to symbols and fields you actively need to reduce bandwidth and processing overhead
Batch Updates
Process incoming messages in batches rather than individually for better performance
Connection Pooling
Reuse WebSocket connections when possible instead of creating new connections frequently
Message Throttling
Implement client-side throttling to handle high-frequency updates without overwhelming your UI
Quick Start Example
Here’s a basic example of connecting to the Market Data WebSocket:Authentication
All WebSocket endpoints require authentication. After connecting, send your OAuth2 access token in a request message:Obtain your access token through the OAuth2 flow. See the API References section for authentication details.