Migration 0002 adds the market data tables on both engines: daily and one-minute bars, corporate actions, FX rates, the exchange calendar, calendar events, mood indicators, spread samples, data issues, source state and universe members, plus the trading rules on instruments. The data layer is format-independent so the venue clients can build on it: the instrument catalogue (rules from the venue, delisted kept), bar upserts with ON CONFLICT, the SPEC 6.4 checks with an issue register that blocks entries until a second reading, freshness by age of the last datum (trap 10), research history in .csv.gz with exact decimals, and adjusted series anchored at the decision day with level and quantity conversion across splits and dividends. Recorded API responses from OKX, the Alpaca docs and the free sources are kept byte for byte as test fixtures; the secret scan now ignores pagination cursors such as Alpaca's next_page_token. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
4.1 KiB
Alpaca REST errors and rate limiting: what the docs actually show
Read 2026-11-10. Verbatim where quoted; "NOT DOCUMENTED" where the docs show nothing.
Market Data API (https://data.alpaca.markets)
Source: OpenAPI blocks on https://docs.alpaca.markets/us/reference/stockbars (and every other stock reference page, e.g. stocklatestquotes-1, stocksnapshots-1, corporateactions-1).
Documented status codes, descriptions only (the OpenAPI declares NO response body schema for any error):
- 400: "One of the request parameters is invalid. See the returned message for details." (carries the X-RateLimit-* headers)
- 401: "Authentication headers are missing or invalid. Make sure you authenticate your request with a valid API key."
- 403: "The requested resource is forbidden."
- 429: "Too many requests. You hit the rate limit. Use the X-RateLimit-... response headers to make sure you're under the rate limit." (carries the X-RateLimit-* headers)
- 500: "Internal server error. We recommend retrying these later. ..."
- 422: not listed on the market data reference pages.
Rate-limit headers (declared on 200, 400 and 429):
| Header | Doc description | Doc example |
|---|---|---|
X-RateLimit-Limit |
"Request limit per minute." | 100 |
X-RateLimit-Remaining |
"Request limit per minute remaining." | 90 |
X-RateLimit-Reset |
"The UNIX epoch when the remaining quota changes." | 1674044551 |
Basic plan: "Historical API calls 200 / min" (https://docs.alpaca.markets/us/docs/about-market-data-api).
Market Data FAQ (https://docs.alpaca.markets/us/docs/market-data-faq), "Why am I getting HTTP 403": 403 is returned if the request was not authenticated, the credentials were incorrect, or the user has insufficient permissions. (So in practice bad keys may yield 403, while the OpenAPI says 401; the docs do not reconcile the two.)
The ONLY error body shown anywhere for market data (FAQ, latest trade with feed=sip on the free plan; HTTP status NOT shown):
$ curl -H "APCA-API-KEY-ID: ${APCA_API_KEY_ID}" -H "APCA-API-SECRET-KEY: ${APCA_API_SECRET_KEY}" \
"https://data.alpaca.markets/v2/stocks/AAPL/trades/latest?feed=sip"
{"code":42210000,"message":"subscription does not permit querying recent SIP data"}
Saved as error-sip-recent.faq.json. Shape: {"code": <int>, "message": <string>}.
Adjustment parameter (stockbars): unknown values, empty values and repeated keys such as
?adjustment=split&adjustment=all "are rejected with a 400". Body NOT DOCUMENTED.
Trading API (https://paper-api.alpaca.markets)
- /v2/assets, /v2/calendar, /v2/clock, /v3/calendar, /v3/clock reference pages (get-v2-assets-1, legacycalendar, legacyclock, calendar-2, clock-1): calendars list 400 / 429 / 500, /v2/clock lists 429 / 500, all with the same X-RateLimit-* headers on 200; /v2/assets lists only 200. No error bodies.
- /v2/assets/{symbol_or_asset_id}: 404 when not found (no body documented).
- POST /v2/orders (postorder): 403 "Forbidden\n\nBuying power or shares is not sufficient.", 422 "Unprocessable\n\nInput parameters are not recognized." No bodies.
- Getting Started with Trading API (https://docs.alpaca.markets/us/docs/getting-started-with-trading-api):
every response carries
X-Request-ID; the example is an unauthenticatedGET /v2/account->HTTP/1.1 403 Forbidden,Content-Type: application/json,Content-Length: 26. The body itself is elided ("...") in the docs: NOT DOCUMENTED. - Trading API rate limit number: NOT DOCUMENTED on the current pages.
429 behaviour
Only the Broker API page documents behaviour explicitly
(https://docs.alpaca.markets/us/docs/broker-api-rate-limits): headers on every response, not
only 429; on 429 "stop, wait, and retry using exponential backoff", ideally not before
X-RateLimit-Reset. For the Trading/Market Data APIs the docs only say "Use the X-RateLimit-...
response headers". No Retry-After header is documented anywhere.
Bodies for 401 / 403 / 422 / 429
NOT DOCUMENTED (no example body exists in the docs). The only observed shape is the FAQ's
{"code":42210000,"message":"..."}. Treat other shapes as unknown and parse defensively.