Can't get BTC Historical data?

Hello,

I’m totally new to API’s and coding and I’m struggling to understand the documentation page. I’m trying to import BTC bar data from the start of 2018 - end of 2022. But when I run my crypto bars request I’m only getting data from 2020-04-08 onward.

Any help would be greatly appreciated. I’m using python in a jupyter notebook. This is what I have:

client = CryptoHistoricalDataClient(alpaca_api_key, alpaca_secret_key)

request_params = CryptoBarsRequest(
                        symbol_or_symbols=["BTC/USD"],
                        timeframe=TimeFrame.Day,
                        start="2018-01-01",
                        end="2022-01-01",
                        limit='10000',
                 )

bars = client.get_crypto_bars(request_params)

# convert to dataframe
bars_df = bars.df

# access bars as list - important to note that you must access by symbol key
# even for a single symbol request - models are agnostic to number of symbols
#bars["BTC/USD"]
bars_df

Hi @gibby,

It appears that our alpaca_py SDK defaults to the newer version of our API (v1beta2) that does not support historical data for more than 2 years. We are working on a fix right now.

An immediate solution for you is to switch to alpaca-trade-API-python (GitHub - alpacahq/alpaca-trade-api-python: Python client for Alpaca's trade API) for now, as this is set up for backward compatibility of API versioning (v1beta1).

Thanks,
Kavin, PM @ Alpaca