NAV
中文
Java Python Go C++

Introduce

OKLink provides OpenAPI for trust service and OpenAPI service for fund deposit and withdrawal, which is convenient for institutional users to integrate the deposit and withdrawal process into their applications.

Generating an APIKey

Create an APIKey on the website before signing any requests. After creating an APIKey, keep the following information safe:

The system returns randomly-generated APIKeys and SecretKeys. You will need to provide the Passphrase to access the API. We store the salted hash of your Passphrase for authentication. We cannot recover the Passphrase if you have lost it. You will need to create a new set of APIKey.

Click to jump to the official website to create V5APIKey page Create my APIKey

Making Requests

All private REST requests must contain the following headers:

Request bodies should have content type application/json and be in valid JSON format.

API request URL: Rest API:https://www.oklink.com

Sign

Signing Messages

The OK-ACCESS-SIGN header is generated as follows:

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 with millisecond ISO format, e.g. 2022-10-07T07:03:54.726Z.

The request method should be in UPPERCASE: e.g. GET and POST.

The requestPath is the path of requesting an endpoint.

Example: /api/v5/asset/balances

The body refers to the String of the request body. It can be omitted if there is no request body (frequently the case for GET requests).

Example: {"amt":"1","fee":"0.0005","dest":"4","ccy":"BTC","chain":"BTC-Bitcoin","toAddr":"17DKe3kkkkiiiiTvAKKi2vMPbm1Bz3CMKw"}

The SecretKey is generated when you create an APIKey.

Example: BD0CF1D1ADBF1D11D1A1D1A1D1A

Funding

The API endpoints of Funding require authentication.

Get balance

Retrieve the balances of all the assets and the amount that is available or on hold.

Rate Limit: 6 requests per second

Rate limit rule: UserID

HTTP Request

GET /api/v5/asset/balances

Request Example

GET /api/v5/asset/balances

Request Parameters

Parameters Types Required Description
ccy String No Single currency or multiple currencies (no more than 20) separated with comma, e.g. BTC or BTC,ETH.

Response Example

{
    "code": "0",
    "msg": "",
    "data": [{
            "availBal": "37.11827078",
            "bal": "37.11827078",
            "ccy": "ETH",
            "frozenBal": "0"
        }
    ]
}

Response Parameters

Parameter Type Description
ccy String Currency
bal String Balance
frozenBal String Frozen balance
availBal String Available balance

Get currencies

Retrieve a list of all currencies.

Rate Limit: 6 requests per second

Rate limit rule: UserID

HTTP Request

GET /api/v5/asset/currencies

Request Example

GET /api/v5/asset/currencies

Request Parameters

Parameters Types Required Description
ccy String No Single currency or multiple currencies (no more than 20) separated with comma, e.g. BTC or BTC,ETH.

Response Example

{
  "code": "0",
  "msg": "",
  "data": [
    {
      "canDep": true,
      "canInternal": false,
      "canWd": true,
      "ccy": "USDT",
      "chain": "USDT-TRC20",
      "logoLink": "https://static.coinall.ltd/cdn/assets/imgs/221/5F74EB20302D7761.png",
      "mainNet": false,
      "maxFee": "1.6",
      "maxWd": "9608350",
      "minDep": "0.00000001",
      "minDepArrivalConfirm": "1",
      "minFee": "0.8",
      "minWd": "2",
      "minWdUnlockConfirm": "1",
      "name": "Tether",
      "needTag": false,
      "usedWdQuota": "0",
      "wdQuota": "500",
      "wdTickSz": "3"
    }
  ]
}

Response Parameters

