8

Does anyone know where to download historical data for the total market capitalization of the cryptocurrency ecosystem? For example, the data behind the "Total Market Capitalization" chart here: https://coinmarketcap.com/charts/.

Their API only allows access to the current market cap, not historical data. I've tried contacting them, but thought I would ask here as well. I would like to avoid calculating it myself if possible...

P.S. I've seen this question but no one suggested a source for the market cap data.

3 Answers 3

6
+100

As @philshem suggested I wrote some python to gather the data

import pandas as pd
import requests
import re
from bs4 import BeautifulSoup

# Create date range for historical snapshots
Date = pd.date_range(start='20130428', end='20171210', freq='7D').strftime('%Y%m%d')

# Retrieve market cap value in dollars
market_cap = []

for date in Date:

    # Retrieve historical snapshot data from date
    page = requests.get('https://coinmarketcap.com/historical/'+date)
    soup = BeautifulSoup(page.content, 'html.parser')

    # Extract marketcap value from span
    market_cap.append(int(re.sub(r',|\$', '', soup.find('span', {'id' : 'total-marketcap'}).text.strip())))

# Create data frame of data
df = pd.DataFrame({'Total Market Cap':market_cap}, index=Date)

# Write data to file
df.to_csv('total_market_cap.csv')

This gets the total market cap value from each snap shot which is taken each sunday.

2
  • This does not seem to work anymore ... Do you know if it would be easily fixable ? Jan 4, 2020 at 19:10
  • Last of what I saw Coinmarketcap were making an API, perhaps there's an API available now for use.
    – Jerry
    Jan 7, 2020 at 9:33
3

Scraping your link is not too difficult, because the raw data is in the source code.

First, create a list of all possible dates, from this URL

https://coinmarketcap.com/historical/

['20130428','20130505','etc...']

Then loop over each date and download the raw HTML. From each file, like 20130428.HTML, you can see the raw data in the source. Here's an example of BTC from that date:

<td class="text-left col-symbol">BTC</td>
<td class="no-wrap market-cap text-right" data-usd="1261032047.28" data-btc="11114671.5035">$1.26 B</td>

corresponds to this view in the browser

enter image description here

1

For Bitcoin only, this page offers download links:

http://data.bitcoinity.org/markets/market_cap/all/USD?t=l

Maybe contact the site owner for more data, seems to be a single person.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.