man-c / pycoingecko

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

add interval option for get_coin_market_chart_by_id #59

Closed Asone closed 2 years ago

Asone commented 2 years ago

As per the coin gecko documentation, the API endpoint /coins/{id}/market_chart alllows an optional interval parameter to request a specific granularity for the retrieved data.

However, it seems this parameter is not implemented in the wrapper with the get_coin_market_chart_by_id.

Could it be added or is there any sort of limitation on implementing it in the wrapper ?

Thanks a lot

man-c commented 2 years ago

Hello, You can just pass the parameter and any optional parameter using same names, as defined in CoinGecko API doc.

For example:

>>> L=cg.get_coin_market_chart_by_id(id='bitcoin', vs_currency='eur', days=14, interval='daily')
>>> for l in L['prices']:
     print(dt.datetime.fromtimestamp(l[0]/1000.0, tz=dt.timezone.utc))

2021-11-17 00:00:00+00:00
2021-11-18 00:00:00+00:00
2021-11-19 00:00:00+00:00
2021-11-20 00:00:00+00:00
2021-11-21 00:00:00+00:00
2021-11-22 00:00:00+00:00
2021-11-23 00:00:00+00:00
2021-11-24 00:00:00+00:00
2021-11-25 00:00:00+00:00
2021-11-26 00:00:00+00:00
2021-11-27 00:00:00+00:00
2021-11-28 00:00:00+00:00
2021-11-29 00:00:00+00:00
2021-11-30 00:00:00+00:00
2021-11-30 09:19:32+00:00

(There are some more examples about optional parameters in REAME) Best,

Asone commented 2 years ago

Thanks !