Parameter Type Description
ccy String Currency, e.g. BTC
name String Chinese name of currency
logoLink String Logo link of currency
chain String Chain name, e.g. USDT-ERC20, USDT-TRC20, USDT-Omni
canDep Boolean Availability to deposit from chain.
false: not available true: available
canWd Boolean Availability to withdraw to chain.
false: not available true: available
canInternal Boolean Availability to internal transfer.
false: not available true: available
minDep String Minimum deposit amount of the currency in a single transaction
minWd String Minimum withdrawal amount of the currency in a single transaction
maxWd String Maximum amount of currency withdrawal in a single transaction
wdTickSz String Withdrawal precision, indicating the number of digits after the decimal point
wdQuota String Withdrawal limit in the past 24 hours, unit in BTC
usedWdQuota String Amount of currency withdrawal used in the past 24 hours, unit in BTC
minFee String Minimum withdrawal fee
maxFee String Maximum withdrawal fee
mainNet Boolean If current chain is main net then return true, otherwise return false
needTag Boolean Whether tag/memo information is required for withdrawal
minDepArrivalConfirm String Minimum number of blockchain confirmations to acknowledge fund deposit. Account is credited after that but the deposit cannot be withdrawn
minWdUnlockConfirm String Minimum number of blockchain confirmations so that the deposit amount and be withdrawn

Get deposit address

Retrieve the deposit addresses of currencies, including previously-used addresses.

Rate Limit: 6 requests per second

Rate limit rule: UserID

HTTP Request

GET /api/v5/asset/deposit-address

Request Example

GET /api/v5/asset/deposit-address?ccy=BTC

Request Parameters

Parameter Type Required Description
ccy String Yes Currency, e.g. BTC

Response Example

{
    "code": "0",
    "data": [
        {
            "chain": "BTC-Bitcoin",
            "ctAddr": "",
            "ccy": "BTC",
            "to": "6",
            "addr": "39XNxK1Ryqgg3Bsyn6HzoqV4Xji25pNkv6",
            "selected": true
        },
        {
            "chain": "BTC-OKC",
            "ctAddr": "",
            "ccy": "BTC",
            "to": "6",
            "addr": "0x66d0edc2e63b6b992381ee668fbcb01f20ae0428",
            "selected": true
        },
        {
            "chain": "BTC-ERC20",
            "ctAddr": "5807cf",
            "ccy": "BTC",
            "to": "6",
            "addr": "0x66d0edc2e63b6b992381ee668fbcb01f20ae0428",
            "selected": true
        }
    ],
    "msg": ""
}

Response Parameters

Parameter Type Description
addr String Deposit address
tag String Deposit tag (This will not be returned if the currency does not require a tag for deposit)
memo String Deposit memo (This will not be returned if the currency does not require a payment_id for deposit)
pmtId String Deposit payment ID (This will not be returned if the currency does not require a payment_id for deposit)
addrEx Object Deposit address attachment (This will not be returned if the currency does not require this)
e.g. TONCOIN attached tag name is comment, the return will be {'comment':'123456'}
ccy String Currency, e.g. BTC
chain String Chain name, e.g. USDT-ERC20, USDT-TRC20, USDT-Omni
to String The beneficiary account
6: Funding account
selected Boolean Return true if the current deposit address is selected by the website page
ctAddr String Last 6 digits of contract address

Get deposit history

Retrieve the deposit records according to the currency, deposit status, and time range in reverse chronological order. The 100 most recent records are returned by default.

Rate Limit: 6 requests per second

Rate limit rule: UserID

HTTP Request

GET /api/v5/asset/deposit-history

Request Example


GET /api/v5/asset/deposit-history

Query deposit history from 2022-06-01 to 2022-07-01
GET /api/v5/asset/deposit-history?ccy=BTC&after=1654041600000&before=1656633600000

Request Parameters

Parameter Type Required Description
ccy String No Currency, e.g. BTC
depId String No Deposit ID
txId String No Hash record of the deposit
state String No Status of deposit
0: waiting for confirmation 1: deposit credited 2: deposit successful
after String No Pagination of data to return records earlier than the requested ts, Unix timestamp format in milliseconds, e.g. 1654041600000
before String No Pagination of data to return records newer than the requested ts, Unix timestamp format in milliseconds, e.g. 1656633600000
limit string No Number of results per request. The maximum is 100; The default is 100

Response Example

{
  "code": "0",
  "msg": "",
  "data": [
    {
      "actualDepBlkConfirm": "17",
      "amt": "135.705808",
      "ccy": "USDT",
      "chain": "USDT-TRC20",
      "depId": "34579090",
      "from": "",
      "state": "2",
      "to": "TN4hxxxxxxxxxxxizqs",
      "ts": "1655251200000",
      "txId": "16f36383292f451xxxxxxxxxxxxxxx584f3391642d988f97"
    }
  ]
}

