Broker API HubMenu

Broker API

Alpaca trading API

US stock, ETF, options and crypto broker, not CFDs or FX: REST Trading API and Market Data API with WebSocket streams, paper trading on its own host.

Independent and unofficialNewest reading Official documentation

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.

Quickstart: key to first call25 endpoints9 messages26 error codes

Alpaca API rate limits and allowances

One record per limit. The scope is part of the limit: a figure without its scope is not a figure you can pace against.

LimitValueScopeSource
client_order_id length128POST /v2/orders and PATCH /v2/orders/{order_id}docs.alpaca.marketschecked
Crypto order size200,000Crypto spot orders, buy or selldocs.alpaca.marketschecked
Market data historical API, Basic plan200Market Data API historical calls, Basic (free) plandocs.alpaca.marketschecked
Market data points per page10,000Market Data API historical bars, trades and quotes, counted across all symbolsdocs.alpaca.marketschecked
Market data historical API, Algo Trader Plus10,000Market Data API historical calls, Algo Trader Plus plan (99 US dollars a month)docs.alpaca.marketschecked
GTC order age90Orders with time in force gtcdocs.alpaca.marketschecked
Trading API request rateHTTP 429 above the limit, with X-RateLimit-Limit, X-RateLimit-Remaining and X-RateLimit-Reset headers on replies; no figure on the pages openedTrading API, per accountdocs.alpaca.marketschecked
Market data WebSocket authentication timeout10Market data WebSocket, from connecting to the auth messagedocs.alpaca.marketschecked
Market data WebSocket connectionsDepends on the subscription; 1 for many subscriptions and with none. A second connection is answered with error 406 connection limit exceededMarket data WebSocket, per accountdocs.alpaca.marketschecked
Market data WebSocket symbols, Basic plan30Market data WebSocket, US equities, Basic (free) plan; Algo Trader Plus is unlimiteddocs.alpaca.marketschecked

Alpaca API rate limits in full, with pacing advice and the related error codes.

Access, authentication and streaming

API types listed in the record: REST (Trading API v2), REST (Market Data API), WebSocket streaming.

How you get a key

Sign up on Alpaca's site with an email address for a Paper Only Account, which gives API access and a dashboard. A paper account has its own API keys, separate from any live account, and the dashboard shows the paper base address. Alpaca's pages do not print the menu steps that generate a key.

Alpaca docs: Paper Tradingchecked Alpaca docs: About Trading APIchecked

Who can use it

Paper Only Account: anyone, anywhere, with an email address. Live brokerage accounts: individual taxable accounts and business accounts (corporations, LLCs and partnerships, with a 30,000 US dollar minimum deposit), for people and entities from around the world; retirement accounts are not supported. Live accounts are opened as margin accounts; margin trading and short selling need 2,000 US dollars or more of equity. Crypto trading is open in select international and some US jurisdictions.

Alpaca docs: Trading Accountchecked Alpaca docs: Crypto Spot Tradingchecked

Demo

Yes: paper trading, a real time simulation on its own host, https://paper-api.alpaca.markets, with its own API keys. New paper accounts start with 100,000 US dollars by default; the dashboard can open and delete paper accounts. Fills are simulated from real time quotes against the NBBO; market impact, slippage from latency, queue position, regulatory fees and dividends are not modelled, and about one order in ten gets a partial fill of random size. A Paper Only Account gets IEX data only.

Alpaca docs: Paper Tradingchecked

Authentication

Two headers on every request, APCA-API-KEY-ID and APCA-API-SECRET-KEY, or HTTP Basic with the key id as the user name and the secret as the password. Live and paper credentials are separate and neither works on the other host. OAuth 2.0 client credentials are documented for the Broker API and marked not yet available for the Trading API.

Alpaca docs: Authenticationchecked

Streaming

