Adjusted bars are now in indefinite beta! With split-adjusted historical price data, we remove large gaps caused by splits. This offers a more accurate representation of stock growth from the past until the present.Please note that this addition does not change current behavior, every call will default to raw adjustment.
Historical Data
Alpaca Data API v2 provides three types of historical data: trades, quotes and bars.
Common behavior
All endpoints provide compressed (gzipped) data when Accept-Encoding: gzip
header is added in the HTTP request, and the response size is bigger than 256 bytes.
Base URL
Alpaca Data API v2 provides historical data through multiple endpoints. These endpoints have the same URL prefix (omitted from now on):
https://data.alpaca.markets/v2
This URL is the same for both subscription plans but users with Free subscription will receive an error when trying to access data that is too recent.
Authentication The authentication is done the same way as with the Trading API, simply set the following HTTP headers:
APCA-API-KEY-ID
APCA-API-SECRET-KEY
Limiting
Use the limit
query parameter. The value should be in the range 1 - 10000 (endpoints included) with 1000 being the default if unspecified.
Paging
To support querying long timespans continuously we support paging in our API. If the result you have received contains a next_page_token
that is not null
there may be more data available in the timeframe you have chosen. Include the token you have received as the page_token
query parameter for the next request you make while leaving the other parameters unchanged to continue where the previous response left off.
Ordering
The results are ordered in ascending order by time.
Timestamps
The timestamps for trades, quotes, and bars are based on market participant timestamps. These correspond to when a trade was executed or a quote was generated. As these timestamps are generated by independent market participants, not the SIP, there is no requirement that the participant used a synchronized clock or nanosecond resolution. In certain cases due to unsynchronized clocks, the SIP timestamp (generated after a trade or quote has been reported) will appear before the participant timestamp. Additionally, though SIP timestamp’s have nanosecond resolution, the participant timestamps may have broader resolution such as milliseconds or seconds.
Trades
The Trades API provides historcial trade data for a given ticker symbol on a specified date.
[GET] Returns trades for the queried stock symbol
Parameters
Path Parameters
Query Parameters
Response
A trades response object.Errors
Example of one trade
{
"t": "2021-02-06T13:04:56.334320128Z",
"x": "C",
"p": 387.62,
"s": 100,
"c": [
" ",
"T"
],
"i": 52983525029461,
"z": "B"
}
Properties
Example of multiple trades
{
"trades": [
{
"t": "2021-02-06T13:04:56.334320128Z",
"x": "C",
"p": 387.62,
"s": 100,
"c": [
" ",
"T"
],
"i": 52983525029461,
"z": "B"
},
{
"t": "2021-02-06T13:09:42.325484032Z",
"x": "C",
"p": 387.69,
"s": 100,
"c": [
" ",
"T"
],
"i": 52983525033813,
"z": "B"
}
],
"symbol": "SPY",
"next_page_token": "MjAyMS0wMi0wNlQxMzowOTo0Mlo7MQ=="
}
Properties
Latest trade
The Latest trade API provides the latest trade data for a given ticker symbol.
[GET] Returns latest trade for the queried stock symbol
Parameters
Path Parameters
Response
A trades response object.Errors
Example of latest trade
{
"symbol": "AAPL",
"trade": {
"t": "2021-11-12T21:46:40.653626613Z",
"x": "V",
"p": 149.99,
"s": 250,
"c": [
"@",
"T"
],
"i": 5585,
"z": "C"
}
}
Properties
Quotes
The Quotes API provides NBBO quotes for a given ticker symbol at a specified date.
[GET] Returns quotes (NBBOs) for the queried stock symbol
Parameters
Path Parameters
Query Parameters
Response
A quotes response object.Errors
Example of one quote
{
"t": "2021-02-06T13:35:08.946977536Z",
"ax": "C",
"ap": 387.7,
"as": 1,
"bx": "N",
"bp": 387.67,
"bs": 1,
"c": [
"R"
]
}
Properties
Example of multiple quotes
{
"quotes": [
{
"t": "2021-02-06T13:35:08.946977536Z",
"ax": "C",
"ap": 387.7,
"as": 1,
"bx": "N",
"bp": 387.67,
"bs": 1,
"c": [
"R"
]
},
{
"t": "2021-02-06T13:35:09.327977984Z",
"ax": "C",
"ap": 387.7,
"as": 1,
"bx": "C",
"bp": 387.58,
"bs": 1,
"c": [
"R"
]
}
],
"symbol": "SPY",
"next_page_token": "MjAyMS0wMi0wNlQxMzozNTowOVo7MQ=="
}
Properties
Latest quote
The Latest quote API provides the latest quote data for a given ticker symbol.
[GET] Returns latest quote for the queried stock symbol
Parameters
Path Parameters
Response
A quotes response object.Errors
Example of latest trade
{
"symbol": "AAPL",
"trade": {
"t": "2021-11-12T21:46:40.653626613Z",
"x": "V",
"p": 149.99,
"s": 250,
"c": [
"@",
"T"
],
"i": 5585,
"z": "C"
}
}
Properties
Bars
The bars API returns aggregate historical data for the requested securities.
[GET] Returns bars for the queried stock symbol
Parameters
Path Parameters
Query Parameters
1Min
, 15Min
, 1Hour
, 1Day
.Response
A bars response object.Errors
Example of one bar
{
"t": "2021-02-01T16:01:00Z",
"o": 133.32,
"h": 133.74,
"l": 133.31,
"c": 133.5,
"v": 9876
"n": 587,
"vw": 630.285205
}
Properties
Example of multiple bars
{
"bars": [
{
"t": "2021-02-01T16:01:00Z",
"o": 133.32,
"h": 133.74,
"l": 133.31,
"c": 133.5,
"v": 9876
"n": 8041,
"vw": 631.145057
},
{
"t": "2021-02-01T16:02:00Z",
"o": 133.5,
"h": 133.58,
"l": 133.44,
"c": 133.58,
"v": 3567
"n": 587,
"vw": 630.285205
}
],
"symbol": "AAPL",
"next_page_token": "MjAyMS0wMi0wMVQxNDowMjowMFo7MQ=="
}
Properties
Snapshot - Multiple tickers
The Snapshot API for multiple tickers provides the latest trade, latest quote, minute bar daily bar and previous daily bar data for the given ticker symbols.
[GET] Returns the snapshots for the queried stock symbols
Parameters
Query Parameters
Response
A snapshot response object.Errors
Example of snapshots for multiple tickers
{
"AAPL": {
"latestTrade": {
"t": "2021-05-11T20:00:00.435997104Z",
"x": "Q",
"p": 125.91,
"s": 5589631,
"c": [
"@",
"M"
],
"i": 179430,
"z": "C"
},
"latestQuote": {
"t": "2021-05-11T21:48:32.342305Z",
"ax": "P",
"ap": 125.68,
"as": 4,
"bx": "P",
"bp": 125.6,
"bs": 2,
"c": [
"R"
]
},
"minuteBar": {
"t": "2021-05-11T21:46:00Z",
"o": 125.57,
"h": 125.67,
"l": 125.57,
"c": 125.57,
"v": 1722
},
"dailyBar": {
"t": "2021-05-11T04:00:00Z",
"o": 123.5,
"h": 126.27,
"l": 122.77,
"c": 125.91,
"v": 125853552
},
"prevDailyBar": {
"t": "2021-05-10T04:00:00Z",
"o": 129.41,
"h": 129.54,
"l": 126.81,
"c": 126.85,
"v": 79569305
}
},
"TSLA": {
"latestTrade": {
"t": "2021-05-11T20:00:00.438347686Z",
"x": "Q",
"p": 617.2,
"s": 268388,
"c": [
"@",
"M"
],
"i": 301112,
"z": "C"
},
"latestQuote": {
"t": "2021-05-11T21:49:14.42603133Z",
"ax": "P",
"ap": 616.4,
"as": 1,
"bx": "Q",
"bp": 616.05,
"bs": 1,
"c": [
"R"
]
},
"minuteBar": {
"t": "2021-05-11T21:45:00Z",
"o": 616,
"h": 616,
"l": 616,
"c": 616,
"v": 479
},
"dailyBar": {
"t": "2021-05-11T04:00:00Z",
"o": 599.24,
"h": 627.0999,
"l": 595.6,
"c": 617.2,
"v": 46393457
},
"prevDailyBar": {
"t": "2021-05-10T04:00:00Z",
"o": 664.71,
"h": 665.05,
"l": 627.6101,
"c": 629.04,
"v": 31336228
}
}
}
Properties
Snapshot - Ticker
The Snapshot API for one ticker provides the latest trade, latest quote, minute bar daily bar and previous daily bar data for a given ticker symbol.
[GET] Returns the snapshot for the queried stock symbol
Parameters
Path Parameters
Response
A snapshot response object.Errors
Example of a snapshot for one ticker
{
"symbol": "AAPL",
"latestTrade": {
"t": "2021-05-11T20:00:00.435997104Z",
"x": "Q",
"p": 125.91,
"s": 5589631,
"c": [
"@",
"M"
],
"i": 179430,
"z": "C"
},
"latestQuote": {
"t": "2021-05-11T22:05:02.307304704Z",
"ax": "P",
"ap": 125.68,
"as": 12,
"bx": "P",
"bp": 125.6,
"bs": 4,
"c": [
"R"
]
},
"minuteBar": {
"t": "2021-05-11T22:02:00Z",
"o": 125.66,
"h": 125.66,
"l": 125.66,
"c": 125.66,
"v": 396
},
"dailyBar": {
"t": "2021-05-11T04:00:00Z",
"o": 123.5,
"h": 126.27,
"l": 122.77,
"c": 125.91,
"v": 125863164
},
"prevDailyBar": {
"t": "2021-05-10T04:00:00Z",
"o": 129.41,
"h": 129.54,
"l": 126.81,
"c": 126.85,
"v": 79569305
}
}