API Kucoin Futures

Kucoin Futures

 

Kucoin is an international multi-language cryptocurrency exchange. It offers some APIs to access Kucoin data. The following APIs are supported:

 

  1. WebSocket streams: allows to subscribe to some methods and get data in real-time. Events are pushed to clients by server to subscribers. Uses WebSocket as protocol.
  2. REST API: clients can request to server market and account data. Requires an API Key, Secret and Passphrase to authenticate and uses HTTPs as protocol.

 

 

Properties

Kucoin API has 2 types of methods: public and private. Public methods can be accessed without authentication, example: get ticker prices. Private and related to user data methods requires the use of Kucoin API keys.

 

 

Most common uses

 

WebSocket Feed

To subscribe channel messages from a certain server, the client side should send subscription message to the server.

If the subscription succeeds, the system will send ack messages to you, when the response is set as true.

{
    "id":"1545910660739",
    "type":"ack"
}
While there are topic messages generated, the system will send the corresponding messages to the client side.

 

The following Subscription / Unsubscription methods are supported.

 

Public Channels

 

Method Parameters Description
SubscribeSymbolTickerV2 Symbol Subscribe this topic to get the realtime push of BBO changes. After subscription, when there are changes in the order book, the system will push the real-time ticker symbol information to you. It is recommended to use the new topic for timely information.
SubscribeSymbolTicker Symbol Subscribe this topic to get the realtime push of BBO changes. The ticker channel provides real-time price updates whenever a match happens. If multiple orders are matched at the same time, only the last matching event will be pushed.
SubscribeLevel2MarketData Symbol Subscribe this topic to get Level 2 order book data.
SubscribeExecutionData Symbol For each order executed, the system will send you the match messages in the format as following.
SubscribeLevel2_5BestAskBid Symbol Returned for every 100 milliseconds at most.
SubscribeLevel2_50BestAskBid Symbol Returned for every 100 milliseconds at most.
SubscribeContractMarketData Symbol Subscribe this topic to get the market data of the contract.
SubscribeSystemAnnouncements Symbol Subscribe this topic to get the system announcements.
SubscribeTransactionStatistics Symbol The transaction statistics will be pushed to users every 5 seconds.

 

If ACK parameter is sent to true, after a successful subcription / unsubscription, client receives a message about it.

 

Private Channels

Requires a valid ApiKey obtained from your Kucoin account. The ApiKey, ApiSecret and Passphrase must be set in the Kucoin property of the client API component.

 

The following data is pushed to client every time there is a change. There is no need to subscribe to any method, this is done automatically if you set a valid ApiKey.

 

Method Description
SubscribeTradeOrders This topic will push all change events of your orders.
SubscribeAccountBalance

You will receive this message when an account balance changes. The message contains the details of the change.

SubscribePositionChange The system will push the change event when the position status changes.
SubscribeStopOrder When a stop order is received by the system, you will receive a message with "open" type. It means that this order entered the system and waited to be triggered.

 

 

REST API

All endpoints return either a JSON object or array. 

 

Public API EndPoints

 

These endpoints can be accessed without any authorization.

 

General EndPoints

 

Method Parameters Description
GetServiceStatus   Test connectivity to the Rest API and get the Service STatus
GetServerTime   Test connectivity to the Rest API and get the current server time.

 

 

Market Data EndPoints

 

