Troubleshooting JSON Parsing in REST Sensor

Hello fellow Home Assistant enthusiasts! I’m reaching out to seek some guidance on an issue I’m encountering while setting up a REST sensor to track cryptocurrency prices. Specifically, I’m trying to monitor Litecoin using data from the CoinMarketCap API. Here’s a bit about what I’ve done so far and where I’m stuck.

I’ve configured my configuration.yaml with the following sensor setup:
yaml
sensor:

However, this setup isn’t working as expected—it results in a blank field. In an attempt to debug, I tried modifying the value_template to '{{ value_json.[0].price_usd }}', but this change led to the sensor displaying “unknown” instead of a blank field.

Upon inspecting the JSON response from the API, I noticed that it’s structured as a single-element array containing an object with various cryptocurrency details. Here’s an example of the response:

[
{
“id”: “litecoin”,
“name”: “Litecoin”,
“symbol”: “LTC”,
“rank”: 1,
“price_usd”: 3.80133,
“price_btc”: 0.00659055,
“24h_volume_usd”: 1649120.0,
“market_cap_usd”: 179968473.0,
“available_supply”: 47343554.0,
“total_supply”: 47343554.0,
“percent_change_1h”: -0.24,
“percent_change_24h”: 1.01,
“percent_change_7d”: -2.71
}
]

Given this structure, I believe the correct way to access the price_usd value should indeed involve referencing the first element of the array, hence the [0] index. However, this approach isn’t yielding the expected results.

I’ve scoured the forums and documentation for similar issues, but I haven’t found a solution that addresses this specific problem. In the meantime, I’m also exploring alternative APIs that might return the data in a format that’s more compatible with Home Assistant’s REST sensor out of the box.

If anyone has encountered a similar issue or has insights into how to correctly parse this JSON response, I’d greatly appreciate your assistance. Your expertise could really help me get this sensor up and running smoothly!

Thank you in advance for your time and support!