man-c / pycoingecko

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

API json result format 'data' instead of "data" #49

Closed beoschmann closed 3 years ago

beoschmann commented 3 years ago

Hi,

I'm trying to understand why when I use the wrapper, the results of my call are not looking like supported json.

Example with the result from get_coin_market_chart_by_id call :

cg.get_coin_market_chart_by_id(bitcoin ,'usd', 1, interval = 'daily')

{ 'prices':[ [ 1628640000000, 45639.51401890709 ] }

when trying to use parser/formatter, it's indicate me that syntax are not json and when I try the same API on coingecko directly I receive the correct format :

{ "prices": [ [ 1628640000000, 45639.51401890709 ] }

Is there any reason for such difference ?

Thanks,

man-c commented 3 years ago

Hello,

The results are already loaded using json library which converts JSON to a Python object. https://github.com/man-c/pycoingecko/blob/6f6d0ba959a2b884dcc3575700001ad01fe8fa25/pycoingecko/api.py#L29-L31

You can find more info about loading objects with json library here: https://docs.python.org/3/library/json.html#json.load

Best,