Hi, I’d like to get the Fear & Greed Index value into a sensor that I can put on a frontend card. It’s stored here in the [value] field. I have no idea how JSON works and how to get it into the application and update every 6 hours:
https://api.alternative.me/fng/
So far I’ve gotten the REST API to show, but I can’t manage to extract the value value
- platform: rest
unique_id: ssd3203923a24save
value_template: "{{ value_json['data']['value'] }}"
resource: https://api.alternative.me/fng/
the json file looks like this:
{
"name": "Fear and Greed Index",
"data": [
{
"value": "44",
"value_classification": "Fear",
"timestamp": "1738886400",
"time_until_update": "63337"
}
],
"metadata": {
"error": null
}
}
I want my sensor to show the value ‘44’. The best I can get so far is the data as a string object:
{'name': 'Fear and Greed Index', 'data': [{'value': '44', 'value_classification': 'Fear', 'timestamp': '1738886400', 'time_until_update': '60815'}], 'metadata': {'error': None}}
Data is not a dict, it is a list containing a dict. Thus:
{{ value_json['data'][0]['value'] }}
1 Like
Data is a dick Thanks @Mayhem_SWE, it works