Kucoin How to Get Order Book for futures from api?

1.1k Views Asked by At

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

1

There are 1 best solutions below

0
On

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)