Alpaca subscribe
Adds symbols to the connection's subscriptions, by channel. The message adds to the current set, so send only what is new; the reply lists everything now subscribed.
Risk warning: CFDs and spread bets are complex instruments and come with a high risk of losing money rapidly due to leverage. You can lose money on these products, and each provider publishes its own loss figure under FCA rules. You should consider whether you understand how they work and whether you can afford to take the high risk of losing your money. Automated and API trading can amplify losses through bugs, connectivity failures and runaway orders.
This is a message of the Alpaca WebSocket streams, not an HTTP endpoint. It has no method and no path: it is sent as JSON, or as MessagePack where the client asks for it, over an open WebSocket connection.
The channels a feed serves are given on each feed's own page: the stock pages list trades, quotes, bars, updatedBars, dailyBars, statuses, lulds, imbalances; the crypto page lists trades, quotes, orderbooks, bars, updatedBars, dailyBars. A channel the feed does not serve is answered with error 410.
The message
- Name
- subscribe
- Direction
- Request, sent by the client
- Carried by
- WebSocket. Every message is a JSON array of objects, each with a T field naming its type; control messages (success, error, subscription) come one to an array. The client must authenticate within 10 seconds of connecting, with a message or with headers in the handshake. The connection limit depends on the plan and is 1 for many; a second connection is answered with error 406.
- Stocks, IEX feed (free plan)
- wss://stream.data.alpaca.markets/v2/iex
- Stocks, SIP feed (Algo Trader Plus)
- wss://stream.data.alpaca.markets/v2/sip
- Stocks, 15 minute delayed SIP
- wss://stream.data.alpaca.markets/v2/delayed_sip
- Test stream outside market hours, symbol FAKEPACA
- wss://stream.data.alpaca.markets/v2/test
- Crypto, Alpaca US
- wss://stream.data.alpaca.markets/v1beta3/crypto/us
Fields
The vendor's page does not say which of these fields are required or always present.
| Name | Type | Description |
|---|---|---|
| action | string | Names the message: subscribe. |
| trades | array of strings | Symbols whose trades to receive; a list of one star means every symbol. Subscribing to trades also subscribes to corrections and cancelErrors. |
| quotes | array of strings | Symbols whose quotes to receive. |
| bars | array of strings | Symbols whose minute bars to receive. |
| updatedBars | array of strings | Symbols whose revised minute bars to receive, sent when a late trade changes a bar. |
| dailyBars | array of strings | Symbols whose running daily bars to receive. |
| statuses | array of strings | Stocks only: trading status messages (halts and resumptions). |
| lulds | array of strings | Stocks only: limit up and limit down bands. |
| imbalances | array of strings | Stocks only: order imbalance messages. |
| orderbooks | array of strings | Crypto only: order book snapshots and updates. |
What arrives
subscription: The whole subscription list after the change, one key per channel, in an array of one object with T subscription. Over the symbol limit of the plan the reply is error 405 and the subscriptions stay as they were.
The vendor's page does not say which of these fields are required or always present.
| Name | Type | Description |
|---|---|---|
| T | string | subscription. |
| trades | array of strings | The symbols now subscribed on each channel; the reply carries one such key per channel the feed serves, such as quotes, bars, updatedBars, dailyBars, statuses, lulds, corrections, cancelErrors and, for crypto, orderbooks. |
Sample
Written by this site from the fields recorded on this page. It has not been run against a terminal, a server or an account, and the values in it are placeholders. No credential is typed into it: where a field holds one, the placeholder says where it comes from. Nothing is entered on this site.
{
"action": "subscribe",
"trades": ["AAPL"],
"quotes": ["AAPL"],
"bars": ["*"]
}Limits that apply at Alpaca
| Limit | Value | Scope | Source |
|---|---|---|---|
| client_order_id length | 128 | POST /v2/orders and PATCH /v2/orders/{order_id} | docs.alpaca.marketschecked |
| Crypto order size | 200,000 | Crypto spot orders, buy or sell | docs.alpaca.marketschecked |
| Market data historical API, Basic plan | 200 | Market Data API historical calls, Basic (free) plan | docs.alpaca.marketschecked |
| Market data points per page | 10,000 | Market Data API historical bars, trades and quotes, counted across all symbols | docs.alpaca.marketschecked |
| Market data historical API, Algo Trader Plus | 10,000 | Market Data API historical calls, Algo Trader Plus plan (99 US dollars a month) | docs.alpaca.marketschecked |
| GTC order age | 90 | Orders with time in force gtc | docs.alpaca.marketschecked |
| Trading API request rate | HTTP 429 above the limit, with X-RateLimit-Limit, X-RateLimit-Remaining and X-RateLimit-Reset headers on replies; no figure on the pages opened | Trading API, per account | docs.alpaca.marketschecked |
| Market data WebSocket authentication timeout | 10 | Market data WebSocket, from connecting to the auth message | docs.alpaca.marketschecked |
| Market data WebSocket connections | Depends on the subscription; 1 for many subscriptions and with none. A second connection is answered with error 406 connection limit exceeded | Market data WebSocket, per account | docs.alpaca.marketschecked |
| Market data WebSocket symbols, Basic plan | 30 | Market data WebSocket, US equities, Basic (free) plan; Algo Trader Plus is unlimited | docs.alpaca.marketschecked |