-2

I'm trying to find how to get futures order book for all tickers, i successfully found how to get active contracts using : https://api-futures.kucoin.com/api/v1/contracts/active

I read the api documentation, it says

Get Order Book

HTTP Request GET /api/v2/order-book

kucoinf = requests.get("https://api-futures.kucoin.com/api/v2/order-book")
e = kucoinf.json()
kucoinf = json_normalize(e['data'])
print (kucoinf)

but it doesn't work https://api-futures.kucoin.com/api/v2/order-book

One boy
  • 216
  • 1
  • 7
  • You are required to post a [mcve] here, **within your question**, and [not a link](https://meta.stackoverflow.com/a/254430/162698) to any other site. – Rob May 31 '22 at 18:44

1 Answers1

2

I recommend you use the CCXT library as it will make your life easier for what you are trying to do.

To retrieve Kucoin spot market order book:

import ccxt

exchange = ccxt.kucoin()

symbol = 'BTC/USDT'
order_book = exchange.fetchOrderBook(symbol)
print(order_book)

To retrieve Kucoin futures market order book:

import ccxt

exchange = ccxt.kucoinfutures()

symbol = 'BTC/USDT:USDT'
order_book = exchange.fetchOrderBook(symbol)
print(order_book)
Alex B
  • 1,092
  • 1
  • 14
  • 39