Response Parameters

Parameter Type Description
ccy String Currency
chain String Chain name
amt String Deposit amount
from String Only the internal OKX account is returned, not the address on the blockchain.
to String Deposit address
txId String Hash record of the deposit
ts String Time that the deposit is credited, Unix timestamp format in milliseconds, e.g. 1655251200000
state String Status of deposit
0: waiting for confirmation
1: deposit credited
2: deposit successful
8: pending due to temporary deposit suspension on this crypto currency
12: account or deposit is frozen
13: sub-account deposit interception
depId String Deposit ID
actualDepBlkConfirm String Actual amount of blockchain confirm in a single deposit

Asset bills details

Query the billing record. You can get the latest 1 month historical data

Rate Limit: 6 Requests per second

Rate limit rule: UserID

HTTP Request

GET /api/v5/asset/bills

Request Example

GET /api/v5/asset/bills

GET /api/v5/asset/bills?type=1

Request Parameters

Parameter Type Required Description
ccy String No Currency
type String No Bill type
1: Deposit
2: Withdrawal
13: Canceled withdrawal
clientId String No Client-supplied ID
A combination of case-sensitive alphanumerics, all numbers, or all letters of up to 32 characters.
after String No Pagination of data to return records earlier than the requested ts, Unix timestamp format in milliseconds, e.g. 1597026383085
before String No Pagination of data to return records newer than the requested ts, Unix timestamp format in milliseconds, e.g. 1597026383085
limit String No Number of results per request. The maximum is 100. The default is 100.

Response Example

{
    "code": "0",
    "msg": "",
    "data": [{
        "billId": "12344",
        "ccy": "BTC",
        "clientId": "",
        "balChg": "2",
        "bal": "12",
        "type": "1",
        "ts": "1597026383085"
    }]
}

Response Parameters

Parameter Type Description
billId String Bill ID
ccy String Account balance currency
clientId String Client-supplied ID
balChg String Change in balance at the account level
bal String Balance at the account level
type String Bill type
ts String Creation time, Unix timestamp format in milliseconds, e.g.1597026383085

Withdrawal

Withdrawal of tokens. Sub-account does not support withdrawal.

Rate Limit: 6 requests per second

Rate limit rule: UserID

HTTP Request

POST /api/v5/asset/withdrawal

Request Example

POST /api/v5/asset/withdrawal
body
{
    "amt":"1",
    "fee":"0.0005",
    "dest":"4",
    "ccy":"BTC",
    "chain":"BTC-Bitcoin",
    "toAddr":"17DKe3kkkkiiiiTvAKKi2vMPbm1Bz3CMKw"
}

Request Parameters

Parameter Type Required Description
ccy String Yes Currency, e.g. USDT
amt String Yes Withdrawal amount
dest String Yes Withdrawal method
3: internal
4: on chain
toAddr String Yes If your dest is 4,toAddr should be a trusted crypto currency address. Some crypto currency addresses are formatted as 'address:tag', e.g. 'ARDOR-7JF3-8F2E-QUWZ-CAN7F:123456'
If your dest is 3,toAddr should be a recipient address which can be email, phone or login account name.
fee String Yes Transaction fee
chain String Optional Chain name
There are multiple chains under some currencies, such as USDT has USDT-ERC20, USDT-TRC20, and USDT-Omni.
If the parameter is not filled in, the default will be the main chain.
clientId String No Client-supplied ID
A combination of case-sensitive alphanumerics, all numbers, or all letters of up to 32 characters.

Response Example

{
    "code": "0",
    "msg": "",
    "data": [{
        "amt": "0.1",
        "wdId": "67485",
        "ccy": "BTC",
        "clientId": "",
        "chain": "BTC-Bitcoin"
    }]
}

Response Parameters

Parameter Type Description
ccy String Currency
chain String Chain name, e.g. USDT-ERC20, USDT-TRC20, USDT-Omni
amt String Withdrawal amount
wdId String Withdrawal ID
clientId String Client-supplied ID
A combination of case-sensitive alphanumerics, all numbers, or all letters of up to 32 characters.

