Friday 16 July 2021

Is there a workaround to get past CoinGecko API security check?

I was running my code at work, and it just went smoothly, but on a different network (Home WiFi), I keep receiving 403 error when accessing CoinGecko V3 API. It can be observed that accessing the API on a private browser (to test it) will prompt a security check (hCaptcha) to be able to continue.

https://api.coingecko.com/api/v3/coins/bitcoin/market_chart?vs_currency=usd&days=30

with requests.get(url) as source:
    print(source.status_code)

I also tried pycoingecko (for checking) and still returns a similar error:

>>> from pycoingecko import CoinGeckoAPI
>>> cg = CoinGeckoAPI()
>>> cg.get_coin_market_chart_by_id(id='bitcoin', vs_currency='usd', days=1)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Users\...\Python39\lib\site-packages\pycoingecko\utils.py", line 12, in input_args
    return func(*args, **kwargs)
  File "C:\Users\...\Python39\lib\site-packages\pycoingecko\api.py", line 169, in get_coin_market_chart_by_id
    return self.__request(api_url)
  File "C:\Users\...\Python39\lib\site-packages\pycoingecko\api.py", line 29, in __request
    response.raise_for_status()
  File "C:\Users\...\Python39\lib\site-packages\requests\models.py", line 941, in raise_for_status
    raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 403 Client Error: Forbidden for url: https://api.coingecko.com/api/v3/coins/bitcoin/market_chart?vs_currency=usd&days=1

I guess Cloudflare is suspecting my network activity, but of course I am using Python scripts to access the API, obviously. Is there a workaround to get past the security check?



from Is there a workaround to get past CoinGecko API security check?

No comments:

Post a Comment