Two WebSocket streams. Account events: wss://paper-api.alpaca.markets/stream and wss://api.alpaca.markets/stream, where a client sends an auth message, then a listen message for the trade_updates stream, and receives one message per order event (new, fill, partial_fill, canceled, expired, replaced and the rest). Market data: wss://stream.data.alpaca.markets/{version}/{feed}, with feeds v2/iex, v2/sip, v2/delayed_sip, v1beta1/boats and v1beta1/overnight for stocks, v1beta3/crypto/{loc} for crypto and v2/test outside market hours, where a client authenticates within 10 seconds, then subscribes by channel (trades, quotes, bars and others) and symbol. Messages are JSON arrays, or MessagePack where the client asks. The connection limit depends on the subscription and is 1 for many; a second connection gets error 406.

Alpaca docs: Websocket Streamingchecked Alpaca docs: WebSocket Stream (market data)checked Alpaca docs: Real-time Stock Datachecked Alpaca docs: Real-time Crypto Datachecked

Rate limits, as worded

The Trading API OpenAPI document gives HTTP 429 for too many requests, with X-RateLimit-Limit, X-RateLimit-Remaining and X-RateLimit-Reset headers on replies, and no figure on the pages opened. The Market Data API pages give figures by plan: the historical API allows 200 calls a minute on the free Basic plan and 10,000 calls a minute on Algo Trader Plus (99 US dollars a month). Basic allows up to 30 WebSocket symbol subscriptions for equities and 200 quote subscriptions for options; Algo Trader Plus has unlimited equity subscriptions and 1,000 option quote subscriptions.

Alpaca Trading API OpenAPI documentchecked Alpaca docs: About Market Data APIchecked

History depth

Stock history since 2016 on both market data plans; the Basic plan is limited to data at least 15 minutes old for SIP, so a query for recent SIP trades or quotes needs Algo Trader Plus. Historical requests page at up to 10,000 data points per page, 1,000 by default, counted across all symbols. The market calendar covers 1970 to 2029.

Alpaca docs: About Market Data APIchecked Alpaca docs: Market Data FAQchecked Alpaca Market Data API OpenAPI documentchecked Alpaca reference: Get US Market Calendarchecked

own_api

Alpaca publishes its own REST Trading API (v2, with paper and live hosts), its own Market Data API on data.alpaca.markets and WebSocket streams for both, with OpenAPI documents for each. The Broker API is a separate business to business product and is outside this site's scope.

Alpaca docs: About Trading APIchecked Alpaca docs: SDKs and Toolschecked Alpaca docs: Authenticationchecked

Alpaca API endpoints

25 documented endpoints. Grouped by what they do

Alpaca messages

9 documented messages and subscriptions of the Alpaca WebSocket streams. They are not HTTP endpoints: none has a method or a path, and each travels over a connection that stays open. Grouped by what they do, each with its summary

Alpaca API error codes

26 decoded error codes. All Alpaca errors

Alpaca API SDKs and wrappers

LibraryLanguageOfficialNoteSource
alpaca-pyPythonOfficialListed on Alpaca's SDK page as its Python SDK.docs.alpaca.marketschecked
alpaca-trade-api-jsJavaScript (Node)OfficialNot recordeddocs.alpaca.marketschecked
alpaca-trade-api-csharpC# (.NET)OfficialNot recordeddocs.alpaca.marketschecked
alpaca-trade-api-goGoOfficialNot recordeddocs.alpaca.marketschecked
alpaca-javaJavaOfficialNot recordeddocs.alpaca.marketschecked

Alpaca API: questions and answers

Each answer is read from the record on this page, not written separately. Where the record is unverified, the answer says so.

Does Alpaca have an API?

Unverified. Yes. This register records Alpaca as having its own API (REST (Trading API v2), REST (Market Data API) and WebSocket streaming), with availability marked as active. US stock, ETF, options and crypto broker, not CFDs or FX: REST Trading API and Market Data API with WebSocket streams, paper trading on its own host. No source is recorded against this entry.

Unverifiedno source opened

