Coins: 17,637
Exchanges: 1,460
Market Cap: $2.621T 1.0%
24h Vol: $100.775B
Gas: 0.046 GWEI
Remove Ads
API
TABLE OF CONTENTS

How to Download Bitcoin Historical Price Data (Step-by-Step Guide)

4.5
| by
Dev Panwar
|
Edited by
Brian Lee
-

Bitcoin has a long and eventful trading history that makes it one of the most analyzed assets in the world. Historical price data is not just numbers on a chart—it’s the foundation for backtesting strategies, spotting market cycles, understanding investor behavior, and even powering apps or research tools. Reliable data helps traders validate decisions, researchers test theories, and developers build features that their users can trust.

In this guide, we’ll walk through two practical ways to download Bitcoin’s historical price data using CoinGecko’s resources:

  • Direct export from the Bitcoin page on CoinGecko (no code required).

  • Using the CoinGecko API for automated access in spreadsheets or code.

By the end, you’ll be equipped to retrieve Bitcoin’s past prices, whether you need a quick CSV file for analysis or an automated data feed for your project.

How To Download Bitcoin Historical Data


How to Download Bitcoin Historical Data in Excel or CSV Format?

The quickest way to download historical Bitcoin data is directly from the CoinGecko Bitcoin Historical Data page. This method is perfect for anyone who needs the data in a CSV or Excel spreadsheet format for a quick one-off analysis, as no account sign-up or login is required.

If you need more granular data, the CoinGecko API provides endpoints like /coins/{id}/market_chart and /coins/{id}/ohlc for historical prices and OHLC data.

How to Download Bitcoin Historical Data From The CoinGecko Website

Follow these simple steps to download the data in just a few clicks.

Step 1: Navigate to the Bitcoin coin page on CoinGecko and click the Historical Data tab.

Step 2: Select your desired timeframe from the options available (e.g., last 7 days, 30 days, 1 year, or a custom date).

Step 3: In the top-right corner of the data table, click the Download Icon and choose to download the data as a CSV or XLS file as seen below:

How To Download Bitcoin Historical Data From The CoinGecko Website

Once downloaded, the file can be opened in any spreadsheet software like Excel or Google Sheets. The data is pre-formatted with clear column headers (Date, Market Cap, Volume, Price), ready for you to create charts, run calculations, or import into other tools.

Here is an example of the exported data in Microsoft Excel:

How To Download Bitcoin Historical Data From The CoinGecko Website|Results


How to Download Bitcoin Historical Data Using CoinGecko API?

For repeatable workflows, precise time windows, or data you can refresh on demand, the CoinGecko API is the ideal solution. It allows you to pull Bitcoin’s historical prices directly into your spreadsheets or projects for analysis, dashboards, or backtesting trading strategies.

There are two primary ways to use the API:

  • No-Code: Import data directly into Google Sheets or Excel.

  • With Code: Fetch data programmatically using languages like Python, JavaScript, PHP, and more.

Both methods require a CoinGecko API key. If you don’t have one, follow this guide to get your free Demo API key. For this guide, the API coin ID for Bitcoin is simply bitcoin.


Download Bitcoin Historical Data in Google Sheets or Excel (No Code)

If you prefer a no-code approach, you can pull Bitcoin's historical price data directly into Google Sheets or Excel using the CoinGecko API. This allows you to analyze, chart, and share the data without any programming.

Google Sheets

You can use the free API Connector extension to pull the data.

  1. Install API Connector: Add the "API Connector by Mixed Analytics" extension from the Google Workspace Marketplace.

  2. Create a New Request: In the extension, create a new request and enter the CoinGecko API request URL for historical data:

    • Demo API:
      https://api.coingecko.com/api/v3/coins/bitcoin/market_chart?vs_currency=usd&days=30&interval=daily&precision=full?x_cg_demo_api_key=YOUR_API_KEY

    • Pro API:
      https://pro-api.coingecko.com/api/v3/coins/bitcoin/market_chart?vs_currency=usd&days=30&interval=daily&precision=full?x_cg_pro_api_key=YOUR_API_KEY

  3. Run the Request: Execute the request to pull the data into your current sheet and download the data in your desired format.

