1. Add Third Party Info to Database#
After information collection, KuCoin will add and upload the third party info. to database and generate ‘partner’, ‘broker-key’ and ‘broker-name’ for the third party platform.2. Access to KuCoin OpenAPI#
KuCoin will provide ‘partner’, ‘broker-key’ and ‘broker-name’ for the third party platforms. Please add the following headers in the request:KC-API-PARTNER-SIGN: The base 64-encoded signature (see Signing a Message)
KC-BROKER-NAME: Broker-name
KC-API-PARTNER-VERIFY: True
It is not mandatory to add this request header, but it is strongly recommended to add it.When the KC-API-PARTNER-VERIFY request header is not added, the KC-API-PARTNER-SIGN request header fails to be signed, but the KC-API-SIGN signature is successful and the order can be placed successfully without carry broker info.After adding this request header, as long as the KC-API-PARTNER-SIGN request header fails to be signed, an error {"code":"400201","msg":"Invalid KC-API-PARTNER-SIGN"} will be reported.Please make sure to add these request headers to all your REST requests, otherwise it will affect your rebate
3. Signing a Message#
For the header of KC-API-PARTNER-SIGN:Use broker-key to encrypt the prehash string timestamp + partner + apiKey with sha256 HMAC.
After that, use base 64-encode to encrypt the result in step 1 again.
The timestamp value is the same as the KC-API-TIMESTAMP header.The partner value is the same as the KC-API-PARTNER header.The apiKey value is the same as KC-API-KEY4. For Example#
String apikey = "6422da9c97b45100018c6e62";
String apiSecretKey = "cde06451-dbed";
String passphrase = "1111111";
broker-name: goodbrokerND
partner: goodbroker
broker-key: e8512b82-a4aa
REQ TIMESTAMP: 1680885532722
REQ URL: https://api.kucoin.com/api/v1/orders
REQ BODY:{"symbol":"BTC-USDT","side":"buy","size":"0.0001","price":"30000","type":"limit","clientOid":"2b802154-8d31-42e6-88ea-c8c18d3e4822","tradeType":"TRADE"}
(4) The request header for user to place order normally without going through the broker1680885532722POST/api/v1/orders{"symbol":"BTC-USDT","side":"buy","size":"0.0001","price":"30000","type":"limit","clientOid":"2b802154- 8d31-42e6-88ea-c8c18d3e4822","tradeType":"TRADE"}
ncPuAcZW8WYUZyvblRVVgMfYoVH+FlCTO6K45/FMLFQ=
{
KC-API-TIMESTAMP=1680885532722,
KC-API-KEY=6422da9c97b45100018c6e62,
KC-API-SIGN=ncPuAcZW8WYUZyvblRVVgMfYoVH+FlCTO6K45/FMLFQ=,
KC-API-PASSPHRASE=rl1Ki0WuwidRT48JnoGQo+AJ4UtZ6mQEKt6F5XYVnT4=,
KC-API-KEY-VERSION=2,
Content-Type=application/json,
accept=*
header.put("KC-BROKER-NAME", "goodbrokerND");
header.put("KC-API-PARTNER", "goodbroker");
String partnerSign = Base64.encodeBase64String( SHA256Util.hmac_sha256("e8512b82-a4aa", timestamp+"goodbroker"+apiKey));
header.put("KC-API-PARTNER-SIGN", partnerSign);
header.put("KC-API-PARTNER-VERIFY", "true");
1680885532722POST/api/v1/orders{"symbol":"BTC-USDT","side":"buy","size":"0.0001","price":"30000","type":"limit","clientOid":"2b802154-8d31-42e6-88ea-c8c18d3e4822","tradeType":"TRADE"}
ncPuAcZW8WYUZyvblRVVgMfYoVH+FlCTO6K45/FMLFQ=
1680885532722goodbroker6422da9c97b45100018c6e62
CN1imIGUz/USkPuhOtGWi5DlZ08VeuVfknJNOPqUEac=
{
KC-API-TIMESTAMP=1680885532722,
KC-API-KEY=6422da9c97b45100018c6e62,
KC-API-PASSPHRASE=rl1Ki0WuwidRT48JnoGQo+AJ4UtZ6mQEKt6F5XYVnT4=,
KC-API-SIGN=ncPuAcZW8WYUZyvblRVVgMfYoVH+FlCTO6K45/FMLFQ=,
KC-API-PARTNER=goodbroker,
KC-API-PARTNER-SIGN=CN1imIGUz/USkPuhOtGWi5DlZ08VeuVfknJNOPqUEac=,
KC-BROKER-NAME=goodbrokerND,
KC-API-PARTNER-VERIFY=true,
KC-API-KEY-VERSION=2,
Content-Type=application/json,
accept=*
(6) Check whether the configuration is successful#
For Spot, by querying the order interface GET /api/v1/orders/{orderId}, if the returned tags are not empty, the config is successfulFor Futures, by querying the order interface GET /api/v1/orders/{order-id}?clientOid={client-order-id}, if the returned tags are not empty, the config is successful