man-c / pycoingecko

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

Add proxies feature; add requirements.txt #57

Closed ksiau closed 2 years ago

ksiau commented 2 years ago

The version of urllib3 is important because the latest version 1.26 has a bug.

man-c commented 2 years ago

Hello, Regarding proxies it doesn't need to be defined as an parameter. You can set your proxies after initializing CoinGeckoAPI() by using the session variable directly, and then call the API endpoints. For example:

>>> import pycoingecko
>>> cg=pycoingecko.CoinGeckoAPI()
>>> print(cg.session.proxies)
{}
# set up a proxy (or any other dictionary with proxies)
>>> cg.session.proxies['https']='http://10.10.1.10:1080'
>>> print(cg.session.proxies)
{'https': 'http://10.10.1.10:1080'}
# for example get price of bitcoin in USD
>>> cg.get_price(ids='bitcoin', vs_currencies='usd')