Welcome to our V5 API documentation. Okcoin provides REST and WebSocket APIs to suit your trading needs.
The V5 API is only applicable to the Unified account.
V5 API Key Creation
Please refer to my api page regarding V5 API Key creation.
Production Trading Services
The Production Trading URL:
REST: https://www.okcoin.com/
Public WebSocket: wss://real.okcoin.com:8443/ws/v5/public
Orders may not be processed in time due to network delay or busy Okcoin servers. You can configure the expiry time of the request using expTime if you want the order request to be discarded after a specific time.
If expTime is specified in the requests for Place (multiple) orders or Amend (multiple) orders, the request will not be processed if the current system time of the server is after the expTime.
You should synchronize with our system time. Use Get system time to obtain the current system time.
REST
Set the following parameters in the request header
Parameter
Type
Required
Description
expTime
String
No
Request effective deadline. Unix timestamp format in milliseconds, e.g. 1597026383085
Create an APIKey on the website before signing any requests. After creating an APIKey, keep the following information safe:
APIKey
SecretKey
Passphrase
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.
Making Requests
All private REST requests must contain the following headers:
OK-ACCESS-KEY The APIKey as a String.
OK-ACCESS-SIGN The Base64-encoded signature (see Signing Messages subsection for details).
OK-ACCESS-TIMESTAMP The UTC timestamp of your request .e.g : 2020-12-08T09:08:57.715Z
OK-ACCESS-PASSPHRASE The passphrase you specified when creating the APIKey.
Request bodies should have content type application/json and be in valid JSON format.
Signature
Signing Messages
The OK-ACCESS-SIGN header is generated as follows:
Create a prehash string of timestamp + method + requestPath + body (where + represents String concatenation).
Prepare the SecretKey.
Sign the prehash string with the SecretKey using the HMAC SHA256.
The SecretKey is generated when you create an APIKey.
Example: 22582BD0CFF14C41EDBF1AB98506286D
Trade
All Trade API endpoints require authentication.
Place order
You can place an order only if you have sufficient funds.
Rate Limit: 60 requests per 2 seconds
Spot rate limit rule: UserID + instrumentID
HTTP Request
POST /api/v5/trade/order
Request Example
place order for SPOT
POST /api/v5/trade/order
body
{
"instId":"BTC-USD",
"tdMode":"cash",
"clOrdId":"b15",
"side":"buy",
"ordType":"limit",
"px":"2.15",
"sz":"2"
}
Client Order ID as assigned by the client A combination of case-sensitive alphanumerics, all numbers, or all letters of up to 32 characters.
tag
String
No
Order tag A combination of case-sensitive alphanumerics, all numbers, or all letters of up to 16 characters.
side
String
Yes
Order side, buysell
ordType
String
Yes
Order type market: Market order limit: Limit order post_only: Post-only order fok: Fill-or-kill order ioc: Immediate-or-cancel order
sz
String
Yes
Quantity to buy or sell
px
String
Conditional
Order price. Only applicable to limit,post_only,fok,ioc order.
tgtCcy
String
No
Whether the target currency uses the quote or base currency. base_ccy: Base currency ,quote_ccy: Quote currency Only applicable to SPOT Market Orders Default is quote_ccy for buy, base_ccy for sell
banAmend
Boolean
No
Whether to disallow the system from amending the size of the SPOT Market Order. Valid options: true or false. The default value is false. If true, system will not amend and reject the market order if user does not have sufficient funds. Only applicable to SPOT Market Orders
The code of the event execution result, 0 means success.
sMsg
String
Rejection message if the request is unsuccessful.
Place multiple orders
Place orders in batches. Maximum 20 orders can be placed per request. Request parameters should be passed in the form of an array.
Rate Limit: 300 orders per 2 seconds
Spot rate limit rule: UserID + instrumentID
HTTP Request
POST /api/v5/trade/batch-orders
Request Example
batch place order for SPOT
POST /api/v5/trade/batch-orders
body
[
{
"instId":"BTC-USD",
"tdMode":"cash",
"clOrdId":"b15",
"side":"buy",
"ordType":"limit",
"px":"2.15",
"sz":"2"
},
{
"instId":"BTC-USD",
"tdMode":"cash",
"clOrdId":"b15",
"side":"buy",
"ordType":"limit",
"px":"2.15",
"sz":"2"
}
]
Request Parameters
Parameter
Type
Required
Description
instId
String
Yes
Instrument ID, e.g. BTC-USD
tdMode
String
Yes
Trade mode Non-Margin mode cash
clOrdId
String
No
Client Order ID as assigned by the client A combination of case-sensitive alphanumerics, all numbers, or all letters of up to 32 characters.
tag
String
No
Order tag A combination of case-sensitive alphanumerics, all numbers, or all letters of up to 16 characters.
side
String
Yes
Order side buysell
ordType
String
Yes
Order type market: Market order limit: Limit order post_only: Post-only order fok: Fill-or-kill order ioc: Immediate-or-cancel order
sz
String
Yes
Quantity to buy or sell
px
String
Conditional
Order price. Only applicable to limit,post_only,fok,ioc order.
tgtCcy
String
No
Order quantity unit setting for sz base_ccy: Base currency ,quote_ccy: Quote currency Only applicable to SPOT Market Orders Default is quote_ccy for buy, base_ccy for sell
banAmend
Boolean
No
Whether to disallow the system from amending the size of the SPOT Market Order. Valid options: true or false. The default value is false. If true, system will not amend and reject the market order if user does not have sufficient funds. Only applicable to SPOT Market Orders
The code of the event execution result, 0 means success.
sMsg
String
Rejection message if the request is unsuccessful.
Amend order
Amend an incomplete order.
Rate Limit: 60 requests per 2 seconds
Spot rate limit rule: UserID + instrumentID
HTTP Request
POST /api/v5/trade/amend-order
Request Example
POST /api/v5/trade/amend-order
body
{
"ordId":"2510789768709120",
"newSz":"2",
"instId":"BTC-USD"
}
Request Parameters
Parameter
Type
Required
Description
instId
String
Yes
Instrument ID
cxlOnFail
Boolean
No
Whether the order needs to be automatically canceled when the order amendment fails Valid options: false or true, the default is false.
ordId
String
Conditional
Order ID Either ordId or clOrdId is required. If both are passed, ordId will be used.
clOrdId
String
Conditional
Client Order ID as assigned by the client
reqId
String
No
Client Request ID as assigned by the client for order amendment A combination of case-sensitive alphanumerics, all numbers, or all letters of up to 32 characters. The response will include the corresponding reqId to help you identify the request if you provide it in the request.
newSz
String
Conditional
New quantity after amendment. Either newSz or newPx is required. When amending a partially-filled order, the newSz should include the amount that has been filled.
Client Request ID as assigned by the client for order amendment.
sCode
String
The code of the event execution result, 0 means success.
sMsg
String
Rejection message if the request is unsuccessful.
Amend multiple orders
Amend incomplete orders in batches. Maximum 20 orders can be amended per request. Request parameters should be passed in the form of an array.
Rate Limit: 300 orders per 2 seconds
Spot rate limit rule: UserID + instrumentID
HTTP Request
POST /api/v5/trade/amend-batch-orders
Request Example
POST /api/v5/trade/amend-batch-orders
body
[
{
"ordId":"2510789768709120",
"newSz":"2",
"instId":"BTC-USD"
},
{
"ordId":"2510789768709121",
"newSz":"2",
"instId":"BTC-USD"
}
]
Request Parameters
Parameter
Type
Required
Description
instId
String
Yes
Instrument ID
cxlOnFail
Boolean
No
Whether the order needs to be automatically canceled when the order amendment fails falsetrue, the default is false.
ordId
String
Conditional
Order ID Either ordId or clOrdIdis required, if both are passed, ordId will be used.
clOrdId
String
Conditional
Client Order ID as assigned by the client
reqId
String
No
Client Request ID as assigned by the client for order amendment A combination of case-sensitive alphanumerics, all numbers, or all letters of up to 32 characters. The response will include the corresponding reqId to help you identify the request if you provide it in the request.
newSz
String
Conditional
New quantity after amendment. Either newSz or newPx is required. When amending a partially-filled order, the newSz should include the amount that has been filled.
Order quantity unit setting for sz base_ccy: Base currency ,quote_ccy: Quote currency Only applicable to SPOT Market Orders Default is quote_ccy for buy, base_ccy for sell
ccy
String
Margin currency. Not enabled. Please disregard.
ordId
String
Order ID
clOrdId
String
Client Order ID as assigned by the client
tag
String
Order tag
px
String
Price
sz
String
Quantity to buy or sell
pnl
String
Profit and loss. Not enabled. Please disregard.
ordType
String
Order type market: Market order limit: Limit order post_only: Post-only order fok: Fill-or-kill order ioc: Immediate-or-cancel order
side
String
Order side
posSide
String
Position side. Not enabled. Please disregard.
tdMode
String
Trade mode
accFillSz
String
Accumulated fill quantity
fillPx
String
Last filled price. If none is filled, it will return 0.
tradeId
String
Last traded ID
fillSz
String
Last filled quantity
fillTime
String
Last filled time
avgPx
String
Average filled price. If none is filled, it will return 0.
state
String
State canceled live partially_filled filled
lever
String
Leverage. Not enabled. Please disregard.
tpTriggerPx
String
Take-profit trigger price.
tpTriggerPxType
String
Take-profit trigger price type. last: last price
tpOrdPx
String
Take-profit order price.
slTriggerPx
String
Stop-loss trigger price.
slTriggerPxType
String
Stop-loss trigger price type. last: last price
slOrdPx
String
Stop-loss order price.
feeCcy
String
Fee currency
fee
String
Fee and rebate It is accumulated fee charged by the platform. It is always negative, e.g. -0.01.
rebateCcy
String
Rebate currency
source
String
Order source 13:The generated limit order after the strategy order is triggered
rebate
String
Rebate amount, only applicable to spot, the reward of placing orders from the platform (rebate) given to user who has reached the specified trading level. If there is no rebate, this field is "".
category
String
Category normal
uTime
String
Update time, Unix timestamp format in milliseconds, e.g. 1597026383085
cTime
String
Creation time, Unix timestamp format in milliseconds, e.g. 1597026383085
Get order List
Retrieve all incomplete orders under the current account.
Rate Limit: 60 requests per 2 seconds
Rate limit rule: UserID
HTTP Request
GET /api/v5/trade/orders-pending
Request Example
GET /api/v5/trade/orders-pending?ordType=post_only,fok,ioc&instType=SPOT
Request Parameters
Parameter
Type
Required
Description
instType
String
No
Instrument type SPOT
instId
String
No
Instrument ID, e.g. BTC-USD
ordType
String
No
Order type market: Market order limit: Limit order post_only: Post-only order fok: Fill-or-kill order ioc: Immediate-or-cancel order
state
String
No
State live partially_filled
after
String
No
Pagination of data to return records earlier than the requested ordId
before
String
No
Pagination of data to return records newer than the requested ordId
limit
String
No
Number of results per request. The maximum is 100; The default is 100
Order quantity unit setting for sz base_ccy: Base currency ,quote_ccy: Quote currency Only applicable to SPOT Market Orders Default is quote_ccy for buy, base_ccy for sell
ccy
String
Margin currency. Not enabled. Please disregard.
ordId
String
Order ID
clOrdId
String
Client Order ID as assigned by the client
tag
String
Order tag
px
String
Price
sz
String
Quantity to buy or sell
pnl
String
Profit and loss. Not enabled. Please disregard.
ordType
String
Order type market: Market order limit: Limit order post_only: Post-only order fok: Fill-or-kill order ioc: Immediate-or-cancel order
side
String
Order side
posSide
String
Position side. Not enabled. Please disregard.
tdMode
String
Trade mode
accFillSz
String
Accumulated fill quantity
fillPx
String
Last filled price
tradeId
String
Last trade ID
fillSz
String
Last filled quantity
fillTime
String
Last filled time
avgPx
String
Average filled price. If none is filled, it will return 0.
state
String
State live partially_filled
lever
String
Leverage. Not enabled. Please disregard.
tpTriggerPx
String
Take-profit trigger price.
tpTriggerPxType
String
Take-profit trigger price type. last: last price
tpOrdPx
String
Take-profit order price.
slTriggerPx
String
Stop-loss trigger price.
slTriggerPxType
String
Stop-loss trigger price type. last: last price
slOrdPx
String
Stop-loss order price.
feeCcy
String
Fee currency
fee
String
Fee and rebate For spot, it is accumulated fee charged by the platform. It is always negative, e.g. -0.01.
rebateCcy
String
Rebate currency
source
String
Order source 13:The generated limit order after the strategy order is triggered
rebate
String
Rebate amount, only applicable to spot, the reward of placing orders from the platform (rebate) given to user who has reached the specified trading level. If there is no rebate, this field is "".
category
String
Category normal
uTime
String
Update time, Unix timestamp format in milliseconds, e.g. 1597026383085
cTime
String
Creation time, Unix timestamp format in milliseconds, e.g. 1597026383085
Get order history (last 7 days)
Retrieve the completed order data for the last 7 days, and the incomplete orders that have been canceled are only reserved for 2 hours.
Rate Limit: 40 requests per 2 seconds
Rate limit rule: UserID
HTTP Request
GET /api/v5/trade/orders-history
Request Example
GET /api/v5/trade/orders-history?ordType=post_only,fok,ioc&instType=SPOT
Request Parameters
Parameter
Type
Required
Description
instType
String
yes
Instrument type SPOT
instId
String
No
Instrument ID, e.g. BTC-USD
ordType
String
No
Order type market: market order limit: limit order post_only: Post-only order fok: Fill-or-kill order ioc: Immediate-or-cancel order
state
String
No
State canceled filled
after
String
No
Pagination of data to return records earlier than the requested ordId
before
String
No
Pagination of data to return records newer than the requested ordId
limit
String
No
Number of results per request. The maximum is 100; The default is 100
Order quantity unit setting for sz base_ccy: Base currency ,quote_ccy: Quote currency Only applicable to SPOT Market Orders Default is quote_ccy for buy, base_ccy for sell
ccy
String
Margin currency. Not enabled. Please disregard.
ordId
String
Order ID
clOrdId
String
Client Order ID as assigned by the client
tag
String
Order tag
px
String
Price
sz
String
Quantity to buy or sell
ordType
String
Order type market: market order limit: limit order post_only: Post-only order fok: Fill-or-kill order ioc: Immediate-or-cancel order
side
String
Order side
posSide
String
Position side. Not enabled. Please disregard.
tdMode
String
Trade mode
accFillSz
String
Accumulated fill quantity
fillPx
String
Last filled price. If none is filled, it will return 0.
tradeId
String
Last trade ID
fillSz
String
Last filled quantity
fillTime
String
Last filled time
avgPx
String
Average filled price. If none is filled, it will return 0.
state
String
State canceled filled
lever
String
Leverage. Not enabled. Please disregard.
tpTriggerPx
String
Take-profit trigger price.
tpTriggerPxType
String
Take-profit trigger price type. last: last price
tpOrdPx
String
Take-profit order price.
slTriggerPx
String
Stop-loss trigger price.
slTriggerPxType
String
Stop-loss trigger price type. last: last price
slOrdPx
String
Stop-loss order price.
feeCcy
String
Fee currency
fee
String
Fee and rebate For spot, it is accumulated fee charged by the platform. It is always negative, e.g. -0.01.
rebateCcy
String
Rebate currency
source
String
Order source 13:The generated limit order after the strategy order is triggered
rebate
String
Rebate amount, only applicable to spot, the reward of placing orders from the platform (rebate) given to user who has reached the specified trading level. If there is no rebate, this field is "".
pnl
String
Profit and loss. Not enabled. Please disregard.
category
String
Category normal
uTime
String
Update time, Unix timestamp format in milliseconds, e.g. 1597026383085
cTime
String
Creation time, Unix timestamp format in milliseconds, e.g. 1597026383085
Get order history (last 3 months)
Retrieve the completed order data of the last 3 months.
Rate Limit: 20 requests per 2 seconds
Rate limit rule: UserID
HTTP Request
GET /api/v5/trade/orders-history-archive
Request Example
GET /api/v5/trade/orders-history-archive?ordType=post_only,fok,ioc&instType=SPOT
Request Parameters
Parameter
Type
Required
Description
instType
String
yes
Instrument type SPOT
instId
String
No
Instrument ID, e.g. BTC-USD
ordType
String
No
Order type market: Market order limit: Limit order post_only: Post-only order fok: Fill-or-kill order ioc: Immediate-or-cancel order
state
String
No
State canceled filled
after
String
No
Pagination of data to return records earlier than the requested ordId
before
String
No
Pagination of data to return records newer than the requested ordId
limit
String
No
Number of results per request. The maximum is 100; The default is 100
Order quantity unit setting for sz base_ccy: Base currency ,quote_ccy: Quote currency Only applicable to SPOT Market Orders Default is quote_ccy for buy, base_ccy for sell
ccy
String
Margin currency. Not enabled. Please disregard.
ordId
String
Order ID
clOrdId
String
Client Order ID as assigned by the client
tag
String
Order tag
px
String
Price
sz
String
Quantity to buy or sell
ordType
String
Order type market: Market order limit: Limit order post_only: Post-only order fok: Fill-or-kill order ioc: Immediate-or-cancel order
side
String
Order side
posSide
String
Position side. Not enabled. Please disregard.
tdMode
String
Trade mode
accFillSz
String
Accumulated fill quantity
fillPx
String
Last filled price. If none is filled, it will return 0.
tradeId
String
Last trade ID
fillSz
String
Last filled quantity
fillTime
String
Last filled time
avgPx
String
Average filled price. If none is filled, it will returns 0.
state
String
State canceled filled
lever
String
Leverage. Not enabled. Please disregard.
tpTriggerPx
String
Take-profit trigger price.
tpTriggerPxType
String
Take-profit trigger price type. last: last price
tpOrdPx
String
Take-profit order price.
slTriggerPx
String
Stop-loss trigger price.
slTriggerPxType
String
Stop-loss trigger price type. last: last price
slOrdPx
String
Stop-loss order price.
feeCcy
String
Fee currency
fee
String
Fee and rebate For spot, it is accumulated fee charged by the platform. It is always negative, e.g. -0.01.
source
String
Order source 13:The generated limit order after the strategy order is triggered
rebateCcy
String
Rebate currency
rebate
String
Rebate amount, only applicable to spot, the reward of placing orders from the platform (rebate) given to user who has reached the specified trading level. If there is no rebate, this field is "".
pnl
String
Profit and loss. Not enabled. Please disregard.
category
String
Category normal
uTime
String
Update time, Unix timestamp format in milliseconds, e.g. 1597026383085
cTime
String
Creation time, Unix timestamp format in milliseconds, e.g. 1597026383085
Get transaction details (last 3 days)
Retrieve recently-filled transaction details in the last 3 day.
Rate Limit: 60 requests per 2 seconds
Rate limit rule: UserID
HTTP Request
GET /api/v5/trade/fills
Request Example
GET /api/v5/trade/fills
Request Parameters
Parameter
Type
Required
Description
instType
String
No
Instrument type SPOT
instId
String
No
Instrument ID, e.g. BTC-USD
ordId
String
No
Order ID
after
String
No
Pagination of data to return records earlier than the requested billId
before
String
No
Pagination of data to return records newer than the requested billId
begin
String
No
Filter with a begin timestamp. Unix timestamp format in milliseconds, e.g. 1597026383085
end
String
No
Filter with an end timestamp. Unix timestamp format in milliseconds, e.g. 1597026383085
limit
String
No
Number of results per request. The maximum is 100; The default is 100
POST /api/v5/trade/order-algo
body
{
"instId":"BTC-USDT",
"tdMode":"cash",
"side":"buy",
"ordType":"conditional",
"sz":"2",
"tpTriggerPx":"15",
"tpOrdPx":"18"
}
Request Parameters
Parameter
Type
Required
Description
instId
String
Yes
Instrument ID, e.g. BTC-USD
tdMode
String
Yes
Trade mode Non-Margin mode cash
side
String
Yes
Order side, buysell
ordType
String
Yes
Order type conditional: One-way stop order oco: One-cancels-the-other order trigger: Trigger order move_order_stop: Trailing order iceberg: Iceberg order twap: TWAP order
sz
String
Yes
Quantity to buy or sell
tag
String
No
Order tag A combination of case-sensitive alphanumerics, all numbers, or all letters of up to 16 characters.
tgtCcy
String
No
Order quantity unit setting for sz base_ccy: Base currency ,quote_ccy: Quote currency Only applicable to SPOT traded with Market buy conditional order Default is quote_ccy for buy, base_ccy for sell
clOrdId
String
No
Client Order ID as assigned by the client A combination of case-sensitive alphanumerics, all numbers, or all letters of up to 32 characters.
Stop Order
Parameter
Type
Required
Description
tpTriggerPx
String
No
Take-profit trigger price If you fill in this parameter, you should fill in the take-profit order price as well.
tpTriggerPxType
String
No
Take-profit trigger price type
last: last price The Default is last
tpOrdPx
String
No
Take-profit order price If you fill in this parameter, you should fill in the take-profit trigger price as well. If the price is -1, take-profit will be executed at the market price.
slTriggerPx
String
No
Stop-loss trigger price If you fill in this parameter, you should fill in the stop-loss order price.
slTriggerPxType
String
No
Stop-loss trigger price type
last: last price The Default is last
slOrdPx
String
No
Stop-loss order price If you fill in this parameter, you should fill in the stop-loss trigger price. If the price is -1, stop-loss will be executed at the market price.
Trigger Order
Parameter
Type
Required
Description
triggerPx
String
Yes
Trigger price
orderPx
String
Yes
Order Price If the price is -1, the order will be executed at the market price.
triggerPxType
String
No
Trigger price type
last: last price The Default is last
Trailing Stop Order
Parameter
Type
Required
Description
callbackRatio
String
Conditional
Callback price ratio , e.g. 0.01
Either callbackRatio or callbackSpread is allowed to be passed.
callbackSpread
String
Conditional
Callback price variance
activePx
String
No
Active price
Iceberg Order
Parameter
Type
Required
Description
pxVar
String
Conditional
Price ratio Either pxVar or pxSpread is allowed to be passed.
pxSpread
String
Conditional
Price variance
szLimit
String
Yes
Average amount
pxLimit
String
Yes
Price Limit
TWAP Order
Parameter
Type
Required
Description
pxVar
String
Conditional
Price ratio Either pxVar or pxSpread is allowed to be passed.
The code of the event execution result, 0 means success.
sMsg
String
Rejection message if the request is unsuccessful.
Cancel algo order
Cancel unfilled algo orders (not including Iceberg order, TWAP order, Trailing Stop order). A maximum of 10 orders can be canceled per request. Request parameters should be passed in the form of an array.
Rate Limit: 20 requests per 2 seconds
Spot rate limit rule: UserID + instrumentID
HTTP Request
POST /api/v5/trade/cancel-algos
Request Example
POST /api/v5/trade/cancel-algos
body
[
{
"algoId":"198273485",
"instId":"BTC-USD"
},
{
"algoId":"198273485",
"instId":"BTC-USD"
}
]
The code of the event execution result, 0 means success.
sMsg
String
Rejection message if the request is unsuccessful.
Cancel advance algo order
Cancel unfilled algo orders (including Iceberg order, TWAP order, Trailing Stop order). A maximum of 10 orders can be canceled per request. Request parameters should be passed in the form of an array.
Rate Limit: 20 requests per 2 seconds
Spot rate limit rule: UserID + instrumentID
HTTP Request
POST /api/v5/trade/cancel-advance-algos
Request Example
POST /api/v5/trade/cancel-advance-algos
body
[
{
"algoId":"198273485",
"instId":"BTC-USD"
},
{
"algoId":"198273485",
"instId":"BTC-USD"
}
]
The code of the event execution result, 0 means success.
sMsg
String
Rejection message if the request is unsuccessful.
Get algo order list
Retrieve a list of untriggered Algo orders under the current account.
Rate Limit: 20 requests per 2 seconds
Rate limit rule: UserID
HTTP Request
GET /api/v5/trade/orders-algo-pending
Request Example
GET /api/v5/trade/orders-algo-pending?ordType=conditional
Request Parameters
Parameter
Type
Required
Description
ordType
String
Yes
Order type conditional: One-way stop order oco: One-cancels-the-other order trigger: Trigger order move_order_stop: Trailing order iceberg: Iceberg order twap: TWAP order
algoId
String
No
Algo ID
clOrdId
String
No
Client Order ID as assigned by the client A combination of case-sensitive alphanumerics, all numbers, or all letters of up to 32 characters.
instType
String
No
Instrument type SPOT
instId
String
No
Instrument ID, e.g. BTC-USD
after
String
No
Pagination of data to return records earlier than the requested algoId.
before
String
No
Pagination of data to return records newer than the requested algoId.
limit
String
No
Number of results per request. The maximum is 100; The default is 100
Order quantity unit setting for sz base_ccy: Base currency ,quote_ccy: Quote currency Only applicable to SPOT traded with Market order
state
String
State,livepausepartially_effective
lever
String
Leverage. Not enabled. Please disregard.
tpTriggerPx
String
Take-profit trigger price
tpTriggerPxType
String
Take-profit trigger price type. last: last price
tpOrdPx
String
Take-profit order price
slTriggerPx
String
Stop-loss trigger price
slTriggerPxType
String
Stop-loss trigger price type. last: last price
slOrdPx
String
Stop-loss order price
triggerPx
String
Trigger price
triggerPxType
String
Trigger price type. last: last price
ordPx
String
Order price
actualSz
String
Actual order quantity
tag
String
Order tag
actualPx
String
Actual order price
actualSide
String
Actual trigger side tp: take profit sl: stop loss
triggerTime
String
Trigger time, Unix timestamp format in milliseconds, e.g. 1597026383085
pxVar
String
Price ratio Only applicable to iceberg order or twap order
pxSpread
String
Price variance Only applicable to iceberg order or twap order
szLimit
String
Average amount Only applicable to iceberg order or twap order
pxLimit
String
Price Limit Only applicable to iceberg order or twap order
timeInterval
String
Time interval Only applicable to twap order
callbackRatio
String
Callback price ratio Only applicable to move_order_stop order
callbackSpread
String
Callback price variance Only applicable to move_order_stop order
activePx
String
Active price Only applicable to move_order_stop order
moveTriggerPx
String
Trigger price Only applicable to move_order_stop order
cTime
String
Creation time, Unix timestamp format in milliseconds, e.g. 1597026383085
Get algo order history
Retrieve a list of all algo orders under the current account in the last 3 months.
Rate Limit: 20 requests per 2 seconds
Rate limit rule: UserID
HTTP Request
GET /api/v5/trade/orders-algo-history
Request Example
GET /api/v5/trade/orders-algo-history?state=effective&ordType=conditional
Request Parameters
Parameter
Type
Required
Description
ordType
String
Yes
Order type conditional: One-way stop order oco: One-cancels-the-other order trigger: Trigger order move_order_stop: Trailing order iceberg: Iceberg order twap: TWAP order
state
String
Conditional
State effective canceled order_failed Either state or algoId is requied
algoId
String
Conditional
Algo ID Either state or algoId is required.
instType
String
No
Instrument type SPOT
instId
String
No
Instrument ID, e.g. BTC-USD
after
String
No
Pagination of data to return records earlier than the requested algoId
before
String
No
Pagination of data to return records new than the requested algoId
limit
String
No
Number of results per request. The maximum is 100; The default is 100
Order quantity unit setting for sz base_ccy: Base currency ,quote_ccy: Quote currency Only applicable to SPOT Market Orders Default is quote_ccy for buy, base_ccy for sell
state
String
State effective canceled order_failed
lever
String
Leverage. Not enabled. Please disregard.
tpTriggerPx
String
Take-profit trigger price.
tpTriggerPxType
String
Take-profit trigger price type. last: last price
tpOrdPx
String
Take-profit order price.
slTriggerPx
String
Stop-loss trigger price.
slTriggerPxType
String
Stop-loss trigger price type. last: last price
slOrdPx
String
Stop-loss order price.
triggerPx
String
trigger price.
triggerPxType
String
trigger price type. last: last price
ordPx
String
Order price
actualSz
String
Actual order quantity
actualPx
String
Actual order price
tag
String
Order tag
actualSide
String
Actual trigger side, tp: take profit sl: stop loss
triggerTime
String
Trigger time, Unix timestamp format in milliseconds, e.g. 1597026383085
pxVar
String
Price ratio Only applicable to iceberg order or twap order
pxSpread
String
Price variance Only applicable to iceberg order or twap order
szLimit
String
Average amount Only applicable to iceberg order or twap order
pxLimit
String
Price Limit Only applicable to iceberg order or twap order
timeInterval
String
Time interval Only applicable to twap order
callbackRatio
String
Callback price ratio Only applicable to move_order_stop order
callbackSpread
String
Callback price variance Only applicable to move_order_stop order
activePx
String
Active price Only applicable to move_order_stop order
moveTriggerPx
String
Trigger price Only applicable to move_order_stop order
cTime
String
Creation time Unix timestamp format in milliseconds, e.g. 1597026383085
Funding
The API endpoints of Funding require authentication.
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.
Unix timestamp format in milliseconds, e.g.1597026383085
details
Array
Asset valuation details for each account
> funding
String
Funding account
> trading
String
Unified account
> classic
String
Classic account
> earn
String
Earn account
Funds transfer
Only API keys with Trade privilege can call this endpoint.
This endpoint supports the transfer of funds between your funding account and trading account, and from the master account to sub-accounts.
Rate Limit: 1 request per second
Rate limit rule: UserID + Currency
HTTP Request
POST /api/v5/asset/transfer
Request Example
Transfer 1.5 USD from funding account to Trading account when current account is master-account
POST /api/v5/asset/transfer
body
{
"ccy":"USD",
"amt":"1.5",
"from":"6",
"to":"18"
}
Transfer 1.5 USD from funding account to subAccount when current account is master-account
POST /api/v5/asset/transfer
body
{
"ccy":"USD",
"type":"1",
"amt":"1.5",
"from":"6",
"to":"6",
"subAcct":"mini"
}
Name of the sub-account When type is 1 or 2, sub-account is required.
type
String
No
Transfer type 0: transfer within account 1: master account to sub-account (Only applicable to APIKey from master account) 2: sub-account to master account (Only applicable to APIKey from master account) 3: sub-account to master account (Only applicable to APIKey from sub-account) The default is 0.
clientId
String
No
Client-supplied ID A combination of case-sensitive alphanumerics, all numbers, or all letters of up to 32 characters.
Retrieve the transfer state data of the last 2 weeks.
Rate Limit: 1 request per second
Rate limit rule: UserID
HTTP Request
GET /api/v5/asset/transfer-state
Request Example
GET /api/v5/asset/transfer-state?transId=1&type=1
Request Parameters
Parameter
Type
Required
Description
transId
String
Conditional
Transfer ID Either transId or clientId is required. If both are passed, transId will be used.
clientId
String
Conditional
Client-supplied ID A combination of case-sensitive alphanumerics, all numbers, or all letters of up to 32 characters.
type
String
No
Transfer type 0: transfer within account 1: master account to sub-account (Only applicable to APIKey from master account) 2: sub-account to master account (Only applicable to APIKey from master account) 3: sub-account to master account (Only applicable to APIKey from sub-account) The default is 0
Transfer type 0: transfer within account 1: master account to sub-account (Only applicable to APIKey from master account) 2: sub-account to master account (Only applicable to APIKey from master account) 3: sub-account to master account (Only applicable to APIKey from sub-account)
from
String
The remitting account 6: Funding account 18: Unified account
to
String
The beneficiary account 6: Funding account 18: Unified account
subAcct
String
Name of the sub-account
instId
String
deprecated
toInstId
String
deprecated
state
String
Transfer state success, pending, failed
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 20: Transfer to sub account 21: Transfer from sub account 22: Transfer out from sub to master account 23: Transfer in from master to sub account 37: Transfer to spot 38: Transfer from spot
clientId
String
No
Client-supplied ID for transfer or withdrawal 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.
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 18: Trading 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
type
String
No
Deposit Type 3: internal transfer 4: deposit from chain
state
String
No
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
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
Only the internal Okcoin 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
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. USD
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
Conditional
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.
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.
Lightning withdrawals
The maximum withdrawal amount is 0.1 BTC per request, and 1 BTC in 24 hours. The minimum withdrawal amount is approximately 0.000001 BTC. Sub-account does not support withdrawal.
Rate Limit: 2 requests per second
Rate limit rule: UserID
HTTP Request
POST /api/v5/asset/withdrawal-lightning
Request Example
POST /api/v5/asset/withdrawal-lightning
body
{
"ccy":"BTC",
"invoice":"lnbc100u1psnnvhtpp5yq2x3q5hhrzsuxpwx7ptphwzc4k4wk0j3stp0099968m44cyjg9sdqqcqzpgxqzjcsp5hz"
}
You can cancel normal withdrawal requests, but you cannot cancel withdrawal requests on Lightning.
Rate Limit: 6 requests per second
Rate limit rule: UserID
HTTP Request
POST /api/v5/asset/cancel-withdrawal
Request Example
POST /api/v5/asset/cancel-withdrawal
body {
"wdId":"1123456"
}
Request Parameters
Parameter
Type
Required
Description
wdId
String
Yes
Withdrawal ID
Response Example
{"code":"0","msg":"","data":[{"wdId":"1123456"}]}
Response Parameters
Parameter
Type
Description
wdId
String
Withdrawal ID
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
type
String
No
Withdrawal type 3: internal transfer 4: withdrawal to chain
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
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 Okcoin 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.
addrEx
Object
Withdrawal 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'}
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
Account
The API endpoints of Account require authentication.
Get balance
Retrieve a list of assets (with non-zero balance), remaining balance, and available amount in the trading account.
Rate Limit: 10 requests per 2 seconds
Rate limit rule: UserID
HTTP Requests
GET /api/v5/account/balance
Request Example
Get the balance of all assets in the account
GET /api/v5/account/balance
Get the balance of BTC and ETH assets in the account
GET /api/v5/account/balance?ccy=BTC,ETH
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.
Update time of account information, millisecond format of Unix timestamp, e.g. 1597026383085
totalEq
String
Total equity in USD
isoEq
String
Isolated margin equity in USD. Not enabled. Please disregard.
adjEq
String
Adjusted / Effective equity in USD . Not enabled. Please disregard.
ordFroz
String
Cross margin frozen for pending orders in USD. Not enabled. Please disregard.
imr
String
Frozen equity for open positions and pending orders in USD. Not enabled. Please disregard.
mmr
String
Maintenance margin requirement in USD. Not enabled. Please disregard.
mgnRatio
String
Margin ratio in USD. Not enabled. Please disregard.
notionalUsd
String
Notional value of positions in USD. Not enabled. Please disregard.
details
Array
Detailed asset information in all currencies
> ccy
String
Currency
> eq
String
Equity of the currency
> cashBal
String
Cash balance
> uTime
String
Update time of currency balance information, Unix timestamp format in milliseconds, e.g. 1597026383085
> isoEq
String
Isolated margin equity of the currency. Not enabled. Please disregard.
> availEq
String
Available equity of the currency . Not enabled. Please disregard.
> disEq
String
Discount equity of the currency in USD.
> availBal
String
Available balance of the currency
> frozenBal
String
Frozen balance of the currency
> ordFrozen
String
Margin frozen for open orders
> liab
String
Liabilities of the currency. Not enabled. Please disregard.
> upl
String
Unrealized profit and loss of the currency. Not enabled. Please disregard.
> uplLiab
String
Liabilities due to Unrealized loss of the currency. Not enabled. Please disregard.
> crossLiab
String
Cross liabilities of the currency. Not enabled. Please disregard.
> isoLiab
String
Isolated liabilities of the currency. Not enabled. Please disregard.
> mgnRatio
String
Margin ratio of the currency. Not enabled. Please disregard.
> interest
String
Interest of the currency. Not enabled. Please disregard.
> twap
String
Risk indicator of auto liability repayment. Not enabled. Please disregard.
> maxLoan
String
Max loan of the currency. Not enabled. Please disregard.
> eqUsd
String
Equity in USD of the currency
> notionalLever
String
Leverage of the currency. Not enabled. Please disregard.
> stgyEq
String
Strategy equity
> isoUpl
String
Isolated unrealized profit and loss of the currency. Not enabled. Please disregard.
> spotInUseAmt
String
Spot in use amount. Not enabled. Please disregard.
Distribution of applicable fields are as follows:
Parameters
Simple
uTime
Yes
totalEq
Yes
isoEq
adjEq
ordFroz
imr
mmr
mgnRatio
notionalUsd
details
> ccy
Yes
> eq
Yes
> cashBal
Yes
> uTime
Yes
> isoEq
> availEq
> disEq
Yes
> availBal
Yes
> frozenBal
Yes
> ordFrozen
Yes
> liab
> upl
> uplLiab
> crossLiab
> isoLiab
> mgnRatio
> interest
> twap
> maxLoan
> eqUsd
Yes
> notionalLever
> stgyEq
Yes
> isoUpl
Get bills details (last 7 days)
Retrieve the bills of the account. The bill refers to all transaction records that result in changing the balance of an account. Pagination is supported, and the response is sorted with the most recent first. This endpoint can retrieve data from the last 7 days.
Rate Limit: 6 requests per second
Rate limit rule: UserID
HTTP Request
GET /api/v5/account/bills
Request Example
GET /api/v5/account/bills
Request Parameters
Parameter
Type
Required
Description
instType
String
No
Instrument type SPOT
ccy
String
No
Bill currency
type
String
No
Bill type 1: Transfer 2: Trade
subType
String
No
Bill subtype 1: Buy 2: Sell 11: Transfer in 12: Transfer out
after
String
No
Pagination of data to return records earlier than the requested bill ID.
before
String
No
Pagination of data to return records newer than the requested bill ID.
begin
String
No
Filter with a begin timestamp. Unix timestamp format in milliseconds, e.g. 1597026383085
end
String
No
Filter with an end timestamp. Unix timestamp format in milliseconds, e.g. 1597026383085
limit
String
No
Number of results per request. The maximum is 100. The default is 100.
Creation time, Unix timestamp format in milliseconds, e.g.1597026383085
balChg
String
Change in balance amount at the account level
posBalChg
String
Change in balance amount at the position level. Not enabled. Please disregard.
bal
String
Balance at the account level
posBal
String
Balance at the position level. Not enabled. Please disregard.
sz
String
Quantity
ccy
String
Account balance currency
pnl
String
Profit and loss. Not enabled. Please disregard.
fee
String
Fee Negative number represents the user transaction fee charged by the platform. Positive number represents rebate.
mgnMode
String
Margin mode. Not enabled. Please disregard.
instId
String
Instrument ID, e.g. BTC-USD
ordId
String
Order ID When bill type is not trade, the field returns ""
execType
String
Liquidity taker or maker, T:taker M:maker
from
String
The remitting account 6: FUNDING 18: Trading account Only applicable to transfer. When bill type is not transfer, the field returns "".
to
String
The beneficiary account 6: FUNDING 18: Trading account Only applicable to transfer. When bill type is not transfer, the field returns "".
notes
String
Notes Only applicable to transfer. When bill type is not transfer, the field returns "".
Get bills details (last 3 months)
Retrieve the account’s bills. The bill refers to all transaction records that result in changing the balance of an account. Pagination is supported, and the response is sorted with most recent first. This endpoint can retrieve data from the last 3 months.
Rate Limit: 6 requests per second
Rate limit rule: UserID
HTTP Request
GET /api/v5/account/bills-archive
Request Example
GET /api/v5/account/bills-archive
Request Parameters
Parameter
Type
Required
Description
instType
String
No
Instrument type SPOT
ccy
String
No
Bill currency
type
String
No
Bill type 1: Transfer 2: Trade
subType
String
No
Bill subtype 1: Buy 2: Sell 11: Transfer in 12: Transfer out
after
String
No
Pagination of data to return records earlier than the requested bill ID.
before
String
No
Pagination of data to return records newer than the requested bill ID.
begin
String
No
Filter with a begin timestamp. Unix timestamp format in milliseconds, e.g. 1597026383085
end
String
No
Filter with an end timestamp. Unix timestamp format in milliseconds, e.g. 1597026383085
limit
String
No
Number of results per request. The maximum is 100. The default is 100.
Whether to borrow coins automatically. Not enabled. Please disregard.
greeksType
String
Current display type of Greeks. Not enabled. Please disregard.
level
String
The user level of the current real trading volume on the platform, e.g Lv1
levelTmp
String
Temporary experience user level of special users. Not enabled. Please disregard.
ctIsoMode
String
Contract isolated margin trading settings. Not enabled. Please disregard.
mgnIsoMode
String
Margin isolated margin trading settings. Not enabled. Please disregard.
spotOffsetType
String
Risk offset type. Not enabled. Please disregard.
The following table is the relation between the level value and tier displayed on the website
level value
Tier displayed on the website
Lv1~Lv5
P0
VIP1
P1
VIP2
P2
VIP3
P3
VIP4
P4
VIP5
P5
VIP6
P6
VIP7
P7
VIP8
P8
VIP9
P9
VIP10
P10
Get maximum buy/sell amount or open amount
Rate Limit: 20 requests per 2 seconds
Rate limit rule: UserID
HTTP Request
GET /api/v5/account/max-size
Request Example
GET /api/v5/account/max-size?instId=BTC-USD&tdMode=cash
Request Parameters
Parameter
Type
Required
Description
instId
String
Yes
Single instrument or multiple instruments (no more than 5) separated with comma, e.g. BTC-USD
tdMode
String
Yes
Trade mode cash
px
String
No
Price When the price is not specified, it will be calculated according to the last traded price. The parameter will be ignored when multiple instruments are specified.
Taker fee rate of USDT-margined contracts. Not enabled. Please disregard.
makerU
String
Maker fee rate of USDT-margined contracts. Not enabled. Please disregard.
delivery
String
Delivery fee rate. Not enabled. Please disregard.
exercise
String
Fee rate for exercising the option. Not enabled. Please disregard.
instType
String
Instrument type
takerUSDC
String
Taker fee rate for the USDC trading pairs. Not enabled. Please disregard.
makerUSDC
String
Maker fee rate for the USDC trading pairs. Not enabled. Please disregard.
ts
String
Data return time, Unix timestamp format in milliseconds, e.g. 1597026383085
category
String
Currency category. Note: this parameter is already deprecated
The following table is the relation between the level value and tier displayed on the website
level value
Tier displayed on the website
Lv1~Lv5
P0
VIP1
P1
VIP2
P2
VIP3
P3
VIP4
P4
VIP5
P5
VIP6
P6
VIP7
P7
VIP8
P8
VIP9
P9
VIP10
P10
Get maximum withdrawals
Retrieve the maximum transferable amount from trading account to funding account. If no currency is specified, the transferable amount of all owned currencies will be returned.
Rate Limit: 20 requests per 2 seconds
Rate limit rule: UserID
HTTP Request
GET /api/v5/account/max-withdrawal
Request Example
GET /api/v5/account/max-withdrawal
Request Parameters
Parameter
Type
Required
Description
ccy
String
No
Single currency or multiple currencies (no more than 20) separated with comma, e.g. BTC or BTC,ETH.
Deposit history query requests can be filtered by the different elements, such as channels, deposit status, and currencies. Paging is also available during query and is stored in reverse order based on the transaction time, with the latest one at the top.
Rate Limit: 6 requests per second
Rate limit rule: UserID
HTTP Request
GET api/v5/fiat/deposit-history
Request Example
GET api/v5/fiat/deposit-history?after=1515&chanId=3&status=0
Request Parameters
Parameter
Type
Required
Description
chanId
String
No
Channel ID used in the transaction. 9:PrimeX; 28:PrimeX US; 21:PrimeX Europe; 3:Silvergate SEN; 27:Silvergate SEN HK; 24:ACH
ccy
String
No
What currency the deposit was made in. USDEURSGD
state
String
No
Deposit state. -2:User canceled the order;-1:Deposit attempt has failed; 0:Deposit request submitted; 1:Deposit request is pending; 2:Deposit has been credited
depId
String
No
Deposit ID used in the transaction
after
String
No
If requesting the page content (previous data) prior to this ID, the value given will be the billId of the corresponding interface.
before
String
No
If requesting the page content (updated data) followed by this ID, the value given will be the billId of the corresponding interfac
limit
String
No
The maximum number of result sets returned by paginations is 100, if not filled in, 100 will be returned by default.
Deposit state. -2:User canceled the order;-1:Deposit attempt has failed; 0:Deposit request submitted; 1:Deposit request is pending; 2:Deposit has been credited
ccy
String
What currency the deposit was made in - USD, EUR, SGD
cTime
String
When the request was created, e.g.1637566660769
uTime
String
When the request was last updated, e.g.1637566660770
Withdrawal
Use GET and POST endpoints to make deposits with PrimeX and SEN to OKCoin accounts.
Rate Limit: 6 requests per second
Rate limit rule: UserID
HTTP Request
POST /api/v5/fiat/withdrawal
Request Example
POST /api/v5/fiat/withdrawal
body {
"chanId": "3",
"bankAcctNum": "hahawang",
"amt": "10"
}
Request Parameters
Parameter
Type
Required
Description
chanId
String
Yes
Channel ID. 9:PrimeX; 28:PrimeX US; 21:PrimeX Europe; 3:Silvergate SEN; 27:Silvergate SEN HK
amt
String
Yes
Amount to withdraw
bankAcctNum
String
Yes
The number of the account linked to the channel. Use GET v5/fiat/channel to get the number, or input it manually.
GET /api/v5/fiat/withdrawal-history?before=360&chanId=3
Request Parameters
Parameter
Type
Required
Description
chanId
String
No
Channel ID used in the transaction. 9:PrimeX; 28:PrimeX US; 21:PrimeX Europe; 3:Silvergate SEN; 27:Silvergate SEN HK
ccy
String
No
What currency the withdrawal was made in. USDEURSGD
state
String
No
Withdrawal state. -2:User canceled the order;-1:Withdrawal attempt has failed; 0:Withdrawal request submitted; 1:Withdrawal request is pending; 2:Withdrawal has been credited
wdId
String
No
Withdrawal request ID. Same as the ID on the withdrawal history page.
after
String
No
If requesting the page content (previous data) prior to this ID, the value given will be the billId of the corresponding interface.
before
String
No
If requesting the page content (updated data) followed by this ID, the value given will be the billId of the corresponding interfac
limit
String
No
The maximum number of result sets returned by paginations is 100, if not filled in, 100 will be returned by default.
Withdrawal state. -2:User canceled the order;-1:Withdrawal attempt has failed; 0:Withdrawal request submitted; 1:Withdrawal request is pending; 2:Withdrawal has been credited
ccy
String
What currency the withdrawal was made in - USD, EUR, SGD
cTime
String
When the request was created, e.g.1637566660769
uTime
String
When the request was last updated, e.g.1637566660770
Get channel info
Rate Limit: 6 requests per second
Rate limit rule: UserID
HTTP Request
GET /api/v5/fiat/channel
Request Example
GET /api/v5/fiat/channel
Request Parameters
Parameter
Type
Required
Description
chanId
String
No
Channel ID used in the transaction. 9:PrimeX; 28:PrimeX US; 21:PrimeX Europe; 3:Silvergate SEN; 27:Silvergate SEN HK; 24:ACH
Retrieve the candlestick charts. This endpoint can retrieve the latest 1,440 data entries. Charts are returned in groups based on the requested bar.
Rate Limit: 40 requests per 2 seconds
Rate limit rule: IP
HTTP Request
GET /api/v5/market/candles
Request Example
GET /api/v5/market/candles?instId=BTC-USD
Request Parameters
Parameter
Type
Required
Description
instId
String
Yes
Instrument ID, e.g. BTC-USD
bar
String
No
Bar size, the default is 1m e.g. [1m/3m/5m/15m/30m/1H/2H/4H] Hong Kong time opening price k-line:[6H/12H/1D/2D/3D/1W/1M/3M] UTC time opening price k-line:[/6Hutc/12Hutc/1Dutc/2Dutc/3Dutc/1Wutc/1Mutc/3Mutc]
after
String
No
Pagination of data to return records earlier than the requested ts
before
String
No
Pagination of data to return records newer than the requested ts
limit
String
No
Number of results per request. The maximum is 300. The default is 100.
Opening time of the candlestick, Unix timestamp format in milliseconds, e.g. 1597026383085
o
String
Open price
h
String
highest price
l
String
Lowest price
c
String
Close price
vol
String
Trading volume, the value is the quantity in base currency.
volCcy
String
Trading volume, the value is the quantity in quote currency.
volCcyQuote
String
Trading volume, the value is the quantity in quote currency. Not enabled. Please disregard.
confirm
String
The state of candlesticks. 0 represents that it is uncompleted, 1 represents that it is completed.
Get candlesticks history
Retrieve history candlestick charts from recent years.
Rate Limit: 20 requests per 2 seconds
Rate limit rule: IP
HTTP Request
GET /api/v5/market/history-candles
Request Example
GET /api/v5/market/history-candles?instId=BTC-USD
Request Parameters
Parameter
Type
Required
Description
instId
String
Yes
Instrument ID, e.g. BTC-USD
after
String
No
Pagination of data to return records earlier than the requested ts
before
String
No
Pagination of data to return records newer than the requested ts
bar
String
No
Bar size, the default is 1m e.g. [1m/3m/5m/15m/30m/1H/2H/4H] Hong Kong time opening price k-line:[6H/12H/1D/2D/3D/1W/1M/3M] UTC time opening price k-line:[6Hutc/12Hutc/1Dutc/2Dutc/3Dutc/1Wutc/1Mutc/3Mutc]
limit
String
No
Number of results per request. The maximum is 100. The default is 100.
ABI-encoded values [kind, timestamp, key, value], where kind equals 'prices', timestamp is the time when price was obtained, key is the asset ticker (e.g. btc) and value is the asset price.
prices
String
Readable asset prices
signatures
String
Ethereum-compatible ECDSA signatures for each message
timestamp
String
Time of latest datapoint, Unix timestamp, e.g. 1597026387
Get exchange rate
This interface provides the average exchange rate data for 2 weeks
Rate Limit: 1 request per 2 seconds
Rate limit rule: IP
HTTP Request
GET /api/v5/market/exchange-rate
Request Example
GET /api/v5/market/exchange-rate
Response Example
{"code":"0","msg":"","data":[{"usdCny":"6.44"}]}
Response Parameters
Parameter
Type
Description
usdCny
String
Exchange rate
Public data
The API endpoints of Public Data do not require authentication.
Get instruments
Retrieve a list of instruments with open contracts.
System time, Unix timestamp format in milliseconds, e.g. 1597026383085
Status
Get event status of system upgrade
Rate Limit: 1 request per 5 seconds
HTTP Requests
GET /api/v5/system/status
Request Example
GET /api/v5/system/status
GET /api/v5/system/status?state=canceled
Request Parameters
Parameters
Types
Required
Description
state
String
No
System maintenance status,scheduled: waiting; ongoing: processing; pre_open: pre_open; completed: completed ;canceled: canceled. Generally, pre_open last about 10 minutes. There will be pre_open when the time of upgrade is too long. If this parameter is not filled, the data with status scheduled, ongoing and pre_open will be returned by default
Response Example
{"code":"0","msg":"","data":[{"title":"Spot System Upgrade","state":"scheduled","begin":"1620723600000","end":"1620724200000","href":"","serviceType":"1","system":"classic","scheDesc":""}]}
Response Parameters
Parameters
Types
Description
title
String
The title of system maintenance instructions
state
String
System maintenance status
begin
String
Begin time of system maintenance, Unix timestamp format in milliseconds, e.g. 1617788463867
end
String
Time of resuming trading totally. Unix timestamp format in milliseconds, e.g. 1617788463867. It is expected end time before completed, changed to actual end time after completed.
preOpenBegin
String
The time of pre_open. Canceling orders, placing Post Only orders, and transferring funds to trading accounts are back after preOpenBegin.
href
String
Hyperlink for system maintenance details, if there is no return value, the default value will be empty. e.g. “”
Rescheduled description, e.g. Rescheduled from 2021-01-26T16:30:00.000Z to 2021-01-28T16:30:00.000Z
WebSocket API
Overview
WebSocket is a new HTML5 protocol that achieves full-duplex data transmission between the client and server, allowing data to be transferred effectively in both directions. A connection between the client and server can be established with just one handshake. The server will then be able to push data to the client according to preset rules. Its advantages include:
The WebSocket request header size for data transmission between client and server is only 2 bytes.
Either the client or server can initiate data transmission.
There's no need to repeatedly create and delete TCP connections, saving resources on bandwidth and server.
Connect
Connection instructions:
Connection limit: 1 request per second
When subscribing to a public channel, use the address of the public service. When subscribing to a private channel, use the address of the private service
Subscription limit: 240 times per hour
Login
Rate Limit: 1 request per second Applicable to single-account login
Rate Limit: 1 request per 15 seconds Applicable to multi-account batch login
api_key: Unique identification for invoking API. Requires user to apply one manually.
passphrase: APIKey password
timestamp: the Unix Epoch time, the unit is seconds
sign: signature string, the signature algorithm is as follows:
First concatenate timestamp, method, requestPath, strings, then use HMAC SHA256 method to encrypt the concatenated string with SecretKey, and then perform Base64 encoding.
secretKey: The security key generated when the user applies for APIKey, e.g. : 22582BD0CFF14C41EDBF1AB98506286D
Example of timestamp: const timestamp = '' + Date.now() / 1,000
Among sign example: sign=CryptoJS.enc.Base64.stringify(CryptoJS.HmacSHA256(timestamp +'GET'+'/users/self/verify', secretKey))
method: always 'GET'.
requestPath : always '/users/self/verify'
Subscribe
Subscription Instructions
Request format description
{"op":"subscribe","args":["<SubscriptionTopic>"]}
WebSocket channels are divided into two categories: public and private channels.
Public channels -- No authentication is required, include tickers channel, K-Line channel, limit price channel, order book channel, and mark price channel etc.
Private channels -- including account channel, order channel, and position channel, etc -- require log in.
Users can choose to subscribe to one or more channels, and the total length of multiple channels cannot exceed 4,096 bytes.
Unique identifier of the message Provided by client. It will be returned in response message for identifying the corresponding request. A combination of case-sensitive alphanumerics, all numbers, or all letters of up to 32 characters.
op
String
Yes
Operation, e.g. order
args
Array
Yes
Request parameters
> instId
String
Yes
Instrument ID,e.g. BTC-USD
> tdMode
String
Yes
Trade mode Non-Margin mode cash
> clOrdId
String
No
Client Order ID as assigned by the client A combination of case-sensitive alphanumerics, all numbers, or all letters of up to 32 characters.
> tag
String
No
Order tag A combination of case-sensitive alphanumerics, all numbers, or all letters of up to 16 characters.
> side
String
Yes
Order side, buysell
> ordType
String
Yes
Order type market: market order limit: limit order post_only: Post-only order fok: Fill-or-kill order ioc: Immediate-or-cancel order
> sz
String
Yes
Quantity to buy or sell.
> px
String
Conditional
Order price Only applicable to limit,post_only,fok,ioc order.
> tgtCcy
String
No
Order quantity unit setting for sz base_ccy: Base currency ,quote_ccy: Quote currency Only applicable to SPOT Market Orders Default is quote_ccy for buy, base_ccy for sell
> banAmend
Boolean
No
Whether to disallow the system from amending the size of the SPOT Market Order. Valid options: true or false. The default value is false. If true, system will not amend and reject the market order if user does not have sufficient funds. Only applicable to SPOT Market Orders
expTime
String
No
Request effective deadline. Unix timestamp format in milliseconds, e.g. 1597026383085
Unique identifier of the message Provided by client. It will be returned in response message for identifying the corresponding request. A combination of case-sensitive alphanumerics, all numbers, or all letters of up to 32 characters.
op
String
Yes
Operation, e.g. batch-orders
args
Array
Yes
Request Parameters
> instId
String
Yes
Instrument ID, e.g. BTC-USDT
> tdMode
String
Yes
Trade mode Non-Margin mode cash
> clOrdId
String
No
Client Order ID as assigned by the client A combination of case-sensitive alphanumerics, all numbers, or all letters of up to 32 characters.
> tag
String
No
Order tag A combination of case-sensitive alphanumerics, all numbers, or all letters of up to 16 characters.
> side
String
Yes
Order side, buysell
> ordType
String
Yes
Order type market: market order limit: limit order post_only: Post-only order fok: Fill-or-kill order ioc: Immediate-or-cancel order
> sz
String
Yes
Quantity to buy or sell.
> px
String
Conditional
Price Only applicable to limit,post_only,fok,ioc order.
> tgtCcy
String
No
Order quantity unit setting for sz base_ccy: Base currency ,quote_ccy: Quote currency Only applicable to SPOT Market Orders Default is quote_ccy for buy, base_ccy for sell
> banAmend
Boolean
No
Whether to disallow the system from amending the size of the SPOT Market Order. Valid options: true or false. The default value is false. If true, system will not amend and reject the market order if user does not have sufficient funds. Only applicable to SPOT Market Orders
expTime
String
No
Request effective deadline. Unix timestamp format in milliseconds, e.g. 1597026383085
Unique identifier of the message Provided by client. It will be returned in response message for identifying the corresponding request. A combination of case-sensitive alphanumerics, all numbers, or all letters of up to 32 characters.
op
String
Yes
Operation, e.g. cancel-order
args
Array
Yes
Request Parameters
> instId
String
Yes
Instrument ID
> ordId
String
Conditional
Order ID Either ordId or clOrdId is required, if both are passed, ordId will be used
> clOrdId
String
Conditional
Client Order ID as assigned by the client A combination of case-sensitive alphanumerics, all numbers, or all letters of up to 32 characters.
Unique identifier of the message Provided by client. It will be returned in response message for identifying the corresponding request. A combination of case-sensitive alphanumerics, all numbers, or all letters of up to 32 characters.
op
String
Yes
Operation, e.g. batch-cancel-orders
args
Array
Yes
Request Parameters
> instId
String
Yes
Instrument ID
> ordId
String
Conditional
Order ID Either ordId or clOrdId is required, if both are passed, ordId will be used
> clOrdId
String
Conditional
Client Order ID as assigned by the client A combination of case-sensitive alphanumerics, all numbers, or all letters of up to 32 characters.
{"id":"1515","op":"batch-cancel-orders","data":[{"clOrdId":"oktswap6","ordId":"2517748157541376","sCode":"0","sMsg":""},{"clOrdId":"oktswap7","ordId":"2517748155771904","sCode":"5XXXX","sMsg":"order not exist"}],"code":"2","msg":""}
Response Example When All Failed
{"id":"1515","op":"batch-cancel-orders","data":[{"clOrdId":"oktswap6","ordId":"2517748157541376","sCode":"5XXXX","sMsg":"order not exist"},{"clOrdId":"oktswap7","ordId":"2517748155771904","sCode":"5XXXX","sMsg":"order not exist"}],"code":"1","msg":""}
Unique identifier of the message Provided by client. It will be returned in response message for identifying the corresponding request. A combination of case-sensitive alphanumerics, all numbers, or all letters of up to 32 characters.
op
String
Yes
Operation, e.g. amend-order
args
Array
Yes
Request Parameters
> instId
String
Yes
Instrument ID
> cxlOnFail
Boolean
No
Whether the order needs to be automatically canceled when the order amendment fails Valid options: false or true, the default is false.
> ordId
String
Conditional
Order ID Either ordId or clOrdId is required, if both are passed, ordId will be used.
> clOrdId
String
Conditional
Client Order ID as assigned by the client
> reqId
String
No
Client Request ID as assigned by the client for order amendment A combination of case-sensitive alphanumerics, all numbers, or all letters of up to 32 characters.
> newSz
String
Conditional
New quantity after amendment. Either newSz or newPx is required. When amending a partially-filled order, the newSz should include the amount that has been filled.
> newPx
String
Conditional
New price after amendment.
expTime
String
No
Request effective deadline. Unix timestamp format in milliseconds, e.g. 1597026383085
{"id":"1512","op":"amend-order","data":[{"clOrdId":"","ordId":"2510789768709120","reqId":"b12344","sCode":"5XXXX","sMsg":"order not exist"}],"code":"1","msg":""}
Unique identifier of the message Provided by client. It will be returned in response message for identifying the corresponding request. A combination of case-sensitive alphanumerics, all numbers, or all letters of up to 32 characters.
op
String
Yes
Operation, e.g. batch-amend-orders
args
Array
Yes
Request Parameters
> instId
String
Yes
Instrument ID
> cxlOnFail
Boolean
No
Whether the order needs to be automatically canceled when the order amendment fails Valid options: false or true, the default is false.
> ordId
String
Conditional
Order ID Either ordId or clOrdId is required, if both are passed, ordId will be used.
> clOrdId
String
Conditional
Client Order ID as assigned by the client
> reqId
String
No
Client Request ID as assigned by the client for order amendment A combination of case-sensitive alphanumerics, all numbers, or all letters of up to 32 characters.
> newSz
String
Conditional
New quantity after amendment. Either newSz or newPx is required. When amending a partially-filled order, the newSz should include the amount that has been filled.
> newPx
String
Conditional
New price after amendment.
expTime
String
No
Request effective deadline. Unix timestamp format in milliseconds, e.g. 1597026383085
{"id":"1513","op":"batch-amend-orders","data":[{"clOrdId":"","ordId":"12345689","reqId":"b12344","sCode":"5XXXX","sMsg":"order not exist"},{"clOrdId":"oktswap7","ordId":"","reqId":"b12344","sCode":"5XXXX","sMsg":"order not exist"}],"code":"1","msg":""}
Response Example When Partially Successful
{"id":"1513","op":"batch-amend-orders","data":[{"clOrdId":"","ordId":"12345689","reqId":"b12344","sCode":"0","sMsg":""},{"clOrdId":"oktswap7","ordId":"","reqId":"b12344","sCode":"5XXXX","sMsg":"order not exist"}],"code":"2","msg":""}
Client Request ID as assigned by the client for order amendment If the user provides reqId in the request, the corresponding reqId will be returned
> sCode
String
Order status code, 0 means success
> sMsg
String
Order status message
Private channel
Account channel
Retrieve account information. Data will be pushed when triggered by events such as placing order, canceling order, transaction execution, etc.
It will also be pushed in regular interval according to subscription granularity.
The latest time to get account information, millisecond format of Unix timestamp, e.g. 1597026383085
> totalEq
String
Total equity in USD
> isoEq
String
Isolated margin equity in USD. Not enabled. Please disregard.
> adjEq
String
Adjusted / Effective equity in USD. Not enabled. Please disregard.
> ordFroz
String
Margin frozen for pending cross orders in USD. Not enabled. Please disregard.
> imr
String
Frozen equity for open positions and pending orders in USD. Not enabled. Please disregard.
> mmr
String
Maintenance margin requirement in USD . Not enabled. Please disregard.
> mgnRatio
String
Margin ratio in USD . Not enabled. Please disregard.
> notionalUsd
String
Notional value of positions in USD . Not enabled. Please disregard.
> details
Array
Detailed asset information in all currencies
>> ccy
String
Currency
>> eq
String
Equity of the currency
>> cashBal
String
Cash Balance
>> uTime
String
Update time, Unix timestamp format in milliseconds, e.g. 1597026383085
>> isoEq
String
Isolated margin equity of the currency. Not enabled. Please disregard.
>> availEq
String
Available equity of the currency. Not enabled. Please disregard.
>> disEq
String
Discount equity of the currency in USD
>> availBal
String
Available balance of the currency
>> frozenBal
String
Frozen balance of the currency
>> ordFrozen
String
Margin frozen for open orders
>> liab
String
Liabilities of the currency. Not enabled. Please disregard.
>> upl
String
Unrealized profit and loss of the currency. Not enabled. Please disregard.
>> uplLiab
String
Liabilities due to Unrealized loss of the currency. Not enabled. Please disregard.
>> crossLiab
String
Cross Liabilities of the currency. Not enabled. Please disregard.
>> isoLiab
String
Isolated Liabilities of the currency. Not enabled. Please disregard.
>> mgnRatio
String
Margin ratio of the currency. Not enabled. Please disregard.
>> interest
String
Interest of the currency. Not enabled. Please disregard.
>> twap
String
System is forced repayment(TWAP) indicator. Not enabled. Please disregard.
>> maxLoan
String
Max loan of the currency. Not enabled. Please disregard.
>> eqUsd
String
Equity usd of the currency
>> notionalLever
String
Leverage of the currency. Not enabled. Please disregard.
>> coinUsdPrice
String
Price index usd of the currency
>> stgyEq
String
strategy equity
>> isoUpl
String
Isolated unrealized profit and loss of the currency. Not enabled. Please disregard.
>> spotInUseAmt
String
Spot in use amount. Not enabled. Please disregard.
Order channel
Retrieve order information. Data will not be pushed when first subscribed. Data will only be pushed when triggered by events such as placing/canceling order.
{"arg":{"channel":"orders","instType":"SPOT","instId":"ETH-USD","uid":"1300041872592896"},"data":[{"accFillSz":"0","amendResult":"","avgPx":"0","cTime":"1672898607313","category":"normal","ccy":"","clOrdId":"","code":"0","execType":"","fee":"0","feeCcy":"ETH","fillFee":"0","fillFeeCcy":"","fillNotionalUsd":"",[Page truncated to keep GeezerVison snappy.]
You are visitor 01402792 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.