For a detailed walkthrough with screenshots, read our full guide on how to import crypto prices into Google Sheets.

Microsoft Excel:

Excel's built-in Power Query tool can fetch data directly from the API.

  1. Open Power Query: In Excel, go to the Data tab and select From Web.

  2. Enter API URL: In the dialog box, enter the API request URL:

    • Demo Api:
      https://api.coingecko.com/api/v3/coins/bitcoin/market_chart?vs_currency=usd&days=30&interval=daily&precision=full?x_cg_demo_api_key=YOUR_API_KEY

    • Pro Api:
      https://pro-api.coingecko.com/api/v3/coins/bitcoin/market_chart?vs_currency=usd&days=30&interval=daily&precision=full?x_cg_pro_api_key=YOUR_API_KEY

  3. Transform and Load: The Power Query Editor will open, allowing you to transform the JSON response into a table before loading it into your worksheet for download and export.

For a detailed walkthrough with screenshots, read our full guide on how to import crypto prices into Excel.


Download Bitcoin Historical Data with Python 

For more advanced or automated use cases, you can fetch data programmatically. While the CoinGecko API works with any language that supports HTTP requests, this guide uses Python due to its popularity in data analysis.

API Endpoints and URLs

The base URLs for the Demo and Pro APIs are:

  • Demo API: https://api.coingecko.com/api/v3

  • Pro API: https://pro-api.coingecko.com/api/v3

For historical price data, we will use the /coins/{id}/market_chart endpoint. This endpoint returns prices, market caps, and 24h volumes for a specified number of days.

In this section, we’ll walk through how to use Python to fetch Bitcoin’s historical price data.

Step 1: Prerequisites

  1. Install Python

    • Download from python.org.

    • Version 3.7 or above is recommended.

    • Confirm installation by running this on your Terminal or Command Prompt:

python --version
 

  1. Create a Virtual Environment

This keeps dependencies clean and project-specific. First, run the command below in your Terminal or Command Prompt to create the environment:

python -m venv coingecko_env

Next, activate it using the command for your operating system:

  • Windows: coingecko_env\Scripts\activate

  • macOS/Linux: source coingecko_env/bin/activate
     

  1. Install Required Packages

In your environment, install the following packages:

  • Requests: Allows your program to make API calls (send and receive data over the web).

  • Pandas: A powerful library for handling and organizing tabular data. We’ll use it to tidy up the API output.

  • Openpxyl: A library that lets Pandas write to Excel workbooks.

  • Pathlib: A handy standard library tool to check if a file already exists.

pip install requests pandas openpxyl pathlib
 

  1. Check If The Packages Are Correctly Installed

You can confirm the packages are installed by running:

pip show requests pandas
 

Step 2: Managing Your API Keys

To keep your API key secure and separate from your code, store it in an external JSON file.

Create a file named api_keys.json and add your keys like this:

Step 3: Setting up key retrieval and API calling

Once you have installed the prerequisites and securely stored your API keys in the appropriate locations, the next step is to set up helper functions that ensures:

  • Your API keys are being loaded correctly.

  • The program can successfully communicate with the CoinGecko API.

First, we'll set up helper functions to load the API key and make requests to the CoinGecko API. The get_Response() function will handle the API calls, taking the endpoint, headers, and parameters as arguments. This modular approach keeps the code clean and reusable.

💡 Pro Tip: Reuse the get_Response() helper function for any API request. Simply provide the specific endpoint, headers with a Demo or Pro key, params, and base_url as arguments for each call.

Step 4: Test the API Connection

Before fetching the full dataset, it's good practice to test your setup. The /ping endpoint is a simple way to confirm that your API key is working correctly. The following script loads your key, pings the API, and then makes a small test call to fetch the first two data points for Bitcoin.

