Crypto Information using Nomics API - Bitcoin, Ethereum etc

There are already a few different ways to get crytpo currency values into HA. Some are now broken, some are not free, so I had a look for another way.

I found https://nomics.com/ which have a free API at Free Cryptocurrency & Market Data API (Historical & Real-Time Price, Exchange & Trade Data) which only has a limit of 1 call per second.

After signing up for the API, the resource to call for a restful sensor is made up like so

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

COINS is comma seperated list of coins to track, so in my usecase was

BTC,ETH,DOGE,BCH,BNB,XRP,BCH,LTC,XLM,TRX

This will return current data for coin values, market caps, record highs etc but with the interval paramaters I also get the change over 1 hour, 1 day etc.

My full rest sensor is as follows

 - resource: !secret nomics_crypto_api
   scan_interval: 10
   sensor:
   ### BTC
     - name: "Crypto - BTC"
       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 - BTC - 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 - BTC - 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 - BTC - 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 - BTC - 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
    ### ETH
     - name: "Crypto - ETH"
       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 - ETH - 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 - ETH - 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 - ETH - 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 - ETH - 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
     ### BNB
     - name: "Crypto - BNB"
       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 - BNB - 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 - BNB - 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 - BNB - 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 - BNB - 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
      ### DOGE
     - name: "Crypto - DOGE"
       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 - DOGE - 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 - DOGE - 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 - DOGE - 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 - DOGE - 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
       ### XRP
     - name: "Crypto - XRP"
       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 - XRP - 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 - XRP - 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 - XRP - 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 - XRP - 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
        ### BCH
     - name: "Crypto - BCH"
       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 - BCH - 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 - BCH - 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 - BCH - 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 - BCH - 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
         ### LTC
     - name: "Crypto - LTC"
       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 - LTC - 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 - LTC - 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 - LTC - 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 - LTC - 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
          ### XLM
     - name: "Crypto - XLM"
       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 - XLM - 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 - XLM - 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 - XLM - 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 - XLM - 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
           ### TRX
     - name: "Crypto - TRX"
       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 - TRX - 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 - TRX - 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 - TRX - 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 - TRX - 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
 

This allows me to display the latest crypto information like so

Hope this can be helpful to somebody.

There is a slight issue at present where by the data is returned every 10 seconds but all the data for the 10 coins I track is pulled in 1 request. This means you dont fall foul of the 1 call per second limit. However, it means all the coins are returned in various arrays to pulling this information into sensors means using template sensors such as value_json[8].price

This is fine if the coins are always returned in the same order on the page. By default, they are returned by marketcap, however by appending the API query with &sort=first_priced_at then you should be able to order them by the time they were first priced in the market. however, this sort function seems to be ignored in my testing and they are always returned by marketcap which is noticeable today as big movements in the market are changing the top 10 listed coins. Ive reached out to nomics to get this paramater fixed.

8 Likes

hey man!

looks amazing, and great work

however, i couldn’t implement it on my system correctly (that on me, no doubt)

I need some more info to make it work, and would appreciate it if you’ll feel like helping.

could you please provide all the needed steps to implement this correctly?
what is the platform to make this sensor work?
cheers
:slight_smile:

Hey,

Thanks for this !!

What card do you use for this ?

Thanks.

Hey, more than happy to help.

How far have you got?

If you get a nomics API and then add the above rest sensor, you should get sensors pulling information in? Did you get this far?

Hi. @Stridel

The card is just a couple of standard entity cards but the Lovelace would require you to have GitHub - thomasloven/lovelace-card-mod: 🔹 Add CSS styles to (almost) any lovelace card and GitHub - thomasloven/lovelace-template-entity-row: 🔹 Display whatever you want in an entities card row. installed.

I’ve also put them in a vertical stack card, but used the GitHub - ofekashery/vertical-stack-in-card: 📐 Home Assistant Card: Similar to vertical/horizontal-stack, but removes card borders card.

If your willing to install them 3 of them, then to get my layout the Lovelace is

