core: Coinmarketcap integration broken/outdated. It uses new API now.

The problem

Coinmarketcap sensors are not working anymore. It seems to use new API now.

Environment

  • Home Assistant release with the issue: 0.106.5
  • Last working Home Assistant release (if known): 0.106.5
  • Operating environment (Hass.io/Docker/Windows/etc.):
  • Integration causing this issue: coinmarketcap
  • Link to integration documentation on our website: https://www.home-assistant.io/integrations/coinmarketcap/

Problem-relevant configuration.yaml

sensor:
  - platform: coinmarketcap

Traceback/Error logs

going to https://api.coinmarketcap.com/v2/ticker/ will give out following message: 

{"statusCode": 410,"error": "Gone","message": "WARNING: This API is now offline. Please switch to the new CoinMarketCap API. (https://pro.coinmarketcap.com/migrate/)"}

Additional information

someone has the same problem and reported it here https://community.home-assistant.io/t/coinmarketcap-platform-uses-an-outdated-api/176812

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 16 (1 by maintainers)

Most upvoted comments

Hi For those still wanting to use Coin Market Cap i have included by configuration which uses the Command_Line integration to use a curl command to hit the new Coin Market Cap REST API and extract relevant data. This solution relies on users subscribing to the new Coin Market Cap API with a Free account which includes 333 API credits. (https://coinmarketcap.com/api/)

Once you have an API key then this can be used with the following configuration. The configuration extracts BTC, ETH, and ETC values every 10 minutes via a single REST quote request. The individual coin prices are then split out into individual sensor templates for presentation. The API documentation is quite good if you wish to extract other information.

Hopefully the integration gets fixed eventually, even if the user has to insert their own API key.

sensor:

  • platform: command_line name: coinmarketcap_curl command: ‘/usr/bin/curl -X GET -H “X-CMC_PRO_API_KEY: INSERT CMC API KEY HERE” -H “Accept: application/json” -d “symbol=ETH,ETC,BTC&convert=AUD” -G “https://pro-api.coinmarketcap.com/v1/cryptocurrency/quotes/latest”’ value_template: ‘{{ value_json.value }}’ scan_interval: 600 #10 mins refresh (144 credits / day used) json_attributes:

    • data
  • platform: template sensors: btc_price: friendly_name: ‘Bitcoin Price’ unit_of_measurement: ‘AUD’ value_template: ‘{{ ((states.sensor.coinmarketcap_curl.attributes.data.BTC.quote.AUD.price) | float) | round(2) }}’

    eth_price: friendly_name: ‘Ethereum Price’ unit_of_measurement: ‘AUD’ value_template: ‘{{ ((states.sensor.coinmarketcap_curl.attributes.data.ETH.quote.AUD.price) | float) | round(2) }}’

    etc_price: friendly_name: ‘Ethereum Classic Price’ unit_of_measurement: ‘AUD’ value_template: ‘{{ ((states.sensor.coinmarketcap_curl.attributes.data.ETC.quote.AUD.price) | float) | round(2) }}’

May i suggest considering a switch to CoinGecko API? https://www.coingecko.com/en/api The endpoints are public, open, and freely available to access all 7000+ tokens data from https://www.coingecko.com

It should be an easy integration and drop in. Let me know what you think, and happy to answer any questions!