README


Welcome to OKCoin developer documentation. Please note that the current version of this document is v3 and it will be updated regularly. Traders are advised to check this document from time to time for latest updates.

OKCoin offers powerful APIs for you to tailor to your needs with different permissions. There are three categories: account, trading, and market trends. After creating an account on OKCoin, developers can create APIs of different permissions according to their needs and perform automated trading as well as withdrawal. Our API trading permissions enable you to instantly capture market trends and trade, check available and locked balance, view pending orders, buy, sell, and cancel orders. All market data endpoints are public.

Instructions

If a developer would like to request the API, please subscribe to our v3 API key via this link. API trading instructions and settings are all included in this document. Should you encounter any problems during your use of the API or have any suggestions for improvement, please feel free to contact us.

Endpoints Configurations

OKCoin offers two types of endpoints, developers may select either one to suit their needs of viewing market data, trading, or withdrawal. Refer to SDK(Please see here for details)

REST API

REST, Representational State Transfer, is one of the most used architectural style for creating web services, as its framework is clear, standardized, user-friendly, and scalable. It also has the following advantages:

  • Under the RESTful framework, each URL represents a kind of resource;
  • The representational state of transferring the resource between client and server;
  • Actualization of REST by using 4 HTTP instructions from the client to operate the resources in the server. We highly recommend developers to use REST API to perform spot trading and withdrawal.
WebSocket API

WebSocket is a new Protocol of HTML5. It achieved full-duplex data transmission between the client and the server, allowing data to transmit effectively in both directions. Through only one simple handshake, the connection between the client and the server is established, and the server can push information to the client according to the business rules. WebSocket has the following advantages:

  • The WebSocket request header for data transmission between client and server is only approximately 2 bytes;
  • Either the client or server can initiate a data transmission;
  • Avoided the multiple-creation and killing of TCP request, saving network and server resources. We highly recommend developers to use WebSocket API to obtain market data.
Contact

Please feel free to join our API community on Telegram (https://t.me/okcoin_en). Our tech experts will help to answer all your questions and you can share your experiences with all other users.

API Summarize

Market overview and general information.

Matching Engine

This chapter explains the matching engine in the following four aspects:

  • Filled Price
  • Order Life Cycle
  • Token Trading Price Limit Rules

Filled Price

OKCoin’s matching engine operates at a first-come, first-serve basis. Orders are executed in price-time priority as received by the matching engine.

Example: 3 orders are placed to the order book respectively: a) 9900USDT for 1BTC, b) 10100USDT for 2BTC, and c) 9900USDT for 1.5BTC. They will be matched in price-time priority, which is b > a > c.

Orders are matched and executed at maker price, not at taker price.

Example: User A placed an order to buy 1BTC at 10000USDT, and after that, user B placed an order to sell 1BTC at 8000USDT. Since the order created by user A was placed in the book first, user A will be the maker in this transaction and the filled price will be 10000USDT.

Order Life Cycle

Valid orders sent to the matching engine are in "unfilled" state. If the order executes against another order, it is considered "filled". An order can be "partially filled" and stays in the orders matching queue. If an open order is recalled, it is considered "cancelled". All cancelled or filled orders will be removed from the matching queue.

Token Trading Price Limit Rules

A new Fill-or-kill feature is now available in spot token trading. It is designed to prevent execution errors which may lead to unnecessary loss when placing orders.

Should an order would be filled, regardless its filled quantity, at the price of ±30% from best bid & offer by the time it executed in the order book, the order would be entirely cancelled. Otherwise, the order would be executed and matched normally.

Example A user placed a market order to buy 100BTC in XRP/BTC. The best offer price at that time is 0.00012. If the order does entirely execute in the market, the market price would be driven up to 0.0002. Based of the calculation (0.0002-0.00012)/0.00012=66.7%>30%), the potential filled price would be deviated >30% from the current best offer. Therefore, the system would cancel the mentioned market order entirely.

Fees

This chapter explains the fee details in the following two aspects:

  • Trading Fees
  • Deposit/Withdrawal Fees

Trading Fees

To encourage more order placement and liquidity, OKCoin adopts a marker-taker fee schedule, which the maker fee is lower than the taker fee. The fee schedule is volume-based, to be eligible for a tier, you are required to meet the minimum trading volume requirements. The higher the tier you are in, the lower the fees you can enjoy. Aside from tiered-volume fees discount, we specifically rewards traders who intend to provide consistent liquidity and competitive bid-ask spread.

Please see here for details

Deposit/Withdrawal Fees

OKCoin does not charge any withdrawal or deposit fees. Also, mining fees are not required for any transfers between OKCoin and OKEx, and the transfers between the two platforms are instant. However, mining fees will be levied by miners for any withdrawals out of OKCoin and OKEx.

Data Centers

The database and servers of OKCoin are based in Hong Kong. To lower the API latency, we suggest you to use an ISP that can communicate smoothly with Hong Kong.

Request

This chapter explains the request details in the following three aspects:

  • Introduction
  • Errors
  • Success

Introduction

REST API provides account management, market data, and transactions features.

REST API Terminal URL https://www.okcoin.com/api

We also provide WebSocket-stream. Subscribe to our WebSocket and you can get our market data push.

All requested are based on https protocol. Please set the contentType of the request message to: “application/json”

Errors

Unless otherwise stated, errors to bad requests will respond with HTTP 4xx or status codes. The body will also contain a message parameter indicating the cause.

Your language’s http library should be configured to provide message bodies for non-2xx requests so that you can read the message field from the body.

Common Error Codes
400 Bad Request — Invalid request format
401 Unauthorized — Invalid API Key
403 Forbidden — You do not have access to the requested resource
404 Not Found
500 Internal Server Error — We had a problem with our server

Success

A successful response is indicated by HTTP status code 200 and may contain an optional body. If the response has a body it will be documented under each resource below.

Rules

This chapter explains the standard specifications in the following three aspects:

  • Timestamps
  • Numbers
  • IDs

Timestamps

Unless otherwise specified, all timestamps from API are returned in ISO 8601 with millisecond. Make sure you can parse the following ISO 8601 format. Most modern languages and libraries will handle this without issues.

Example

2014-11-06T10:34:47.123Z

Numbers

Decimal numbers are returned as strings to preserve full precision across platforms. When making a request, it is recommended that you also convert your numbers to strings to avoid truncation and precision errors.

Integer numbers (like trade id and sequence) are unquoted.

IDs

Most identifiers are UUID unless otherwise specified. When making a request which requires a UUID, both forms (with and without dashes) are accepted.

132fb6ae-456b-4654-b4e0-d681ac05cea1 or 132fb6ae456b4654b4e0d681ac05cea1

Endpoints

This chapter explains the details of endpoint types in the following two aspects:

  • Public Endpoints
  • Private Endpoints

Public Endpoints

Public APIs are available for acquiring information and market data. Public requests do not require any verifications.

Private Endpoints

Private endpoints are available for order management, and account management. Every private request must be signed using the described authentication scheme.

Private endpoints require authentication using your API key. You can generate API keys here.

Rate Limits

This chapter explains the details of access restriction in the following two aspects:

  • REST API
  • WebSocket

When a rate limit is exceeded, a status of 429 Too Many Requests will be returned.

REST API

We use user id for rate limiting if you have a valid API key. If not, we use the public IP for rate limiting.

Rate limit: There are instructions for each endpoint. If not specified, the speed limit is 6 times / s

WebSocket

The WebSocket throttles the number of incoming messages to 50 commands per second.

Authentication

This chapter explains the details of authentication in the following five aspects:

  • Generating an API Key
  • Creating a Request
  • Signing a Message
  • Timestamp
  • Getting Server Time

Generating an API Key

Before being able to sign any requests, you must create an API key via the OKCoin website. Upon creating a key you will have 3 pieces of information which you must remember:

API Key

Secret

Passphrase

The API Key and Secret will be randomly generated and provided by OKCoin; the Passphrase will be provided by you to further secure your API access. OKCoin stores the salted hash of your passphrase for verification, but cannot recover the passphrase if you forget it.

Creating a Request

All private endpoints REST requests must contain the following headers:

OK-ACCESS-KEY The api key as a string.

OK-ACCESS-SIGN The base64-encoded signature (see Signing a Message).

OK-ACCESS-TIMESTAMP A timestamp for your request.

OK-ACCESS-PASSPHRASE The passphrase you specified when creating the API key.

All request bodies should have content type application/json and be valid JSON.

Signing a Message

The OK-ACCESS-SIGN header is generated by creating a sha256 HMAC using the base64-decoded secret key on the prehash string timestamp + method + requestPath + body (where + represents string concatenation), secretKey and base64-encode the output. For example: sign=CryptoJS.enc.Base64.stringify(CryptoJS.HmacSHA256(timestamp + 'GET' + '/users/self/verify', secretKey))

The timestamp value is the same as the OK-ACCESS-TIMESTAMP header and nanometer precision.

The method should be UPPER CASE, like GET/POST.

requestPath is the path of requesting an endpoint, such as:/orders?before=2&limit=30.

The body is the request body string or omitted if there is no request body (typically for GET requests). For example:{"product_id":"BTC-USD-0309","order_id":"377454671037440"}

secretKey is generated when a user is subscribing to an Apikey. Prehash string:2018-03-08T10:59:25.789ZPOST/orders?before=2&limit=30{"product_id":"BTC-USD-0309","order_id":"377454671037440"}

public enum ContentTypeEnum {

    APPLICATION_JSON("application/json"),
    APPLICATION_JSON_UTF8("application/json; charset=UTF-8"),
    // The server does not support types
    APPLICATION_FORM("application/x-www-form-urlencoded; charset=UTF-8"),;


    private String contentType;

    ContentTypeEnum(String contentType) {
        this.contentType = contentType;
    }

    public String contentType() {
        return contentType;
    }
}


public enum HttpHeadersEnum {

    OK_ACCESS_KEY("OK-ACCESS-KEY"),
    OK_ACCESS_SIGN("OK-ACCESS-SIGN"),
    OK_ACCESS_TIMESTAMP("OK-ACCESS-TIMESTAMP"),
    OK_ACCESS_PASSPHRASE("OK-ACCESS-PASSPHRASE"),

    OK_FROM("OK-FROM"),
    OK_TO("OK-TO"),
    OK_LIMIT("OK-LIMIT"),;

    private String header;

    HttpHeadersEnum(String header) {
        this.header = header;
    }

    public String header() {
        return header;
    }
}

import com.okcoin.commons.okcoin.open.api.config.APIConfiguration;
import com.okcoin.commons.okcoin.open.api.constant.APIConstants;
import com.okcoin.commons.okcoin.open.api.enums.ContentTypeEnum;
import com.okcoin.commons.okcoin.open.api.enums.HttpHeadersEnum;
import com.okcoin.commons.okcoin.open.api.exception.APIException;
import com.okcoin.commons.okcoin.open.api.utils.DateUtils;
import com.okcoin.commons.okcoin.open.api.utils.HmacSHA256Base64Utils;
import okhttp3.*;
import okio.Buffer;

public class APIHttpClient {

    private APIConfiguration config;
    private APICredentials credentials;

    public APIHttpClient(APIConfiguration config, APICredentials credentials) {
        this.config = config;
        this.credentials = credentials;
    }

    public OkHttpClient client() {
        OkHttpClient.Builder clientBuilder = new OkHttpClient.Builder();
        clientBuilder.connectTimeout(this.config.getConnectTimeout(), TimeUnit.SECONDS);
        clientBuilder.readTimeout(this.config.getReadTimeout(), TimeUnit.SECONDS);
        clientBuilder.writeTimeout(this.config.getWriteTimeout(), TimeUnit.SECONDS);
        clientBuilder.retryOnConnectionFailure(this.config.isRetryOnConnectionFailure());
        clientBuilder.addInterceptor((Interceptor.Chain chain) -> {
            Request.Builder requestBuilder = chain.request().newBuilder();
            String timestamp = DateUtils.getUnixTime();
            requestBuilder.headers(headers(chain.request(), timestamp));
            Request request = requestBuilder.build();
            if (this.config.isPrint()) {
                printRequest(request, timestamp);
            }
            return chain.proceed(request);
        });
        return clientBuilder.build();
    }

    private Headers headers(Request request, String timestamp) {
        Headers.Builder builder = new Headers.Builder();
        builder.add(APIConstants.ACCEPT, ContentTypeEnum.APPLICATION_JSON.contentType());
        builder.add(APIConstants.CONTENT_TYPE, ContentTypeEnum.APPLICATION_JSON_UTF8.contentType());
        builder.add(APIConstants.COOKIE, getCookie());
        if (StringUtils.isNotEmpty(this.credentials.getSecretKey())) {
            builder.add(HttpHeadersEnum.OK_ACCESS_KEY.header(), this.credentials.getApiKey());
            builder.add(HttpHeadersEnum.OK_ACCESS_SIGN.header(), sign(request, timestamp));
            builder.add(HttpHeadersEnum.OK_ACCESS_TIMESTAMP.header(), timestamp);
            builder.add(HttpHeadersEnum.OK_ACCESS_PASSPHRASE.header(), this.credentials.getPassphrase());
        }
        return builder.build();
    }

    private String getCookie() {
        StringBuilder cookie = new StringBuilder();
        cookie.append(APIConstants.LOCALE).append(this.config.getI18n().i18n());
        return cookie.toString();
    }

    private String sign(Request request, String timestamp) {
        String sign;
        try {
            sign = HmacSHA256Base64Utils.sign(timestamp, method(request), requestPath(request),
                    queryString(request), body(request), this.credentials.getSecretKey());
        } catch (IOException e) {
            throw new APIException("Request get body io exception.", e);
        } catch (CloneNotSupportedException e) {
            throw new APIException("Hmac SHA256 Base64 Signature clone not supported exception.", e);
        } catch (InvalidKeyException e) {
            throw new APIException("Hmac SHA256 Base64 Signature invalid key exception.", e);
        }
        return sign;
    }

    private String url(Request request) {
        return request.url().toString();
    }

    private String method(Request request) {
        return request.method().toUpperCase();
    }

    private String requestPath(Request request) {
        String url = url(request);
        url = url.replace(this.config.getEndpoint(), APIConstants.EMPTY);
        String requestPath = url;
        if (requestPath.contains(APIConstants.QUESTION)) {
            requestPath = requestPath.substring(0, url.lastIndexOf(APIConstants.QUESTION));
        }
        if(this.config.getEndpoint().endsWith(APIConstants.SLASH)){
            requestPath = APIConstants.SLASH + requestPath;
        }
        return requestPath;
    }

    private String queryString(Request request) {
        String url = url(request);
        String queryString = APIConstants.EMPTY;
        if (url.contains(APIConstants.QUESTION)) {
            queryString = url.substring(url.lastIndexOf(APIConstants.QUESTION) + 1);
        }
        return queryString;
    }

    private String body(Request request) throws IOException {
        RequestBody requestBody = request.body();
        String body = APIConstants.EMPTY;
        if (requestBody != null) {
            Buffer buffer = new Buffer();
            requestBody.writeTo(buffer);
            body = buffer.readString(APIConstants.UTF_8);
        }
        return body;
    }
}



import okhttp3.Headers;
import okhttp3.OkHttpClient;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import retrofit2.Call;
import retrofit2.Response;
import retrofit2.Retrofit;

import java.io.IOException;
import java.util.List;
import java.util.Optional;

public class APIClient {

    /**
     * Synchronous send request
     */
    public <T> T executeSync(Call<T> call) {
        try {
            Response<T> response = call.execute();
            if (this.config.isPrint()) {
                printResponse(response);
            }
            int status = response.code();
            String message = new StringBuilder().append(response.code()).append(" / ").append(response.message()).toString();
            if (response.isSuccessful()) {
                return response.body();
            } else if (APIConstants.resultStatusArray.contains(status)) {
                HttpResult result = JSON.parseObject(new String(response.errorBody().bytes()), HttpResult.class);
                result.setStatusCode(status);
                throw new APIException(result.message());
            } else {
                throw new APIException(message);
            }
        } catch (IOException e) {
            throw new APIException("APIClient executeSync exception.", e);
        }
    }

}
package okcoin

import (
    "bytes"
    "errors"
    "fmt"
    "io/ioutil"
    "net/http"
    "strconv"
    "strings"
    "time"
)

type Client struct {
    Config     Config
    HttpClient *http.Client
}

type ApiMessage struct {
    Message string `json:"message"`
}

/*
 Get a http client
*/
func NewClient(config Config) *Client {
    var client Client
    client.Config = config
    timeout := config.TimeoutSecond
    if timeout <= 0 {
        timeout = 30
    }
    client.HttpClient = &http.Client{
        Timeout: time.Duration(timeout) * time.Second,
    }
    return &client
}

/*
 Send a http request to remote server and get a response data
*/
func (client *Client) Request(method string, requestPath string,
    params, result interface{}) (response *http.Response, err error) {
    config := client.Config
    // uri
    endpoint := config.Endpoint
    if strings.HasSuffix(config.Endpoint, "/") {
        endpoint = config.Endpoint[0:len(config.Endpoint)-1]
    }
    url := endpoint + requestPath

    // get json and bin styles request body
    var jsonBody string
    var binBody = bytes.NewReader(make([]byte, 0))
    if params != nil {
        jsonBody, binBody, err = ParseRequestParams(params)
        if err != nil {
            return response, err
        }
    }

    // get a http request
    request, err := http.NewRequest(method, url, binBody)
    if err != nil {
        return response, err
    }

    // Sign and set request headers
    timestamp := IsoTime()
    preHash := PreHashString(timestamp, method, requestPath, jsonBody)
    sign, err := HmacSha256Base64Signer(preHash, config.SecretKey)
    if err != nil {
        return response, err
    }
    Headers(request, config, timestamp, sign)

    if config.IsPrint {
        printRequest(config, request, jsonBody, preHash)
    }

    // send a request to remote server, and get a response
    response, err = client.HttpClient.Do(request)
    if err != nil {
        return response, err
    }
    defer response.Body.Close()

    // get a response results and parse
    status := response.StatusCode
    message := response.Status
    body, err := ioutil.ReadAll(response.Body)
    if err != nil {
        return response, err
    }

    if config.IsPrint {
        printResponse(status, message, body)
    }

    response.Header.Add(ResultJsonString, string(body))

    if status >= 200 && status < 300 {
        if body != nil && result != nil {
            err := JsonBytes2Struct(body, result)
            if err != nil {
                return response, err
            }
        }
        return response, nil
    } else if status == 400 || status == 401 || status == 500 {
        if body != nil {
            var apiMessage ApiMessage
            err := JsonBytes2Struct(body, &apiMessage)
            if err != nil {
                return response, err
            }
            message = strconv.Itoa(status) + " " + apiMessage.Message
        }
        return response, errors.New(message)
    } else {
        return response, errors.New(message)
    }
    return response, nil
}

