0

I am trying to get historical USD prices for BTC from the Coinbase API. The relevant section of the documentation is here. I've never interacted directly with an API before, so at the moment I'm just trying to figure out how to format the request.

To get the current price, this works:

https://api.coinbase.com/v2/prices/BTC-USD/spot

However, if I want to get historical prices I need to specify a date as indicated in the docs, but I can't seem to get the format right. I'm sure this is a standard format of which I am just unaware, so hopefully someone can point me in the right direction.

I've tried:

https://api.coinbase.com/v2/prices/BTC-USD/2018-01-01

https://api.coinbase.com/v2/prices/BTC-USD/date/2018-01-01

https://api.coinbase.com/v2/prices/BTC-USD/resource?date=2018-01-01

https://api.coinbase.com/v2/prices/BTC-USD/resource/date=2018-01-01

(something along the lines suggested here)

What is the correct formatting for the API request?

KBriggs
  • 1,098
  • 2
  • 16
  • 38

1 Answers1

1

You should format the request as

https://api.coinbase.com/v2/prices/BTC-USD/spot?date=2018-05-21

And you should include a CB-VERSION

CB-VERSION: 2017-08-07

if you want to avoid an API warning

Roger Lindsjö
  • 10,912
  • 1
  • 39
  • 49