How to get current Bitcoin price from API?

Hi,
this can’t be that hard. I’d like to display the current Bitcoin price value on my lovelace dashboard.

Could get it e.g. from here: https://api.coindesk.com/v1/bpi/currentprice/EUR.json

return is a JSON format, I’m only interested in the EUR value, but those are details.

Do I need to create an entity? a device? a service? a template? a script? I am a bit confused by all the options. Tried templating but failed on the syntax :-/ Would appreciate if someone can help me get the json return, i can probably take it from there.

Thanks

There’s an integration for that:

1 Like

Oh wow, that was quick! Thanks a lot Tediore! Even easier with that.

Well, consider the topic closed, but as a curious person I’d still love to know if there is an easy way to ping an external API and parse the incoming JSON. You never know when you need that again :slight_smile:

Yes there is! You can use a REST sensor.
You’d want to define a value_template to only grab the data you want. In this case, it would be

value_template: "{{ value_json['bpi']['EUR']['rate'] }}"

(or rate_float if you don’t want the comma)

1 Like

I am getting ConnectionResetError: [Errno 104] Connection reset by peer error from this integration for 2 days now. Until then it was working perfectly.

Perfect! The sky is the limit :smiley:

We made BitFetch and started using it with HA due to the unreliability of the Bitcoin sensor as well as the CoinMarketCap and other cryptocurrency HA sensors stopped working. We don’t have a custom component (yet!) but our team is successfully using it with HA in their homes via Node Red.

More info here: BitFetch.io - Integrate Bitcoin & Cryptocurrency Data into Home Assistant!

BitFetch supports hundreds of cryptocurrencies and multiple exchanges. We’re happy to help you set it up if you need help, just DM us or reply here, and would love your feedback.