coinmarketcapr icon indicating copy to clipboard operation
coinmarketcapr copied to clipboard

API error

Open topsoil opened this issue 4 years ago • 14 comments

I guess this coincap's API changes.

latest_marketcap <- get_global_marketcap('EUR') ‼ The old API is used when no 'apikey' is given. x The request was not succesfull! Request URL: https://api.coinmarketcap.com/v1/global/?convert=EUR Response Content: { "statusCode": 410, "error": "Gone", "message": "WARNING: This API is now offline. Please switch to the new CoinMarketCap API. (https://pro.coinmarketcap.com/migrate/)" }

Error in check_response(d) :

topsoil avatar Mar 12 '20 20:03 topsoil

I have same error, please update the functions as well, get_marketcap_ticker_all has been depricated

advisely avatar Mar 22 '20 21:03 advisely

@iboumiza Did you try the new API functions (with the key) ?

amrrs avatar Mar 23 '20 17:03 amrrs

@amrrs , I did try: https://pro-api.coinmarketcap.com/v1/cryptocurrency/listings/latest?api_key=API_KEY_HERE

but I keep getting: { "status": { "timestamp": "2020-03-23T18:29:38.913Z", "error_code": 1002, "error_message": "API key missing.", "elapsed": 0, "credit_count": 0 } }

Can you provide a working example to test, please?

advisely avatar Mar 23 '20 18:03 advisely

In that above example you pasted, there's no API Key, you need to first get the API Key here https://pro.coinmarketcap.com/signup/?plan=0

amrrs avatar Mar 23 '20 20:03 amrrs

Indeed, I removed my private API KEY as it's not public and have monthly limits (new coinmarketcap business model), that's why I'm referring to you to update the current script to work with private API KEYs

Thanks

advisely avatar Mar 24 '20 05:03 advisely

@iboumiza The package should work with API-keys, so I dont really understand which script should be updated?

Previously it also worked without an API-key, but apparently that old API is now offline. Is that correct @amrrs ? If yes, then we should update some functions/warnings/docs, ec..

trafficonese avatar Mar 27 '20 10:03 trafficonese

@iboumiza The package should work with API-keys, so I dont really understand which script should be updated?

Previously it also worked without an API-key, but apparently that old API is now offline. Is that correct @amrrs ? If yes, then we should update some functions/warnings/docs, ec..

Can you please post a screenshot of your code with the result, because I did all the possible combinations, and none of them work.

Thank you

advisely avatar Mar 27 '20 12:03 advisely

I just tried out these functions. They all worked for me. But I can confirm, the old API is no longer valid.

coinmarketcapr::setup('YOUR_API_KEY')

res <- get_crypto_listings()
res <- get_global_marketcap('AUD')
res <- get_global_marketcap(latest = T, time_start = Sys.Date() - 180,
                            time_end = Sys.Date(), count = 10,
                            interval = "yearly")

trafficonese avatar Mar 27 '20 13:03 trafficonese

Perfect, it works! Thank you :)

advisely avatar Mar 27 '20 14:03 advisely

@trafficonese guess we might need to remove the old functions. What say ?

amrrs avatar Mar 27 '20 14:03 amrrs

Yes definitly, since they will not work anymore. We also need to adapt the docs/warnings/errors/etc. And maybe make the tests finally consistent, so they always run through.

Aren't you also trying to publish the package to ropensci ? I think they require tests and a vignette?

trafficonese avatar Mar 27 '20 14:03 trafficonese

Also, some functions will not work under the free plan (no historical data):

https://coinmarketcap.com/api/pricing/

For example: get_crypto_quotes(latest = FALSE, symbol = c("BTC","ETH"), time_start = Sys.Date()-180, time_end=Sys.Date(), count = 10, interval = "30m")

advisely avatar Mar 27 '20 14:03 advisely

This should be visible in the response.

    "status": {
        "timestamp": "2020-03-27T14:41:48.467Z",
        "error_code": 1006,
        "error_message": "Your API Key subscription plan doesn't support this endpoint.",
        "elapsed": 0,
        "credit_count": 0
    }

I think that information should be sufficient.

trafficonese avatar Mar 27 '20 14:03 trafficonese

Thank you to @trafficonese for outlining the solution. The documentation needs to be updated, it says functions like get_global_marketcap work without an API key but that is not the case, and there is nothing that I saw outlined relating to using coinmarketcapr::setup('YOUR_API_KEY') which is exactly what I needed. Might want to update some of the documentation accordingly. Thanks for the package!

ries9112 avatar Sep 29 '20 14:09 ries9112