type: 'custom:vertical-stack-in-card'
cards:
  - type: entities
    entities:
      - type: 'custom:template-entity-row'
        entity: sensor.crypto_btc
        name: '{{ state_attr(config.entity, ''name'') }}'
        secondary: '{{ state_attr(config.entity, ''symbol'') }}'
        image: '{{ state_attr(config.entity, ''logo_url'') }}'
        state: '${{ state_attr(config.entity, ''price'') | round(2) }}'
      - type: 'custom:template-entity-row'
        entity: sensor.crypto_btc
        name: High
        icon: 'mdi:currency-usd'
        state: '${{ state_attr(config.entity, ''high'') | round (2)}}'
        secondary: >-
          {{ as_timestamp(state_attr(config.entity, 'high_timestamp')) |
          timestamp_custom('%d-%m-%Y %H:%M ') }}
      - type: 'custom:template-entity-row'
        entity: sensor.crypto_btc
        name: Crypto Rank
        icon: 'mdi:chart-line'
        state: '{{ state_attr(config.entity, ''rank'') }}'
        secondary: '${{"{:,}".format(state_attr(config.entity, ''market_cap'')|int)}}'
  - type: 'custom:mini-graph-card'
    hours_to_show: 3
    points_per_hour: 60
    show:
      icon: false
      name: false
    entities:
      - entity: sensor.crypto_btc
  - type: entities
    entities:
      - entity: sensor.crypto_btc_1_hr
        name: 1 Hour
        type: 'custom:template-entity-row'
        state: '${{ states(config.entity) | round(2) }}'
        secondary: >-
          {{ state_attr(config.entity, 'price_change_pct')  | multiply(100) |
          round(4) }}%
        icon: |
          {% if states(config.entity) | float > 0 %}
             mdi:arrow-up-bold
          {% elif states(config.entity) | float < 0 %}
             mdi:arrow-down-bold
          {% else %}
             mdi:arrow-right-bold
          {% endif %}
        card_mod:
          style: |
            {% if states(config.entity) | float > 0 %}
               :host {
                 --paper-item-icon-color: green;
                 color: green
               }
            {% elif states(config.entity) | float < 0 %}
               :host {
                 --paper-item-icon-color: red;
                 color: red
               }
            {% else %}
               :host {
                 --paper-item-icon-color: black;
                 color: black
               }
            {% endif %}
      - entity: sensor.crypto_btc_1_d
        name: 1 Day
        type: 'custom:template-entity-row'
        state: '${{ states(config.entity) | round(2) }}'
        secondary: >-
          {{ state_attr(config.entity, 'price_change_pct') | multiply(100) |
          round(4) }}%
        icon: |
          {% if states(config.entity) | float > 0 %}
             mdi:arrow-up-bold
          {% elif states(config.entity) | float < 0 %}
             mdi:arrow-down-bold
          {% else %}
             mdi:arrow-right-bold
          {% endif %}
        card_mod:
          style: |
            {% if states(config.entity) | float > 0 %}
               :host {
                 --paper-item-icon-color: green;
                 color: green
               }
            {% elif states(config.entity) | float < 0 %}
               :host {
                 --paper-item-icon-color: red;
                 color: red
               }
            {% else %}
               :host {
                 --paper-item-icon-color: black;
                 color: black
               }
            {% endif %}
      - entity: sensor.crypto_btc_7_d
        name: 7 Days
        type: 'custom:template-entity-row'
        state: '${{ states(config.entity) | round(2) }}'
        secondary: >-
          {{ state_attr(config.entity, 'price_change_pct') | multiply(100) |
          round(4) }}%
        icon: |
          {% if states(config.entity) | float > 0 %}
             mdi:arrow-up-bold
          {% elif states(config.entity) | float < 0 %}
             mdi:arrow-down-bold
          {% else %}
             mdi:arrow-right-bold
          {% endif %}
        card_mod:
          style: |
            {% if states(config.entity) | float > 0 %}
               :host {
                 --paper-item-icon-color: green;
                 color: green
               }
            {% elif states(config.entity) | float < 0 %}
               :host {
                 --paper-item-icon-color: red;
                 color: red
               }
            {% else %}
               :host {
                 --paper-item-icon-color: black;
                 color: black
               }
            {% endif %}
      - entity: sensor.crypto_btc_30_d
        name: 30 Days
        type: 'custom:template-entity-row'
        state: '${{ states(config.entity) | round(2) }}'
        secondary: >-
          {{ state_attr(config.entity, 'price_change_pct') | multiply(100) |
          round(4) }}%
        icon: |
          {% if states(config.entity) | float > 0 %}
             mdi:arrow-up-bold
          {% elif states(config.entity) | float < 0 %}
             mdi:arrow-down-bold
          {% else %}
             mdi:arrow-right-bold
          {% endif %}
        card_mod:
          style: |
            {% if states(config.entity) | float > 0 %}
               :host {
                 --paper-item-icon-color: green;
                 color: green
               }
            {% elif states(config.entity) | float < 0 %}
               :host {
                 --paper-item-icon-color: red;
                 color: red
               }
            {% else %}
               :host {
                 --paper-item-icon-color: black;
                 color: black
               }
            {% endif %}

