3

I am trying to get all tickers (currency pairs) with their corresponding Bid and Ask price data in one single JSON payload response from the Coinbase REST API. If I have GET request for each individual ticker symbol, I will have to avoid getting a 729 error as mentioned in the Coinbase API documentation.

I have a GET request to this URL -> https://api-public.sandbox.pro.coinbase.com/products/BTC-USD/book

Which returns the data I need for BTC-USD, but actually I am interested in all of tickers listed on the exchange with their corresponding Bid and Ask price data in one single query.

For exmaple, many other exchanges replace the currency code acronym with "ALL." So my JSON payload response would look something like the following:

I have tried setting a timer function to parse individual tickers 3 seconds at a time but that is not the fastest way to get all the data I need from the JSON.

JSON response should look something like this:

{
  "ticker": [
    {
      "symbol": "ABBCBTC",
      "24hrHigh": "0.00000850",
      "last": "0.00000842",
      "24hrVol": "1507399.04",
      "ask": "0.0000084",
      "24hrLow": "0.00000813",
      "bid": "0.00000833",
      "24hrAmt": "12.52040928"
    },
    {
      "symbol": "ABTETH",
      "24hrHigh": "0.001078",
      "last": "0.001078",
      "24hrVol": "5.27",
      "ask": "0.001988",
      "24hrLow": "0.000964",
      "bid": "0.000983",
      "24hrAmt": "0.005681"
    },
    {
      "symbol": "ABTUSDT",
      "24hrHigh": "0.212",
      "last": "0.202",
      "24hrVol": "944.91",
      "ask": "0.203",
      "24hrLow": "0.190",
      "bid": "0.197",
      "24hrAmt": "183.148"
    },
    {
      "symbol": "ABYSSETH",
      "24hrHigh": "0.0000500",
      "last": "0.0000500",
      "24hrVol": "0",
      "ask": "0.000055",
      "24hrLow": "0.0000500",
      "bid": "0.0000301",
      "24hrAmt": "0.0000000"
    },
    {
      "symbol": "ACDCBTC",
      "24hrHigh": "0.000000011",
      "last": "0.000000010",
      "24hrVol": "86773.47",
      "ask": "0.00000001",
      "24hrLow": "0.000000009",
      "bid": "0.000000009",
      "24hrAmt": "0.000858894"
    },
    {
      "symbol": "ACDCUSDT",
      "24hrHigh": "0.000110",
      "last": "0.000107",
      "24hrVol": "24011.63",
      "ask": "0.000107",
      "24hrLow": "0.000085",
      "bid": "0.000087",
      "24hrAmt": "2.088214"
    },
    {
      "symbol": "ADDETH",
      "24hrHigh": "0.000046",
      "last": "0.000046",
      "24hrVol": "0",
      "ask": "0.000062",
      "24hrLow": "0.000046",
      "bid": "--",
      "24hrAmt": "0.000000"
    },
    {
      "symbol": "ADIETH",
      "24hrHigh": "0.00000310",
      "last": "0.00000310",
      "24hrVol": "0",
      "ask": "0.00000744",
      "24hrLow": "0.00000310",
      "bid": "0.0000031",
      "24hrAmt": "0.00000000"
    },
    {
      "symbol": "ADNBTC",
      "24hrHigh": "0.0000000378",
      "last": "0.0000000375",
      "24hrVol": "551104713.07",
      "ask": "0.0000000379",
      "24hrLow": "0.0000000366",
      "bid": "0.0000000367",
      "24hrAmt": "20.4085431339"
    }
  ]
}
Danny Buonocore
  • 3,731
  • 3
  • 24
  • 46

2 Answers2

2

It seems that you can’t get all the tickers in one call (( I do not want to use web sockets, so I make a series of requests like https://api.gdax.com/products/BTC-EUR/ticker with pauses between them. This is bad practice, but I don’t have time to remake the infrastructure for web sockets yet. Coinbase is the only exchange that does not allow to receive all tickers in one call. I get quotes from Bittrex,Bitmex,Kraken,Bitfinex,Binance - and there are no problems getting all the tickers in one go.

Good luck!

2

From Coinbase docs: his URL will provide data for all the tickers on Coinbase:

curl --request GET \
     --url https://api.exchange.coinbase.com/products \
     --header 'Accept: application/json'

If you need more detailed data about each ticker, you can iterate over the response and make individual calls for each ticker name.

SergeyB
  • 9,478
  • 4
  • 33
  • 47