Coinbase API v2 Getting Historic Price for Multiple Days

0 votes

I'm having some trouble with a Coinbase.com API call for historical data.

Previously, I was getting a variable length of days that would match the amount of space available on a terminal screen with a request URL that looked like this:

https://api.coinbase.com/v2/prices/historic?currency=USD&days=76

This would pull the previous 76 days of price history. An example of the old output is here: https://gist.github.com/KenDB3/f071a06ab3ef1a899d3cd8df8b40a049#file-coinbase-historic-days-example-2017-12-23-json

This stopped working a few days ago. The closest I can get to this is with this request URL:

https://api.coinbase.com/v2/prices/BTC-USD/historic?days=76

The output from this can be seen here: https://gist.github.com/KenDB3/f071a06ab3ef1a899d3cd8df8b40a049#file-coinbase-historic-days-example-2018-07-19-json

In the second example, it is just displaying prices from the day of the query at different times of that day. What I really want is the first example output where it gives a single price per day going back as many days as the request is for.

The project this is connected to is here: https://github.com/KenDB3/SyncBTC

Links that do not work: https://api.coinbase.com/v2/prices/historic?currency=BTC-USD&days=76 (No Results) https://api.coinbase.com/v2/prices/BTC-USD/historic?2018-07-15T00:00:00-04:00 (Does not pull data from 7/15/2018)

Apr 6, 2022 in Blockchain by Rahul
• 9,690 points
4,259 views
well your first query only specified USD, not BTC-USD, for starters...

1 answer to this question.

0 votes

Any reason you aren't using coinbase pro?

The new API is very easy to use. Simply add the get command you want to be followed by the parameters separated with a question mark. Here is the new historic rates API documentation: https://docs.cloud.coinbase.com/exchange/reference/exchangerestapi_getproductcandles

The get command with the new API most similar to prices is "candles". It requires three parameters to be identified, start and stop time in iso format and granularity which is in seconds. Here is an example:

https://api.pro.coinbase.com/products/BTC-USD/candles?start=2018-07-10T12:00:00&end=2018-07-15T12:00:00&granularity=900

Check out Blockchain course to learn more about blockchain technology.

answered Apr 12, 2022 by Soham
• 9,730 points

Related Questions In Blockchain

0 votes
1 answer

How to get historic Bitcoin Price Index using coinbase or any other open source API?

I would recommend you to use the ...READ MORE

answered Apr 7, 2022 in Blockchain by Rahul
• 9,690 points
2,625 views
0 votes
1 answer

How do I add multiple recipients for transactions via Blockchain API?

Convert the recipes into JSON objects. x = ...READ MORE

answered Jul 6, 2018 in Blockchain by Perry
• 17,100 points
1,605 views