nathanramoscfa / pycgapi

An unofficial Python wrapper for the CoinGecko API
MIT License
2 stars 0 forks source link

401 Client error for "multiple coins" functions #16

Open starlordbets opened 2 weeks ago

starlordbets commented 2 weeks ago

Hello,

Just wanted to let you know that there is an error being thrown for the functions involving multiple coins such as "multiple_coins_historical_data" and it gives the following error:

HTTPError: 401 Client Error: Unauthorized for url: https://api.coingecko.com/api/v3/coins/bitcoin/market_chart?vs_currency=usd&days=max&interval=daily&precision=full

If you click on that link then it gives more info on the error:

{ "error": { "status": { "timestamp": "2024-06-18T15:04:20.238+00:00", "error_code": 10012, "error_message": "Your request exceeds the allowed time range. Public API users are limited to querying historical data within the past 365 days. Upgrade to a paid plan to enjoy full historical data access: https://www.coingecko.com/en/api/pricing. " } } }

If you can update the default function parameter for "days" to be "365" instead of "max" this seems to solve the issue:

https://api.coingecko.com/api/v3/coins/bitcoin/market_chart?vs_currency=usd&days=365&interval=daily&precision=full

nathanramoscfa commented 2 weeks ago

Thank you for your interest in the pycgapi project. I am currently working on version 1.0.0 completely refactored version of pycgapi, where this issue will be fixed. If you'd like to use this version now, simply pip install the dev branch of the pycgapi GitHub repo using the pip install git+https://github.com/nathanramoscfa/pycgapi.git@dev command. I have completely refactored the project and so the project will be updated from version 0.1.4 to 1.0.0 and is not backwards compatible. Try it out, and tell me if this solves the problem you highlighted. See the examples directory for usage examples.

starlordbets commented 2 weeks ago

If I install this dev version in the same environment as the current package, will it override the previous version? I was able to tweak the package source code for the published version and got it working for my needs. Much appreciate the work you put into this. Light years better than the official Coin Gecko package.

On Wed, Jun 19, 2024 at 9:18 PM Nathan Ramos, CFA @.***> wrote:

Thank you for your interest in the pycgapi project. I am currently working on version 1.0.0 completely refactored version of pycgapi, where this issue will be fixed. If you'd like to use this version now, simply pip install the dev branch of the pycgapi GitHub repo using the pip install @.*** command. I have completely refactored the project and so the project will be updated from version 0.1.4 to 1.0.0 and is not backwards compatible. Try it out, and tell me if this solves the problem you highlighted. See the examples directory for usage examples.

— Reply to this email directly, view it on GitHub https://github.com/nathanramoscfa/pycgapi/issues/16#issuecomment-2179647334, or unsubscribe https://github.com/notifications/unsubscribe-auth/A6NDQLKGMJFZC7LB4NT3LLTZIIUWVAVCNFSM6AAAAABJQHUBZSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCNZZGY2DOMZTGQ . You are receiving this because you authored the thread.Message ID: @.***>

nathanramoscfa commented 2 weeks ago

@starlordbets If you're able to do what you set out to do using pycgapi 0.1.4, then great. It's stable and likely won't change, as I am focusing all my development work and improvements to pycgapi 1.0.0, yet to be released, but currently usable on the dev branch. It might not matter as you'll get the same outputs as before. pycgapi 1.0.0 is being developed more for the purpose of improving the project's maintainability and code quality, rather than adding any new features. However, CoinGecko's new ON CHAIN DEX API endpoints have been added to pycgapi 1.0.0, so if you want access to those endpoints, you'll have to use pycgapi 1.0.0 on the dev branch.

If you decided to use the dev branch on the same environment you're currently using, then yes, you'd want to override the previous version so they don't conflict. In that case, I'd recommend:

  1. Backup your current environment: Use pip freeze > requirements.txt to save the current state of your environment.
  2. Uninstall the current version: Run pip uninstall pycgapi.
  3. Install the dev version: Use pip install git+https://github.com/nathanramoscfa/pycgapi.git@dev.

You might have to refactor your code to how pycgapi is now structured. See the examples directory in the dev for usage examples. Search the project for the endpoint you want to use, and you'll find the function for it. Let me know if you have trouble finding a particular endpoint.

Note: The source code in the dev branch is mostly finished. Working on tests and adapting the documentation to the newly refactored project. I wouldn't call it stable, but it's stable enough for you to try out and use. I tested every function in the examples directory and they all worked.