Alpaca API key: how do I get one?

Sign up on Alpaca's site with an email address for a Paper Only Account, which gives API access and a dashboard. A paper account has its own API keys, separate from any live account, and the dashboard shows the paper base address.

Alpaca docs: Paper Tradingchecked Alpaca docs: About Trading APIchecked

Who can use the Alpaca API?

Paper Only Account: anyone, anywhere, with an email address.

Alpaca docs: Trading Accountchecked Alpaca docs: Crypto Spot Tradingchecked

Alpaca API demo: is there a demo or sandbox?

Yes: paper trading, a real time simulation on its own host, https://paper-api.alpaca.markets, with its own API keys. New paper accounts start with 100,000 US dollars by default; the dashboard can open and delete paper accounts.

Alpaca docs: Paper Tradingchecked

What are the Alpaca API rate limits?

client_order_id length: 128 characters. Scope: POST /v2/orders and PATCH /v2/orders/{order_id}. Crypto order size: 200,000 US dollars notional per order. Scope: Crypto spot orders, buy or sell. Market data historical API, Basic plan: 200 requests per minute. Scope: Market Data API historical calls, Basic (free) plan. Market data points per page: 10,000 data points per page. Scope: Market Data API historical bars, trades and quotes, counted across all symbols. Market data historical API, Algo Trader Plus: 10,000 requests per minute. Scope: Market Data API historical calls, Algo Trader Plus plan (99 US dollars a month). GTC order age: 90 days. Scope: Orders with time in force gtc. 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. Scope: Trading API, per account. Market data WebSocket authentication timeout: 10 seconds. Scope: Market data WebSocket, from connecting to the auth message. 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. Scope: Market data WebSocket, per account. Market data WebSocket symbols, Basic plan: 30 symbol subscriptions. Scope: Market data WebSocket, US equities, Basic (free) plan; Algo Trader Plus is unlimited. As the record words it: The Trading API OpenAPI document gives HTTP 429 for too many requests, with X-RateLimit-Limit, X-RateLimit-Remaining and X-RateLimit-Reset headers on replies, and no figure on the pages opened.

docs.alpaca.marketschecked docs.alpaca.marketschecked docs.alpaca.marketschecked docs.alpaca.marketschecked docs.alpaca.marketschecked docs.alpaca.marketschecked

How does Alpaca API authentication work?

Two headers on every request, APCA-API-KEY-ID and APCA-API-SECRET-KEY, or HTTP Basic with the key id as the user name and the secret as the password. Live and paper credentials are separate and neither works on the other host.

Alpaca docs: Authenticationchecked

Does the Alpaca API support streaming?

Two WebSocket streams.

Alpaca docs: Websocket Streamingchecked Alpaca docs: WebSocket Stream (market data)checked Alpaca docs: Real-time Stock Datachecked Alpaca docs: Real-time Crypto Datachecked

How much history does the Alpaca API return?

Stock history since 2016 on both market data plans; the Basic plan is limited to data at least 15 minutes old for SIP, so a query for recent SIP trades or quotes needs Algo Trader Plus.

Alpaca docs: About Market Data APIchecked Alpaca docs: Market Data FAQchecked Alpaca Market Data API OpenAPI documentchecked Alpaca reference: Get US Market Calendarchecked

Is there a Python library for the Alpaca API?

This register lists one Python library for the Alpaca API. alpaca-py (official, Python): Listed on Alpaca's SDK page as its Python SDK.

alpaca-pychecked

Alpaca API questions, each answered in a sentence or two.

The capability tables read one feature at a time across every broker and platform record, Alpaca included.

Everything this site records for Alpaca, as one JSON file. Each section of the file states its own licence. About the files. This page as Markdown.

Alpaca API guides and reference

How to cite this

Alpaca trading API. Broker API Hub, https://openbrokerapi.com/brokers/alpaca, newest check .

Where you rely on a single figure, cite the source and the checked date printed beside it as well.

Sections