Market Endpoints¶
-
class
kucoin.client.
Client
(api_key, api_secret, passphrase, sandbox=False, requests_params=None)[source] -
get_24hr_stats
(symbol)[source] Get 24hr stats for a symbol. Volume is in base currency units. open, high, low are in quote currency units.
Parameters: symbol (string) – (optional) Name of symbol e.g. KCS-BTC stats = client.get_24hr_stats('ETH-BTC')
Returns: ApiResponse Without a symbol param
{ "symbol": "BTC-USDT", "changeRate": "0.0128", # 24h change rate "changePrice": "0.8", # 24h rises and falls in price (if the change rate is a negative number, # the price rises; if the change rate is a positive number, the price falls.) "open": 61, # Opening price "close": 63.6, # Closing price "high": "63.6", # Highest price filled "low": "61", # Lowest price filled "vol": "244.78", # Transaction quantity "volValue": "15252.0127" # Transaction amount }
Raises: KucoinResponseException, KucoinAPIException
-
get_full_order_book
(symbol)[source] Get a list of all bids and asks aggregated by price for a symbol.
This call is generally used by professional traders because it uses more server resources and traffic, and Kucoin has strict access frequency control.
https://docs.kucoin.com/#get-full-order-book-aggregated
Parameters: symbol (string) – Name of symbol e.g. KCS-BTC orders = client.get_order_book('KCS-BTC')
Returns: ApiResponse { "sequence": "3262786978", "bids": [ ["6500.12", "0.45054140"], # [price size] ["6500.11", "0.45054140"] ], "asks": [ ["6500.16", "0.57753524"], ["6500.15", "0.57753524"] ] }
Raises: KucoinResponseException, KucoinAPIException
-
get_full_order_book_level3
(symbol)[source] Get a list of all bids and asks non-aggregated for a symbol.
This call is generally used by professional traders because it uses more server resources and traffic, and Kucoin has strict access frequency control.
https://docs.kucoin.com/#get-full-order-book-atomic
Parameters: symbol (string) – Name of symbol e.g. KCS-BTC orders = client.get_order_book('KCS-BTC')
Returns: ApiResponse { "sequence": "1545896707028", "bids": [ [ "5c2477e503aa671a745c4057", # orderId "6", # price "0.999" # size ], [ "5c2477e103aa671a745c4054", "5", "0.999" ] ], "asks": [ [ "5c24736703aa671a745c401e", "200", "1" ], [ "5c2475c903aa671a745c4033", "201", "1" ] ] }
Raises: KucoinResponseException, KucoinAPIException
-
get_historical_orders
(symbol=None, side=None, start=None, end=None, page=None, limit=None)[source] List of KuCoin V1 historical orders.
https://docs.kucoin.com/#get-v1-historical-orders-list
Parameters: - symbol (string) – (optional) Name of symbol e.g. KCS-BTC
- side (string) – (optional) buy or sell
- start (string) – (optional) Start time as unix timestamp
- end (string) – (optional) End time as unix timestamp
- page (int) – (optional) Page to fetch
- limit (int) – (optional) Number of orders
orders = client.get_historical_orders(symbol='KCS-BTC')
Returns: ApiResponse { "currentPage": 1, "pageSize": 50, "totalNum": 1, "totalPage": 1, "items": [ { "symbol": "SNOV-ETH", "dealPrice": "0.0000246", "dealValue": "0.018942", "amount": "770", "fee": "0.00001137", "side": "sell", "createdAt": 1540080199 } ] }
Raises: KucoinResponseException, KucoinAPIException
-
get_kline_data
(symbol, kline_type='5min', start=None, end=None)[source] Get kline data
For each query, the system would return at most 1500 pieces of data. To obtain more data, please page the data by time.
Parameters: - symbol (string) – Name of symbol e.g. KCS-BTC
- kline_type (string) – type of symbol, type of candlestick patterns: 1min, 3min, 5min, 15min, 30min, 1hour, 2hour, 4hour, 6hour, 8hour, 12hour, 1day, 1week
- start (int) – Start time as unix timestamp (optional) default start of day in UTC
- end (int) – End time as unix timestamp (optional) default now in UTC
https://docs.kucoin.com/#get-historic-rates
klines = client.get_kline_data('KCS-BTC', '5min', 1507479171, 1510278278)
Returns: ApiResponse [ [ "1545904980", //Start time of the candle cycle "0.058", //opening price "0.049", //closing price "0.058", //highest price "0.049", //lowest price "0.018", //Transaction amount "0.000945" //Transaction volume ], [ "1545904920", "0.058", "0.072", "0.072", "0.058", "0.103", "0.006986" ] ]
Raises: KucoinResponseException, KucoinAPIException
-
get_markets
()[source] Get supported market list
https://docs.kucoin.com/#get-market-list
markets = client.get_markets()
Returns: ApiResponse { "data": [ "BTC", "ETH", "USDT" ] }
Raises: KucoinResponseException, KucoinAPIException
-
get_order_book
(symbol)[source] Get a list of bids and asks aggregated by price for a symbol.
Returns up to 100 depth each side. Fastest Order book API
https://docs.kucoin.com/#get-part-order-book-aggregated
Parameters: symbol (string) – Name of symbol e.g. KCS-BTC orders = client.get_order_book('KCS-BTC')
Returns: ApiResponse { "sequence": "3262786978", "bids": [ ["6500.12", "0.45054140"], # [price, size] ["6500.11", "0.45054140"] ], "asks": [ ["6500.16", "0.57753524"], ["6500.15", "0.57753524"] ] }
Raises: KucoinResponseException, KucoinAPIException
-
get_symbols
()[source] Get a list of available currency pairs for trading.
https://docs.kucoin.com/#symbols-amp-ticker
symbols = client.get_symbols()
Returns: ApiResponse [ { "symbol": "BTC-USDT", "name": "BTC-USDT", "baseCurrency": "BTC", "quoteCurrency": "USDT", "baseMinSize": "0.00000001", "quoteMinSize": "0.01", "baseMaxSize": "10000", "quoteMaxSize": "100000", "baseIncrement": "0.00000001", "quoteIncrement": "0.01", "priceIncrement": "0.00000001", "enableTrading": true } ]
Raises: KucoinResponseException, KucoinAPIException
-
get_ticker
(symbol=None)[source] Get symbol tick
https://docs.kucoin.com/#get-ticker
Parameters: symbol (string) – (optional) Name of symbol e.g. KCS-BTC all_ticks = client.get_ticker() ticker = client.get_ticker('ETH-BTC')
Returns: ApiResponse { "sequence": "1545825031840", # now sequence "price": "3494.367783", # last trade price "size": "0.05027185", # last trade size "bestBid": "3494.367783", # best bid price "bestBidSize": "2.60323254", # size at best bid price "bestAsk": "3499.12", # best ask price "bestAskSize": "0.01474011" # size at best ask price }
Raises: KucoinResponseException, KucoinAPIException
-
get_trade_histories
(symbol)[source] List the latest trades for a symbol
https://docs.kucoin.com/#get-trade-histories
Parameters: symbol (string) – Name of symbol e.g. KCS-BTC orders = client.get_trade_histories('KCS-BTC')
Returns: ApiResponse [ { "sequence": "1545896668571", "price": "0.07", # Filled price "size": "0.004", # Filled amount "side": "buy", # Filled side. The filled side is set to the taker by default. "time": 1545904567062140823 # Transaction time }, { "sequence": "1545896668578", "price": "0.054", "size": "0.066", "side": "buy", "time": 1545904581619888405 } ]
Raises: KucoinResponseException, KucoinAPIException
-