1 Like

Thanks, I will mix your config and I.

Thanks.

hey craig, thanks for helping out

i got the api, and used the url you provided with my api and LTC as “coins” in it.

im not sure about the configuration.yaml / sensor syntax
if i understand correctly, all “sensor” need some kind of “platform”. is that what i am missing in my config? (in your example i did not see any).
can you show me a basic syntex for getting the “entity” to work?
and thanks
:slight_smile:

This is my config.

In "configuration.yaml’’

rest:
  - resource: https://api.nomics.com/v1/currencies/ticker?key=YOUR_API_KEY&ids=ETH&interval=1h,1d,7d,30d&convert=EUR&per-page=100&page=1&sort=first_priced_at
    scan_interval: 10
    sensor:
      ### ETH
       - name: "Crypto - ETH"
         json_attributes_path: "€.[0]"
         value_template: '{{ value_json[0].price | round(4) }}'
         unit_of_measurement: "EUR"
         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: "EUR"
         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: "EUR"
         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: "EUR"
         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: "EUR"
         value_template: '{{ value_json[0]["30d"]["price_change"] | round(4) }}'
         json_attributes:
           - price_change_pct

My URL convert in Euro.
But with this config, I can’t have attributs ( name, symbol, logo, etc … ) I don’t know how.

I think the reason your not getting the attributes is because youve also changed the attribute path to a euro sign!!

json_attributes_path: “€.[0]”

should have remained as

json_attributes_path: “$.[0]”

Hi @tennbaum

As mentioned by @Stridel you just need to set this up on the rest platform.

So it would start like

rest:
 - resource: !secret nomics_crypto_api
   scan_interval: 10

Then the rest of the code from my original post.

OK

so i did all that, got the green mark for the config to “check out”, and restart my machine. however i dont see any new “sensors” under entities.
shouldn’t they be there?

Yes, you should have something like sensor.crypto_btc

Anything in your error logs?

What happens if you go direct to the resource url, is there data there?

yes.
the url is giving back a lot of info (that is hard to read)
that says to me i have a problem with the sensor config.
when i paste the code under “tamplate”
i get:
UndefinedError: ‘value_json’ is undefined
so i assume it has something to do with:
‘{{ value_json[0].price | round(4) }}’

and ill admit - i don’t know what it means…
can you show me a more “basic” code for the base value? maybe ill figure out my mistake base on that?

If the URL is giving code that’s hard to read, is it JSON? Can you paste that here please

Set your sensor just to this to test, putting in your API key.

rest:
 - resource: https://api.nomics.com/v1/currencies/ticker?key=*APIKEY*&ids=BTC&interval=1h,1d,7d,30d&per-page=100&page=1&sort=first_priced_at
   scan_interval: 10
   sensor:
   ### BTC
     - name: "Crypto - BTC"
       json_attributes_path: "$.[0]"
       value_template: '{{ value_json[0].price | round(4) }}'
       unit_of_measurement: "USD"
       json_attributes:
         - name

this is what the url is giving back.