Get withdrawal history

Retrieve the withdrawal records according to the currency, withdrawal status, and time range in reverse chronological order. The 100 most recent records are returned by default.

Rate Limit: 6 requests per second

Rate limit rule: UserID

HTTP Request

GET /api/v5/asset/withdrawal-history

Request Example


GET /api/v5/asset/withdrawal-history

Query withdrawal history from 2022-06-01 to 2022-07-01
GET /api/v5/asset/withdrawal-history?ccy=BTC&after=1654041600000&before=1656633600000

Request Parameters

Parameter Type Required Description
ccy String No Currency, e.g. BTC
wdId String No Withdrawal ID
clientId String No Client-supplied ID
A combination of case-sensitive alphanumerics, all numbers, or all letters of up to 32 characters.
txId String No Hash record of the deposit
state String No Status of withdrawal
-3: pending cancel -2: canceled -1: failed
0: pending 1:sending 2: sent
3: awaiting email verification
4: awaiting manual verification
5: awaiting identity verification
after String No Pagination of data to return records earlier than the requested ts, Unix timestamp format in milliseconds, e.g. 1654041600000
before String No Pagination of data to return records newer than the requested ts, Unix timestamp format in milliseconds, e.g. 1656633600000
limit String No Number of results per request. The maximum is 100; The default is 100

Response Example

{
  "code": "0",
  "msg": "",
  "data": [
    {
      "chain": "ETH-Ethereum",
      "fee": "0.007",
      "ccy": "ETH",
      "clientId": "",
      "amt": "0.029809",
      "txId": "0x35c******b360a174d",
      "from": "156****359",
      "to": "0xa30d1fab********7CF18C7B6C579",
      "state": "2",
      "ts": "1655251200000",
      "wdId": "15447421"
    }
  ]
}

Response Parameters

Parameter Type Description
ccy String Currency
chain String Chain name, e.g. USDT-ERC20, USDT-TRC20, USDT-Omni
amt String Token amount
ts String Time the withdrawal request was submitted, Unix timestamp format in milliseconds, e.g. 1655251200000.
from String Remitting address
User account ID will be shown for OKX addresses.
to String Receiving address
tag String Some currencies require a tag for withdrawals. This is not returned if not required.
pmtId String Some currencies require a payment ID for withdrawals. This is not returned if not required.
memo String Some currencies require this parameter for withdrawals. This is not returned if not required.
txId String Hash record of the withdrawal.
This parameter will returned "" for internal transfers.
fee String Withdrawal fee
state String Status of withdrawal
-3: pending cancel -2: canceled -1: failed
0: pending 1:sending 2: sent
3: awaiting email verification
4: awaiting manual verification
5: awaiting identity verification
wdId String Withdrawal ID
clientId String Client-supplied ID

OTC

The trust asset service will provide you with a place for custody without slippage, where the liquidity is smooth, the disposal is efficient, and it is basically unaffected by the market order.

Obtain a list of tradable token pairs

Speed limit:2/2s

HTTP request

GET /api/v5/otc/rfq/instruments

Request Example

GET /api/v5/otc/rfq/instruments

Response Example

{
    "code": "0",
    "data": [
        {
            "instruments": [
                {
                    "baseCcy": "BTC",
                    "baseSingleMin": "0.1395",
                    "instId": "BTC-HKD",
                    "quoteCcy": "HKD",
                    "quoteSingleMin": "78225.84"
                }
            ],
            "ts": "1710224803406"
        }
    ],
    "msg": ""
}

Response Parameters

Parameters Parameters types Description
ts String Data update time Unix timestamp in milliseconds, such as: 1597026383085
instruments Array List of token pairs for trading
>instId String Trading pair
>baseCcy String Base currency, such as BTC in BTC-USD, BTC in BTC-USDT
>quoteCcy String Quote currency, such as USD in BTC-USD, USDT in BTC-USDT
>baseSingleMin String Minimum transaction amount in base currency
>quoteSingleMin String Minimum transaction amount in quote currency

Query current market quotation information

