Historical Data

Please note that Alpaca Crypto Data is in beta - we welcome any feedback to improve our offering.

Alpaca provides crypto data from multiple venues and does not route orders to all venues even though it offers data.

List of crypto exchanges which are supported by Alpaca.

Exchange Code Name of Exchange
CBSE Coinbase
ERSX ErisX
FTX FTX

Common behavior

Base URL

The Crypto Data API provides historical data through multiple endpoints. These endpoints have the same URL prefix (omitted from now on):

https://data.alpaca.markets/v1beta1/crypto

This URL is the same for both subscription plans, there is no limitation

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 correspond to when a trade was executed or a quote was generated on the exchange or OTC desk.

Trades

The Trades API provides historcial trade data for a given crypto symbol on a specified date.

[GET] Returns trades for the queried crypto symbol

GET/v1beta1/crypto/{symbol}/trades
This endpoint returns trade historical data for the requested crypto symbol.

Parameters

Path Parameters

symbol
string
The symbol to query for

Query Parameters

exchanges
string
The comma-separated exchanges which can be ERSX, FTX or CBSE. Defaults to All.
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.
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 query parameters
403 Forbidden
Unauthorized
429 Too many requests
Too many requests

Response

{
  "trades": [
      {
          "t": "2021-04-01T00:00:00.348Z",
          "x": "CBSE",
          "p": 58800.01,
          "s": 8.473e-05,
          "tks": "B",
          "i": 151521553
      },
      ...
  ],
  "symbol": "BTCUSD",
  "next_page_token": "QlRDVVNEfDIwMjEtMDQtMDFUMDA6MDI6MTcuMDc0MDAwMDAwWnxDQlNFfDA5MjIzMzcyMDM3MDA2Mjk4MzYw"
}

Properties

t
stringRequired
Timestamp in RFC-3339 format with nanosecond precision.
x
stringRequired
Exchange where the trade happened.
p
numberRequired
Trade price.
s
doubleRequired
Trade size.
tks
stringRequired
TakerSide of the trade (buy, sell, or unspecified)
i
intRequired
Trade ID.

Latest trade

The Latest trade API provides the latest trade data for a given crypto symbol.

[GET] Returns latest trade for the queried crypto symbol

GET/v1beta1/crypto/{symbol}/trades/latest
This endpoint returns latest trade for the requested crypto symbol.

Parameters

Path Parameters

symbol
string
The symbol to query for

Query Parameters

exchange
stringRequired
The comma-separated exchanges which can be ERSX, FTX or CBSE. Defaults to All.

Response

A Trade response object.

Errors

400 Bad request
Invalid query parameters
403 Forbidden
Unauthorized
404 Not found
Not found
429 Too many requests
Too many requests

Response

{
  "symbol": "BTCUSD",
  "trade": {
      "t": "2021-09-18T11:14:46.80939002Z",
      "x": "ERSX",
      "p": 48577.3,
      "s": 1.3003,
      "tks": "B",
      "i": 0
  }
}

Properties

t
stringRequired
Timestamp in RFC-3339 format with nanosecond precision.
x
stringRequired
Exchange where the trade happened.
p
numberRequired
Trade price.
s
doubleRequired
Trade size.
tks
stringRequired
TakerSide of the trade (buy, sell, or unspecified)
i
intRequired
Trade ID.

Quotes

The Quotes API provides quotes for a given crypto symbol at a specified date.

[GET] Returns quotes for the queried crypto symbol

GET/v1beta1/crypto/{symbol}/quotes
This endpoint returns quote historical data for the requested crypto.

Parameters

Path Parameters

symbol
string
The symbol to query for

Query Parameters

exchanges
string
The comma-separated exchanges which can be ERSX, FTX or CBSE. Defaults to All.
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. Defaults to current time.
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 query parameters
403 Forbidden
Unauthorized
429 Too many requests
Too many requests

Response

{
  "quotes": [
      {
          "t": "2021-04-01T00:00:10.495Z",
          "x": "CBSE",
          "bp": 58798.69,
          "bs": 0.12,
          "ap": 58805.39,
          "as": 0.0131436
      },
      ...
  ],
  "symbol": "BTCUSD",
  "next_page_token": "QlRDVVNEfDIwMjEtMDQtMDFUMDg6NDg6NTYuODUyMDAwMDAwWnxDQlNFfDY2OTBCRkQ1"
}