Method Parameters Description
GetOpenContractList   Submit request to get the info of all open contracts.
GetOrderInfoContract   Submit request to get info of the specified contract.
GetTicker Symbol The real-time ticker includes the last traded price, the last traded size, transaction ID, the side of liquidity taker, the best bid price and size, the best ask price and size as well as the transaction time of the orders. These messages can also be obtained through Websocket. The Sequence Number is used to judge whether the messages pushed by Websocket is continuous.
GetPartOrderBook20 Symbol Get a snapshot of aggregated open orders for a symbol.
GetPartOrderBook100 Symbol Get a snapshot of aggregated open orders for a symbol.
GetFullOrderBook Symbol Get a snapshot of aggregated open orders for a symbol.
GetLevel2PullingMessages Symbol If the messages pushed by Websocket is not continuous, you can submit the following request and re-pull the data to ensure that the sequence is not missing. In the request, the start parameter is the sequence number of your last received message plus 1, and the end parameter is the sequence number of your current received message minus 1. After re-pulling the messages and applying them to your local exchange order book, you can continue to update the order book via Websocket incremental feed. If the difference between the end and start parameter is more than 500, please stop using this request and we suggest you to rebuild the Level 2 orderbook.
GetTradeHistory Symbol List the last 100 trades for a symbol.
GetInterestRateList Symbol Check interest rate list.
GetIndexList Symbol Check index list
GetCurrentMarkPrice Symbol Check the current mark price.
GetPremiumIndex Symbol Submit request to get premium index.
GetCurrentFundingRate Symbol Submit request to check the current mark price.
GetKLine Symbol Get K Line Data of Contract

 

 

 

Private API EndPoints

 

Requires an APIKey and APISecret to get authorized by server.

 

User EndPoints

 

Method Parameters Description
GetAccountOverview   Get Account Overview
GetTransactionHistory   If there are open positions, the status of the first page returned will be Pending, indicating the realised profit and loss in the current 8-hour settlement period. Please specify the minimum offset number of the current page into the offset field to turn the page.

 

 

Trade Endpoints

 

Method Parameters Description
PlaceOrder   You can place two types of orders: limit and market. Orders can only be placed if your account has sufficient funds. Once an order is placed, your funds will be put on hold for the duration of the order. The amount of funds on hold depends on the order type and parameters specified.
PlaceMarketOrder   Places a Market Order.
PlaceLimitOrder   Places a Limit Order.
CancelOrder   Cancels an Order by Order Id.
LimitOrderMassCancellation   Cancel all open orders (excluding stop orders). The response is a list of orderIDs of the canceled orders.
StopOrderMassCancellation   Cancel all untriggered stop orders. The response is a list of orderIDs of the canceled stop orders. To cancel triggered stop orders, please use 'Limit Order Mass Cancelation'.
GetOrderList   List your current orders.
GetUntriggeredStopOrderList   Get the un-triggered stop orders list.
GetListOrdersCompleted24hr   Get a list of recent 1000 orders in the last 24 hours. If you need to get your recent traded order history with low latency, you may query this endpoint.
GetOrder   Get a single order by order id (including a stop order).
GetOrderByClientOid   Get a single order by client order id (including a stop order).
GetFills   Get a list of recent fills.
GetRecentFills   Get a list of recent 1000 fills in the last 24 hours. If you need to get your recent traded order history with low latency, you may query this endpoint.
ActiveOrderValueCalculation   You can query this endpoint to get the the total number and value of the all your active orders.
GetPositionDetails   Get the position details of a specified position.
GetPositionList   Get the position details of a specified position.
AutoDepositMargin   Enable/Disable of Auto-Deposit Margin
AddMarginManually   Add Margin Manually
ObtainFuturesRiskLimitLevel   This interface can be used to obtain information about risk limit level of a specific contract
AdjustRiskLimitLevel   This interface is for the adjustment of the risk limit level. To adjust the level will cancel the open order, the response can only indicate whether the submit of the adjustment request is successful or not.
GetFundingHistory   Submit request to get the funding history.

 

 

Events

Kucoin Messages are received in TsgcWebSocketClient component, you can use the following events:

 

OnConnect

After a successful connection to Kucoin server.

OnDisconnect

After a disconnection from Kucoin server

OnMessage

Messages sent by server to client are handled in this event.

OnError

If there is any error in protocol, this event will be called.

OnException

If there is an unhandled exception, this event will be called.

 

Additionally, there is a specific event in Kucoin API Component, called OnKucoinHTTPException, which is raised every time there is an error calling an HTTP Request (REST API or WebSocket Feeds).