Crypto Information using Nomics API - Bitcoin, Ethereum etc

Can you show your nomicsapi (with the actual key obfuscated. Are you sure the coins are set correct in there?

Actually, try going to the address from your nomicsapi - it should return a load of json?

Really, if the key and api is correct, there isnt a lot to go wrong.

nomicsapi: https://api.nomics.com/v1/currencies/ticker?key=<xxxxxd00afdc1e2bxxxxxxe317d5687b8xxxxxx>&ids=<BTC,ETH,LTC>&interval=1h,1d,7d,30d&per-page=100&page=1&sort=first_priced_at

That it is what I have on secrets.yaml

Cool, a nice easy fix then. Youā€™ve kept the angular brackets around the API Key and COINS. These needed to be removed.

https://api.nomics.com/v1/currencies/ticker?key=861fa1d00afdc1e2b659889e317d5687b80968a9&ids=BTC,ETH,LTC&interval=1h,1d,7d,30d&per-page=100&page=1&sort=first_priced_at

This works perfect. Just substitute a new API key back in.

ahhh! Ok thank you very much! :slight_smile:

It works!

Butā€¦ I see it goes all sensor to unavailable every 10 seconds

Edit:

After a day, I see sometimes is unavailable during most of the time, taking up to 30 minutes to retrieve new data. It is normal?

Screen Shot 2021-05-31 at 18.18.59

Great Job Craig. Thank you so much. It was exactly what I was looking for. But one small problem :slight_smile: When i insert the data for Dodge Coin the card is showing XRP symbol. Does somebody have the same problem or is it just me?

sorry. it was me

Sorry, I must have missed your message a couple of days ago.

Looking at the constant unknown values your having - im going to suggest that maybe you have more than one template sensor connecting to the nomics API? You are limited to 1 call per second with Nomics.

This is why I call the data for all the coins I access in one template.

Have you made multiple rest sensors? You should only have one connection to the resource. So you code shouold be something like the below, with the sensors set up from just one rest call.

  - resource: !secret nomicsapi
    scan_interval: 10
    sensor:
      - name: "Coin one".
       .........
       .........
      - name: "Coin two".
       .........
       .........
      - name: "Coin three".
       .........
       .........

I pull both DOGE and XRP and they both work fine so im guessing as youve figured out it was something your end :slight_smile:
You do need to call all the coins in the same rest sensor and then split them out to seperate sensors though, which can be problematic as you can only sort by market cap or the time they were first listed on nomics.
Sorting by market cap isnt ideal for anyone wanting info from various coins as it can change. So you would think sorting by the time first listed would solve this issue - however nomics only listed a load of coins last year so it falls back to sorting by market cap. Therefore, i do sometimes get my XRP and DOGE coin sensors interchange due to them having similar caps

From the guys at nomics they told me

 We started tracking the first price date about a year ago and before that we don't have data, so since you're asking about a bunch of older coins here they actually all have the same start date when we started tracking things. So then they fall back to rank sort.

I dont really understand why they therefore wont allow you to filter by first trade, first candle or first order book as they do store all this info in their API and the info is correct. I did ask if they would add any of these as potential filters but the answer was no :frowning:

when i change everything to EUR it doesnā€™t work and still shows USD prices strange?
anyone idea?

      - name: "Crypto - SUSHI"
        json_attributes_path: "$.[1]"
        value_template: '{{ value_json[1].price | round(4) }}'
        unit_of_measurement: "EUR"
        json_attributes:

Did you also add convert=EUR to the link?

https://api.nomics.com/v1/currencies/ticker?key=<APIKEY>&ids=<COINS>&convert=EUR&interval=1h,1d,7d,30d&per-page=100&page=1&sort=first_priced_at

This is such a cool integration, but I am having trouble with the sort order. I managed to figure out how to get the attributes path (regardless of order) as follows. Does anyone know if the value_json can also use a JSONPath instead of the index? I cannot use the index because the sort order could change.

  - name: "Crypto - ETH"
    json_attributes_path: "$.[?(@.id == 'ETH')]"
    value_template: '{{ value_json[0].price | round(4) }}'
    unit_of_measurement: "USD"
    json_attributes:
      - name
      - symbol
      - price
      - logo_url
      - rank
      - high
      - high_timestamp
      - market_cap
      - first_trade

Regards,
Ultrajones

For those trying to deal with the sort order issue, I am posting the solution here. Simply duplicate the code below for each coin you want to track, then replace RTM with the desired crypto coin (e.g. ETH).

  ### RTM
  - name: "Crypto - RTM"
    json_attributes_path: "$[?(@.id=='RTM')]"
    value_template: "{{ value_json | selectattr('id', 'equalto', 'RTM') | map(attribute='price') | list | first | round(4) }}"
    unit_of_measurement: "USD"
    json_attributes:
      - name
      - symbol
      - price
      - logo_url
      - rank
      - high
      - high_timestamp
      - market_cap
      - first_trade
  - name: "Crypto - RTM - 1 Hr"
    json_attributes_path: "$[?(@.id=='RTM')].1h"
    unit_of_measurement: "USD"
    value_template: "{{ value_json | selectattr('id', 'equalto', 'RTM') | map(attribute='1h') | map(attribute='price_change') | list | first | round(4) }}"
    json_attributes:
      - price_change_pct
  - name: "Crypto - RTM - 1 Day"
    json_attributes_path: "$[?(@.id=='RTM')].1d"
    unit_of_measurement: "USD"
    value_template: "{{ value_json | selectattr('id', 'equalto', 'RTM') | map(attribute='1d') | map(attribute='price_change') | list | first | round(4) }}"
    json_attributes:
      - price_change_pct
  - name: "Crypto - RTM - 7 Day"
    json_attributes_path: "$[?(@.id=='RTM')].7d"
    unit_of_measurement: "USD"
    value_template: "{{ value_json | selectattr('id', 'equalto', 'RTM') | map(attribute='7d') | map(attribute='price_change') | list | first | round(4) }}"
    json_attributes:
      - price_change_pct
  - name: "Crypto - RTM - 30 Day"
    json_attributes_path: "$[?(@.id=='RTM')].30d"
    unit_of_measurement: "USD"
    value_template: "{{ value_json | selectattr('id', 'equalto', 'RTM') | map(attribute='30d') | map(attribute='price_change') | list | first | round(4) }}"
    json_attributes:
      - price_change_pct
3 Likes

Perfect solution and works, however a quick heads up that if you used the original post you canā€™t do a straight drop in.

In the original post the sensors were named Crypto - [coin] - 1 D
In the above solution theyā€™re called Crypto - [coin] - 1 Day
(same for 7 and 30 days)

Took me ages to spot this and work out why my views in Lovelace has stopped rendering. Thanks for the solution @ultrajones

Had a great day having found this thread and updated my previous solution for crypto tracking to use this. - thanks to all who have contributed and of course the original post!! This then led me to having a good play with the lovelace example provided which Iā€™ve tweaked (cos thatā€™s what you do in HomeAssistant) and come out with a slightly different take on an already excellent example:

Played around the monetary and percentage fields to fix them as currency (where required) and also to carry 2 decimals. Added a range selector for the graph which is now rendered in Apex Charts and also changed the styling of the movement data.

Would love to see what others have doneā€¦

Hi all,

First of all thanks @Craig_McGowan for sharing this, I was going to use another solution using coingecko but found this one to be more easy to implement but I must say that I had a bad surprise when after my first month I got a bill for $420 so I must clearly be doing something wrong.

I followed up the details provided by @Craig_McGowan but must have definitively missed something.

Did I get this wrong that this would be free if under a certain data consomption?

Hereā€™s my rest sensor setup, can anyone help me spot what the issue is please, I love this integration but +$400/month is not coing to cut it.

Thanks in advance

rest:
    resource: !secret nomics_crypto_api
    scan_interval: 10
    sensor:
   ### ETH
     - name: "Crypto - ETH"
       json_attributes_path: "$.[0]"
       value_template: '{{ value_json[0].price | round(4) }}'
       unit_of_measurement: "USD"
       json_attributes:
         - name
         - symbol
         - price
         - logo_url
         - rank
         - high
         - high_timestamp
         - market_cap
         - first_trade
     - name: "Crypto - ETH- 1 Hr"
       json_attributes_path: "$.[0].1h"
       unit_of_measurement: "USD"
       value_template: '{{ value_json[0]["1h"]["price_change"] | round(4) }}'
       json_attributes:
         - price_change_pct
     - name: "Crypto - ETH - 1 D"
       json_attributes_path: "$.[0].1d"
       unit_of_measurement: "USD"
       value_template: '{{ value_json[0]["1d"]["price_change"] | round(4) }}'
       json_attributes:
         - price_change_pct
     - name: "Crypto - ETH - 7 D"
       json_attributes_path: "$.[0].7d"
       unit_of_measurement: "USD"
       value_template: '{{ value_json[0]["7d"]["price_change"] | round(4) }}'
       json_attributes:
         - price_change_pct
     - name: "Crypto - ETH - 30 D"
       json_attributes_path: "$.[0].30d"
       unit_of_measurement: "USD"
       value_template: '{{ value_json[0]["30d"]["price_change"] | round(4) }}'
       json_attributes:
         - price_change_pct
    ### ADA
     - name: "Crypto - ADA"
       json_attributes_path: "$.[1]"
       value_template: '{{ value_json[1].price | round(4) }}'
       unit_of_measurement: "USD"
       json_attributes:
         - name
         - symbol
         - price
         - logo_url
         - rank
         - high
         - high_timestamp
         - market_cap
         - first_trade
     - name: "Crypto - ADA - 1 Hr"
       json_attributes_path: "$.[1].1h"
       unit_of_measurement: "USD"
       value_template: '{{ value_json[1]["1h"]["price_change"] | round(4) }}'
       json_attributes:
         - price_change_pct
     - name: "Crypto - ADA - 1 D"
       json_attributes_path: "$.[1].1d"
       unit_of_measurement: "USD"
       value_template: '{{ value_json[1]["1d"]["price_change"] | round(4) }}'
       json_attributes:
         - price_change_pct
     - name: "Crypto - ADA - 7 D"
       json_attributes_path: "$.[1].7d"
       unit_of_measurement: "USD"
       value_template: '{{ value_json[1]["7d"]["price_change"] | round(4) }}'
       json_attributes:
         - price_change_pct
     - name: "Crypto - ADA - 30 D"
       json_attributes_path: "$.[1].30d"
       unit_of_measurement: "USD"
       value_template: '{{ value_json[1]["30d"]["price_change"] | round(4) }}'
       json_attributes:
         - price_change_pct
     ### BAT
     - name: "Crypto - BAT"
       json_attributes_path: "$.[2]"
       value_template: '{{ value_json[2].price | round(4) }}'
       unit_of_measurement: "USD"
       json_attributes:
         - name
         - symbol
         - price
         - logo_url
         - rank
         - high
         - high_timestamp
         - market_cap
         - first_trade
     - name: "Crypto - BAT - 1 Hr"
       json_attributes_path: "$.[2].1h"
       unit_of_measurement: "USD"
       value_template: '{{ value_json[2]["1h"]["price_change"] | round(4) }}'
       json_attributes:
         - price_change_pct
     - name: "Crypto - BAT - 1 D"
       json_attributes_path: "$.[2].1d"
       unit_of_measurement: "USD"
       value_template: '{{ value_json[2]["1d"]["price_change"] | round(4) }}'
       json_attributes:
         - price_change_pct
     - name: "Crypto - BAT - 7 D"
       json_attributes_path: "$.[2].7d"
       unit_of_measurement: "USD"
       value_template: '{{ value_json[2]["7d"]["price_change"] | round(4) }}'
       json_attributes:
         - price_change_pct
     - name: "Crypto - BAT - 30 D"
       json_attributes_path: "$.[2].30d"
       unit_of_measurement: "USD"
       value_template: '{{ value_json[2]["30d"]["price_change"] | round(4) }}'
       json_attributes:
         - price_change_pct
      ### RUNE
     - name: "Crypto - RUNE"
       json_attributes_path: "$.[3]"
       value_template: '{{ value_json[3].price | round(4) }}'
       unit_of_measurement: "USD"
       json_attributes:
         - name
         - symbol
         - price
         - logo_url
         - rank
         - high
         - high_timestamp
         - market_cap
         - first_trade
     - name: "Crypto - RUNE - 1 Hr"
       json_attributes_path: "$.[3].1h"
       unit_of_measurement: "USD"
       value_template: '{{ value_json[3]["1h"]["price_change"] | round(4) }}'
       json_attributes:
         - price_change_pct
     - name: "Crypto - RUNE - 1 D"
       json_attributes_path: "$.[3].1d"
       unit_of_measurement: "USD"
       value_template: '{{ value_json[3]["1d"]["price_change"] | round(4) }}'
       json_attributes:
         - price_change_pct
     - name: "Crypto - RUNE - 7 D"
       json_attributes_path: "$.[3].7d"
       unit_of_measurement: "USD"
       value_template: '{{ value_json[3]["7d"]["price_change"] | round(4) }}'
       json_attributes:
         - price_change_pct
     - name: "Crypto - RUNE - 30 D"
       json_attributes_path: "$.[3].30d"
       unit_of_measurement: "USD"
       value_template: '{{ value_json[3]["30d"]["price_change"] | round(4) }}'
       json_attributes:
         - price_change_pct
       ### MATIC
     - name: "Crypto - MATIC"
       json_attributes_path: "$.[4]"
       value_template: '{{ value_json[4].price | round(4) }}'
       unit_of_measurement: "USD"
       json_attributes:
         - name
         - symbol
         - price
         - logo_url
         - rank
         - high
         - high_timestamp
         - market_cap
         - first_trade
     - name: "Crypto - MATIC - 1 Hr"
       json_attributes_path: "$.[4].1h"
       unit_of_measurement: "USD"
       value_template: '{{ value_json[4]["1h"]["price_change"] | round(4) }}'
       json_attributes:
         - price_change_pct
     - name: "Crypto - MATIC - 1 D"
       json_attributes_path: "$.[4].1d"
       unit_of_measurement: "USD"
       value_template: '{{ value_json[4]["1d"]["price_change"] | round(4) }}'
       json_attributes:
         - price_change_pct
     - name: "Crypto - MATIC - 7 D"
       json_attributes_path: "$.[4].7d"
       unit_of_measurement: "USD"
       value_template: '{{ value_json[4]["7d"]["price_change"] | round(4) }}'
       json_attributes:
         - price_change_pct
     - name: "Crypto - MATIC - 30 D"
       json_attributes_path: "$.[4].30d"
       unit_of_measurement: "USD"
       value_template: '{{ value_json[4]["30d"]["price_change"] | round(4) }}'
       json_attributes:
         - price_change_pct
        ### DOT
     - name: "Crypto - DOT"
       json_attributes_path: "$.[5]"
       value_template: '{{ value_json[5].price | round(4) }}'
       unit_of_measurement: "USD"
       json_attributes:
         - name
         - symbol
         - price
         - logo_url
         - rank
         - high
         - high_timestamp
         - market_cap
         - first_trade
     - name: "Crypto - DOT - 1 Hr"
       json_attributes_path: "$.[5].1h"
       unit_of_measurement: "USD"
       value_template: '{{ value_json[5]["1h"]["price_change"] | round(4) }}'
       json_attributes:
         - price_change_pct
     - name: "Crypto - DOT - 1 D"
       json_attributes_path: "$.[5].1d"
       unit_of_measurement: "USD"
       value_template: '{{ value_json[5]["1d"]["price_change"] | round(4) }}'
       json_attributes:
         - price_change_pct
     - name: "Crypto - DOT - 7 D"
       json_attributes_path: "$.[5].7d"
       unit_of_measurement: "USD"
       value_template: '{{ value_json[5]["7d"]["price_change"] | round(4) }}'
       json_attributes:
         - price_change_pct
     - name: "Crypto - DOT - 30 D"
       json_attributes_path: "$.[5].30d"
       unit_of_measurement: "USD"
       value_template: '{{ value_json[5]["30d"]["price_change"] | round(4) }}'
       json_attributes:
         - price_change_pct
         ### FTM
     - name: "Crypto - FTM"
       json_attributes_path: "$.[6]"
       value_template: '{{ value_json[6].price | round(4) }}'
       unit_of_measurement: "USD"
       json_attributes:
         - name
         - symbol
         - price
         - logo_url
         - rank
         - high
         - high_timestamp
         - market_cap
         - first_trade
     - name: "Crypto - FTM - 1 Hr"
       json_attributes_path: "$.[6].1h"
       unit_of_measurement: "USD"
       value_template: '{{ value_json[6]["1h"]["price_change"] | round(4) }}'
       json_attributes:
         - price_change_pct
     - name: "Crypto - FTM - 1 D"
       json_attributes_path: "$.[6].1d"
       unit_of_measurement: "USD"
       value_template: '{{ value_json[6]["1d"]["price_change"] | round(4) }}'
       json_attributes:
         - price_change_pct
     - name: "Crypto - FTM - 7 D"
       json_attributes_path: "$.[6].7d"
       unit_of_measurement: "USD"
       value_template: '{{ value_json[6]["7d"]["price_change"] | round(4) }}'
       json_attributes:
         - price_change_pct
     - name: "Crypto - FTM - 30 D"
       json_attributes_path: "$.[6].30d"
       unit_of_measurement: "USD"
       value_template: '{{ value_json[6]["30d"]["price_change"] | round(4) }}'
       json_attributes:
         - price_change_pct
          ### ATOM
     - name: "Crypto - ATOM"
       json_attributes_path: "$.[7]"
       value_template: '{{ value_json[7].price | round(4) }}'
       unit_of_measurement: "USD"
       json_attributes:
         - name
         - symbol
         - price
         - logo_url
         - rank
         - high
         - high_timestamp
         - market_cap
         - first_trade
     - name: "Crypto - ATOM - 1 Hr"
       json_attributes_path: "$.[7].1h"
       unit_of_measurement: "USD"
       value_template: '{{ value_json[7]["1h"]["price_change"] | round(4) }}'
       json_attributes:
         - price_change_pct
     - name: "Crypto - ATOM - 1 D"
       json_attributes_path: "$.[7].1d"
       unit_of_measurement: "USD"
       value_template: '{{ value_json[7]["1d"]["price_change"] | round(4) }}'
       json_attributes:
         - price_change_pct
     - name: "Crypto - ATOM - 7 D"
       json_attributes_path: "$.[7].7d"
       unit_of_measurement: "USD"
       value_template: '{{ value_json[7]["7d"]["price_change"] | round(4) }}'
       json_attributes:
         - price_change_pct
     - name: "Crypto - ATOM - 30 D"
       json_attributes_path: "$.[7].30d"
       unit_of_measurement: "USD"
       value_template: '{{ value_json[7]["30d"]["price_change"] | round(4) }}'
       json_attributes:
         - price_change_pct
           ### UST
     - name: "Crypto - UST"
       json_attributes_path: "$.[8]"
       value_template: '{{ value_json[8].price | round(4) }}'
       unit_of_measurement: "USD"
       json_attributes:
         - name
         - symbol
         - price
         - logo_url
         - rank
         - high
         - high_timestamp
         - market_cap
         - first_trade
     - name: "Crypto - UST - 1 Hr"
       json_attributes_path: "$.[8].1h"
       unit_of_measurement: "USD"
       value_template: '{{ value_json[8]["1h"]["price_change"] | round(4) }}'
       json_attributes:
         - price_change_pct
     - name: "Crypto - UST - 1 D"
       json_attributes_path: "$.[8].1d"
       unit_of_measurement: "USD"
       value_template: '{{ value_json[8]["1d"]["price_change"] | round(4) }}'
       json_attributes:
         - price_change_pct
     - name: "Crypto - UST - 7 D"
       json_attributes_path: "$.[8].7d"
       unit_of_measurement: "USD"
       value_template: '{{ value_json[8]["7d"]["price_change"] | round(4) }}'
       json_attributes:
         - price_change_pct
     - name: "Crypto - UST - 30 D"
       json_attributes_path: "$.[8].30d"
       unit_of_measurement: "USD"
       value_template: '{{ value_json[8]["30d"]["price_change"] | round(4) }}'
       json_attributes:
         - price_change_pct

Iā€™m not sure how you have ended up being charged for anything.

The API is free for personal use

Did you sign up for a commercial API or something? Iā€™ve never entered any card details to allow for a payment to be taken either so unsure what you have done?

Hi @Craig_McGowan,

If the code I posted above is ok, then I definitively must have done an error during the sign up as I was ask for my credit card.

Thanks for pointing out that you used no card during the registration, Iā€™ll follow up with Nomics.

Hi all,

Just thought Iā€™d give an update after speaking to Nomics, I explained the situation to them and they advise me on how to proceed to cancel the subscription to the paid api and recreate an account for the free api so all sorted now.

Have a great day everyone and again thanks @Craig_McGowan for sharing this.

Can you share the YAMl?
THanks!

Sorry, Iā€™ve since decommissioned those dashboards and removed this from HA (turned out I never looked at it in home assistant so it seemed pointless having in there!)

Sad, do you remember how u did the dinamically period changer?