"
[{“id”:“LTC”,“currency”:“LTC”,“symbol”:“LTC”,“name”:“Litecoin”,“logo_url”:“https://s3.us-east-2.amazonaws.com/nomics-api/static/images/currencies/ltc.svg",“status”:“active”,“price”:“295.73643109”,“price_date”:“2021-05-11T00:00:00Z”,“price_timestamp”:“2021-05-11T09:13:00Z”,“circulating_supply”:“66752415”,“max_supply”:“84000000”,“market_cap”:“19741120835”,“num_exchanges”:“319”,“num_pairs”:“2779”,“num_pairs_unmapped”:“426”,“first_candle”:“2013-03-25T00:00:00Z”,“first_trade”:“2013-03-25T00:00:00Z”,“first_order_book”:“2018-08-29T00:00:00Z”,“rank”:“11”,“high”:“319.06757427”,“high_timestamp”:“2021-05-09T00:00:00Z”,“1h”:{“volume”:“270085415.76”,“price_change”:"-4.71335307",“price_change_pct”:"-0.0157",“volume_change”:"-20697164.89",“volume_change_pct”:"-0.0712",“market_cap_change”:"-314627697.86",“market_cap_change_pct”:"-0.0157"},“1d”:{“volume”:“12586695827.68”,“price_change”:"-29.43077610",“price_change_pct”:"-0.0905",“volume_change”:"-232641276.28",“volume_change_pct”:"-0.0181",“market_cap_change”:"-1964575365.68",“market_cap_change_pct”:"-0.0905"},“7d”:{“volume”:“74245742493.72”,“price_change”:“38.83447457”,“price_change_pct”:“0.1512”,“volume_change”:“33894034812.09”,“volume_change_pct”:“0.8400”,“market_cap_change”:“2592294944.23”,“market_cap_change_pct”:“0.1512”},“30d”:{“volume”:“260252423450.95”,“price_change”:“82.64131309”,“price_change_pct”:“0.3878”,“volume_change”:“110314958745.57”,“volume_change_pct”:“0.7357”,“market_cap_change”:“5516507187.56”,“market_cap_change_pct”:"0.3878”}}]
"

im gussing that the “json” part in the sensor code somehow does not read it well
and i dont have the programing skill necessary to understand why
:slight_smile:
thanks for the help man, i appreciate it

(you probably guessed yourself its for LTC)

Sorry, I think I updated my last post whilst you were typing that. Ive put the most basic sensor in there for you to try.

nothing to b sorry about man

just followed your instruction - and surprise - it works…

basic BTC entity 4 now, but thats a good enough start for me to crack this interrogation further

thanks a lot. ill write back when i’ll re-hit that glass ceiling of my own lack of understanding…

cheers for now

1 Like

Hi, I copied the code, that’s what I added to configuration.yaml

######## Crypto
rest:
  - resource: !secret nomicsapi
    scan_interval: 10
    sensor:
    ### BTC
      - name: "Crypto - BTC"
        json_attributes_path: "$.[0]"
        value_template: '{{ value_json[0].price | round(4) }}'
        unit_of_measurement: "EUR"
        json_attributes:
          - name
          - symbol
          - price
          - logo_url
          - rank
          - high
          - high_timestamp
          - market_cap
          - first_trade
      - name: "Crypto - BTC - 1 Hr"
        json_attributes_path: "$.[0].1h"
        unit_of_measurement: "EUR"
        value_template: '{{ value_json[0]["1h"]["price_change"] | round(4) }}'
        json_attributes:
          - price_change_pct
      - name: "Crypto - BTC - 1 D"
        json_attributes_path: "$.[0].1d"
        unit_of_measurement: "EUR"
        value_template: '{{ value_json[0]["1d"]["price_change"] | round(4) }}'
        json_attributes:
          - price_change_pct
      - name: "Crypto - BTC - 7 D"
        json_attributes_path: "$.[0].7d"
        unit_of_measurement: "EUR"
        value_template: '{{ value_json[0]["7d"]["price_change"] | round(4) }}'
        json_attributes:
          - price_change_pct
      - name: "Crypto - BTC - 30 D"
        json_attributes_path: "$.[0].30d"
        unit_of_measurement: "EUR"
        value_template: '{{ value_json[0]["30d"]["price_change"] | round(4) }}'
        json_attributes:
          - price_change_pct
     ### ETH
      - name: "Crypto - ETH"
        json_attributes_path: "$.[1]"
        value_template: '{{ value_json[1].price | round(4) }}'
        unit_of_measurement: "EUR"
        json_attributes:
          - name
          - symbol
          - price
          - logo_url
          - rank
          - high
          - high_timestamp
          - market_cap
          - first_trade
      - name: "Crypto - ETH - 1 Hr"
        json_attributes_path: "$.[1].1h"
        unit_of_measurement: "EUR"
        value_template: '{{ value_json[1]["1h"]["price_change"] | round(4) }}'
        json_attributes:
          - price_change_pct
      - name: "Crypto - ETH - 1 D"
        json_attributes_path: "$.[1].1d"
        unit_of_measurement: "EUR"
        value_template: '{{ value_json[1]["1d"]["price_change"] | round(4) }}'
        json_attributes:
          - price_change_pct
      - name: "Crypto - ETH - 7 D"
        json_attributes_path: "$.[1].7d"
        unit_of_measurement: "EUR"
        value_template: '{{ value_json[1]["7d"]["price_change"] | round(4) }}'
        json_attributes:
          - price_change_pct
      - name: "Crypto - ETH - 30 D"
        json_attributes_path: "$.[1].30d"
        unit_of_measurement: "EUR"
        value_template: '{{ value_json[1]["30d"]["price_change"] | round(4) }}'
        json_attributes:
          - price_change_pct
      ### BNB
      - name: "Crypto - BNB"
        json_attributes_path: "$.[2]"
        value_template: '{{ value_json[2].price | round(4) }}'
        unit_of_measurement: "EUR"
        json_attributes:
          - name
          - symbol
          - price
          - logo_url
          - rank
          - high
          - high_timestamp
          - market_cap
          - first_trade
      - name: "Crypto - BNB - 1 Hr"
        json_attributes_path: "$.[2].1h"
        unit_of_measurement: "EUR"
        value_template: '{{ value_json[2]["1h"]["price_change"] | round(4) }}'
        json_attributes:
          - price_change_pct
      - name: "Crypto - BNB - 1 D"
        json_attributes_path: "$.[2].1d"
        unit_of_measurement: "EUR"
        value_template: '{{ value_json[2]["1d"]["price_change"] | round(4) }}'
        json_attributes:
          - price_change_pct
      - name: "Crypto - BNB - 7 D"
        json_attributes_path: "$.[2].7d"
        unit_of_measurement: "EUR"
        value_template: '{{ value_json[2]["7d"]["price_change"] | round(4) }}'
        json_attributes:
          - price_change_pct
      - name: "Crypto - BNB - 30 D"
        json_attributes_path: "$.[2].30d"
        unit_of_measurement: "EUR"
        value_template: '{{ value_json[2]["30d"]["price_change"] | round(4) }}'
        json_attributes:
          - price_change_pct
       ### DOGE
      - name: "Crypto - DOGE"
        json_attributes_path: "$.[3]"
        value_template: '{{ value_json[3].price | round(4) }}'
        unit_of_measurement: "EUR"
        json_attributes:
          - name
          - symbol
          - price
          - logo_url
          - rank
          - high
          - high_timestamp
          - market_cap
          - first_trade
      - name: "Crypto - DOGE - 1 Hr"
        json_attributes_path: "$.[3].1h"
        unit_of_measurement: "EUR"
        value_template: '{{ value_json[3]["1h"]["price_change"] | round(4) }}'
        json_attributes:
          - price_change_pct
      - name: "Crypto - DOGE - 1 D"
        json_attributes_path: "$.[3].1d"
        unit_of_measurement: "EUR"
        value_template: '{{ value_json[3]["1d"]["price_change"] | round(4) }}'
        json_attributes:
          - price_change_pct
      - name: "Crypto - DOGE - 7 D"
        json_attributes_path: "$.[3].7d"
        unit_of_measurement: "EUR"
        value_template: '{{ value_json[3]["7d"]["price_change"] | round(4) }}'
        json_attributes:
          - price_change_pct
      - name: "Crypto - DOGE - 30 D"
        json_attributes_path: "$.[3].30d"
        unit_of_measurement: "EUR"
        value_template: '{{ value_json[3]["30d"]["price_change"] | round(4) }}'
        json_attributes:
          - price_change_pct
        ### XRP
      - name: "Crypto - XRP"
        json_attributes_path: "$.[4]"
        value_template: '{{ value_json[4].price | round(4) }}'
        unit_of_measurement: "EUR"
        json_attributes:
          - name
          - symbol
          - price
          - logo_url
          - rank
          - high
          - high_timestamp
          - market_cap
          - first_trade
      - name: "Crypto - XRP - 1 Hr"
        json_attributes_path: "$.[4].1h"
        unit_of_measurement: "EUR"
        value_template: '{{ value_json[4]["1h"]["price_change"] | round(4) }}'
        json_attributes:
          - price_change_pct
      - name: "Crypto - XRP - 1 D"
        json_attributes_path: "$.[4].1d"
        unit_of_measurement: "EUR"
        value_template: '{{ value_json[4]["1d"]["price_change"] | round(4) }}'
        json_attributes:
          - price_change_pct
      - name: "Crypto - XRP - 7 D"
        json_attributes_path: "$.[4].7d"
        unit_of_measurement: "EUR"
        value_template: '{{ value_json[4]["7d"]["price_change"] | round(4) }}'
        json_attributes:
          - price_change_pct
      - name: "Crypto - XRP - 30 D"
        json_attributes_path: "$.[4].30d"
        unit_of_measurement: "EUR"
        value_template: '{{ value_json[4]["30d"]["price_change"] | round(4) }}'
        json_attributes:
          - price_change_pct
         ### BCH
      - name: "Crypto - BCH"
        json_attributes_path: "$.[5]"
        value_template: '{{ value_json[5].price | round(4) }}'
        unit_of_measurement: "EUR"
        json_attributes:
          - name
          - symbol
          - price
          - logo_url
          - rank
          - high
          - high_timestamp
          - market_cap
          - first_trade
      - name: "Crypto - BCH - 1 Hr"
        json_attributes_path: "$.[5].1h"
        unit_of_measurement: "EUR"
        value_template: '{{ value_json[5]["1h"]["price_change"] | round(4) }}'
        json_attributes:
          - price_change_pct
      - name: "Crypto - BCH - 1 D"
        json_attributes_path: "$.[5].1d"
        unit_of_measurement: "EUR"
        value_template: '{{ value_json[5]["1d"]["price_change"] | round(4) }}'
        json_attributes:
          - price_change_pct
      - name: "Crypto - BCH - 7 D"
        json_attributes_path: "$.[5].7d"
        unit_of_measurement: "EUR"
        value_template: '{{ value_json[5]["7d"]["price_change"] | round(4) }}'
        json_attributes:
          - price_change_pct
      - name: "Crypto - BCH - 30 D"
        json_attributes_path: "$.[5].30d"
        unit_of_measurement: "EUR"
        value_template: '{{ value_json[5]["30d"]["price_change"] | round(4) }}'
        json_attributes:
          - price_change_pct
          ### LTC
      - name: "Crypto - LTC"
        json_attributes_path: "$.[6]"
        value_template: '{{ value_json[6].price | round(4) }}'
        unit_of_measurement: "EUR"
        json_attributes:
          - name
          - symbol
          - price
          - logo_url
          - rank
          - high
          - high_timestamp
          - market_cap
          - first_trade
      - name: "Crypto - LTC - 1 Hr"
        json_attributes_path: "$.[6].1h"
        unit_of_measurement: "EUR"
        value_template: '{{ value_json[6]["1h"]["price_change"] | round(4) }}'
        json_attributes:
          - price_change_pct
      - name: "Crypto - LTC - 1 D"
        json_attributes_path: "$.[6].1d"
        unit_of_measurement: "EUR"
        value_template: '{{ value_json[6]["1d"]["price_change"] | round(4) }}'
        json_attributes:
          - price_change_pct
      - name: "Crypto - LTC - 7 D"
        json_attributes_path: "$.[6].7d"
        unit_of_measurement: "EUR"
        value_template: '{{ value_json[6]["7d"]["price_change"] | round(4) }}'
        json_attributes:
          - price_change_pct
      - name: "Crypto - LTC - 30 D"
        json_attributes_path: "$.[6].30d"
        unit_of_measurement: "EUR"
        value_template: '{{ value_json[6]["30d"]["price_change"] | round(4) }}'
        json_attributes:
          - price_change_pct
           ### XLM
      - name: "Crypto - XLM"
        json_attributes_path: "$.[7]"
        value_template: '{{ value_json[7].price | round(4) }}'
        unit_of_measurement: "EUR"
        json_attributes:
          - name
          - symbol
          - price
          - logo_url
          - rank
          - high
          - high_timestamp
          - market_cap
          - first_trade
      - name: "Crypto - XLM - 1 Hr"
        json_attributes_path: "$.[7].1h"
        unit_of_measurement: "EUR"
        value_template: '{{ value_json[7]["1h"]["price_change"] | round(4) }}'
        json_attributes:
          - price_change_pct
      - name: "Crypto - XLM - 1 D"
        json_attributes_path: "$.[7].1d"
        unit_of_measurement: "EUR"
        value_template: '{{ value_json[7]["1d"]["price_change"] | round(4) }}'
        json_attributes:
          - price_change_pct
      - name: "Crypto - XLM - 7 D"
        json_attributes_path: "$.[7].7d"
        unit_of_measurement: "EUR"
        value_template: '{{ value_json[7]["7d"]["price_change"] | round(4) }}'
        json_attributes:
          - price_change_pct
      - name: "Crypto - XLM - 30 D"
        json_attributes_path: "$.[7].30d"
        unit_of_measurement: "EUR"
        value_template: '{{ value_json[7]["30d"]["price_change"] | round(4) }}'
        json_attributes:
          - price_change_pct
            ### TRX
      - name: "Crypto - TRX"
        json_attributes_path: "$.[8]"
        value_template: '{{ value_json[8].price | round(4) }}'
        unit_of_measurement: "EUR"
        json_attributes:
          - name
          - symbol
          - price
          - logo_url
          - rank
          - high
          - high_timestamp
          - market_cap
          - first_trade
      - name: "Crypto - TRX - 1 Hr"
        json_attributes_path: "$.[8].1h"
        unit_of_measurement: "EUR"
        value_template: '{{ value_json[8]["1h"]["price_change"] | round(4) }}'
        json_attributes:
          - price_change_pct
      - name: "Crypto - TRX - 1 D"
        json_attributes_path: "$.[8].1d"
        unit_of_measurement: "EUR"
        value_template: '{{ value_json[8]["1d"]["price_change"] | round(4) }}'
        json_attributes:
          - price_change_pct
      - name: "Crypto - TRX - 7 D"
        json_attributes_path: "$.[8].7d"
        unit_of_measurement: "EUR"
        value_template: '{{ value_json[8]["7d"]["price_change"] | round(4) }}'
        json_attributes:
          - price_change_pct
      - name: "Crypto - TRX - 30 D"
        json_attributes_path: "$.[8].30d"
        unit_of_measurement: "EUR"
        value_template: '{{ value_json[8]["30d"]["price_change"] | round(4) }}'
        json_attributes:
          - price_change_pct
########

But it give an error when I check configuration.yaml before restart home assistant:


Invalid config for [rest]: invalid url for dictionary value @ data['rest'][0]['resource']. Got 'xxxx1d00afdc1e2b6598xxxxxd5687b80xxxxx'. (See /config/configuration.yaml, line 102).

(I changed here some numbers of the API Key with x)

What’s the problem?

Is maybe your nomicsapi secret just the api key, rather than the full url?

It should be

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

Thanks, now don’t give any error but all sensors has “unknown” value