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

GET/v2/stocks/{symbol}/trades
This endpoint returns trade historical data for the requested security.

Parameters

Path Parameters

symbol
string
The symbol to query for

Query Parameters

start
string
Filter data equal to or after this time in RFC-3339 format. Fractions of a second are not accepted. Defaults to the current day in CT.
end
string
Filter data equal to or before this time in RFC-3339 format. Fractions of a second are not accepted. Default value is now.
feed
string
Defaults to IEX for Free users and SIP for users with an Unlimited subscription.
limit
int
Number of data points to return. Must be in range 1-10000, defaults to 1000.
page_token
string
Pagination token to continue from.

Response

A trades response object.

Errors

400 Bad request
Invalid value for query parameter
403 Forbidden
Unauthorized
422 Unprocessable
Invalid query parameter
429 Too many requests
Rate limit exceeded

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

t
stringRequired
Timestamp in RFC-3339 format with nanosecond precision.
x
stringRequired
Exchange where the trade happened.
p
numberRequired
Trade price.
s
intRequired
Trade size.
c
array<string>Required
Trade conditions.
i
intRequired
Trade ID.
z
stringRequired
Tape.

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

trades
array<trade>Required
Array of trades.
symbol
stringRequired
Symbol that was queried.
next_page_token
string (Nullable)Required
Token that can be used to query the next page.

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

GET/v2/stocks/{symbol}/trades/latest
This endpoint returns latest trade for the requested security.

Parameters

Path Parameters

symbol
string
The symbol to query for
feed
string
Defaults to IEX for Free users and SIP for users with an Unlimited subscription.
limit

Response

A trades response object.

Errors

400 Bad request
Invalid value for query parameter
403 Forbidden
Unauthorized
404 Not found
Not found
429 Too many requests
Rate limit exceeded

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

t
stringRequired
Timestamp in RFC-3339 format with nanosecond precision.
x
stringRequired
Exchange where the trade happened.
p
numberRequired
Trade price.
s
intRequired
Trade size.
c
array<string>Required
Trade conditions.
i
intRequired
Trade ID.
z
stringRequired
Tape.

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

GET/v2/stocks/{symbol}/quotes
This endpoint returns quote (NBBO) historical data for the requested security.

Parameters

Path Parameters

symbol
string
The symbol to query for

Query Parameters

start
string
Filter data equal to or after this time in RFC-3339 format. Fractions of a second are not accepted. Defaults to the current day in CT.
end
string
Filter data equal to or before this time in RFC-3339 format. Fractions of a second are not accepted. Default value is now.
feed
string
Defaults to IEX for Free users and SIP for users with an Unlimited subscription.
limit
int
Number of data points to return. Must be in range 1-10000, defaults to 1000.
page_token
string
Pagination token to continue from.

Response

A quotes response object.

Errors

400 Bad request
Invalid value for query parameter
403 Forbidden
Unauthorized
404 Not found
Not found
429 Too many requests
Rate limit exceeded

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

t
stringRequired
Timestamp in RFC-3339 format with nanosecond precision.
ax
stringRequired
Ask exchange.
ap
numberRequired
Ask price.
as
intRequired
Ask size.
bx
stringRequired
Bid exchange.
bp
numberRequired
Bid price.
bs
intRequired
Bid size.
c
array<string>Required
Quote conditions.

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

quotes
array<quote>Required
Array of quotes.
symbol
stringRequired
Symbol that was queried.
next_page_token
string (Nullable)Required
Token that can be used to query the next page.

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

GET/v2/stocks/{symbol}/quotes/latest
This endpoint returns latest quote for the requested security.

Parameters

Path Parameters

symbol
string
The symbol to query for
feed
string
Defaults to IEX for Free users and SIP for users with an Unlimited subscription.

Response

A quotes response object.

Errors

400 Bad request
Invalid value for query parameter
403 Forbidden
Unauthorized
422 Unprocessable
Invalid query parameter
429 Too many requests
Rate limit exceeded

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

t
stringRequired
Timestamp in RFC-3339 format with nanosecond precision.
x
stringRequired
Exchange where the trade happened.
p
numberRequired
Trade price.
s
intRequired
Trade size.
c
array<string>Required
Trade conditions.
i
intRequired
Trade ID.
z
stringRequired
Tape.

Bars

The bars API returns aggregate historical data for the requested securities.

[GET] Returns bars for the queried stock symbol

GET/v2/stocks/{symbol}/bars
This endpoint returns aggregate historical data for the requested security.

Parameters

Path Parameters

symbol
string
The symbol to query for

Query Parameters

start
stringRequired
Filter data equal to or after this time in RFC-3339 format. Fractions of a second are not accepted.
end
stringRequired
Filter data equal to or before this time in RFC-3339 format. Fractions of a second are not accepted.
limit
int
Number of data points to return. Must be in range 1-10000, defaults to 1000.
page_token
string
Pagination token to continue from.
timeframe
stringRequired
Timeframe for the aggregation. Values are customizeable, frequently used examples: 1Min, 15Min, 1Hour, 1Day.
adjustment
string
Specifies the corporate action adjustment for the stocks. Enum: ‘raw’, ‘split’, ‘dividend’ or ‘all’. Default value is ‘raw’.
feed
string
Defaults to IEX for Free users and SIP for users with an Unlimited subscription.

Response

A bars response object.

Errors

400 Bad request
Invalid value for query parameter
403 Forbidden
Unauthorized
422 Unprocessable
Invalid query parameter
429 Too many requests
Rate limit exceeded

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

t
stringRequired
Timestamp in RFC-3339 format with nanosecond precision.
o
numberRequired
Open price.
h
numberRequired
High price.
l
numberRequired
Low price.
c
numberRequired
Close price.
v
intRequired
Volume.
n
intRequired
Number of trades.
vw
intRequired
Volume weighted average price.

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

bars
array<bar>Required
Array of bars.
symbol
stringRequired
Symbol that was queried.
next_page_token
string (Nullable)Required
Token that can be used to query the next page.

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

GET/v2/stocks/snapshots
This endpoint returns the snapshots for the requested securities.

Parameters

Query Parameters

symbols
string
The comma-separated symbols to query for

Response

A snapshot response object.

Errors

400 Bad request
Invalid value for query parameter
403 Forbidden
Unauthorized
429 Too many requests
Rate limit exceeded

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

latestTrade
objectRequired
Latest trade object.
latestQuote
objectRequired
Latest quote object.
minuteBar
objectRequired
Minute bar object.
dailyBar
objectRequired
Daily bar object.
prevDailyBar
objectRequired
Previous daily close bar object.

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

GET/v2/stocks/{symbol}/snapshot
This endpoint returns the snapshot for the requested security.

Parameters

Path Parameters

symbol
string
The symbol to query for

Response

A snapshot response object.

Errors

400 Bad request
Invalid value for query parameter
403 Forbidden
Unauthorized
429 Too many requests
Rate limit exceeded

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
  }
}

Properties

latestTrade
objectRequired
Latest trade object.
latestQuote
objectRequired
Latest quote object.
minuteBar
objectRequired
Minute bar object.
dailyBar
objectRequired
Daily bar object.
prevDailyBar
objectRequired
Previous daily close bar object.

Suggestions or questions?
We're always happy to hear from you. You can contribute to these docs on GitHub, or you can join our Community Forum or Community Slack to get help from other community members and the Alpaca team.