Properties

t
stringRequired
Timestamp in RFC-3339 format with nanosecond precision.
x
stringRequired
Exchange.
ap
numberRequired
Ask price.
as
intRequired
Ask size.
bp
numberRequired
Bid price.
bs
intRequired
Bid size.

Latest quote

The Latest quote API provides the latest quote data for a given ticker symbol.

[GET] Returns latest quote for the queried crypto symbol

GET/v1beta1/crypto/{symbol}/quotes/latest
This endpoint returns latest quote for the requested crypto symbol.

Parameters

Path Parameters

symbol
string
The symbol to query for

Query Parameters

exchange
stringRequired
The comma-separated exchanges which can be ERSX, FTX or CBSE. Defaults to All.

Response

A quotes response object.

Errors

400 Bad request
Invalid query parameters
403 Forbidden
Unauthorized
404 Not found
Not found
429 Too many requests
Too many requests

Response

{
  "symbol": "BTCUSD",
  "quote": {
      "t": "2021-09-18T11:32:24.108Z",
      "x": "ERSX",
      "bp": 48132.12,
      "bs": 0.5456,
      "ap": 49126.6,
      "as": 0.7596
  }
}

Properties

t
stringRequired
Timestamp in RFC-3339 format with nanosecond precision.
x
stringRequired
Exchange.
ap
numberRequired
Ask price.
as
intRequired
Ask size.
bp
numberRequired
Bid price.
bs
intRequired
Bid size.

Bars

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

[GET] Returns bars for the queried crypto symbol

GET/v1beta1/crypto/{symbol}/bars
This endpoint returns aggregate historical data for the requested crypto.

Parameters

Path Parameters

symbol
string
The symbol to query for

Query Parameters

exchanges
string
The comma-separated exchanges which can be ERSX, FTX or CBSE. Defaults to All.
start
string
Filter data equal to or before this time in RFC-3339 format. Fractions of a second are not accepted. Defaults to current time.
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. Limits: 1Min-59Min, 1Hour-23Hour.

Response

A bars response object.

Errors

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

Response

{
  "bars": [
      {
          "t": "2021-04-01T00:00:00Z",
          "x": "CBSE",
          "o": 58800.01,
          "h": 58838,
          "l": 58756.07,
          "c": 58837.71,
          "v": 9.43435863,
          "n": 375,
          "vw": 58792.3224699778
      },
      ...
  ],
  "symbol": "BTCUSD",
  "next_page_token": "QlRDVVNEfE18MjAyMS0wNC0wMVQxNjozOTowMC4wMDAwMDAwMDBafENCU0U="
}

Properties

t
stringRequired
Timestamp in RFC-3339 format with nanosecond precision.
x
numberRequired
Exchnage code for the bar.
o
numberRequired
Open price.
h
numberRequired
High price.
l
numberRequired
Low price.
c
numberRequired
Close price.
v
intRequired
Volume.
false
intRequired
Number of trades.
vw
numberRequired
Volume weighted average price.

XBBO

The XBBO API best bid and offer across venues.

[GET] Returns latest Cross Best Bid and Offer for the queried crypto symbol.

GET/v1beta1/crypto/{symbol}/xbbo/latest
Returns the XBBO for a crypto symbol that calculates the Best Bid and Offer across multiple exchanges. If exchanges is not specified then only the exchanges that can be traded on Alpaca are included in the calculation.

Parameters

Path Parameters

symbol
string
The symbol to query for

Query Parameters

exchanges
string
The comma-separated exchanges which can be ERSX, FTX or CBSE. Defaults to ERSX.

Response

A quotes response object.

Errors

400 Bad request
Invalid query parameters
403 Forbidden
Unauthorized
404 Not found
Not found
429 Too many requests
Too many requests

Response

{
  "t": "2021-08-30T14:25:35.129Z",
  "ax": "ERSX",
  "ap": 48025.71,
  "as": 1.122,
  "bx": "CBSE",
  "bp": 47845.81,
  "bs": 1.65113,
}

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.

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.