If everything is working, you should see a response as shown below:

Test the API Connection | Expected Results

Step 5: Fetching Bitcoin Historical Price Data

Now, let's use the /coins/{id}/market_chart endpoint to fetch historical data for the last 7 days.

What this does:

  • Calls the Coin Historical Chart Data by ID endpoint via get_Response().

  • Stores the JSON response in mc.

  • Make sure to define the key, headers, endpoint, and params.

Step 6: Process and Download the Data to Excel

The API response returns prices, market caps, and volumes in separate lists of lists. The following code processes this raw JSON data, combines it into a clean Pandas DataFrame, and saves it to a sheet in an Excel workbook. If the file already exists, it will replace the sheet to allow for easy reruns of the script.

Example output:

Process and Download the Data to Excel | Example Output

You can customize the output by changing these variables:

  • value_col: rename columns (e.g., "price_in_usd").

  • sheet_name: set how your Excel sheet will appear (e.g., "btc_30d_eur").

  • out_path: choose the filename or folder for saving your Excel workbook.

💡 Pro Tip: During development, it’s best to keep Excel files closed when you run the script to avoid write errors.

How to Download Historical Data for Other Cryptocurrencies

While this guide uses Bitcoin as the example, the same methods apply to thousands of other cryptocurrencies available on CoinGecko. To fetch another coin’s data, simply replace the coin ID in your API call (for example, change "bitcoin" to "ethereum" or "solana").

You can find the API ID on any individual coin page on the CoinGecko website.

How to Get a Coin's API ID from CoinGecko Website

💡 Pro Tip: Coin IDs are case-sensitive, and multiple coins may share similar tickers. To avoid mistakes, always obtain and use the correct ID directly from the CoinGecko website or our API documentation.

Future Developments

With access to historical data, you can build a variety of powerful tools. For readers who want to explore further, here are some related guides:

Subscribe to CoinGecko API


Conclusion

In this guide, we demonstrated two effective methods for downloading Bitcoin historical data from CoinGecko. The direct export from the website is ideal for quick, manual data pulls into CSV or Excel, while the CoinGecko API offers a powerful, programmatic solution for developers and analysts using tools like Google Sheets, Excel, or Python. By following the steps outlined, you can access the rich historical data needed to power your analysis, backtest strategies, and build DeFi applications.

While the endpoints used in this article can be accessed with a free Demo API key, it only provides up to 365 days of historical data. To access data back to 2013 with greater granularity, higher rate limits, and access to exclusive endpoints, consider subscribing to a paid API plan.

CoinGecko's Content Editorial Guidelines
CoinGecko’s content aims to demystify the crypto industry. While certain posts you see may be sponsored, we strive to uphold the highest standards of editorial quality and integrity, and do not publish any content that has not been vetted by our editors.
Learn more
Want to be the first to know about upcoming airdrops?
Subscribe to the CoinGecko Daily Newsletter!
Join 600,000+ crypto enthusiasts, traders, and degens in getting the latest crypto news, articles, videos, and reports by subscribing to our FREE newsletter.
Tell us how much you like this article!
Vote count: 8
Dev Panwar
Dev Panwar
Dev Panwar is a Growth Marketing intern at CoinGecko with a background in computer science and experience in blockchain engineering. He writes on technology, innovation, and practical applications, aiming to make complex ideas accessible to readers.

Related Articles

