man-c / pycoingecko

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

calling with pro api key #75

Closed plang454 closed 1 year ago

plang454 commented 1 year ago

Hi, I'm using a Jupyter notebook to call the coingecko api client as follows:

cg = CoinGeckoAPI(api_key = 'xxx')

This throws an error: "TypeError: init() got an unexpected keyword argument 'api_key'"

I've looked at the init function and see an variable for 'api_key' so not sure why this is failing. I've also tried per the README:

from pycoingecko import CoinGeckoAPI cg = pycoingecko.CoinGeckoAPI(api_key='YOUR_API_KEY')

which throws another error related to the library where 'pycoingecko' is not defined.

What's the correct way to call with a pro api key?

Thanks.

man-c commented 1 year ago

Hello! It seems like you are using a previous version of pycoingecko (PRO api is supported from version 2.3.0). You can check your current installed version using:

pip show pycoingecko

To update pycoingecko use:

pip install -U pycoingecko

Then you can use pycoingecko with Pro API Key:

from pycoingecko import CoinGeckoAPI
cg = CoinGeckoAPI(api_key='YOUR_API_KEY')

I will update also READE to fix usage.