Speed limit:2/2s

HTTP request

POST /api/v5/otc/rfq/quote

Request Example

POST /api/v5/otc/rfq/quote
body
{
    "baseCcy": "ETH",
    "quoteCcy": "USD",
    "side": "sell",
    "rfqSz": "0.05",
    "rfqSzCcy": "ETH",
    "clQReqId": "1709015682"
}

Request Parameters

Parameters Parameters types Required Description
baseCcy String Yes Base currency, such as BTC in BTC-USD
quoteCcy String Yes Quote currency, such as USD in BTC-USD
side String Yes Side buy:buy sell:sell Buy & sell: two_way
From the perspective of a customer, it describes the transaction side of baseCcy
rfqSz String Yes Amount
rfqSzCcy String Yes Token
clQReqId String No Client-defined RFID, order id, with only length limitation
clQReqTs String No Client rfq sending time, Unix timestamp in milliseconds.

Response Example

{
    "code": "0",
    "data": [
        {
            "askBaseSz": "0",
            "askPx": "0",
            "askQuoteSz": "0",
            "baseCcy": "ETH",
            "bidBaseSz": "0.05",
            "bidPx": "3981.2672",
            "bidQuoteSz": "199.06336",
            "clQReqId": "1709015682",
            "origRfqSz": "0.05",
            "quoteCcy": "USD",
            "quoteId": "quoternextETH-USD17103260943476811",
            "quoteTs": "1710326094347",
            "rfqSz": "0.05",
            "rfqSzCcy": "ETH",
            "side": "sell",
            "ttlMs": "15000"
        }
    ],
    "msg": ""
}

Response Parameters

Parameters Parameters types Description
quoteTs String Time of quote generation, Unix timestamp in milliseconds
ttlMs String Quote time, Unix timestamp in milliseconds
clQReqId String Client-defined RFID
quoteId String Quote ID, as the input in a transaction request
baseCcy String Base currency, such as BTC in BTC-USDT
quoteCcy String Quote currency, such as USDT in BTC-USDT
side String Side buy:buy sell:sell Buy & sell: two_way
origRfqSz String Original amount
rfqSz String Amount can be quoted
rfqSzCcy String Token can be quoted
bidPx String Bid price
bidBaseSz String The amount of baseCcy that a customer may need to pay. This field is only valid when the quotation request is Sell or TwoWay
bidQuoteSz String The amount of quoteCcy that a customer may obtain. This field is only valid when the quotation request is Sell or TwoWay
askPx String Ask price
askBaseSz String The amount of baseCcy that a customer may obtain. This field is only valid when the quotation request is Buy or TwoWay
askQuoteSz String The amount of quoteCcy that a customer may need to pay. This field is only valid when the quotation request is Buy or TwoWay

Query order

Speed limit: 2/2s

HTTP request

GET /api/v5/otc/rfq/trade

Request Example

GET/api/v5/otc/rfq/trade?tradeId=134

Request parameters

Parameters Parameters types Required Description
clTReqId String Optional Client-defined RFID
tradeId String Optional Order ID. One of clTReqId and tradeId must be filled in. If the user passes both values, only the tradeId parameter will be checked.

Response Example

{
    "code": "0",
    "data": [
        {
            "baseCcy": "ETH",
            "clQReqId": "ETHTest005",
            "filledBaseSz": "0.05",
            "filledQuoteSz": "199.06336",
            "instId": "ETH-USD",
            "px": "3981.2672",
            "quoteCcy": "USD",
            "quoteId": "quoternextETH-USD17103260943476811",
            "side": "sell",
            "state": "FullyFilled",
            "tradeId": "tradernext217103261021411004",
            "ts": "1710326102144"
        }
    ],
    "msg": ""
}

Response Parameters

Parameters Parameters types Description
ts String Unix timestamp in milliseconds
tradeId String Transaction ID
quoteId String Quotation ID returned by quotation query
clTReqId String User-defined ID
state String Order status,
PendingNew: the transaction has been created
FullyFilled: the order is completely filled
Rejected: the transaction is rejected
instId String Trading pair
baseCcy String Base currency, such as BTC in BTC-USDT
quoteCcy String Quote currency, such as USDT in BTC-USDT
side String Side buy:buy sell:sell
px String Trading price
filledBaseSz String Size of order
filledQuoteSz String Size of order