New Portfolio
Icon & name
Select Currency
Suggested Currencies
USD
US Dollar
IDR
Indonesian Rupiah
TWD
New Taiwan Dollar
EUR
Euro
KRW
South Korean Won
JPY
Japanese Yen
RUB
Russian Ruble
CNY
Chinese Yuan
Fiat Currencies
AED
United Arab Emirates Dirham
ARS
Argentine Peso
AUD
Australian Dollar
BDT
Bangladeshi Taka
BHD
Bahraini Dinar
BMD
Bermudian Dollar
BRL
Brazil Real
CAD
Canadian Dollar
CHF
Swiss Franc
CLP
Chilean Peso
CZK
Czech Koruna
DKK
Danish Krone
GBP
British Pound Sterling
GEL
Georgian Lari
HKD
Hong Kong Dollar
HUF
Hungarian Forint
ILS
Israeli New Shekel
INR
Indian Rupee
KWD
Kuwaiti Dinar
LKR
Sri Lankan Rupee
MMK
Burmese Kyat
MXN
Mexican Peso
MYR
Malaysian Ringgit
NGN
Nigerian Naira
NOK
Norwegian Krone
NZD
New Zealand Dollar
PHP
Philippine Peso
PKR
Pakistani Rupee
PLN
Polish Zloty
SAR
Saudi Riyal
SEK
Swedish Krona
SGD
Singapore Dollar
THB
Thai Baht
TRY
Turkish Lira
UAH
Ukrainian hryvnia
VEF
Venezuelan bolívar fuerte
VND
Vietnamese đồng
ZAR
South African Rand
XDR
IMF Special Drawing Rights
Cryptocurrencies
BTC
Bitcoin
ETH
Ether
LTC
Litecoin
BCH
Bitcoin Cash
BNB
Binance Coin
EOS
EOS
XRP
XRP
XLM
Lumens
LINK
Chainlink
DOT
Polkadot
YFI
Yearn.finance
SOL
Solana
Bitcoin Units
BITS
Bits
SATS
Satoshi
Commodities
XAG
Silver - Troy Ounce
XAU
Gold - Troy Ounce
Select Language
Popular Languages
EN
English
RU
Русский
DE
Deutsch
PL
język polski
ES
Español
VI
Tiếng việt
FR
Français
PT-BR
Português
All Languages
AR
العربية
BG
български
CS
čeština
DA
dansk
EL
Ελληνικά
FI
suomen kieli
HE
עִבְרִית
HI
हिंदी
HR
hrvatski
HU
Magyar nyelv
ID
Bahasa Indonesia
IT
Italiano
JA
日本語
KO
한국어
LT
lietuvių kalba
NL
Nederlands
NO
norsk
RO
Limba română
SK
slovenský jazyk
SL
slovenski jezik
SV
Svenska
TH
ภาษาไทย
TR
Türkçe
UK
украї́нська мо́ва
ZH
简体中文
ZH-TW
繁體中文
Welcome to CoinGecko
Welcome back!
Login or Sign up in seconds
or
Sign in with . Not you?
Forgot your password?
Didn't receive confirmation instructions?
Resend confirmation instructions
Password must contain at least 8 characters including 1 uppercase letter, 1 lowercase letter, 1 number, and 1 special character
By continuing, you acknowledge that you've read and agree fully to our Terms of Service and Privacy Policy.
Get Price Alerts with CoinGecko App
Forgot your password?
You will receive an email with instructions on how to reset your password in a few minutes.
Resend confirmation instructions
You will receive an email with instructions for how to confirm your email address in a few minutes.
Get the CoinGecko app.
Scan this QR code to download the app now App QR Code Or check it out in the app stores
Add NFT
Track wallet address
Paste
We only display assets from supported networks.
Ethereum Mainnet
Base Mainnet
BNB Smart Chain
Arbitrum
Avalanche
Fantom
Flare
Gnosis
Linea
Optimism
Polygon
Polygon zkEVM
Scroll
Stellar
Story
Syscoin
Telos
X Layer
Xai
Read-only access
We only fetch public data. No private keys, no signing, and we can't make any changes to your wallet.
Create Portfolio
Select icon
💎
🔥
👀
🚀
💰
🦍
🌱
💩
🌙
🪂
💚
CoinGecko
Better on the app
Real-time price alerts and a faster, smoother experience.
You’ve reached the limit.
Guest portfolios are limited to 10 coins. Sign up or log in to keep the coins listed below.