type Config struct {
    // Rest api endpoint url. eg: http://www.okcoin.com/
    Endpoint string
    // The user's api key provided by OKCOIN.
    ApiKey string
    // The user's secret key provided by OKCOIN. The secret key used to sign your request data.
    SecretKey string
    // The Passphrase will be provided by you to further secure your API access.
    Passphrase string
    // Http request timeout.
    TimeoutSecond int
    // Whether to print API information
    IsPrint bool
    // Internationalization @see file: constants.go
    I18n string
}




func NewTestClient() *Client {
    // Set OKCOIN API's config
    var config Config
    config.Endpoint = "https://www.okcoin.com/"
    config.ApiKey = ""
    config.SecretKey = ""
    config.Passphrase = ""
    config.TimeoutSecond = 45
    config.IsPrint = false
    config.I18n = ENGLISH

    client := NewClient(config)
    return client
}



import "testing"

const (
    productId = "BTC-USD-180928"
    currency  = "BTC"
)
string OKCOINAPI::GetSign(string timestamp, string method, string requestPath, string body) {
    string sign;
    unsigned char * mac = NULL;
    unsigned int mac_length = 0;
    string data = timestamp + method + requestPath + body;
    string key = m_config.SecretKey;
    int ret = HmacEncode("sha256", key.c_str(), key.length(), data.c_str(), data.length(), mac, mac_length);
    sign = base64_encode(mac, mac_length);
    return sign;
}

string OKCOINAPI::Request(const string &method, const string &requestPath, const string &params) {
    /************************** set request method ***************************/
    http_request request;
    request.set_method(method);
    /************************** set request uri ***************************/
    uri_builder builder;
    builder.append_path(requestPath);
    request.set_request_uri(builder.to_uri());

    /************************** set request headers ***************************/
    char * timestamp = new char[32];
    timestamp = GetTimestamp(timestamp, 32);
    string sign = GetSign(timestamp, method, builder.to_string(), params);
    request.headers().clear();
    request.headers().add(U("OK-ACCESS-KEY"), m_config.ApiKey);
    request.headers().add(U("OK-ACCESS-SIGN"), sign);
    request.headers().add(U("OK-ACCESS-TIMESTAMP"), timestamp);
    request.headers().add(U("OK-ACCESS-PASSPHRASE"), m_config.Passphrase);
    request.headers().add(U("Accept"), U("application/json"));
    request.headers().set_content_type(U("application/json; charset=UTF-8"));
    request.headers().add(U("Cookie"),U("locale="+m_config.I18n));

    /************************** set request body ***************************/
    request.set_body(params,"application/json; charset=UTF-8");

    /************************** get response ***************************/
    http_response response;
    string str;
    http_client client(m_config.Endpoint);
    response = client.request(request).get();
    str = response.extract_string(true).get();

    delete []timestamp;
    return str;
}


string GetSpotOrdersExample() {
    OKCOINAPI okcoinapi;
    /************************** set config **********************/
    struct Config config;
    config.Endpoint = "https://www.okcoin.com";
    config.SecretKey = "";
    config.ApiKey = "";
    config.Passphrase = "";
    okapi.SetConfig(config);

    /************************** set parameters **********************/
    string method(GET);
    map<string,string> m;
    m.insert(make_pair("productId", "BTC-USD"));
    m.insert(make_pair("status", "all"));

    /************************** request and response **********************/
    string request_path = BuildParams("/api/spot/v3/orders", m);
    return okcoinapi.Request(method, request_path);
}

string AddSpotOrderExample() {
    OKCOINAPI okcoinapi;
    /************************** set config **********************/
    struct Config config;
    config.Endpoint = "https://www.okcoin.com";
    config.SecretKey = "";
    config.ApiKey = "";
    config.Passphrase = "";
    okapi.SetConfig(config);

    /************************** set parameters **********************/
    value obj;
    obj["size"] = value::number(1);
    obj["price"] = value::number(8);
    obj["side"] = value::string("buy");
    obj["instrument_id"] = value::string("BTC-USD");

    /************************** request and response **********************/
    string params = obj.serialize();
    return okcoinapi.Request(POST, "/api/spot/v3/orders", params);
}
}
import hmac
import base64
import requests
import json

CONTENT_TYPE = 'Content-Type'
OK_ACCESS_KEY = 'OK-ACCESS-KEY'
OK_ACCESS_SIGN = 'OK-ACCESS-SIGN'
OK_ACCESS_TIMESTAMP = 'OK-ACCESS-TIMESTAMP'
OK_ACCESS_PASSPHRASE = 'OK-ACCESS-PASSPHRASE'
APPLICATION_JSON = 'application/json'


# signature
def signature(timestamp, method, request_path, body, secret_key):
    if str(body) == '{}' or str(body) == 'None':
        body = ''
    message = str(timestamp) + str.upper(method) + request_path + str(body)
    mac = hmac.new(bytes(secret_key, encoding='utf8'), bytes(message, encoding='utf-8'), digestmod='sha256')
    d = mac.digest()
    return base64.b64encode(d)


# set request header
def get_header(api_key, sign, timestamp, passphrase):
    header = dict()
    header[CONTENT_TYPE] = APPLICATION_JSON
    header[OK_ACCESS_KEY] = api_key
    header[OK_ACCESS_SIGN] = sign
    header[OK_ACCESS_TIMESTAMP] = str(timestamp)
    header[OK_ACCESS_PASSPHRASE] = passphrase
    return header


def parse_params_to_str(params):
    url = '?'
    for key, value in params.items():
        url = url + str(key) + '=' + str(value) + '&'

    return url[0:-1]


# request example
# set the request url
base_url = 'https://www.okcoin.com'
request_path = '/api/account/v3/currencies'
# set request header
header = get_header('your_api_key', signature('timestamp', 'GET', request_path, 'your_secret_key'), 'timestamp', 'your_passphrase')
# do request
response = requests.get(base_url + request_path, headers=header)
# json
print(response.json())

# [{
#     "id": "BTC",
#     "name": “Bitcoin”,
#      "deposit": "1",
#      "withdraw": “1”,
#       “withdraw_min”:”0.000001btc”
# }, {
#     "id": "ETH",
#     "name": “Ethereum”,
#     "deposit": "1",
#      "withdraw": “1”,
#      “withdraw_min”:”0.0001eth”
#     }
#  …
# ]


########################################################
# take order
base_url = 'https://www.okcoin.com'
request_path = '/api/spot/v3/orders'

# request params
params = {'type': 'market', 'side': 'buy', 'instrument_id': 'usdt_okb', 'size': '10', 'client_oid': '',
                  'price': '10', 'funds': ''}

# request path
request_path = request_path + parse_params_to_str(params)
url = base_url + request_path

# request header and body
header = get_header('your_api_key', signature('timestamp', 'POST', request_path, 'your_secret_key'), 'timestamp', 'your_passphrase')
body = json.dumps(params)

# do request
response = requests.post(url, data=body, headers=header)

#########################################################
# get order info
base_url = 'https://www.okcoin.com'
request_path = '/api/spot/v3/orders'

params = {'status':'all', 'instrument_id': 'okb_usdt'}

# request path
request_path = request_path + parse_params_to_str(params)
url = base_url + request_path

# request header and body
header = get_header('your_api_key', signature('timestamp', 'GET', request_path, 'your_secret_key'), 'timestamp', 'your_passphrase')

# do request
response = requests.get(url, headers=header)

Timestamp

The OK-ACCESS-TIMESTAMP request header must be in the UTC time zone Unix timestamp decimal seconds format or the ISO8601 standard time format. It needs to be accurate to milliseconds.

Your timestamp must be within 30 seconds of the api service time or your request will be considered expired and rejected. We recommend using the time endpoint to query for the API server time if you believe there many be time skew between your server and the API servers.

Getting Server Time

API server time. This is a public endpoint, no verification is required.

HTTP Requests

GET /api/general/v3/time

Return Parameters
Parameters Description
iso ISO 8601 format
epoch Unix Epoch in UTC
Return Sample
{

"iso": "2015-01-07T23:47:25.201Z",

"epoch": 1420674445.201

}

Wallet API

The Wallet API endpoints include transfer between main account, sub accounts and various trading accounts, getting deposit addresses, withdrawal functions and more.

Get Currencies

This endpoint retrieves a list of all tokens. Not all tokens can be used for trading. Tokens which have or had no representation in ISO 4217 may use a custom code.

HTTP Requests

GET /api/account/v3/currencies

Request Sample

GET /api/account/v3/currencies

Return Parameters
Parameters Parameters Types Description
currency String Token code
name String Token name
can_deposit number availability of depositing, 0 = not available,1 = available
can_withdraw number availability of withdrawal,0 = not available,1 = available
min_withdrawal number the minimum withdrawal limit
Return Sample
    {
         "can_deposit":1,
         "can_withdraw":1,
         "currency":"BTC",
         "min_withdrawal":0.01,
         "name":""
     },
     {
         "can_deposit":1,
         "can_withdraw":1,
         "currency":"LTC",
         "min_withdrawal":0.1,
         "name":""
     }

Wallet Information

This endpoint retrieves a list of all assets, including the information about the balances of all tokens, the token amount on hold/available.

HTTP Requests

GET /api/account/v3/wallet

Request Sample

GET /api/account/v3/wallet

Return Parameters
Parameters Parameters Types Description
currency String Token
balance number Amount remaining in the account
hold number Amount on hold
available number Available amount
Return Sample

    {
        "available":37.11827078,
        "balance":37.11827078,
        "currency":"EOS",
        "hold":0
    },
    {
        "available":0,
        "balance":0,
        "currency":"XMR",
        "hold":0
    }

Wallet of a Currency

This endpoint retrieves the information about a single token, including the remaining balance, the token amount on hold/available.

HTTP Requests

GET /api/account/v3/wallet/<currency>

Request Sample

GET /api/account/v3/wallet/btc

Return Parameters
Parameters Parameters Types Description
balance number Remaining balance
hold number Amount on hold
available number Available amount
currency String Token
Return Sample
{
    "currency":"XMR",
    "available":0.00049136,
    "balance":0.00049136,
    "hold":0
}

Funds Transfer

This endpoint supports the transfer of funds between wallet, trading accounts, main account and sub accounts.

Limit: 3 times / s
HTTP Requests

POST /api/account/v3/transfer

Request Sample

POST /api/account/v3/transfer

Request Parameters
Parameters Parameters Types Required Description
currency String Yes Token
amount number Yes Transfer amount
from number Yes the remitting account (0: sub account 1: spot 5: margin 6: wallet 8:PiggyBank )
to number Yes the beneficiary account(0: sub account 1:spot 5: margin 6: wallet 8:PiggyBank )
sub_account String No sub account name
instrument_id number No margin token pair ID, for supported pairs only
Return Parameters
Parameters Parameters Types Description
transfer_id number Transfer ID
currency String Token to be transferred
from number The remitting account
amount number Transfer amount
to number The beneficiary account
result boolean Transfer result. An error code will be displayed if it failed.
Explanation

When ‘from’ or ‘to’ is 0, sub account parameter is required.

When ‘from’ or ‘to’ is 5, instrument_id is required.

OK06ETT can only be transferred between ETT and spot accounts

Return Sample
{
    "transfer_id": 754147,
    "currency”:"ETC”
    "from": 6,
    "amount": 0.1,
    "to”: 1,
    "result": true
}

Withdrawal

This endpoint supports the withdrawal of tokens to OKCoin International, other OKEx accounts or other addresses.

HTTP Requests

POST /api/account/v3/withdrawal

Request Sample

POST /api/account/v3/withdrawal

{"amount":1,"fee":0.0005,"trade_pwd":"123456","destination":4,"currency":"btc","to_address":"17DKe3kkkkiiiiTvAKKi2vMPbm1Bz3CMKw"}

Request Parameters
Parameters Parameters Types Required Description
currency String Yes token
amount number Yes withdrawal amount
destination number Yes withdrawal address(2:OKCoin International 3:OKEx 4:others)
to_address String Yes verified digital asset address, email or mobile number ,some digital asset address format is address+tag , eg: "ARDOR-7JF3-8F2E-QUWZ-CAN7F:123456"
trade_pwd String Yes fund password
fee number Yes Network transaction fee≥0. Withdrawals to OKCoin or OKEx are fee-free, please set as 0. Withdrawal to external digital asset address requires network transaction fee.
Return Parameters
Parameters Parameters Types Description
currency String token
amount number withdrawal amount
withdraw_id number withdrawal ID
result boolean withdrawal result. An error code will be displayed if it failed.
Return Sample
{
    "amount":0.1,
    "withdrawal_id":67485,
    "currency":"btc",
    "result":true
}

Withdrawal Fees

This endpoint retrieves the information about the recommended network transaction fee for withdrawals to digital asset addresses. The higher the fees are, the sooner the confirmations you will get.

HTTP Requests

GET /api/account/v3/withdrawal/fee

Request Sample

GET /api/account/v3/withdrawal/fee?currency=btc

Request Parameters
Parameters Parameters Types Required Description
currency String No token, information of all tokens will be returned if the field is left blank
Return Parameters
Parameters Parameters Types Description
currency String token
min_fee number minimum withdrawal fee
max_fee number maximum withdrawal fee
Return Sample
{
        "currency":"BTC",
        "max_fee":0.02,
        "min_fee":0.0005
    },
    {
        "currency":"LTC",
        "max_fee":0.2,
        "min_fee":0.001
    },
    {
        "currency":"ETH",
        "max_fee":0.2,
        "min_fee":0.01
    }

Recent Withdrawal History

This endpoint retrieves all recent withdrawal records.

HTTP Requests

GET /api/account/v3/withdrawal/history

Request Sample

GET /api/account/v3/withdrawal/history

Return Parameters
Parameters Parameters Types Description
currency String token
amount number amount
timestamp String withdrawal request creation date
from String remitting address(OKCoin account will be shown for OKCoin address)
to String beneficiary address
tag String tag is required for some tokens. Please leave the field blank if not required
payment_id String payment ID is required for some tokens. Please leave the field blank if it is not required
txid String the txid for withdrawals (leave it blank for internal transfer)
fee String withdrawal fee
status number -3:pending cancel; -2: cancelled; -1: failed; 0 :pending; 1 :sending; 2:sent; 3 :email confirmation; 4 :manual confirmation; 5:awaiting identity confirmation
Explanation

The remitting account is an OKCoin account, it does not represent the actual address on the blockchain. If the beneficiary account is also an OKCoin account, the txid will not be returned. 100 recent withdrawal records will be returned at maximum. For more records, please request the record of a specific token instead. Please note that the transactions shown here may not be recorded on the blockchain yet. Please be patient if the funds haven’t been credited yet.

Return Sample

    {
        "amount":0.094,
        "fee":"0.01000000eth",
        "txid":"0x62477bac6509a04512819bb1455e923a60dea5966c7caeaa0b24eb8fb0432b85",
        "currency":"ETH",
        "from":"13426335357",
        "to":"0xA41446125D0B5b6785f6898c9D67874D763A1519",
        "timestamp":"2018-04-22T23:09:45.000Z",
        "status":2
    },
    {
        "amount":0.01,
        "fee":"0.00000000btc",
        "txid":"",
        "currency":"BTC",
        "from":"13426335357",
        "to":"13426335357",
        "timestamp":"2018-05-17T02:43:08.000Z",
        "status":2
    }

Recent Withdrawal History of a Currency

This endpoint retrieves the withdrawal history of a specific token.

HTTP Request

GET /api/account/v3/withdrawal/history/<currency>

Request Sample

GET /api/account/v3/withdrawal/history/btc

Request Parameters
Parameters Parameters Types Required Description
currency String Yes token
Return Parameters
Parameters Parameters Types Description
currency String Token
amount number amount
timestamp String withdrawal request creation date
from String remitting address(OKCoin account will be shown for OKCoin address)
to String beneficiary address
tag String tag is required for some tokens. Please leave the field blank if not required
payment_id String payment ID is required for some tokens. Please leave the field blank if it is not required
txid String the txid for withdrawals (leave it blank for internal transfer)
fee String withdrawal fee
status String -3:pending cancel; -2: cancelled; -1: failed; 0 :pending; 1 :sending; 2:sent; 3 :email confirmation; 4 :manual confirmation; 5:awaiting identity confirmation
Explanation

The remitting account is an OKCoin account, it does not represent the actual address on the blockchain. If the beneficiary account is also an OKCoin account, the txid will not be returned. 100 recent withdrawal records will be returned at maximum. For more records, please request the record of a specific token instead. Please note that the transactions shown here may not be recorded on the blockchain yet. Please be patient if the funds haven’t been credited yet.

Return Sample
    {
        "amount":0.01105486,
        "fee":"0.00000000btc",
        "from":"13426335357",
        "to":"13426335357",
        "timestamp":"2018-09-30T02:49:29.000Z",
        "status":2
    },
    {
        "amount":0.01144408,
        "fee":"0.00000000btc",
        "from":"13426335357",
        "to":"13426335357",
        "timestamp":"2018-09-18T00:44:56.000Z",
        "status":2
    }

Bills Details

This endpoint retrieves the bill details of the wallet. All the information will be paged and sorted in reverse chronological order, which means the latest will be at the top. 3 months recent records will be returned at maximum

HTTP Requests

GET /api/account/v3/ledger

Request Sample

GET /api/account/v3/ledger?type=2&currency=btc&from=4&limit=10

Request Parameters
Parameters Parameters Types Required Description
currency String No token , information of all tokens will be returned if the field is left blank
type number No 1:deposit 2:withdrawal 13:cancel withdrawal 20:into sub account 21:out of sub account 28: claim 33: into margin account 34: out of margin account 37: into spot account 38: out of spot account
from number No you would request pages after this page.
to number No you would request pages before this page
limit number No Number of results per request. Maximum 100. (default 100)
Return Parameters
Parameters Parameters Types Description
ledger_id number bill ID
currency String token
balance number remaining balance
amount number quantity
typename String type of bills
fee number service fees
timestamp String creation time
Return Sample
{
        "amount":-0.00100941,
        "balance":0,
        "currency":"BTC",
        "fee":0,
        "ledger_id":9260348,
        "timestamp":"2018-10-19T01:12:21.000Z",
        "typename":"To: spot account"
    },
    {
        "amount":0.00051843,
        "balance":0.00100941,
        "currency":"BTC",
        "fee":0,
        "ledger_id":8987285,
        "timestamp":"2018-10-12T11:01:14.000Z",
        "typename":"Get from activity"
    }

Get Deposit Address

This endpoint retrieves the deposit addresses of different tokens, including previously used addresses.

HTTP Requests

GET /api/account/v3/deposit/address

Request Sample

GET /api/account/v3/deposit/address?currency=btc

Request Parameters
Parameters Parameters Types Required Description
currency String Yes token
Return Parameters
Parameters Parameters Types Description
address String deposit address
tag String Deposit tag (This string will not be returned if the token does not require a deposit tag)
payment_id String Deposit payment_id (This string will not be returned if the token does not require a payment_id)
currency String token
Explanation

IOTA deposit address cannot be reused! Depositing into a previously used IOTA address will not be confirmed and credited.

Tag or payment ID is required for some tokens. Please fill in the values to ensure the arrival of your funds.

Return Sample

{
    "currency":"btc"
    "address":"dafdsafdsfe",
    "tag":"123",
}, {
    "currency":"btc"
    "address":"dafdsafkkkdsfe",
    "tag”:”xyzddrrrsdfsdf"
}

Get Deposit History of All Currencies

This endpoint retrieves the deposit history of all tokens. 100 recent records will be returned at maximum

HTTP Requests

GET /api/account/v3/deposit/history

Request Sample

GET /api/account/v3/deposit/history

Return Parameters
Parameters Parameters Types Description
currency String token
amount number deposit amount
to String deposit address
txid String TXID
timestamp String deposit arrival date
status number The status of withdrawals (0: waiting for confirmation; 1: confirmation account; 2: recharge success);
Return Sample
{
        "amount":0.01044408,
        "txid":"1915737_3_0_0_WALLET",
        "currency":"BTC",
        "to":"",
        "timestamp":"2018-09-30T02:45:50.000Z",
        "status":2
    },
    {
        "amount":491.6784211,
        "txid":"1744594_3_184_0_WALLET",
        "currency":"OKB",
        "to":"",
        "timestamp":"2018-08-21T08:03:10.000Z",
        "status":2
    },
    {
        "amount":223.18782496,
        "txid":"6d892c669225b1092c780bf0da0c6f912fc7dc8f6b8cc53b003288624c",
        "currency":"USDT",
        "to":"39kK4XvgEuM7rX9frgyHoZkWqx4iKu1spD",
        "timestamp":"2018-08-17T09:18:40.000Z",
        "status":2
    }

Get Deposit History of a Currency

This endpoint retrieves the deposit history of a token. 100 recent records will be returned at maximum

HTTP Requests

GET /api/account/v3/deposit/history/<currency>

Request Sample

GET /api/account/v3/deposit/history/btc

Request Parameters
Parameters Parameters Types Required Description
currency String Yes token
Return Parameters
Parameters Parameters Types Description
amount number deposit amount
to String deposit address
txid String TXID
timestamp String deposit arrival date
currency number token
status number The status of withdrawals (0: waiting for confirmation; 1: confirmation account; 2: recharge success);
Return Sample
[{
 "amount": 2,
 "currency":"USDT",
 "to”:”[0x9edfe04c866d636526828e523a60501a37daf8f6](https://etherscan.io/address/0x9edfe04c866d636526828e523a60501a37daf8f6)", 
 "txid”:"0xf1fb12a03c483f475fc33abcb5bf42a765c7131e2f955025aec706be3f616da4”,
  "status":2,
 "timestamp": "2018-09-20T09:21:26.528Z"
}]

Error Code

Error Code Sample
Business Error Messages Business Error Codes http Status Code Scenarios
withdrawal suspended 34001 400 withdrawal endpoint: account suspended
please add a withdrawal address 34002 400 withdrawal endpoint: address required
sorry, this token cannot be withdrawn to xx at the moment 34003 400 withdrawal endpoint: incorrect address
withdrawal fee is smaller than minimum limit 34004 400 withdrawal endpoint: incorrect fee
withdrawal fee exceeds the maximum limit 34005 400 withdrawal endpoint: incorrect withdrawal fee
withdrawal amount is lower than the minimum limit 34006 400 minimum withdrawal amount%} endpoint: incorrect amount
withdrawal amount exceeds the maximum limit 34007 400 maximum withdrawal amount endpoint: incorrect amount
insufficient balance 34008 400 transfer & withdrawal endpoint: insufficient balance
your withdrawal amount exceeds the daily limit 34009 400 withdrawal endpoint: withdrawal limit exceeded
transfer amount must be larger than 0 34010 400 transfer endpoint: incorrect amount
conditions not met 34011 400 transfer & withdrawal endpoint: conditions not met, e.g. KYC level
the minimum withdrawal amount for NEO is 1, and the amount must be an integer 34012 400 withdrawal endpoint: special requirements
please transfer 34013 400 transfer endpoint: Token margin trading instrument ID required
transfer limited 34014 400 transfer endpoint:Transfer limited
subaccount does not exist 34015 400 transfer endpoint: subaccount does not exist
transfer suspended 34016 400 transfer endpoint: either end of the account does not authorize the transfer
account suspended 34017 400 transfer & withdrawal endpoint: either end of the account does not authorize the transfer
incorrect trades password 34018 400 incorrect trades password
please bind your email before withdrawal 34019 400 withdrawal endpoint : email required
please bind your funds password before withdrawal 34020 400 withdrawal endpoint : funds password required
Not verified address 34021 400 withdrawal endpoint
Withdrawals are not available for sub accounts 34022 400 withdrawal endpoint

Token Trading API

Token trading API includes endpoints relating to retrieving market data, account information, orders operations, order enquiry and bills details of spot account.

Description: in order to integrate with the old version, some of the API return parameters may be redundant.

Please refer to the parameter description in the documentation,For example, the returned parameters of frozen, hold are the same with holds of spot trading account, take hold as the criterion. The returned parameters of repay_amount are the same with the parameters of returned_amount, repay_interest and paid_interest. The returned parameters of product_id and instrument_id are the same.

Spot Trading Account

This endpoint supports getting the list of assets(only show pairs with balance larger than 0), the balances, amount available/on hold in spot accounts.

Rate limit: 20 /2s
HTTP Requests

GET /api/spot/v3/accounts

End Certificate Request Sample

2018-09-12T07:27:58.996ZGET/api/spot/v3/accounts

Return Parameters
Parameters Parameters Types Description
currency String token
balance String balance
hold String amount on hold(not available)
available String available amount
id String account ID
Explanation

After you placed an order, the amount of the order will be put on hold. This amount will not be available for transfer or using in other orders until the order is completed or cancelled.

Return Sample
[
    {
        "frozen":"0",
        "hold":"0",
        "id":"9150707",
        "currency":"BTC",
        "balance":"0.0049925",
        "available":"0.0049925",
        "holds":"0"
    },
    {
        "frozen":"0",
        "hold":"0",
        "id":"9150707",
        "currency":"USDT",
        "balance":"226.74061435",
        "available":"226.74061435",
        "holds":"0"
    },
    {
        "frozen":"0",
        "hold":"0",
        "id":"9150707",
        "currency":"EOS",
        "balance":"0.4925",
        "available":"0.4925",
        "holds":"0"
    }
]

Spot Trading Account of a Currency

This endpoint supports getting the balance, amount available/on hold of a token in spot account.

Rate limit: 20/2s
HTTP Requests

GET /api/spot/v3/accounts/<currency>

End Certificate Request Sample

2018-09-12T07:28:43.497ZGET/api/spot/v3/accounts/btc

Requests Parameters
Parameters Parameters Types Description
currency String [required]token
Return Parameters
Parameters Parameters Types Description
currency String token
balance String balance
hold String amount on hold(not available)
available String available amount
id String account id
Return Sample

{
    "frozen":"0",
    "hold":"0",
    "id":"9150707",
    "currency":"BTC",
    "balance":"0.0049925",
    "available":"0.0049925",
    "holds":"0"
}

Bills Details

All paginated requests return the latest information (newest) as the first page sorted by newest (in chronological time) first. This API can retrieve data in the last 3 months.

Rate limit: 20/2s
HTTP Requests

GET /api/spot/v3/accounts/<currency>/ledger

End Certificate Request Sample

2018-03-13T11:46:19.435ZGET/api/spot/v3/accounts/btc/ledger?limit=3&from=2&to=4

Parameters Parameters Types Description
from String [optional]request page before(newer) this id.
to String [optional]request page after(older) this id.
limit String [optional]number of results per request. Maximum 100.(default 100)
currency String [required] token
Return Parameters
Parameters Parameters Types Description
ledger_id String bill ID
balance String balance
currency String token
amount String amount
type String type of bills
timestamp String creation time
details String if the type is trade or fee, order details will be included under this
order_id String order ID
instrument_id String trading pair
Explanation

The following is the enumeration value for the parameters types

Type value Description
transfer funds transfer
trade funds moved as a result of a trade
rebate fee rebate as per our fee schedule
Return Sample
[
    {
        "timestamp":"2019-03-18T07:26:50.000Z",
        "ledger_id":"3995466151",
        "created_at":"2019-03-18T07:26:50.000Z",
        "currency":"BTC",
        "amount":"0.0009985",
        "balance":"0.0049925",
        "type":"trade",
        "details":{
            "instrument_id":"BTC-USDT",
            "order_id":"2500723297813504",
            "product_id":"BTC-USDT"
        }
    },
    {
        "timestamp":"2019-03-18T07:26:50.000Z",
        "ledger_id":"3995466150",
        "created_at":"2019-03-18T07:26:50.000Z",
        "currency":"BTC",
        "amount":"0.0009985",
        "balance":"0.003994",
        "type":"trade",
        "details":{
            "instrument_id":"BTC-USDT",
            "order_id":"2500723297223680",
            "product_id":"BTC-USDT"
        }
    },
    {
        "timestamp":"2019-03-18T07:08:25.000Z",
        "ledger_id":"3995334780",
        "created_at":"2019-03-18T07:08:25.000Z",
        "currency":"BTC",
        "amount":"0.0009985",
        "balance":"0.0029955",
        "type":"trade",
        "details":{
            "instrument_id":"BTC-USDT",
            "order_id":"2500650881647616",
            "product_id":"BTC-USDT"
        }
    }
]

Place an Order

OKCoin token trading only supports limit and market orders (more order types will become available in the future). You can place an order only if you have enough funds.

Once your order is placed, the amount will be put on hold.

Rate limit: 100/2s
HTTP Requests

POST /api/spot/v3/orders

End Certificate Request Sample

POST/api/spot/v3/orders{'type': 'limit', 'side': 'buy', 'instrument_id': 'BTC-USDT', 'size': 0.001, 'client_oid': 'oktspot79', 'price': '4638.51', 'funds': '', 'margin_trading': 1, 'order_type': '3'}

Request Parameters
Parameters Parameters Types Required Description
client_oid String No the order ID customized by yourself , The client_oid type should be comprised of alphabets + numbers or only alphabets within 1 – 32 characters, both uppercase and lowercase letters are supported
type String No limit / market(default: limit),When posting orders at market price, order_type can only be 0 (regular order)
side String Yes buy or sell
instrument_id String Yes trading pair
margin_trading String Yes order type (The request value is 1)
order_type String No Fill in number for parameter,0: Normal limit order (Unfilled and 0 represent normal limit order) 1: Post only 2: Fill Or Kill 3: Immediatel Or Cancel
Limit Order Parameters
Parameters Parameters Types Required Description
price String Yes price
size String Yes quantity bought or sold
Market Order Parameters
Parameters Parameters Types Required Description
size String Yes quantity sold. (for orders sold at market price only)
notional String Yes amount bought. (for orders bought at market price only)
Return Parameters
Parameters Parameters Types Description
order_id String order ID
client_oid String the order ID customised by yourself
result Boolean result of the order. Error message will be returned if the order failed.
error_code String Error code for order placement. Success = 0. Failure = error code
error_message String It will be blank if order placement is success. Error message will be returned if order placement fails.
Explanation

The client_oid type should be comprised of alphabets + numbers or only alphabets within 1 – 32 characters, both uppercase and lowercase letters are supported , and needs to make sure the ID does not repeat and there is no repetition alert. In case of repetition, only the latest entry will be queried and canceled .

instrument_id

The instrument_id must match a valid instrument. The instruments list is available via the /instrument endpoint

client_oid

The optional client_oid field must be a UUID generated by your trading application. This field value will be broadcast in the public feed for received messages. You can use this field to identify your orders in the public feed.

The client_oid is different than the server-assigned order id. If you are consuming the public feed and see a received message with your client_oid, you should record the server-assigned order_id as it will be used for future order status updates. The client_oid will NOT be used after the received message is sent.

type

When placing an order, you can specify the order type. The order type you specify will influence which other order parameters are required as well as how your order will be executed by the matching engine. If type is not specified, the order will default to a limit order.

limit orders are both the default and basic order type. A limit order requires specifying a price and size. The size is the number of tokens to buy or sell, and the price is the price per bitcoin. The limit order will be filled at the price specified or better. A sell order can be filled at the specified price per token or a higher price per token and a buy order can be filled at the specified price or a lower price depending on market conditions. If market conditions cannot fill the limit order immediately, then the limit order will become part of the open order book until filled by another incoming order or cancelled by the user.

market orders differ from limit orders in that they provide no pricing guarantees. They however do provide a way to buy or sell specific amounts of tokens without having to specify the price. Market orders execute immediately and no part of the market order will go on the open order book. Market orders are always considered takers and incur taker fees. When placing a market order you can specify funds and/or size. Funds will limit how much of your quote currency account balance is used and size will limit the token amount transacted.

price

The price must be specified in quote_increment product units. The quote increment is the smallest unit of price. This value can be acquired via the /instrument endpoint.

size

Size is the quantity of buying or selling and must be larger than the base_min_size. Base_increment is the minimum increment size. The above parameters can be acquired via the /instrument endpoint.

Example: If the base_min_size of OKB/USDT is 10 and the base_increment is 0.0001, then it is impossible to trade 9.99 OKB but possible to trade 10.0001 OKB.

notional

The notional field is the quantity of quote currency when placing market orders, it is required for market orders. For example, a market buy for BTC-USDT with funds specified as 5000 will spend 5000 USDT to buy BTC.

hold

For limit buy order, we will freeze the quote currency, of which the amount on hold = specific price x buying size. For limit sell orders, we will freeze the currency you want to sell, of which the amount equals to the amount you want to sell. For market buy orders, the quantity of funds in quote currency will be on hold. For market sell orders, the quantity of size will be on hold. Cancelling an open order releases the amount on hold.

Order Lifecycle

The HTTP Request will respond when an order is either rejected (insufficient funds, invalid parameters, etc) or received (accepted by the matching engine). A 200 response indicates that the order was received and is active. Active orders may execute immediately (depending on price and market conditions) either partially or fully. A partial execution will put the remaining size of the order in the open state. An order that is filled completely, will go into the done state.

Users listening to streaming market data are encouraged to use the client_oid field to identify their received messages in the feed. The REST response with a server order_id may come after the received message in the public data feed.

Response

A successful order will be assigned an order id. A successful order is defined as one that has been accepted by the matching engine.Open orders will not expire until being filled or cancelled.

Return Sample
{
    "client_oid":"oktspot79",
    "error_code":"",
    "error_message":"",
    "order_id":"2510789768709120",
    "result":true
}

Place Multiple Orders

This endpoint supports placing multiple orders for specific trading pairs( up to 4 trading pairs, Maximum 10 orders can be placed at a time for each trading pair).

Rate limit: 50/2s
HTTP Requests

POST /api/spot/v3/batch_orders

End Certificate Request Sample

Limit Order: 2018-09-14T09:51:24.959ZPOST/api/spot/v3/batch_orders[{"client_oid":"ww20180728","instrument_id":"btc-usdt","side":"sell","type":"limit","size":"0.001","price":"10001","margin_trading ":"1"},{"client_oid":"w20180728","instrument_id":"btc-usdt","side":"sell","type":"limit","size":"0.001","price":"10002","margin_trading ":"1"}]

Request Parameters
Parameters Parameters Types Required Description
client_oid String No the order ID customized by yourself ,The type should be comprised of alphabets + numbers or only alphabets within 1 – 32 characters, Both uppercase and lowercase letters are supported
type String Yes limit / market(default: limit),When posting orders at market price, order_type can only be 0 (regular order)
side String Yes buy or sell
instrument_id String Yes trading pair
margin_trading String Yes order type (The request value is 1)
order_type String No Fill in number for parameter,0: Normal limit order (Unfilled and 0 represent normal limit order) 1: Post only 2: Fill Or Kill 3: Immediatel Or Cancel
Limit Order Parameters
Parameters Parameters Types Required Description
price String Yes price
size String Yes quantity bought or sold
Market Order Parameters
Parameters Parameters Types Required Description
size String No quantity sold. (for orders sold at market price only)
notional String No amount bought. (for orders bought at market price only)
Return Parameters
Parameters Parameters Types Description
order_id String order ID
client_oid String the order ID customised by yourself
result Boolean result of the order. Error message will be returned if the order failed.
error_code String Error code for order placement. Success = 0. Failure = error code
error_message String It will be blank if order placement is success. Error message will be returned if order placement fails.
Explanation

The client_oid type should be comprised of alphabets + numbers or only alphabets within 1 – 32 characters, both uppercase and lowercase letters are supported , and needs to make sure the ID does not repeat and there is no repetition alert. In case of repetition, only the latest entry will be queried and canceled .

You may place up to 4 trading pairs with 10 orders at maximum for each pair. We recommend you to use the "Get order list" endpoint" after using the "Cancel multiple orders" endpoint to confirm the cancellation of orders.

Return Sample
{
    "btc_usdt":[
        {
            "client_oid":"oktspot80",
            "error_code":0,
            "error_message":"",
            "order_id":"2510832677159936",
            "result":true
        },
        {
            "client_oid":"oktspot81",
            "error_code":0,
            "error_message":"",
            "order_id":"2510832677225472",
            "result":true
        },
        {
            "client_oid":"oktspot82",
            "error_code":0,
            "error_message":"",
            "order_id":"2510832677225473",
            "result":true
        }
    ]
}

Cancel an Order

Cancelling an unfilled order.

Rate limit: 100/2s
HTTP Requests

POST /api/spot/v3/cancel_orders/<order_id>

or

POST /api/spot/v3/cancel_orders/<client_oid>

End Certificate Request Sample

2018-10-12T07:34:30.223ZPOST/api/spot/v3/cancel_orders/a123{"instrument_id":"btc-usdt"}

Request Parameters
Parameters Parameters Types Required Description
instrument_id String Yes By providing this parameter, the corresponding order of a designated trading pair will be cancelled. If not providing this parameter, it will be back to error code.
client_oid String Yes the order ID created by yourself, The client_oid type should be comprised of alphabets + numbers or only alphabets within 1 – 32 characters, both uppercase and lowercase letters are supported
order_id String Yes order ID
Return Parameters
Parameters Parameters Types Description
order_id String order ID
client_oid String the order ID created by yourself
result Boolean order cancellation result. Error code will be returned if it failed
Explanation

Only fill in either parameter client_oid or order_id

When using client_oid for order cancellation, The user needs to make sure the ID does not repeat and there is no repetition alert. In case of repetition, only the latest entry will be canceled.

If the order cannot be cancelled (already settled or cancelled), the error description it returns to will display the corresponding reason.

Return Sample
{
    "btc-usdt":[
    {
       "result":true,
        "client_oid":"a123",
        "order_id": "2510832677225473"
     }
]
}

Cancel All Orders

With best effort, this endpoints supports cancelling all open orders for a specific trading pair or several trading pairs. Maximum 10 orders can be cancelled at a time for each trading pair

Rate limit: 20/2s
HTTP Requests

POST /api/spot/v3/cancel_batch_orders

End Certificate Request Sample

2018-10-12T07:30:49.664ZPOST/api/spot/v3/cancel_batch_orders[{"instrument_id":"btc-usdt","client_oids":["a123","a1234"]},{"instrument_id":"ltc-usdt","client_oids":["a12345","a123456"]}]

Request Parameters
Parameters Parameters Types Required Description
order_ids list<String> Yes order ID. You may cancel up to 4 orders of a trading pair
instrument_id String Yes by providing this parameter, the corresponding order of a designated trading pair will be cancelled. If not providing this parameter, it will be back to error code.
client_oids String Yes The client_oid type should be comprised of alphabets + numbers or only alphabets within 1 – 32 characters, both uppercase and lowercase letters are supported
Return Parameters
Parameters Parameters Types Description
order_id list<String> order ID
client_oid String the order ID created by yourself
result Boolean order cancellation result. Error code will be returned if it failed
Explanation

For bulk order cancellation, the parameters should be either all order_id or all client_oid, otherwise it will trigger an error code.

When using client_oid for bulk order cancellation, only one client_oid canceled for one trading pair, maximum 4 pairs per time. The user needs to make sure the ID does not repeat and there is no repetition alert. In case of repetition, only the latest entry will be canceled.

You may place up to 4 trading pairs with 10 orders at maximum for each pair. We recommend you to use the "Get order list" endpoint" after using the "Cancel multiple orders" endpoint to confirm the cancellation of orders.

Return Sample
{
    "btc-usdt":[
    {
       "result":true,
        "client_oid":"a123",
        "order_id": "2510832677225473"
     },
   {
       "result":true,
        "client_oid":"a1234",
        "order_id": "2510832677225474"
     }
],
"ltc-usdt":[
    {
       "result":true,
        "client_oid":"a12345",
        "order_id": "2510832677225475"
     },
   {
       "result":true,
        "client_oid":"a123456",
        "order_id": "2510832677225476"
     }
]
}

Get Order List

List your orders. Cursor pagination is used. All paginated requests return the latest information (newest) as the first page sorted by newest (in chronological time) first.This interface can fetch the information of the latest 100 orders.

Rate limit: 20/2s
HTTP Requests

GET /api/spot/v3/orders

End Certificate Request Sample

2019-03-18T07:49:43.306ZGET/api/spot/v3/orders?instrument_id=BTC-USDT&status=filled&limit=2&from=1&to=2

Request Parameters
Parameters Parameters Types Description
instrument_id String [required] list the orders of specific trading pairs
from String [optional]request page after this id (latest information) (eg. 1, 2, 3, 4, 5. There is only a 5 "from 4", while there are 1, 2, 3 "to 4")
to String [optional]request page after (older) this id.
limit String [optional]number of results per request. Maximum 100. (default 100)
state String [required] Order Status("-2":Failed,"-1":Cancelled,"0":Open ,"1":Partially Filled, "2":Fully Filled,"3":Submitting,"4":Cancelling,"6": Incomplete(open+partially filled),"7":Complete(cancelled+fully filled))
Return Parameters
Parameters Parameters Types Description
order_id String order ID
client_oid String the order ID customised by yourself
price String price
size String quantity
notional String the total buying amount. This value will be returned for market orders
instrument_id String trading pair
type String limit,market(defaulted as limit)
side String buy or sell
timestamp String trading pair
filled_size String quantity filled
filled_notional String amount filled
status String order status
order_type String 0: Normal limit order 1: Post only 2: Fill Or Kill 3: Immediatel Or Cancel
state String Order Status("-2":Failed,"-1":Cancelled,"0":Open ,"1":Partially Filled, "2":Fully Filled,"3":Submitting,"4":Cancelling,)
Explanation

"status" is the older version of the "state" parameter and is compatible in the short term. It is recommended to switch to "state".

The client_oid type should be comprised of alphabets + numbers or only alphabets within 1 – 32 characters, both uppercase and lowercase letters are supported , and needs to make sure the ID does not repeat and there is no repetition alert. In case of repetition, only the latest entry will be queried .

This endpoint can only provide the filled orders of the recent two days and the cancelled orders.

If the order is not filled in the order lifecycle, the record may be removed. This indicates that this order cannot be retrieved with this endpoint.

Unfilled orders’ status may change depending on the market between the time of request creation and server response.

Return Sample
[
    [
        {
            "client_oid":"oktspot76",
            "created_at":"2019-03-18T07:26:49.000Z",
            "filled_notional":"3.9734",
            "filled_size":"0.001",
            "funds":"",
            "instrument_id":"BTC-USDT",
            "notional":"",
            "order_id":"2500723297813504",
            "order_type":"0",
            "price":"4013",
            "product_id":"BTC-USDT",
            "side":"buy",
            "size":"0.001",
            "status":"filled",
             "state": "2",     
            "timestamp":"2019-03-18T07:26:49.000Z",
            "type":"limit"
        },
        {
            "client_oid":"oktspot75",
            "created_at":"2019-03-18T07:26:49.000Z",
            "filled_notional":"3.9734",
            "filled_size":"0.001",
            "funds":"",
            "instrument_id":"BTC-USDT",
            "notional":"",
            "order_id":"2500723297223680",
            "order_type":"0",
            "price":"4013",
            "product_id":"BTC-USDT",
            "side":"buy",
            "size":"0.001",
            "status":"filled",
            "state": "2",     
            "timestamp":"2019-03-18T07:26:49.000Z",
            "type":"limit"
        },
        {
            "client_oid":"oktspot74",
            "created_at":"2019-03-18T07:08:24.000Z",
            "filled_notional":"3.9768",
            "filled_size":"0.001",
            "funds":"",
            "instrument_id":"BTC-USDT",
            "notional":"",
            "order_id":"2500650881647616",
            "order_type":"0",
            "price":"4016.8",
            "product_id":"BTC-USDT",
            "side":"buy",
            "size":"0.001",
            "status":"filled",
            "state": "2",     
            "timestamp":"2019-03-18T07:08:24.000Z",
            "type":"limit"
        }
    ],
    {
        "before":"2500723297813504",
        "after":"2500650881647616"
    }
]

Get All Open Orders

List all your current open orders. Cursor pagination is used. All paginated requests return the latest information (newest) as the first page sorted by newest (in chronological time) first.

Rate limit: 20/2s
HTTP Requests

GET /api/spot/v3/orders_pending

End Certificate Request Sample

2018-09-12T07:51:51.138ZGET/api/spot/v3/orders_pending?limit=2&instrument_id=Btc-usdT&from=2&to=4

Request Parameters
Parameters Parameters Types Description
from String [optional]request page after this id (latest information) (eg. 1, 2, 3, 4, 5. There is only a 5 "from 4", while there are 1, 2, 3 "to 4")
to String [optional]request page after (older) this id.
limit String [optional]number of results per request. Maximum 100. (default 100)
instrument_id String [optional]trading pair ,information of all trading pair will be returned if the field is left blank
Return Parameters
Parameters Parameters Types Description
order_id String order ID
client_oid String the order ID customised by yourself
price String price
size String quantity
notional String the total buying amount. This value will be returned for market orders
instrument_id String trading pair
side String buy or sell
type String limit,market(defaulted as limit)
timestamp String order creation date
filled_size String quantity filled
filled_notional String amount filled
state String Order Status("0":Open ,)
Explanation

"status" is the older version of the "state" parameter and is compatible in the short term. It is recommended to switch to "state".

The client_oid type should be comprised of alphabets + numbers or only alphabets within 1 – 32 characters, both uppercase and lowercase letters are supported , and needs to make sure the ID does not repeat and there is no repetition alert. In case of repetition, only the latest entry will be queried .

This endpoint can provide the filled orders and the cancelled orders.

Unfilled orders’ status may change depending on the market between the time of request creation and server response.

