man-c / pycoingecko

Python wrapper for the CoinGecko API
MIT License
1.04k stars 268 forks source link

Could not find coin with the given id when I call /coins/{id}/contract/{contract_address} #42

Closed Jakin-Liu closed 3 years ago

Jakin-Liu commented 3 years ago

I can get data from https://api.coingecko.com/api/v3/coins/uniswap

so id = uniswap

but when i get data by https://api.coingecko.com/api/v3/coins/uniswap/contract/0x1f9840a85d5af5bf1d1762f925bdaddc4201f984/market_chart?vs_currency=usd&days=7 it show me

{ "error": "Could not find coin with the given id" }

Kindly help me

man-c commented 3 years ago

Hi!

The id that required for the endpoint /coins/{id}/contract/{contract_address}/market_chart/, should be the id of the platform issuing tokens (not the coin id). It is defined in the description of the parameter for the endpoint at CoinGecko API doc (https://www.coingecko.com/api/docs/v3):

The id of the platform issuing tokens (See asset_platforms endpoint for list of options)

Using as id: ethereum (found from /asset_platforms endpoint), it seems to response properly (https://api.coingecko.com/api/v3/coins/ethereum/contract/0x1f9840a85d5af5bf1d1762f925bdaddc4201f984/market_chart/?vs_currency=usd&days=7):

{
  "prices": [
    [
      1624280532715,
      17.163310802863062
    ],
    [
      1624284191759,
      17.640360562103297
    ],

                 ...

  "market_caps": [
    [
      1624280532715,
      8987930499.719141
    ],
    [
      1624284191759,
      9118909291.252293
    ],

                 ...

  "total_volumes": [
    [
      1624280532715,
      492328343.20710766
    ],
    [
      1624284191759,
      451551174.71456736
    ],

                 ...

    [
      1624882477000,
      213056411.41325995
    ]
  ]
}