Place order

Speed limit: 2/2s

HTTP request

POST /api/v5/otc/rfq/trade

Request Example

POST /api/v5/otc/rfq/trade
body
{
    "clTReqId": "ETHTest005",
    "quoteId": "quoternextETH-USD17103260943476811",
    "baseCcy": "ETH",
    "quoteCcy": "USD",
    "side": "sell",
    "Sz": "0.05",
    "szCcy": "ETH"
}

Request parameters

Parameters Parameters types Required Description
clTReqId String Yes Client-defined RFID
clTReqTs String No Client rfq sending time, Unix timestamp in milliseconds
quoteId String Yes Quotation number returned by quotation query.
baseCcy String Yes Base currency, such as BTC in BTC-USD
quoteCcy String Yes Quote currency, such as USD in BTC-USD
side String Yes Side buy:buy sell:sell
sz String Yes Amount
szCcy String Yes Token

Response Example

{
    "code": "0",
    "data": [
        {
            "baseCcy": "ETH",
            "clQReqId": "ETHTest005",
            "filledBaseSz": "0.05",
            "filledQuoteSz": "199.06336",
            "instId": "ETH-USD",
            "px": "3981.2672",
            "quoteCcy": "USD",
            "quoteId": "quoternextETH-USD17103260943476811",
            "side": "sell",
            "state": "FullyFilled",
            "tradeId": "tradernext217103261021411004",
            "ts": "1710326102144"
        }
    ],
    "msg": ""
}

Response Parameters

Parameters Parameters types Description
ts String Unix timestamp in milliseconds
tradeId String Transaction ID
quoteId String Quotation ID returned by quotation query
clTReqId String User-defined ID
state String Order status,
PendingNew: the transaction has been created
FullyFilled: the order is completely filled
Rejected: the transaction is rejected
instId String Trading pair
baseCcy String Base currency, such as BTC in BTC-USDT
quoteCcy String Quote currency, such as USDT in BTC-USDT
side String Side buy:buy sell:sell
px String Price
filledBaseSz String Size of order
filledQuoteSz String Size of order

Query order history

Speed limit:2/2s

HTTP request

GET /api/v5/otc/rfq/history

Request Example

GET /api/v5/otc/rfq/history

Request Parameters

Parameters Parameters types Required Description
begin String No Start of trading time, Unix timestamp in milliseconds
end String No End of trading time, Unix timestamp in milliseconds.
pageSz String No Returned quantity per page, default 100
pageIdx String No Which page does it currently belong to, the default value is 0

Response Example

{
    "code": "0",
    "data": [
        {
            "pageIdx": "1",
            "totalPageCnt": "0",
            "totalRecordCnt": "1",
            "trades": [
                {
                    "baseCcy": "ETH",
                    "baseSz": "0.05",
                    "clTReqId": "ETHTest005",
                    "instId": "ETH-USD",
                    "px": "3981.2672",
                    "quoteCcy": "USD",
                    "quoteSz": "199.06336",
                    "side": "sell",
                    "tradeId": "tradernext217103261021411004",
                    "tradeTs": "1710326102000",
                    "ts": "1710326102000"
                }
            ],
            "ts": "1710327316118"
        }
    ],
    "msg": ""
}

Response Parameters

Parameters Parameters types Description
ts String Unix timestamp in milliseconds
pageIdx String Which page does it currently belong to, the default value is 0
totalPageCnt String Pages in total
totalRecordCnt String Items in total
trades Array Transaction history list
>ts String Record generation time, Unix timestamp in milliseconds
>tradeTs String Transaction ID
>tradeId String Client-defined ID
>clTReqId String Amount can be quoted
>instId String Trading pair
>side String Side buy: buy sell: sell
>px String Price
>baseCcy String Base currency, such as BTC in BTC-USDT
>baseSz String Amount of base currency
>quoteCcy String Quote currency, such as USDT in BTC-USDT
>quoteSz String Amount of quote currency