Return Sample
[
    [
        {
            "client_oid":"oktspot86",
            "created_at":"2019-03-20T03:28:14.000Z",
            "filled_notional":"0",
            "filled_size":"0",
            "funds":"",
            "instrument_id":"BTC-USDT",
            "notional":"",
            "order_id":"2511109744100352",
            "order_type":"0",
            "price":"3594.7",
            "product_id":"BTC-USDT",
            "side":"buy",
            "size":"0.001",
            "status":"open",
            "state": "0",     
            "timestamp":"2019-03-20T03:28:14.000Z",
            "type":"limit"
        },
        {
            "client_oid":"oktspot85",
            "created_at":"2019-03-20T03:28:10.000Z",
            "filled_notional":"0",
            "filled_size":"0",
            "funds":"",
            "instrument_id":"BTC-USDT",
            "notional":"",
            "order_id":"2511109459543040",
            "order_type":"0",
            "price":"3594.9",
            "product_id":"BTC-USDT",
            "side":"buy",
            "size":"0.001",
            "status":"open",
            "state": "0",     
            "timestamp":"2019-03-20T03:28:10.000Z",
            "type":"limit"
        }
    ],
    {
        "before":"2511109744100352",
        "after":"2511109459543040"
    }

Get Order Details

Get order details by order ID.Canceled unfilled orders will be kept in record for 2 hours only.

Rate limit: 20/2s
HTTP Requests

GET /api/spot/v3/orders/<order_id>

or

GET /api/spot/v3/orders/<client_oid>

End Certificate Request Sample

2018-09-12T07:54:01.582ZGET/api/spot/v3/orders/23356?instrument_id=BTC-USDT

or

2018-09-12T07:54:01.582ZGET/api/spot/v3/orders/e23356?instrument_id=BTC-USDT

Requests Parameters
Parameters Parameters Types Description
instrument_id String [required]trading pair
order_id String [ optional] order ID
client_oid String [ optional ] The client_oid type should be comprised of alphabets + numbers or only alphabets within 1 – 32 characters, both uppercase and lowercase letters are supported
Return Parameters
Parameters Parameters Types Description
order_id String description ID
client_oid String the order ID customised by yourself
price String price
size String size of order
notional String buying amount (for market orders)
instrument_id String trading pair
side String buy or sell
type String limit,market(defaulted as limit)
timestamp String order creation date
filled_size String size filled
filled_notional String amount filled
order_type String 0: Normal limit order 1: Post only 2: Fill Or Kill 3: Immediatel Or Cancel
state String Order Status("-2":Failed,"-1":Cancelled,"0":Open ,"1":Partially Filled, "2":Fully Filled,"3":Submitting,"4":Cancelling,)
Explanation

"status" is the older version of the "state" parameter and is compatible in the short term. It is recommended to switch to "state".

Only fill in either parameter client_oid or order_id The client_oid type should be comprised of alphabets + numbers or only alphabets within 1 – 32 characters, both uppercase and lowercase letters are supported , and needs to make sure the ID does not repeat and there is no repetition alert. In case of repetition, only the latest entry will be queried .

If the order is not filled in the order lifecycle, its record may be removed, the status code 404 may be returned as there are no matches.

Unfilled order status may change according to the market conditions at the time period between your request creation and the server’s response.

status include(all, open, part_filled, canceling, filled, cancelled)

Return Sample
{
    "client_oid":"oktspot70",
    "created_at":"2019-03-15T02:52:56.000Z",
    "filled_notional":"3.8886",
    "filled_size":"0.001",
    "funds":"",
    "instrument_id":"BTC-USDT",
    "notional":"",
    "order_id":"2482659399697408",
    "order_type":"0",
    "price":"3927.3",
    "product_id":"BTC-USDT",
    "side":"buy",
    "size":"0.001",
    "status":"filled",
    "state": "2",     
    "timestamp":"2019-03-15T02:52:56.000Z",
    "type":"limit"
}

Get Transaction Details

Get details of the recent filled orders. Cursor pagination is used. All paginated requests return the latest information (newest) as the first page sorted by newest (in chronological time) first. This API can retrieve data in the last 3 months.

Rate limit: 20/2s
HTTP Requests

GET /api/spot/v3/fills

End Certificate Request Sample

2018-09-12T07:56:11.922ZGET/api/spot/v3/fills?order_id=23212&instrument_id=btc-usdt&limit=2&from=2&to=4

Requests Parameters
Parameters ParametersTypes Description
order_id String [required]list all transaction details of this order_id.
instrument_id String [required]list all transaction details of this instrument_id.
from String [optional]request page after this id (latest information) (eg. 1, 2, 3, 4, 5. There is only a 5 "from 4", while there are 1, 2, 3 "to 4")
to String [optional]request page after (older) this id.
limit String [optional]number of results per request. Maximum 100. (default 100)
Return Parameters
Parameters Parameters Types Description
ledger_id String bill ID
instrument_id String trading pair
price String price
size String quantity
order_id String order ID
timestamp String create date
exec_type String liquidity side (T or M)
fee String liquidity side
side String bills side(buy ,sell or points_fee)
Explanation

Fees

If the value of "side" is "settle with loyalty points", then the value of "fee" should be the fee amount settled by loyalty points.

Liquidity

The parameter exec_type shows whether the order is maker or taker. (M=Maker, T=Taker)

Pagination

Ledger_id are listed in a descending order, from biggest to smallest. The first ledger_id can be found under OK-FROM, so it would be easier to acquire a larger ledger_id (new bills) by using OK-FROM in the future.

Return Sample
[
    [
        {
            "created_at":"2019-03-15T02:52:56.000Z",
            "exec_type":"T",
            "fee":"0.00000067",
            "instrument_id":"BTC-USDT",
            "ledger_id":"3963052722",
            "liquidity":"T",
            "order_id":"2482659399697408",
            "price":"3888.6",
            "product_id":"BTC-USDT",
            "side":"buy",
            "size":"0.00044694",
            "timestamp":"2019-03-15T02:52:56.000Z"
        },
        {
            "created_at":"2019-03-15T02:52:56.000Z",
            "exec_type":"T",
            "fee":"0.00000082",
            "instrument_id":"BTC-USDT",
            "ledger_id":"3963052721",
            "liquidity":"T",
            "order_id":"2482659399697408",
            "price":"3888.6",
            "product_id":"BTC-USDT",
            "side":"buy",
            "size":"0.00055306",
            "timestamp":"2019-03-15T02:52:56.000Z"
        },
        {
            "created_at":"2019-03-15T02:52:56.000Z",
            "exec_type":"T",
            "fee":"0",
            "instrument_id":"BTC-USDT",
            "ledger_id":"3963052719",
            "liquidity":"T",
            "order_id":"2482659399697408",
            "price":"3888.6",
            "product_id":"BTC-USDT",
            "side":"sell",
            "size":"1.73797088",
            "timestamp":"2019-03-15T02:52:56.000Z"
        },
        {
            "created_at":"2019-03-15T02:52:56.000Z",
            "exec_type":"T",
            "fee":"0",
            "instrument_id":"BTC-USDT",
            "ledger_id":"3963052718",
            "liquidity":"T",
            "order_id":"2482659399697408",
            "price":"3888.6",
            "product_id":"BTC-USDT",
            "side":"sell",
            "size":"2.15062911",
            "timestamp":"2019-03-15T02:52:56.000Z"
        }
    ],
    {
        "before":"3963052722",
        "after":"3963052718"
    }
]

Get Token Pair Details

Get market data. This endpoint provides the snapshots of market data and can be used without verifications.

List trading pairs and get the trading limit, price, and more information of different trading pairs.

Rate limit: 20/2s
HTTP Requests

GET /api/spot/v3/instruments

End Certificate Request Sample

2018-09-12T07:56:45.645ZGET/api/spot/v3/instruments

Return Parameters
Parameters Parameters Types Description
instrument_id String trading pair
base_currency String base currency
quote_currency String quote currency
min_size String minimum trading size
size_increment String minimum increment size
tick_size String trading price increment
Explanation

Min_size is the quantity of buying or selling and must be larger than the base_min_size and also mean the minimum loan amount. Base_increment is the minimum increment size. If the base_increment is 0.000001, entering a size of 0.0.0000126 will be adjusted to 0.000012.

The tick size is the smallest unit of price. The order price must be a multiple of the tick_size. If the tick_size is 0.0001, entering a price of 0.02237 will be adjusted to 0.0223 instead.

Return Sample
[
    {
        "base_currency":"BTC",
        "instrument_id":"BTC-USDT",
        "min_size":"0.001",
        "quote_currency":"USDT",
        "size_increment":"0.00000001",
        "tick_size":"0.1"
    },
    {
        "base_currency":"OKB",
        "instrument_id":"OKB-USDT",
        "min_size":"1",
        "quote_currency":"USDT",
        "size_increment":"0.0001",
        "tick_size":"0.0001"
    }
]

Get Order Book

Getting the order book of a trading pair. Pagination is not supported here. The whole book will be returned for one request. WebSocket is recommended here.

Rate limit: 20/2s
HTTP Requests

GET /api/spot/v3/instruments/<instrument_id>/book

End Certificate Request Sample

2019-03-20T07:48:09.130ZGET/api/spot/v3/instruments/BTC-USDT/book?size=5&depth=0.2

Requests Parameters
Parameters Parameters Types Description
size String [optional]number of results per request. Maximum 200
depth String [optional]the aggregation of the book. e.g . 0.1,0.001
instrument_id String [required] trading pairs
Return Parameters
Parameters Parameters Types Description
price String price
size String Size
num_orders String total orders in the book
timestamp String timestamp
Explanation

Aggregation (depth) is the formation of a certain price range into a cluster.

Return Sample
{
    "asks":[
        [
            "3993.2",
            "0.41600068",
            "1"
        ],
        [
            "3993.4",
            "1.24807818",
            "3"
        ],
        [
            "3993.6",
            "0.03",
            "1"
        ],
        [
            "3993.8",
            "0.03",
            "1"
        ]
    ],
    "bids":[
        [
            "3993",
            "0.15149658",
            "2"
        ],
        [
            "3992.8",
            "1.19046818",
            "1"
        ],
        [
            "3992.6",
            "0.20831389",
            "1"
        ],
        [
            "3992.4",
            "0.01669446",
            "2"
        ]
    ],
    "timestamp":"2019-03-20T03:55:37.888Z"
}

Get All Token Pairs Information

Get the last traded price, best bid/ask price, 24 hour trading volume and more info of all trading pairs.

Rate limit: 20/2s
HTTP Requests

GET /api/spot/v3/instruments/ticker

End Certificate Request Sample

2018-09-12T07:57:26.537ZGET/api/spot/v3/instruments/ticker

Return Parameters
Parameters Parameters Types Description
instrument_id String trading pair
last String last traded price
best_bid String best bid price
best_ask String best ask price
open_24h String 24 hour open
high_24h String 24 hour high
low_24h String 24 hour low
base_volume_24h String 24 trading volume of the base currency
quote_volume_24h String 24 trading volume of the quote currency
timestamp String timestamp
Explanation

The high, low and trading volume are all computed based on the data in the last 24 hours.

The 24 hour open is the price of the minute before the last 24 hours.

Return Sample
[
    {
        "best_ask":"3995.4",
        "best_bid":"3995.3",
        "instrument_id":"BTC-USDT",
        "product_id":"BTC-USDT",
        "last":"3995.3",
        "ask":"3995.4",
        "bid":"3995.3",
        "open_24h":"3989.7",
        "high_24h":"4031.9",
        "low_24h":"3968.9",
        "base_volume_24h":"31254.359231295",
        "timestamp":"2019-03-20T04:07:07.912Z",
        "quote_volume_24h":"124925963.3459723295"
    },
    {
        "best_ask":"1.3205",
        "best_bid":"1.3204",
        "instrument_id":"OKB-USDT",
        "product_id":"OKB-USDT",
        "last":"1.3205",
        "ask":"1.3205",
        "bid":"1.3204",
        "open_24h":"1.0764",
        "high_24h":"1.44",
        "low_24h":"1.0601",
        "base_volume_24h":"183010468.2062",
        "timestamp":"2019-03-20T04:07:05.878Z",
        "quote_volume_24h":"233516598.011530085"
    }
]

Get a Token Pair Information

Get the last traded price, best bid/ask price, 24 hour trading volume and more info of a trading pair.

Rate limit: 20 / 2s
HTTP Requests

GET /api/spot/v3/instruments/<instrument_id>/ticker

End Certificate Request Sample

2019-03-13T11:42:09.849ZGET/api/spot/v3/instruments/BTC-USDT/ticker

Requests Parameters
Parameters Parameters Types Description
instrument_id String [required]trading pair
Return Parameters
Parameters Parameters Types Description
instrument_id String trading pair
last String last traded price
best_bid String best bid price
best_ask String best ask price
open_24h String 24 hour open
high_24h String 24 hour high
low_24h String 24 hour low
base_volume_24h String 24 trading volume of the base currency
quote_volume_24h String 24 trading volume of the quote currency
timestamp String timestamp
Explanation

The high, low and trading volume are all computed based on the data in the last 24 hours.

The 24 hour open is the price of the minute before the last 24 hours.

Return Sample
{
  best_ask:3858.8
  best_bid:3858.6
  instrument_id:BTC-USDT
  product_id:BTC-USDT
  last:3858.6
  ask:3858.8
  bid:3858.6
  open_24h:3886
  high_24h:3900.8
  low_24h:3839.1
  base_volume_24h:19081.61024493
  timestamp:2019-03-13T11:42:09.849Z
  quote_volume_24h:73978722.5
}

Get Filled Orders Information

Get the recent 60 transactions of all trading pairs. Cursor pagination is used. All paginated requests return the latest information (newest) as the first page sorted by newest (in chronological time) first.

Rate limit: 20/2s
HTTP Requests

GET /api/spot/v3/instruments/<instrument_id>/trades

End Certificate Request Sample

2018-09-12T07:58:34.414ZGET/api/spot/v3/instruments/LTC-USDT/trades?limit=20&from=2&to=4

Requests Parameters
Parameters Parameters Types Description
from String [optional]request page after this id (latest information) (eg. 1, 2, 3, 4, 5. There is only a 5 "from 4", while there are 1, 2, 3 "to 4")
to String [optional]request page after (older) this id.
limit String [optional]number of results per request. Maximum 100. (default 100)
instrument_id String [required] trading pairs
Return Parameters
Parameters Parameters Types Description
timestamp String filled time
trade_id String transaction time ID
price String filled price
size String filled size
side String filled side
Explanation

The filled side is the order side of the Taker. Taker is the one who actively take the order on the book. Buying indicates the taker is taking liquidity from the book, so the price is rising. While selling indicates the price is falling.

trade_id is the increasing ID of the filled orders (could be incomplete).

Return Sample
[
    {
        "time":"2019-04-12T02:07:30.523Z",
        "timestamp":"2019-04-12T02:07:30.523Z",
        "trade_id":"1296412902",
        "price":"4913.4",
        "size":"0.00990734",
        "side":"buy"
    },
    {
        "time":"2019-04-12T02:07:30.455Z",
        "timestamp":"2019-04-12T02:07:30.455Z",
        "trade_id":"1296412899",
        "price":"4913.2",
        "size":"0.17820096",
        "side":"sell"
    }
]

Get Market Data

Get the charts of the trading pairs.This API can retrieve the latest 2000 entries of data. Charts are returned in grouped buckets based on requested granularity,Maximum 2,000 recent Strings of chart data can be retrieved.

Rate limit: 20/2s
HTTP Requests

GET /api/spot/v3/instruments/<instrument_id>/candles

End Certificate Request Sample

2019-03-14T16:55:06.000Z GET/api/spot/v3/instruments/BTC-USDT/candles?granularity=86400&start=2019-03-18T08%3A28%3A48.899Z&end=2019-03-19T09%3A28%3A48.899Z

Requests Parameters
Parameters Parameters Types Description
start String [optional]start time in ISO 8601
end String [optional] end time in ISO 8601
granularity String [optional] desired timeslice in seconds
instrument_id String [required] trading pairs
Return Parameters
Parameters Parameters Types Description
time String Start time
open String Open price
high String Highest price
low String Lowest price
close String Close price
volume String Trading volume
Explanation

If either one of the start or end fields are not provided then both fields will be ignored. If a custom time range is not declared then it will return the last 200 datas..

The granularity field must be one of the following values: {60, 180, 300, 900, 1800, 3600, 7200, 14400, 43200, 86400, 604800}. Otherwise, your request will be rejected. These values correspond to timeslices representing one minute, three minutes, five minutes, fifteen minutes, thirty minutes, one hour, two hours, six hours, twelve hours, one day, and 1 week respectively.

The chart data may be incomplete and should not be polled.

The maximum number of data points for a single request is 200 candles. If your selection of start/end time and granularity will result in more than 200 data points, your request will be rejected. If you wish to retrieve fine granularity data over a larger time range, you will need to make multiple requests with new start/end ranges.

Return Sample

[
    [
        "2019-03-19T16:00:00.000Z",
        "3997.3",
        "4031.9",
        "3982.5",
        "3998.7",
        "26175.21141385"
    ],
    [
        "2019-03-18T16:00:00.000Z",
        "3980.6",
        "4014.6",
        "3968.9",
        "3997.3",
        "33053.48725643"
    ]
]

Error Code

Error Code Sample
Business Error Messages Business Error Codes http Status Code Scenarios
margin account for this pair is not enabled yet 33001 400 the service must be enabled before trading
margin account for this pair is suspended 33002 400 margin account suspended
no loan balance 33003 400 insufficient balance for loan
loan amount cannot be smaller than the minimum limit 33004 400 minimum loan amount limit not reached
repayment amount must exceed 0 33005 400 invalid repayment amount
loan order not found 33006 400 loan order not found
status not found 33007 400 status unchanged
loan amount cannot exceed the maximum limit 33008 400 invalid loan amount
user ID is blank 33009 400 user ID not provided
you cannot cancel an order during session 2 of call auction 33010 400 order cancellation not allowed during call auction
no new market data 33011 400 no market data
order cancellation failed 33012 400 order cancellation failed
order placement failed 33013 400 order placement failed
order does not exist 33014 400 order canceled already. Invalid order number
exceeded maximum limit 33015 400 exceeded maximum limit during multiple-order placement
margin trading is not open for this token 33016 400 insufficient balance for order placement
insufficient balance 33017 400 margin trading not supported for this pair
this parameter must be smaller than 1 33018 400 invalid parameter for getting market data
request not supported 33020 400 margin trading not supported for some exchanges
token and the pair do not match 33021 400 incorrect token for the token pair during repayment
pair and the order do not match 33022 400 incorrect token for the order during repayment
you can only place market orders during call auction 33023 400 you can only place market orders during call auction
trading amount too small 33024 400 invalid trading amount
base token amount is blank 33025 400 settings not completed during order placement
transaction completed 33026 400 cancel limited when the transaction completed
cancelled order or order cancelling 33027 400 cancel limited when the order is cancelling or cancelled
the decimal places of the trading price exceeded the limit 33028 400 order endpoint: The decimal places of the trading price exceeded the limit
the decimal places of the trading size exceeded the limit 33029 400 order endpoint::The decimal places of the trading size exceeded the limit

Margin Trading API

The market data, account info, order operations, bill details and more of token margin trading.

Description: in order to integrate with the old version, some of the API return parameters may be redundant.

Please refer to the parameter description in the documentation. For example, the parameters of frozen, old, and hoids of token account information API return are the same. Take hold as the criterion. The API return parameters to capture borrowed token records repay_amount and returned_amount, as well as repay_interest and paid_interest are the same, to name a few.

Margin account

List all assets under token margin trading account, including information such as balance, amount on hold and more.

Rate limit: 20/ 2s
HTTP Requests

GET /api/margin/v3/accounts

End Certificate Request Sample

2018-09-13T02:25:41.946ZGET/api/margin/v3/accounts

Return Parameters
Parameters Parameters Types Description
instrument_id String trading pair
balance String balance
hold String amount on hold(not available)
available String available amount
risk_rate String risk rate
can_withdraw String available transfer amount
liquidation_price String liquidation price
borrowed String borrowed tokens (unpaid)
lending_fee String interest (unpaid)
Explanation

The funds for order placement will be put on hold. They will not be able to transfer or used for other purposes until the order is filled or cancelled.

Return Sample
[
    {
        "currency:BTC":{
            "available":"0",
            "balance":"0",
            "borrowed":"0",
            "can_withdraw":"0",
            "frozen":"0",
            "hold":"0",
            "holds":"0",
            "lending_fee":"0"
        },
        "currency:USDT":{
            "available":"100",
            "balance":"100",
            "borrowed":"0",
            "can_withdraw":"100",
            "frozen":"0",
            "hold":"0",
            "holds":"0",
            "lending_fee":"0"
        },
        "instrument_id":"BTC-USDT",
        "liquidation_price":"0",
        "product_id":"BTC-USDT",
        "risk_rate":""
    },
    {
        "currency:EOS":{
            "available":"0.59957711",
            "balance":"0.59957711",
            "borrowed":"0.20000208",
            "can_withdraw":"0.483",
            "frozen":"0",
            "hold":"0",
            "holds":"0",
            "lending_fee":"0.00003661"
        },
        "currency:USDT":{
            "available":"0.496",
            "balance":"0.496",
            "borrowed":"0",
            "can_withdraw":"0.496",
            "frozen":"0",
            "hold":"0",
            "holds":"0",
            "lending_fee":"0"
        },
        "instrument_id":"EOS-USDT",
        "liquidation_price":"0",
        "product_id":"EOS-USDT",
        "risk_rate":"3.6681"
    }
]

Margin Account of a Currency

Get the balance, amount on hold and more useful information.

Rate limit: 20 / 2s
HTTP Requests

GET /api/margin/v3/accounts/<instrument_id>

End Certificate Request Sample

2018-09-13T02:25:41.946ZGET/api/margin/v3/accounts/eos-usdt

Request Parameters
Parameters Parameters Types Description
instrument_id String [required] trading pair
Return Parameters
Parameters Parameters Types Description
balance String balance
hold String amount on hold(not available)
available String available amount
risk_rate String risk rate
can_withdraw String available transfer amount
liquidation_price String liquidation price
borrowed String borrowed tokens (unpaid)
lending_fee String interest (unpaid)
Return Sample
{
    "currency:EOS":{
        "available":"0.59957711",
        "balance":"0.59957711",
        "borrowed":"0.20000208",
        "can_withdraw":"0.48351954",
        "frozen":"0",
        "hold":"0",
        "holds":"0",
        "lending_fee":"0.00003661"
    },
    "currency:USDT":{
        "available":"0.496",
        "balance":"0.496",
        "borrowed":"0",
        "can_withdraw":"0.496",
        "frozen":"0",
        "hold":"0",
        "holds":"0",
        "lending_fee":"0"
    },
    "liquidation_price":"0",
    "risk_rate":"3.6675"
}

Bills Details

List all bill details. Pagination is used here. before and after cursor arguments should not be confused with before and after in chronological time. Most paginated requests return the latest information (newest) as the first page sorted by newest (in chronological time) first. This API can retrieve data in the last 3 months.

Rate limit: 20/ 2s
HTTP Requests

GET /api/margin/v3/accounts/<instrument_id>/ledger

End Certificate Request Sample

2019-03-18T03:45:56.000ZGET/api/margin/v3/accounts/btc-usdt/ledger?limit=10&type=1&from=1&to=2

Request Parameters
Parameters Parameters Types Description
type String [optional]3. Borrow 4. Repayment 5. Interest 7. Buy 8. Sell 9. From Wallet 10. From C2C 11. From Futures 12. From Spot 13. From ETT 14. To Wallet 15. To C2C 16. To Spot 17. To Futures 18. To ETT 19. Mandatory Repayment 20. From Piggybank 21. To Piggybank 22. From Perpetual 23. To Perpetual 24. Liquidation Fee 54. Clawback 59. Airdrop Return. All types will be returned if this filed is left blank
from String [optional]request page before(newer) this id
to String [optional]request page after(older) this id
limit String [optional]number of results per request. Maximum 100(default 100)
instrument_id String [required] trading pair
Return Parameters
Parameters Parameters Types Description
ledger_id String bill ID
instrument_id String trading pair
currency String token
balance String remaining balance
amount String amount
type String type of bill
timestamp String bill creation time
details String if the type is trade or fee, order details will be included under this.
order_id String order ID
Type value Description
transfer funds transfer
trade funds moved as a result of a trade
rebate fee rebate as per our fee schedule
Return Sample
[
    [
        {
            "created_at":"2019-03-20T05:45:10.000Z",
            "ledger_id":"78965766",
            "timestamp":"2019-03-20T05:45:10.000Z",
            "currency":"EOS",
            "amount":"0",
            "balance":"0.59957711",
            "type":"transfer",
            "details":{
                "instrument_id":"EOS-USDT",
                "order_id":"787057",
                "product_id":"EOS-USDT"
            }
        },
        {
            "created_at":"2019-03-20T04:45:07.000Z",
            "ledger_id":"78942699",
            "timestamp":"2019-03-20T04:45:07.000Z",
            "currency":"EOS",
            "amount":"0",
            "balance":"0.59957711",
            "type":"transfer",
            "details":{
                "instrument_id":"EOS-USDT",
                "order_id":"787057",
                "product_id":"EOS-USDT"
            }
        },
        {
            "created_at":"2019-03-20T03:45:05.000Z",
            "ledger_id":"78918186",
            "timestamp":"2019-03-20T03:45:05.000Z",
            "currency":"EOS",
            "amount":"0",
            "balance":"0.59957711",
            "type":"transfer",
            "details":{
                "instrument_id":"EOS-USDT",
                "order_id":"787057",
                "product_id":"EOS-USDT"
            }
        }
    ],
    {
        "before":"78965766",
        "after":"78918186"
    }
]

Margin Account Settings

Get all information of the margin trading account, including the maximum loan amount, interest rate, and maximum leverage.

Rate limit:20/2s
HTTP Requests

GET /api/margin/v3/accounts/availability

End Certificate Request Sample

2018-09-13T02:27:05.580ZGET/api/margin/v3/accounts/availability

Return Parameters
Parameters Parameters Types Description
instrument_id String trading pair
currency String token
available String maximum loan amount
rate String interest rate
leverage String maximum leverage
Return Sample
[
    {
        "currency:BTC":{
            "available":"0.09995502",
            "leverage":"5",
            "leverage_ratio":"5",
            "rate":"0.00009984"
        },
        "currency:USDT":{
            "available":"400.00000000",
            "leverage":"5",
            "leverage_ratio":"5",
            "rate":"0.00019992"
        },
        "instrument_id":"BTC-USDT",
        "product_id":"BTC-USDT"
    },
    {
        "currency:EOS":{
            "available":"1.9343",
            "leverage":"5",
            "leverage_ratio":"5",
            "rate":"0.00009984"
        },
        "currency:USDT":{
            "available":"7.1571",
            "leverage":"5",
            "leverage_ratio":"5",
            "rate":"0.00019992"
        },
        "instrument_id":"EOS-USDT",
        "product_id":"EOS-USDT"
    }
]

Margin Account Settings for a Currency

Get all information of the margin trading account of a specific token, including the maximum loan amount, interest rate, and maximum leverage.

Rate limit:20/2s
HTTP Requests

GET /api/margin/v3/accounts/<instrument_id>/availability

End Certificate Request Sample

2019-03-18T02:27:37.723ZGET/api/margin/v3/accounts/BTC-USDT/availability

Request Parameters
Parameters Parameters Types Description
instrument_id String [required] trading pair
Return Parameters
Parameters Parameters Types Description
currency String token
available String maximum loan amount
rate String interest rate
leverage String maximum leverage
instrument_id String trading pair
Return Sample
[
    {
        "currency:BTC":{
            "available":"0.09989261",
            "leverage":"5",
            "leverage_ratio":"5",
            "rate":"0.00009984"
        },
        "currency:USDT":{
            "available":"400.00000000",
            "leverage":"5",
            "leverage_ratio":"5",
            "rate":"0.00019992"
        },
        "instrument_id":"BTC-USDT",
        "product_id":"BTC-USDT"
    }
]

Get Loan History

Get loan history of the margin trading account. Pagination is used here. before and after cursor arguments should not be confused with before and after in chronological time. Most paginated requests return the latest information (newest) as the first page sorted by newest (in chronological time) first.

Rate limit:20/2s
HTTP Requests

GET /api/margin/v3/accounts/borrowed

End Certificate Request Sample

2018-09-13T02:28:14.618ZGET/api/margin/v3/accounts/borrowed?status=0& limit=1&from=2&to=4

Request Parameters
Parameters Parameters Types Description
status String [optional] status(0: outstanding 1: repaid)
from String [optional]request page from(newer) this id.
to String [optional]request page to(older) this id.
limit String [optional]number of results per request. Maximum 100.(default 100)
Return Parameters
Parameters Parameters Types Description
borrow_id String borrow ID
instrument_id String trading pair
currency String token
created_at String borrow time
amount String borrow amount
interest String interest
returned_amount String amount repaid
paid_interest String interest repaid
last_interest_time String last interest accrual time
force_repay_time String force repay time
rate String rate
Return Sample
[
    [
        {
            "amount":"0.5",
            "borrow_id":"787057",
            "created_at":"2019-03-18T09:41:44.000Z",
            "currency":"EOS",
            "force_repay_time":"2019-03-25T09:42:19.000Z",
            "instrument_id":"EOS-USDT",
            "interest":"0.0000386883807232",
            "last_interest_time":"2019-03-20T05:45:11.000Z",
            "paid_interest":"0.00000208",
            "product_id":"EOS-USDT",
            "rate":"0.00000416",
            "repay_amount":"0.29999792",
            "repay_interest":"0.00000208",
            "returned_amount":"0.29999792",
            "timestamp":"2019-03-18T09:41:44.000Z"
        }
    ],
    {
        "before":"787057",
        "after":"787057"
    }
]

Get Loan History of a Currency

Get loan history of the margin trading account of a specific token. Pagination is used here. before and after cursor arguments should not be confused with before and after in chronological time. Most paginated requests return the latest information (newest) as the first page sorted by newest (in chronological time) first.

Rate limit:20/2s
HTTP Requests

GET /api/margin/v3/accounts/<instrument_id>/borrowed

End Certificate Request Sample

2018-09-13T02:29:06.610ZGET/api/margin/v3/accounts/BTC-USDT/borrowed?limit=2&status=1&from=2&to=4

Request Parameters
Parameters Parameters Types Description
status String [optional]status(0: outstanding 1: repaid)
from String [optional]request page from(newer) this id.
to String [optional]request page to(older) this id.
limit String [optional]number of results per request. Maximum 100.(default 100)
instrument_id String [required] trading pair
Return Parameters
Parameters Parameters Types Description
borrow_id String borrow ID
currency String token
created_at String borrow time
amount String borrow amount
interest String interest
returned_amount String amount repaid
paid_interest String interest repaid
last_interest_time String Last interest accrual time
force_repay_time String force repay time
rate String rate
Return Sample
[
    [
        {
            "amount":"0.5",
            "borrow_id":"787057",
            "created_at":"2019-03-18T09:41:44.000Z",
            "currency":"EOS",
            "force_repay_time":"2019-03-25T09:42:19.000Z",
            "instrument_id":"EOS-USDT",
            "interest":"0.0000386883807232",
            "last_interest_time":"2019-03-20T05:45:11.000Z",
            "paid_interest":"0.00000208",
            "product_id":"EOS-USDT",
            "rate":"0.00000416",
            "repay_amount":"0.29999792",
            "repay_interest":"0.00000208",
            "returned_amount":"0.29999792",
            "timestamp":"2019-03-18T09:41:44.000Z"
        }
    ],
    {
        "before":"787057",
        "after":"787057"
    }
]

Loan

Borrowing tokens in a margin trading account.

Rate limit:100/2s
HTTP Requests

POST /api/margin/v3/accounts/borrow

End Certificate Request Sample

2018-10-08T03:00:56.799ZPOST/api/margin/v3/accounts/borrow{"instrument_id":"ltc-usdt","currency":"usdt","amount":"0.1"}

Request Parameters
Parameters Parameters Types Required Description
instrument_id String Yes trading pair
currency String Yes token
amount String Yes borrowed amount
Return Parameters
Parameters Parameters Types Description
borrow_id String borrow ID
result Boolean result
Return Sample
{
    "borrow_id":"791434",
    "client_oid":"",
    "result":true
}

Repayment

Repaying tokens in a margin trading account.

Rate limit:100/2s
HTTP Requests

POST /api/margin/v3/accounts/repayment

End Certificate Request Sample

2018-10-08T03:04:52.002ZPOST/api/margin/v3/accounts/repayment{"instrument_id":"ltc-usdt","currency":"usdt","amount":"0.1","borrow_id":"185759"}

Request Parameters
Parameters Parameters Types Required Description
borrow_id String No borrow ID . all borrowed token under this trading pair will be repay if the field is left blank
instrument_id String Yes trading pair
currency String Yes token
amount String Yes amount repaid
Return Parameters
Parameters Parameters Types Description
repayment_id String borrow ID
result Boolean result
Return Sample
{
    "client_oid":"",
    "repayment_id":"791434",
    "result":true
}

Place an Order

API only supports limit and market orders (more orders will become available in the future). You can place an order only if you have enough funds. Once your order is placed, the amount will be put on hold.

Rate limit: 100/ 2s
HTTP Requests

POST /api/margin/v3/orders

End Certificate Request Sample

2018-09-12T07:46:47.098ZPOST/api/margin/v3/orders{"client_oid":"20180728","order_type”:”1”,"instrument_id":"btc-usdt","side":"buy","type":"limit","size":"0.1","notional":"100","margin_trading ":"2"}

Request Parameters
Parameters Parameters Types Required Description
client_oid String No the order ID customized by yourself,The client_oid type should be comprised of alphabets + numbers or only alphabets within 1 – 32 characters, both uppercase and lowercase letters are supported
type String No Limit/market(default:limit),When posting orders at market price, order_type can only be 0 (regular order)
side String Yes buy/sell
instrument_id String Yes Trading pair
margin_trading String Yes Order type (The request value is 2)
order_type String No Fill in number for parameter,0: Normal limit order (Unfilled and 0 represent normal limit order) 1: Post only 2: Fill Or Kill 3: Immediatel Or Cancel
Limit Order Parameters
Parameters Parameters Types Required Description
price String Yes price
size String Yes quantity bought or sold
Market Order Parameters
Parameters Parameters Types Compulsory Description
size String No quantity sold.(for orders sold at market price only)
notional String No amount bought.(for orders bought at market price only)
Return Parameters
Parameters Parameters Types Description
order_id String order ID
client_oid String the order ID customized by yourself
error_code String Error code for order placement. Success = 0. Failure = error code
error_message String It will be blank if order placement is success. Error message will be returned if order placement fails.
result Boolean result of the order.Error message will be returned if the order failed.
Explanation

instrument_id

The instrument_id must match a valid instrument. The instruments list is available via the /instrument endpoint

client_oid

The client_oid type should be comprised of alphabets + numbers or only alphabets within 1 – 32 characters, both uppercase and lowercase letters are supported , and needs to make sure the ID does not repeat and there is no repetition alert. In case of repetition, only the latest entry will be queried and canceled

When placing an order, you can specify the order type. The order type you specify will influence which other order parameters are required as well as how your order will be executed by the matching engine. If type is not specified, the order will default to a limit order.

limit orders are both the default and basic order type. A limit order requires specifying a price and size. The size is the number of tokens to buy or sell, and the price is the price per bitcoin. The limit order will be filled at the price specified or better. A sell order can be filled at the specified price per token or a higher price per token and a buy order can be filled at the specified price or a lower price depending on market conditions. If market conditions cannot fill the limit order immediately, then the limit order will become part of the open order book until filled by another incoming order or cancelled by the user.

market orders differ from limit orders in that they provide no pricing guarantees. They however do provide a way to buy or sell specific amounts of tokens without having to specify the price. Market orders execute immediately and no part of the market order will go on the open order book. Market orders are always considered takers and incur taker fees. When placing a market order you can specify funds and/or size. Funds will limit how much of your quote currency account balance is used and size will limit the token amount transacted.

price

The price must be specified in quote_increment product units. The quote increment is the smallest unit of price. This value can be acquired via the /instrument endpoint.

size

Size is the quantity of buying or selling and must be larger than the base_min_size. Base_increment is the minimum increment size. The above parameters can be acquired via the /instrument endpoint.

Example: If the base_min_size of OKB/USDT is 10 and the base_increment is 0.0001, then it is impossible to trade 9.99 OKB but possible to trade 10.0001 OKB.

notional

The notional field is optionally used for market orders. When specified it indicates how much of the product quote currency to buy or sell. For example, a market buy for BTC-USDT with funds specified as 5000 will spend 5000 USDT to buy BTC.

hold

The amount on hold of a limit order = specific price x buying size. Cancelling an open order releases the amount on hold.

Order Lifecycle

The HTTP Request will respond when an order is either rejected (insufficient funds, invalid parameters, etc) or received (accepted by the matching engine). A 200 response indicates that the order was received and is active. Active orders may execute immediately (depending on price and market conditions) either partially or fully. A partial execution will put the remaining size of the order in the open state. An order that is filled completely, will go into the done state.

Users listening to streaming market data are encouraged to use the client_oid field to identify their received messages in the feed. The REST response with a server order_id may come after the received message in the public data feed.

Response

A successful order will be assigned an order id. A successful order is defined as one that has been accepted by the matching engine.

Return Sample
{
    "client_oid":"oktlever50",
    "error_code":"",
    "error_message":"",
    "order_id":"2512084870235136",
    "result":true
}

Place Multiple Orders

Place multiple orders for specific trading pairs (up to 4 trading pairs, Maximum 10 orders can be placed at a time for each trading pair).

Rate limit: 50 / 2s
HTTP Requests

POST /api/margin/v3/batch_orders

End Certificate Request Sample

Market Order:2018-09-14T09:51:24.959ZPOST/api/spot/v3/batch_orders[{"client_oid":"E20180728","order_type”:”1”,"instrument_id":"btc-usdt","side":"sell","type":"limit"," size ":"0.001"," notional ":"10001","margin_trading ":"1"},{"client_oid":"20180728","instrument_id":"btc-usdt","side":"sell","type":"limit"," size ":"0.001","notional":"10002","margin_trading ":"1"}

Limit Order:2018-09-14T09:51:24.959ZPOST/api/spot/v3/batch_orders[{"client_oid":"T20180728","order_type”:”1”,"instrument_id":"btc-usdt","side":"sell","type":"limit","size":"0.001","price":"10001","margin_trading ":"1"},{"client_oid":"20180728","instrument_id":"btc-usdt","side":"sell","type":"limit","size":"0.001","price":"10002","margin_trading ":"1"}

Request Parameters
Parameters Parameters Types Required Description
client_oid String No The order ID customized by yourself ,The type should be comprised of alphabets + numbers or only alphabets within 1 – 32 characters, Both uppercase and lowercase letters are supported
type String No Limit/market(default:limit),When posting orders at market price, order_type can only be 0 (regular order)
side String Yes buy/sell
instrument_id String Yes Trading pair
margin_trading String Yes Order type (The request value is 2)
order_type String No Fill in number for parameter,0: Normal limit order (Unfilled and 0 represent normal limit order) 1: Post only 2: Fill Or Kill 3: Immediatel Or Cancel
Limit Order Parameters
Parameters Parameters Types Required Description
price String Yes price
size String Yes quantity bought or sold
Market Order Parameters
Parameters Parameters Types Required Description
size String No quantity sold.(for orders sold at market price only)
notional String No amount bought.(for orders bought at market price only)
Return Parameters
Parameters Parameters Types Description
order_id String Order ID
client_oid String This client_oid is the order ID sent by the user.
error_code String Error code for order placement.
error_message String It will be blank if order placement is success. Error message will be returned if order placement fails.
result Boolean If the order cannot be cancelled (already settled or cancelled),the error description it returns to will display the corresponding reason.
Explanation

The client_oid type should be comprised of alphabets + numbers or only alphabets within 1 – 32 characters, both uppercase and lowercase letters are supported , and needs to make sure the ID does not repeat and there is no repetition alert. In case of repetition, only the latest entry will be queried and canceled .

You may place up to 4 trading pairs with 10 orders at maximum for each pair. We recommend you to use the "Get order list" endpoint" before using the "Cancel multiple orders" endpoint to confirm the cancellation of orders.

Return Sample
{
    "BTC-USDT":[
        {
            "client_oid":"oktlever51",
            "error_code":"0",
            "error_message":"",
            "order_id":"2512113685627904",
            "result":true
        },
        {
            "client_oid":"oktlever52",
            "error_code":"0",
            "error_message":"",
            "order_id":"2512113687135232",
            "result":true
        }
    ]
}

Cancel an Order

Cancelling an unfilled order.

Rate limit: 100 / 2s
HTTP Requests

DELETE /api/margin/v3/cancel_orders/<order_id>

or

DELETE /api/margin/v3/cancel_orders/<client_oid>

End Certificate Request Sample

2018-10-12T07:34:30.223ZPOST/api/margin/v3/cancel_orders/a123{"instrument_id":"btc-usdt"}

Request Parameters
Parameters Parameters Types Compulsory Description
instrument_id String yes by providing this parameter,the corresponding order of a designated trading pair will be cancelled.If not providing this parameter,it will be back to error code.
client_oid String No the order ID created by yourself , The client_oid type should be comprised of alphabets + numbers or only alphabets within 1 – 32 characters, both uppercase and lowercase letters are supported
order_id String yes order ID
Return Parameters
Parameters Parameters Types Description
order_id String order ID
client_oid String this client_oid is the order ID sent by the user.
error_code String Error code for order placement.
error_message String It will be blank if order placement is success. Error message will be returned if order placement fails.
result Boolean if the order cannot be cancelled (already settled or cancelled),the error description it returns to will display the corresponding reason.
Explanation

When using client_oid for order cancellation, The user needs to make sure the ID does not repeat and there is no repetition alert. In case of repetition, only the latest entry will be canceled.

If the order cannot be cancelled (already settled or cancelled), the error description it returns to will display the corresponding reason.

Return Sample
{
    "btc-usdt":[
    {
       "result":true,
        "client_oid":"a123",
        "order_id": "2510832677225473"
     }
]
}

Cancel all Orders

With best effort, cancel all open orders.Maximum 10 orders can be cancelled at a time for each trading pair

Rate limit: 50/ 2s
HTTP Requests

DELETE /api/margin/v3/cancel_batch_orders

End Certificate Request Sample

2018-10-12T07:30:49.664ZPOST/api/spot/v3/cancel_batch_orders[{"instrument_id":"btc-usdt","client_oids":["a123","a1234"]},{"instrument_id":"ltc-usdt","client_oids":["a12345","a123456"]}]

Request Parameters
Parameters Parameters Types Required Description
instrument_id String Yes by providing this parameter,the corresponding order of a designated trading pair will be cancelled.If not providing this parameter,it will be.
order_ids String Yes order ID
client_oids String Yes The client_oid type should be comprised of alphabets + numbers or only alphabets within 1 – 32 characters, both uppercase and lowercase letters are supported
Return Parameters
Parameters Parameters Types Description
order_id String<String> order ID
client_oid String this client_oid is the order ID sent by the user.
instrument_id String trading pair
result Boolean if the order cannot be cancelled (already settled or cancelled),the error description it returns to will display the corresponding reason.
Explanation

For bulk order cancellation, the parameters should be either all order_id or all client_oid, otherwise it will trigger an error code.

When using client_oid for bulk order cancellation, only one client_oid canceled for one trading pair, maximum 4 pairs per time. The user needs to make sure the ID does not repeat and there is no repetition alert. In case of repetition, only the latest entry will be canceled.

You may place up to 4 trading pairs with 10 orders at maximum for each pair. We recommend you to use the "Get order list" endpoint" before using the "Cancel multiple orders" endpoint to confirm the cancellation of orders.

Return Sample
{
    "btc-usdt":[
    {
       "result":true,
        "client_oid":"a123",
        "order_id": "2510832677225473"
     },
   {
       "result":true,
        "client_oid":"a1234",
        "order_id": "2510832677225474"
     }
],
"ltc-usdt":[
    {
       "result":true,
        "client_oid":"a12345",
        "order_id": "2510832677225475"
     },
   {
       "result":true,
        "client_oid":"a123456",
        "order_id": "2510832677225476"
     }
]
}

Get Order List

List your orders. Cursor pagination is used. All paginated requests return the latest information (newest) as the first page sorted by newest (in chronological time) first.This interface can fetch the information of the latest 100 orders.

Rate limit: 20/ 2s
HTTP Requests

GET /api/margin/v3/orders

End Certificate Request Sample

2018-09-12T07:49:43.306ZGET/api/spot/v3/orders?instrument_id=BTC-USDT&state=0&limit=2&from=2&to=4

Request Parameters
Parameters Parameters Types Description
instrument_id String [required] list the orders of specific trading pairs
from String [optional]request page from(newer)this id.
to String [optional]request page to(older)this id.
limit String [optional]number of results per request.Maximum 100.(default 100)
state String [required] Order Status("-2":Failed,"-1":Cancelled,"0":Open ,"1":Partially Filled, "2":Fully Filled,"3":Submitting,"4":Cancelling,"6": Incomplete(open+partially filled),"7":Complete(cancelled+fully filled))
Return Parameters
Parameters Parameters Types Description
order_id String order ID
client_oid String the order ID customised by yourself
price String price
size String quantity
notional String the total buying amount.This value will be returned for market orders
instrument_id String trading pair
side String order side
type String order type
timestamp String order creation date
filled_size String quantity filled
filled_notional String amount filled
order_type String 0: Normal limit order 1: Post only 2: Fill Or Kill 3: Immediatel Or Cancel
state String Order Status("-2":Failed,"-1":Cancelled,"0":Open ,"1":Partially Filled, "2":Fully Filled,"3":Submitting,"4":Cancelling,)
Explanation

"status" is the older version of the "state" parameter and is compatible in the short term. It is recommended to switch to "state".

The client_oid type should be comprised of alphabets + numbers or only alphabets within 1 – 32 characters, both uppercase and lowercase letters are supported , and needs to make sure the ID does not repeat and there is no repetition alert. In case of repetition, only the latest entry will be queried .

This endpoint can only provide the filled orders of the recent two days and the cancelled orders.

If the order is not filled in the order lifecycle, the record may be removed. This indicates that this order cannot be downloaded with this endpoint.

Unfilled orders status may change depending on the market between the time of request creation and server response.

Return Sample
[
    [
        {
            "client_oid":"oktlever56",
            "created_at":"2019-03-20T08:21:49.000Z",
            "filled_notional":"0",
            "filled_size":"0",
            "funds":"",
            "instrument_id":"BTC-USDT",
            "notional":"",
            "order_id":"2512264176206848",
            "order_type":"0",
            "price":"3613.3",
            "product_id":"BTC-USDT",
            "side":"buy",
            "size":"0.001",
            "status":"open",
            "state": "0",    
            "timestamp":"2019-03-20T08:21:49.000Z",
            "type":"limit"
        },
        {
            "client_oid":"oktlever55",
            "created_at":"2019-03-20T08:21:49.000Z",
            "filled_notional":"0",
            "filled_size":"0",
            "funds":"",
            "instrument_id":"BTC-USDT",
            "notional":"",
            "order_id":"2512264174306304",
            "order_type":"0",
            "price":"3613.3",
            "product_id":"BTC-USDT",
            "side":"buy",
            "size":"0.001",
            "status":"open",
            "state": "0",    
            "timestamp":"2019-03-20T08:21:49.000Z",
            "type":"limit"
        }
    ],
    {
        "before":"2512264176206848",
        "after":"2512264174306304"
    }
]

Get Order Details

Get order details by order ID,Canceled unfilled orders will be kept in record for 2 hours only.

Rate limit:20/2s
HTTP Requests

GET /api/margin/v3/orders/<order_id>

or

GET /api/margin/v3/orders/<client_oid>

End Certificate Request Sample

2018-09-13T02:39:22.475ZGET/api/margin/v3/orders/23458?instrument_id=btc-usdt

or

2018-09-13T02:39:22.475ZGET/api/margin/v3/orders/ebetd2?instrument_id=btc-usdt

Requests Parameters
Parameters Parameters Types Description
instrument_id String [required]trading pair
order_id String [required]order ID
client_oid String [ required ] The client_oid type should be comprised of alphabets + numbers or only alphabets within 1 – 32 characters, both uppercase and lowercase letters are supported
Return Parameters
Parameters Parameters Types Description
order_id String order ID
client_oid String the order ID customised by yourself
price String price
size String size of order
notional String buying amount(for market orders)
instrument_id String trading pair
side String order side
type String order type
timestamp String order creation date
filled_size String size filled
filled_notional String amount filled
order_type String 0: Normal limit order 1: Post only 2: Fill Or Kill 3: Immediatel Or Cancel
state String Order Status("-2":Failed,"-1":Cancelled,"0":Open ,"1":Partially Filled, "2":Fully Filled,"3":Submitting,"4":Cancelling,)
Explanation

"status" is the older version of the "state" parameter and is compatible in the short term. It is recommended to switch to "state".

Only fill in either parameter client_oid or order_id

The client_oid type should be comprised of alphabets + numbers or only alphabets within 1 – 32 characters, both uppercase and lowercase letters are supported , and needs to make sure the ID does not repeat and there is no repetition alert. In case of repetition, only the latest entry will be queried .

If the order is not filled in the order lifecycle, its record may be removed, the status code 404 may be returned as there are no matches.

Unfilled order status may change according to the market conditions at the time period between your request creation and the server’s response.

status include(all, open, part_filled, canceling, filled, cancelled)

Return Sample
{
    "client_oid":"",
    "created_at":"2019-03-18T03:45:55.000Z",
    "filled_notional":"1.504",
    "filled_size":"0.4",
    "funds":"",
    "instrument_id":"EOS-USDT",
    "notional":"",
    "order_id":"2499854635054080",
    "order_type":"0",
    "price":"3.76",
    "product_id":"EOS-USDT",
    "side":"buy",
    "size":"0.4",
    "status":"filled",
    "state": "-2",       
    "timestamp":"2019-03-18T03:45:55.000Z",
    "type":"limit"
}

Get All Open Orders

List all your current orders. Cursor pagination is used. All paginated requests return the latest information (newest) as the first page sorted by newest (in chronological time) first.

Rate limit: 20/ 2s
HTTP Requests

GET /api/margin/v3/orders_pending

End Certificate Request Sample

2019-03-20T07:51:51.138ZGET/api/margin/v3/orders_pending?limit=2&instrument_id=BTC-usdt&from=1&to=2

Request Parameters
Parameters Parameters Types Description
from String [optional] request page after this id (latest information) (eg. 1, 2, 3, 4, 5. There is only a 5 "from 4", while there are 1, 2, 3 "to 4")
to String [optional]request page after (older) this id.
limit String [optional]number of results per request. Maximum 100. (default 100)
instrument_id String [optional]trading pair ,information of all trading pair will be returned if the field is left blank
Return Parameters
Parameters Parameters Types Description
order_id String order ID
client_oid String the order ID customised by yourself
price String price
size String quantity
notional String the total buying amount. This value will be returned for market orders
instrument_id String trading pair
side String buy or sell
type String limit,market(defaulted as limit)
timestamp String order creation date
filled_size String quantity filled
filled_notional String amount filled
state String Order Status("0":Open ,
Explanation

"status" is the older version of the "state" parameter and is compatible in the short term. It is recommended to switch to "state".

The client_oid type should be comprised of alphabets + numbers or only alphabets within 1 – 32 characters, both uppercase and lowercase letters are supported , and needs to make sure the ID does not repeat and there is no repetition alert. In case of repetition, only the latest entry will be queried .

This endpoint can provide the filled orders and the cancelled orders.

Unfilled orders’ status may change depending on the market between the time of request creation and server response.

Return Sample
[
    [
        {
            "client_oid":"oktlever56",
            "created_at":"2019-03-20T08:21:49.000Z",
            "filled_notional":"0",
            "filled_size":"0",
            "funds":"",
            "instrument_id":"BTC-USDT",
            "notional":"",
            "order_id":"2512264176206848",
            "order_type":"0",
            "price":"3613.3",
            "product_id":"BTC-USDT",
            "side":"buy",
            "size":"0.001",
            "status":"open",
            "state": "0",    
            "timestamp":"2019-03-20T08:21:49.000Z",
            "type":"limit"
        },
        {
            "client_oid":"oktlever55",
            "created_at":"2019-03-20T08:21:49.000Z",
            "filled_notional":"0",
            "filled_size":"0",
            "funds":"",
            "instrument_id":"BTC-USDT",
            "notional":"",
            "order_id":"2512264174306304",
            "order_type":"0",
            "price":"3613.3",
            "product_id":"BTC-USDT",
            "side":"buy",
            "size":"0.001",
            "status":"open",
            "state": "0",    
            "timestamp":"2019-03-20T08:21:49.000Z",
            "type":"limit"
        }
    ],
    {
        "before":"2512264176206848",
        "after":"2512264174306304"
    }
]

Get Transaction Details

Get details of the recent filled orders. Cursor pagination is used. All paginated requests return the latest information (newest) as the first page sorted by newest (in chronological time) first. This API can retrieve data in the last 3 months.

Rate limit: 20/ 2s
HTTP Requests

GET /api/margin/v3/fills

End Certificate Request Sample

2018-09-13T02:44:54.823ZGET/api/margin/v3/fills?order_id=23239&instrument_id=btc-usdt&limit=1&from=2&to=4

Request Parameters
Parameters Parameters Types Description
order_id String [required]list all transaction details of this order_id.
instrument_id String [required]list all transaction details of this instrument_id.
from String [optional]request page from(newer)this id.
to String [optional]request page to(older)this id.
limit String [optional]number of results per request.Maximum 100(default 100)
Return Parameters
Parameters Parameters Types Description
ledger_id String bill ID
instrument_id String trading pair
price String price
size String order size
order_id String order ID
timestamp String order creation time
exec_type String taker or Maker(T or M)
fee String fees
side String side of order (buy or sell)
Explanation

Fees The fee levied in the transactions

Liquidity The order is created by maker or taker. (M=Maker, T=Taker)

Pagination Ledger_id are listed in a descending order, from biggest to smallest. The first ledger_id can be found under OK-FROM, so it would be easier to acquire a larger ledger_id (new bills) by using OK-FROM in the future.

Return Sample
[
    [
        {
            "created_at":"2019-03-18T03:45:57.000Z",
            "exec_type":"M",
            "fee":"0.0004",
            "instrument_id":"EOS-USDT",
            "ledger_id":"77622945",
            "liquidity":"M",
            "order_id":"2499854635054080",
            "price":"3.76",
            "product_id":"EOS-USDT",
            "side":"buy",
            "size":"0.4",
            "timestamp":"2019-03-18T03:45:57.000Z"
        },
        {
            "created_at":"2019-03-18T03:45:57.000Z",
            "exec_type":"M",
            "fee":"0",
            "instrument_id":"EOS-USDT",
            "ledger_id":"77622944",
            "liquidity":"M",
            "order_id":"2499854635054080",
            "price":"3.76",
            "product_id":"EOS-USDT",
            "side":"sell",
            "size":"1.504",
            "timestamp":"2019-03-18T03:45:57.000Z"
        }
    ],
    {
        "before":"77622945",
        "after":"77622944"
    }
]

Margin Trading Market Data

Get market data. This endpoint provides the snapshots of market data and can be used without verifications.

To acquire updated market data, please read the WebSocket document, which can help you to get and create more comprehensive data.

Spot trading and margin trading shares the same market data, please visit token trading for endpoints details.

Error Code

Error Code Sample
Business Error Messages Business Error Codes http Status Code Scenarios
margin account for this pair is not enabled yet 33001 400 the service must be enabled before trading
margin account for this pair is suspended 33002 400 margin account suspended
no loan balance 33003 400 insufficient balance for loan
loan amount cannot be smaller than the minimum limit 33004 400 minimum loan amount limit not reached
repayment amount must exceed 0 33005 400 invalid repayment amount
loan order not found 33006 400 loan order not found
status not found 33007 400 status unchanged
loan amount cannot exceed the maximum limit 33008 400 invalid loan amount
user ID is blank 33009 400 user ID not provided
you cannot cancel an order during session 2 of call auction 33010 400 order cancellation not allowed during call auction
no new market data 33011 400 no market data
order cancellation failed 33012 400 order cancellation failed
order placement failed 33013 400 order placement failed
order does not exist 33014 400 order canceled already. Invalid order number
exceeded maximum limit 33015 400 exceeded maximum limit during multiple-order placement
margin trading is not open for this token 33016 400 insufficient balance for order placement
insufficient balance 33017 400 margin trading not supported for this pair
this parameter must be smaller than 1 33018 400 invalid parameter for getting market data
request not supported 33020 400 margin trading not supported for some exchanges
token and the pair do not match 33021 400 incorrect token for the token pair during repayment
pair and the order do not match 33022 400 incorrect token for the order during repayment
you can only place market orders during call auction 33023 400 you can only place market orders during call auction
trading amount too small 33024 400 invalid trading amount
base token amount is blank 33025 400 settings not completed during order placement
transaction completed 33026 400 cancel limited when the transaction completed
cancelled order or order cancelling 33027 400 cancel limited when the order is cancelling or cancelled
the decimal places of the trading price exceeded the limit 33028 400 order endpoint: The decimal places of the trading price exceeded the limit
the decimal places of the trading size exceeded the limit 33029 400 order endpoint::The decimal places of the trading size exceeded the limit

This is RestAPI Error Codes.

Common Error Codes

Error codes of v3 API start from 30000.

Common error codes include the signatures and error codes of all business lines.

Error Message Error Codes http Status Code
request header "OK_ACCESS_KEY" cannot be blank 30001 400
request header "OK_ACCESS_SIGN" cannot be blank 30002 400
request header "OK_ACCESS_TIMESTAMP" cannot be blank 30003 400
request header "OK_ACCESS_PASSPHRASE" cannot be blank 30004 400
invalid OK_ACCESS_TIMESTAMP 30005 400
invalid OK_ACCESS_KEY 30006 400
invalid Content_Type, please use "application/json" format 30007 400
timestamp request expired 30008 400
system error 30009 500
API validation failed 30010 401
invalid IP 30011 400
invalid authorization 30012 401
invalid sign 30013 401
request too frequent 30014 429
request header "OK_ACCESS_PASSPHRASE" incorrect 30015 400
you are using v1 apiKey, please use v1 endpoint. If you would like to use v3 endpoint, please subscribe to v3 apiKey 30016 400
apikey's broker id does not match 30017 400
apikey's domain does not match 30018 400
Api is offline or unavailable 30019 400
Json data format error 30021 400
Api has been frozen 30022 400
Description Error Codes http Status Code Scenarios
body cannot be blank 30020 400 body cannot be blank
json data format error 30021 400 json data format error
{0} parameter cannot be blank; required parameter cannot be blank 30023 400 parameters returned respectively
{0} parameter value error 30024 400 parameters returned respectively
{0} parameter category error 30025 400 parameter category error
requested too frequent; endpoint limit exceeded 30026 429 requested too frequent; endpoint limit exceeded
login failure 30027 401 operating orders of other users
unauthorized execution 30028 400 unauthorized execution
account suspended 30029 400 account suspended
endpoint request failed. Please try again 30030 400 endpoint request failed. Please try again
token does not exist 30031 400 token requested does not exist
pair does not exist 30032 400 pair requested does not exist
exchange domain does not exist 30033 400 the error returned when the exchange for the apikey validation is not filled
exchange ID does not exist 30034 400 the error returned when the exchange ID for the apikey validation is not filled
trading is not supported in this website 30035 400 the error returned when the exchange is closed
no relevant data 30036 400 no relevant data when enquiring the endpoint
user does not exist 30038 400 user does not exist
endpoint is offline or unavailable 30037 400 endpoint is offline or unavailable
successful 0 200 when the order placement / cancellation / operation is successful

Token and margin error codes

Error Messages Error Codes http Status Code Scenarios
margin account for this pair is not enabled yet 33001 400 the service must be enabled before trading
margin account for this pair is suspended 33002 400 margin account suspended
no loan balance 33003 400 insufficient balance for loan
loan amount cannot be smaller than the minimum limit 33004 400 minimum loan amount limit not reached
repayment amount must exceed 0 33005 400 invalid repayment amount
loan order not found 33006 400 loan order not found
status not found 33007 400 status unchanged
loan amount cannot exceed the maximum limit 33008 400 invalid loan amount
user ID is blank 33009 400 user ID not provided
you cannot cancel an order during session 2 of call auction 33010 400 order cancellation not allowed during call auction
no new market data 33011 400 no market data
order cancellation failed 33012 400 order cancellation failed
order placement failed 33013 400 order placement failed
order does not exist 33014 400 order canceled already. Invalid order number
exceeded maximum limit 33015 400 exceeded maximum limit during multiple-order placement
margin trading is not open for this token 33016 400 insufficient balance for order placement
insufficient balance 33017 400 margin trading not supported for this pair
this parameter must be smaller than 1 33018 400 invalid parameter for getting market data
request not supported 33020 400 margin trading not supported for some exchanges
token and the pair do not match 33021 400 incorrect token for the token pair during repayment
pair and the order do not match 33022 400 incorrect token for the order during repayment
you can only place market orders during call auction 33023 400 you can only place market orders during call auction
trading amount too small 33024 400 invalid trading amount
base token amount is blank 33025 400 settings not completed during order placement
transaction completed 33026 400 cancel limited when the transaction completed
cancelled order or order cancelling 33027 400 cancel limited when the order is cancelling or cancelled
the decimal places of the trading price exceeded the limit 33028 400 order endpoint: The decimal places of the trading price exceeded the limit
the decimal places of the trading size exceeded the limit 33029 400 order endpoint::The decimal places of the trading size exceeded the limit
client_oid or order_id is required 33059 400
Only fill in either parameter client_oid or order_id 33060 400
You can only place limit order after Call Auction has started 33034 400

Wallet error codes

Error Messages Error Codes http Status Code Scenarios
withdrawal suspended 34001 400 withdrawal endpoint: account suspended
please add a withdrawal address 34002 400 withdrawal endpoint: address required
sorry, this token cannot be withdrawn to xx at the moment 34003 400 withdrawal endpoint: incorrect address
withdrawal fee is smaller than minimum limit 34004 400 withdrawal endpoint: incorrect fee
withdrawal fee exceeds the maximum limit 34005 400 withdrawal endpoint: incorrect withdrawal fee
withdrawal amount is lower than the minimum limit 34006 400 minimum withdrawal amount%} endpoint: incorrect amount
withdrawal amount exceeds the maximum limit 34007 400 maximum withdrawal amount endpoint: incorrect amount
insufficient balance 34008 400 transfer & withdrawal endpoint: insufficient balance
your withdrawal amount exceeds the daily limit 34009 400 withdrawal endpoint: withdrawal limit exceeded
transfer amount must be larger than 0 34010 400 transfer endpoint: incorrect amount
conditions not met 34011 400 transfer & withdrawal endpoint: conditions not met, e.g. KYC level
the minimum withdrawal amount for NEO is 1, and the amount must be an integer 34012 400 withdrawal endpoint: special requirements
please transfer 34013 400 transfer endpoint: Token margin trading instrument ID required
transfer limited 34014 400 transfer endpoint:Transfer limited
subaccount does not exist 34015 400 transfer endpoint: subaccount does not exist
transfer suspended 34016 400 transfer endpoint: either end of the account does not authorize the transfer
account suspended 34017 400 transfer & withdrawal endpoint: either end of the account does not authorize the transfer
incorrect trades password 34018 400 incorrect trades password
please bind your email before withdrawal 34019 400 withdrawal endpoint : email required
please bind your funds password before withdrawal 34020 400 withdrawal endpoint : funds password required
Not verified address 34021 400 withdrawal endpoint
Withdrawals are not available for sub accounts 34022 400 withdrawal endpoint

Spot&Margin WebsocketAPI

This is the V3 Websocket API for spot and margin ,Except for the separate channel of "account", data of other channels is open to both token and margin trading users.

General

WebSocket protocol is a new HTML5 protocol, which provides full-duplex communication between web browsers and web servers. Connection can be established after one handshake. Web server can then push business logic data to web browsers.Advantages:

Request header is small in size (around 2 bytes) during communication Since there is no need to create and delete TCP connection repeatedly, it saves resources We strongly recommend developers to use Websocket API to access market related information and trading depth. Should you have any questions, feel free to contact our support team.

We strongly recommend developers to use Websocket API to access market related information and trading depth.

All the messages returning from WebSocket API will be optimized by Deflate compression. All users will be required to decompress the messages by themselves with the methods they find most appropriate. Please refer to our demo

The connection will break automatically when a network problem occurs

url:wss://real.okcoin.com:10442/ws/v3

Command Format

send format:

{"op": "<value>", "args": ["<value1>","<value2>"]}

the value of op 1-- subscribe 2--unsubscribe 3--login

args: the value is the channel name, which can be one or more channels

Successful response format:

  {"event": "<value>","channel":"<value>"}
  {"table":"channel","data":"[{"<value1>","<value2>"}]"}

In the spot/depth channel, the return formats for distinguishing between the first full amount and the subsequent incremental are:


{"table":"channel", "action":"<value>","data":"[{"<value1>","<value2>"}]"}

Failure response format:

{"event":"error","message":"<error_message>","errorCode":"<errorCode>"}

Subscription

Users may subscribe to one or more channels,The total length of multiple channels should not exceed 4,096 bytes.

{"op": "subscribe", "args": ["<SubscriptionTopic>"]}

Description : the value of op is subscribe

args :The array content is channel names :<channelname>:<filter>

The channel name is composed of business/channel

spot push business is spot, channel for each specific name under this business, If a channel name consists of two separate words, they will be connected with an underscore " _ "

Example:

"spot/ticker:ETH-USDT"or "spot/margin_account:ETH-USDT"

Filter is filterable data. For details, please refer to the description of each channel

Example :

send:

{"op": "subscribe", "args": ["spot/ticker:ETH-USDT","spot/candle60s:ETH-USDT"]}

response:

 {"event":"subscribe","channel":"spot/ticker:ETH-USDT"}

 {"event":"subscribe","channel":"spot/candle60s:ETH-USDT"}

 {"table":"spot/ticker","data":[{"instrument_id":"ETH-USDT","last":"8.8","best_bid":"3","best_ask":"8.1","open_24h":"5.1","high_24h":"8.8","low_24h":"3","base_volume_24h":"13.77340909",
 "quote_volume_24h":"78.49886361","timestamp":"2018-12-20T03:13:41.664Z"}]}

 {"table":"spot/candle60s","data":[{"candle":["2018-12-20T06:18:00.000Z","8.8","8.8","8.8","8.8","0"],"instrument_id":"ETH-USDT"}]}

Unsubscription

Users can cancel one or more channels.

{"op": "unsubscribe", "args": [<SubscriptionTopic>]}

send:

{"op": "unsubscribe", "args": ["spot/ticker:BTC-USDT", "spot/candle60s:BTC-USDT"]}

response:

{"event":"unsubscribe","channel":"spot/ticker:BTC-USDT"}
{"event":"unsubscribe","channel":"spot/candle60s:BTC-USDT"}

Login

The login method description can be found in the verification part in the API overview

Login subscription format:

{"op":"login","args":["<api_key>","<passphrase>","<timestamp>","<sign>"]

Response:

{"event":"login","success":"true"}

Example:

{"op":"login","args":["985d5b66-57ce-40fb-b714-afc0b9787083","123456","1538054050.975",
"7L+zFQ+CEgGu5rzCj4+BdV2/uUHGqddA9pI6ztsRRPs="]}

api_key:'api_key' is apply 'apiKey' for users

passphrase:The passphrase entered when subscribing the apikey

timestamp: Must be number of seconds since unix-epoch in UTC Decimal values are allowed,your timestamp must be within 30 seconds of the api service time or your request will be considered expired and rejected, We recommend using the time endpoint to query for the API server time if you believe there many be time skew between your server and the API servers.

sign:is a signing String. The signing rules can be seen in the request description (API overview and validation part).A passphrase should be filled when applying for v3 API

Example of timestamp:const timestamp = '' + Date.now() / 1000

Example of sign : sign=CryptoJS.enc.Base64.Stringify(CryptoJS.HmacSHA256(timestamp +'GET'+ '/users/self/verify', secret))

methodis preset as'GET'。

requestPath is preset as '/users/self/verify'

If the login fails, the link will be automatically disconnected.

Connect limit

Connection limit:1 times/s

Subscription limit:240 times/hour

if there is no data return after connecting to ws, the connection will break in 30s.Users are advised to do the followings:

Set a timer after receiving a message. If the timer is triggered (no new message received within N seconds) send the String 'ping'.Expect a text String 'pong' as a response. If you do not receive it within 5 seconds, please issue an error or reconnect.

Checksum

This function can help users verify the accuracy of depth data.

Checksum rule: Every time when depth data is pushed, a timestamp and a checksum check are added. Take the price and quantity in the first 25 entries of bids and asks data out of the 200 entries of depth data after each data merge, and use the crc32 value of the String comprised of the price and number connected by a colon. User can compare the value of their checksum with the checksum value of the subscription. If there is no match, the users can re-subscribe. This function can help users verify the accuracy of depth data.

Instructions of depth merge: 200 entries of depth data for the first time, Then take the data of each increment and scan the prices in the asks and bids in the 200 entries. If the prices match, look at the quantity. If the quantity is 0, then delete the depth data; if the quantity has changed, replace the original data; if the price cannot be matched, sort the entry by the price.

Calculation Description: A checksum message will be sent every book iteration,where CHECKSUM is a signed integer (32-bit)

1,The following data is aligned with bid and ask, the checksum String will be bid:ask:bid:ask:....

(see the following example)


"data": [{
        "instrument_id": "BTC-USDT",
        "asks": [["3366.8", "9", 10],[ "3368","8",3]],
        "bids": [
            ["3366.1", "7", 0],[ "3366","6",3 ]
        ],
        "timestamp": "2018-12-04T09:38:36.300Z",
        "checksum": -1881014294
    }]

The checksum String of this example will be 3366.1:7:3366.8:9:3366:6:3368:8

2,If bid and ask data does not align , the checksum String will be bid:ask:ask:ask:.... (see the following example)

"data": [{
        "instrument_id": "BTC-USDT",
        "asks": [["3366.8", "9", 10],[ "3368","8",3],[ "3372","8",3 ]],
        "bids": [
            ["3366.1", "7", 0]
        ],
        "timestamp": "2018-12-04T09:38:36.300Z",
        "checksum": 831078360
    }]

The checksum String of this example will be 3366.1:7:3366.8:9:3368:8:3372:8

The push data depth channel users receive is:

First 200 amount


{
    "table": "spot/depth",
    "action": "partial",
    "data": [{
        "instrument_id": "ETH-USDT",
        "asks": [
            ["8.8", "96.99999966", 1],
            ["9", "39", 3],
            ["9.5", "100", 1],
            ["12", "12", 1],
            ["95", "0.42973686", 3],
            ["11111", "1003.99999795", 1]
        ],
        "bids": [
            ["5", "7", 4],
            ["3", "5", 3],
            ["2.5", "100", 2],
            ["1.5", "100", 1],
            ["1.1", "100", 1],
            ["1", "1004.9998", 1]
        ],
        "timestamp": "2018-12-18T07:27:13.655Z",
        "checksum": 468410539
    }]
}

Increment:

{
    "table": "spot/depth",
    "action": "update",
    "data": [{
        "instrument_id": "BTC-USDT",
        "asks": [],
        "bids": [
            ["3983", "789", 0, 3]
        ],
        "timestamp": "2018-12-04T09:38:36.300Z",
        "checksum": -1200119424
    }]
}

Channel List

Channels that don't require login

spot/ticker // ticker channel

spot/candle60s // 1mins kline channel

spot/candle180s // 3mins kline channel

spot/candle300s // 5mins kline channel

spot/candle900s // 15mins kline channel

spot/candle1800s // 30mins kline channel

spot/candle3600s // 1hour kline channel

spot/candle7200s // 2hour kline channel

spot/candle14400s // 4hour kline channel

spot/candle21600 // 6hour kline channel

spot/candle43200s // 12hour kline channel

spot/candle86400s // 1day kline channel

spot/candle604800s // 1week kline channel

spot/trade // trade information

spot/depth //depth information,200 entries of depth data for the first time, then increment data

spot/depth5 //depth information, the previous five entries of depth data

Channels that require login

spot/account //User's account information

spot/margin_account //User's margin account information

spot/order //User's order information

Ticker

To capture the latest traded price, best-bid price, best-ask price, and 24-hour trading volume of all perpetual swap contracts on the platform.

send examples:
{"op": "subscribe", "args": ["spot/ticker:ETH-USDT"]}

spot/ticker is channel name ,ETH-USDT is instrument_id

response parameters
Parameters Parameters type Description
instrument_id String trading pair
last String last traded price
best_bid String best bid price
best_ask String best ask price
open_24h String 24 hour open
high_24h String 24 hour high
low_24h String 24 hour high
base_volume_24h String 24 trading volume of the base currency
quote_volume_24h String 24 trading volume of the quote currency
timestamp String timestamp
response examples
{
    "table": "spot/ticker",
    "data": [{
        "instrument_id": "ETH-USDT",
        "last": "8.8",
        "best_bid": "5",
        "best_ask": "8.8",
        "open_24h": "6.6",
        "high_24h": "8.8",
        "low_24h": "4",
        "base_volume_24h": "85.68492053",
        "quote_volume_24h": "570.14238013",
        "timestamp": "2018-12-17T12:28:29.250Z"
    }]
}

Kline

Kline information for spot business

channel lists:

spot/candle60s // 1mins kline channel

spot/candle180s // 3mins kline channel

spot/candle300s // 5mins kline channel

spot/candle900s // 15mins kline channel

spot/candle1800s // 30mins kline channel

spot/candle3600s // 1hour kline channel

spot/candle7200s // 2hour kline channel

spot/candle14400s // 4hour kline channel

spot/candle21600 // 6hour kline channel

spot/candle43200s // 12hour kline channel

spot/candle86400s // 1day kline channel

spot/candle604800s // 1week kline channel

send examples
{"op": "subscribe", "args": ["spot/candle60s:ETH-USDT"]}

spot/candle60s is channel name,ETH-USDT is instrument_id

response parameters
Parameters Parameters Types Description
timestamp String Start time
open String Open price
high String Highest price
low String Lowest price
close String Close price
volume String Trading volume
currency_volume String The trading volume in a specific token
instrument_id String trading pair
response examples
{
    "table": "spot/candle60s",
    "data": [{
        "candle": ["2018-12-18T02:55:00.000Z", "8.8", "8.8", "8.8", "8.8", "0"],
        "instrument_id": "ETH-USDT"
    }]

}

Trade

Get the filled orders data

send examples
{"op": "subscribe", "args": ["spot/trade:ETH-USDT"]}

spot/trade is channel name ,ETH-USDT is instrument_id

response parameters
Parameters Parameters Types Description
trade_id String Transaction id
price String Filled price
size String Filled size
side String Filled side (buy/sell)
timestamp String Filled time
instrument_id String trading pair
response examples

{
        ”table”: "spot/trade”,
        ”data”: [
                [{
                        ”instrument_id”: "ETH-USDT”,
                        ”price”: "22888”,
                        ”side”: "buy”,
                        ”size”: "7”,
                        ”timestamp”: "2018-11-22T03:58:57.709Z”,
                        ”trade_id”: "108223090144493569”
               }]
        ]
}

Depth5

Back to the previous five entries of depth data

send examples
{"op": "subscribe", "args": ["spot/depth5:ETH-USDT"]}

spot/depth5 is channel name ,ETH-USDT is instrument_id

response parameters
Parameters Parameters Types Description
price String price
size String Size
timestamp String timestamp
num_orders String total orders in the book
instrument_id String trading pair

["411.8","10",8][price ,size ,num_orders ]

response examples

{
    "table": "spot/depth5",
    "data": [{
        "asks": [
            ["8.8", "96.99999966", 1],
            ["9", "39", 3],
            ["9.5", "100", 1],
            ["12", "12", 1],
            ["95", "0.42973686", 3]
        ],
        "bids": [
            ["5", "7", 4],
            ["3", "5", 3],
            ["2.5", "100", 2],
            ["1.5", "100", 1],
            ["1.1", "100", 1]
        ],
        "instrument_id": "ETH-USDT",
        "timestamp": "2018-12-18T07:27:13.655Z"

Depth

First time return 200 entries, followed by increment data

send examples
{"op": "subscribe", "args": ["spot/depth:ETH-USDT"]}

spot/depth is channel name ,ETH-USDT is trading pair

response parameters
Parameters Parameters Types Description
price String price
size String Size
timestamp String timestamp
num_orders String total orders in the book
instrument_id String trading pair
checksum String checksum

["411.8","10",8][price ,size ,num_orders ]

response examples
 First 200 entries 


{
    "table": "spot/depth",
    "action": "partial",
    "data": [{
        "instrument_id": "ETH-USDT",
        "asks": [
            ["8.8", "96.99999966", 1],
            ["9", "39", 3],
            ["9.5", "100", 1],
            ["12", "12", 1],
            ["95", "0.42973686", 3],
            ["11111", "1003.99999795", 1]
        ],
        "bids": [
            ["5", "7", 4],
            ["3", "5", 3],
            ["2.5", "100", 2],
            ["1.5", "100", 1],
            ["1.1", "100", 1],
            ["1", "1004.9998", 1]
        ],
        "timestamp": "2018-12-18T07:27:13.655Z",
        "checksum": 468410539
    }]
}

Increment:

{
    "table": "spot/depth",
    "action": "update",
    "data": [{
        "instrument_id": "BTC-USDT",
        "asks": [],
        "bids": [
            ["3983", "789", 0, 3]
        ],
        "timestamp": "2018-12-04T09:38:36.300Z",
        "checksum": -1200119424
    }]
}

User Spot Account

Get the user's spot account information , require login.

send examples
{"op": "subscribe", "args": ["spot/account:BTC"]}

spot/account is channel name ,BTC is token

response parameters
Parameters Parameters type Description
currency String token
balance String balance
hold String amount on hold(not available)
available String available amount for trading or transfer
id String account id
response examples
{
    "table": "spot/account",
    "data": [{
        "balance": "881.5011237890123457",
        "available": "868.4011237890123457",
        "currency": "USDT",
        "id": "6916752",
        "hold": "13.1"
    }]
}

User Margin Account

Get the user's margin account information , require login.

send example
{"op": "subscribe", "args": ["spot/margin_account:ETH-USDT"]}

spot/margin_account is channel name ,ETH-USDT is instrument_id

response parameters
Parameters Parameters type Description
instrument_id String trading pair
balance String balance
hold String amount on hold(not available)
available String available amount for trading or transfer
borrowed String borrowed tokens (unpaid))
lending_fee String interest (unpaid)
response example
{
"table”:”spot/margin_account”,
"data”:[
{
"equity”:”333378.858”,
"fixed_balance”:”555.649”,
"instrument_id”:”LTC-USDT”,
"margin”:”554.017”,
"margin_frozen”:”7.325”,
"margin_mode”:”fixed”,
"margin_ratio”:”0.000”,
"realized_pnl”:”-1.633”,
"timestamp”:”2018-11-26T07:43:52.303Z”,
"total_avail_balance”:”332774.283”,
"unrealized_pnl”:”50.556”
}]
}

User Orders

Get user's order information , users need to log in first

send examples
{"op": "subscribe", "args": ["spot/order:LTC-USDT"]}

spot/order is channel name ,LTC-USDT is instrument_id

response parameters
Parameters Parameters type Description
order_id String order ID
client_oid String the order ID customised by yourself
price String price
size String size of order
notional String size of order
instrument_id String trading pair
side String buy or sell
type String limit,market(defaulted as limit)
timestamp String order creation date
filled_size String size filled
filled_notional String amount filled
margin_trading String 1 spot order. 2 margin order
order_type String 0: Normal limit order 1: Post only 2: Fill Or Kill 3: Immediatel Or Cancel
last_fill_px String Last transaction price (if none, push 0))
last_fill_qty String Last transaction amount (if none, push 0)
last_fill_time String Last transaction time (if none, push 0)
state String Order Status("-2":Failed,"-1":Cancelled,"0":Open ,"1":Partially Filled, "2":Fully Filled,"3":Submitting,"4":Cancelling,)
Explanation

"status" is the older version of the "state" parameter and is compatible in the short term. It is recommended to switch to "state".

response examples
{
    "table": "spot/order",
    "data": [{
        "filled_notional": "0",
        "filled_size": "0",
        "instrument_id": "LTC-USDT",
        "margin_trading": "2",
        "notional": "",
        "order_id": "1997224323070976",
        "client_oid":"20181009e",
        "price": "1",
        "side": "buy",
        "order_type”:”1”,
        "size": "1",
        "status": "open",
        "state": "0",    
        "timestamp": "2018-12-19T09:20:24.608Z",
        "type": "limit",
        "last_fill_px": "1",
        "last_fill_qty": "1",
        "last_fill_time": "2018-12-19T09:20:24.608Z"
    }]
}

error code

error message format:

{"event”:”error”,” message”:” ",”errorCode”:”"}

Example
Description Code
OK_ACCESS_KEY cannot be blank 30001
OK_ACCESS_SIGN cannot be blank 30002
OK_ACCESS_PASSPHRASE cannot be blank 30004
Invalid OK_ACCESS_TIMESTAMP 30005
Invalid OK_ACCESS_KEY 30006
Timestamp request expired 30008
Invalid sign 30013
Requested too frequent; endpoint limit exceeded 30026
Login failure 30027
Unrecognized request 30039
{0} Channel : {1} doesn't exist 30040
User not logged in / User must be logged in 30041
Already logged in 30042
Internal system error 30043

Change Log

【2019-4-28】

Spot trading order status fetch is not available.

Spot, margin, futures and perpetual swap

rest: Get Order List, Get All Open Orders, Get Order Details, Add Parameters state String Order Status("-2":Failed,"-1":Cancelled,"0":Open ,"1":Partially Filled, "2":Fully Filled,"3":Submitting,"4":Cancelling, "6": Incomplete (open + partially filled), "7":Complete (cancelled + fully filled) )

ws:order add parameters state String Order Status("-2":Failed,"-1":Cancelled,"0":Open,"1":Partially Filled, "2":Fully Filled,"3":Submitting,"4":Cancelling, )

【2019-04-26】

spot:The return parameters in the depth channel,depth5 channel,trade channel of spot websocket will be unified into the String type.

【2019-04-24】

public error_code and error_message add:

30019 400 Api is offline or unavailable 30021 400 Json data format error 30022 401 Api has been frozen

【2019-3-27】

For spot and margin trading, use client_oid to cancel multiple orders. The order cancelation function has been upgraded from 1 order per trading pairs to 10 orders per trading pairs. Request example after the launch: 2018-10-12T07:30:49.664ZPOST/api/spot/v3/cancel_batch_orders[{"instrument_id":"btc-usdt","client_oids”:[“A1600593327162368”,”A1600593327162369”]},{“instrument_id":"ltc-usdt","client_oids”:[“A243464”,”A234465”]}]

Spot, margin

New parameters added in web socket order channel: "last_fill_px”, ”last_fill_qty”, and “last_fill_time”

【2019-01-21】

Spot, margin Modification: modified the return value format for kline endpoints

FAQ


 1、How do I withdraw tokens from my sub account to an external address?

First, transfer your tokens to your sub account’s wallet, you can then transfer them to your main account wallet through the fund transfer port and withdraw your tokens there.

2、Is there any limit on the numbers of API order cancellation?

There are no limitations.

3、How did Http status code 429 happen?

Your visit frequency is too high. Please lower the frequency.

4、My API v3 account generated a new key. Do I have to use API v3 to send requests?

Yes, v1 and v3 are independent APIs. You must use a V1 key for a v1 API and v3 key for v3 API.

5、Why I cannot check on order details using the order ID returned from a canceled order?

Only the history of the canceled unfulfilled orders in the last 2 hours are kept in our system.

6、Can I use v3 key with okcoin.co?

The API address on our documents has always been “www.okcoin.com”. The domain name “www.okcoin.co” was only created to allow mainland Chinese users to access our website without VPN. There are no contradictions in the two addresses. Please fill in your request address according to our documents.

7、Can I use the API of the main account to check the balance of my sub account?


No, main accounts and sub accounts use independent APIs.

8、How many API keys can I apply for an account?

50.

9、How many entries of historical data can the K charts API obtain?

The K charts API can only obtain the most recent 2,000 entries of data.

10、Can I change the leverage level of my perpetual swap and futures contracts through API?

Yes, you can.

11、Are the return data different when using different keys in the same account?

The data is the same as they point at the same account.


12、What is the order unit when using v3 to make an order?

The order unit is 1, or multiples of 1.

13、Do I have to fill in my IP address when creating an API v3 key?

No, it’s not mandatory to enter your IP address, but we suggest you do so to make your account more secure.

14、Why did my API timeout?

Your network has timeout. Please check your network and use the Hong Kong Alibaba Cloud server instead.

15、Can I increase margin with v3 API?

No, you can only do so on the website.


16、What is the okcoin API visit frequency limit based on?

The limit for public data is based on IP, and that for individual data is based on User ID.

17、Will my IP address be banned if the API exceeds the visit frequency? How long will it be banned?

No, you won’t be banned. You only have to lower your visit frequency.

Questions And Feedback

If you have any questions or suggestions regarding our API, you are more than welcome to give us feedback via this link: (please indicate API v3). We will respond as soon as possible.

results matching ""

    No results matching ""