Skip to content
Advertisement

Coingecko links properties can’t be accessed

I’m using the following way to access a property on coingecko’s API: https://api.coingecko.com/api/v3/coins, this returns all crypto coins and their properties.

While using the above link I can access the IDs of any object in the response. but if I’m using the next link: https://api.coingecko.com/api/v3/coins/bitcoin I’m still getting the ID as I can see in response, but I can’t access the id like this: data[index].id (which I can do with the first link).

Advertisement

Answer

The second rest call returns an object, whereas the first link returns an array of objects.

To access id in the second example, simply use data.id (no array, so no index here).

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement