Amberdata Blog

How To Get Bitcoin Historical Data Using API

Written by Amberdata | Feb 16, 2024

Digital asset data APIs allow direct access to historical BTC data that can be used to conduct market research and backtest trading strategies. Rather than sifting through spreadsheets or multiple pages of charts from each exchange, a historical crypto price API allows you to directly integrate granular datasets into your analysis and applications. 

Why Use an API for Bitcoin Historical Data?

APIs make it easy to get granular Bitcoin historical data in a structured format. The benefits include:

  • Specify BTC price data by time frames: When price data for specific time periods is needed, an API allows you to pull the data within the exact time frame necessary. If you need large historical datasets of Bitcoin prices, Amberdata also offers AWS S3 for bulk downloads.

  • Automating custom analysis and alerting tailored to your needs: Whether you're building trading algorithms, conducting research, or developing custom applications, an API provides the flexibility to create solutions that align with your objectives.

  • Building scalable solutions for enterprise teams: API integration enables every team in your organization to seamlessly access the datasets relevant to their roles. As the organization becomes more involved in digital assets, the price data API scales alongside you and ensures continuous access to data.

Here is an example of how you can retrieve Bitcoin historical data with Amberdata's API using curl:

curl --request GET \

  --url https://web3api.io/api/v2/market/spot/prices/assets/btc/historical/ \

  --header 'accept: application/json' \

  --header 'x-api-key: YOUR_API_KEY' \

  --query 'startDate=2023-12-01' \

  --query 'endDate=2023-12-31' 

Using Amberdata’s API, you could also download bitcoin's daily VWAP data, which can provide an indicator of recent cryptocurrency volatility.

Retrieving this data manually from multiple exchanges would be quite time consuming. With Amberdata’s historical crypto prices API, you can focus on refining trading strategies instead of data gathering.

Types of Bitcoin Historical Data

As an aggregated DEX/CEX data API, Amberdata offers both centralized and decentralized exchange historical data to deliver complete market insights. Amberdata provides normalized real-time and historical spot price data, derivatives data, full order book depth, liquidations data, and more across both CEX and DEX venues.

With a single integration point, you can access comprehensive historical datasets spanning both on-chain and off-chain activity to understand Bitcoin's full trading history and ecosystem dynamics. Amberdata's unified API makes integrating, analyzing, and displaying unified CEX and DEX data seamless for gaining an information advantage in these complex markets.

CEX – Centralized Exchange Data

Centralized exchanges like Coinbase publish historical market data including prices, tickers, trades, and order books. This enables traders to reconstruct and backtest the exchange environment. 

Here are some key types of historical CEX data available through Amberdata's API:

  1. OHLCV: This dataset provides a comprehensive overview of Bitcoin’s price movements over specific time intervals. Traders often use OHLCV data for technical analysis and chart pattern recognition.

  2. TWAP: Calculated by dividing the total traded value by the total trading time, TWAP is useful for assessing the average price over a specified time period.

  3. VWAP: This metric takes into account both Bitcoin’s price and the trading volume, providing a more nuanced view of market activity.

  4. Best Bid and Best Offer data (BBO): BBO data provides the current best bid and ask prices for a trading pair, representing the highest price a buyer is willing to pay and the lowest price a seller is willing to accept.

Analyzing historical liquidations against prices and order book dynamics offers clues to market behavior and risk exposure at key inflection points. These insights help anticipate downside volatility and major BTC price changes.

DEX – Decentralized Exchange Data

Decentralized exchanges generate historical OHLCV and liquidity data that captures the on-chain activity of DeFi protocols. Exchange prices only reveal part of the story due to the DeFi price data calculation which is derived from the following formula: (O+H+L+C) / 4 with the prices being denominated in ETH. 

However, decentralized exchange data requires specialized calculations compared to centralized counterparts because Bitcoin’s prices are determined algorithmically based on liquidity pools rather than order book bids and offers.

Here's a breakdown of key metrics and their nuances in the DEX realm:

  • OHLCV: DEX OHLCV data is typically derived from historical transactions rather than order books. It's calculated by aggregating transaction prices for a given time interval (e.g., hourly, daily) to determine the open, high, low, close, and volume values.

  • TWAP: TWAP on DEXs is often calculated using a formula that weights prices based on the amount of assets traded at each price point within a specified time period. This accounts for the varying liquidity levels across different price levels.

  • VWAP: Similar to TWAP, VWAP on DEXs considers both price and volume but uses a different weighting approach. It calculates a cumulative average price based on the total volume traded at each price point within a given time period.

  • Liquidity and Liquidity Pools: Total liquidity locked in a liquidity pool is typically calculated by summing the value of all assets deposited in the pool at current market prices.

  • Transactions: Transaction data is extracted directly from DEX blockchains and includes timestamps, token amounts, addresses, and other relevant details.

Analyzing DEX data provides visibility into emerging crypto sectors beyond just Bitcoin, like decentralized finance and NFTs. This equips traders to diversify and manage risk across assets. 

Role of Bitcoin Historical Data In Trading

Institutional traders utilize historical data for trading to identify patterns and probabilities that can inform future price movements. This may involve spotting recurring formations like flags, head and shoulders, peaks and troughs or computing indicators like moving averages, Bollinger Bands, RSI, and Fibonacci levels. 

Historical data also enables backtesting trading strategies by replaying them across different periods. This allows traders to objectively evaluate an asset’s performance before risking capital. 

Correlation with Other Financial Instruments

Analyzing correlations between Bitcoin and altcoin markets as well as traditional assets using historical data uncovers opportunities to buy and sell between instruments. For example, quantifying that Ether price movements lead Bitcoin’s by a few days provides an edge in the market. 

Understanding Market Behavior and Volatility

Understanding Bitcoin’s historical volatility through metrics like standard deviation, value at risk, and maximum drawdown ensures appropriate position sizing. By studying previous market crashes, traders gain perspective for navigating panic cycles and managing emotions. 

Timing Investments

While past performance does not guarantee future results, historical data at key support and resistance levels serves as a reference point for entering and exiting positions. Traders may look to buy Bitcoin after a 30% drawdown if previous drawdowns of this magnitude led to rebounds. 

No single indicator provides perfect signals, but combining insights from historical exchange data, on-chain data, and social data can mean the difference between making informed trading decisions versus gambling in the dark. 

This is why learning how to get Bitcoin historical data using an API is the first step to developing effective trading strategies, managing risks, and ultimately making better-informed investment decisions in the highly volatile cryptocurrency markets.

Amberdata Provides Comprehensive Historical Bitcoin Market Data

Amberdata provides historical Bitcoin market data from over 100 global crypto exchanges going back to 2013 for trading venues like Coinbase, Binance, and Gemini spanning 5,000+ trading pairs.

Here are a few key highlights of Amberdata's offerings:

  • Coinbase Exchange Market Data Partnership: Amberdata's collaboration with Coinbase enhances the platform's data coverage, providing users with a more comprehensive view of historical market trends, including full order book history.

  • Wide Range of Exchanges and Trading Pairs: With data spanning across 100+ CEX and DEX exchanges and 5,000+ trading pairs, Amberdata ensures users have access to an extensive dataset for in-depth analysis and research.

  • Amberdata delivers this data via flexible APIs and bulk downloads via Amazon AWS S3, as well as through partnerships with Snowflake and Google Analytics Hub.

To learn more about how to get Bitcoin historical data via API, book a demo to gain firsthand insights into the platform's capabilities and how it can be leveraged for institutional crypto trading