Token trading

Contract Price API

Contract Price API Receive the latest OKEX contract data
Resource Description
GET /api/v1/future_ticker Get OKEX Contract Price

URL https://www.okex.com/api/v1/future_ticker.do

Example

# Request 
GET https://www.okex.com/api/v1/future_ticker.do?symbol=btc_usd&contract_type=this_week
# Response
{
	"date":"1411627632",
	"ticker":{
		"last":409.2, 
		"buy" :408.23, 
		"sell":409.18, 
		"high":432.0, 
		"low":405.71, 
		"vol":55168.0, 
		"contract_id":20140926012, 
		"unit_amount":100.0
	}
}
  

Return Values

buy: best bid
contract_id: contract ID
high: highest price
last: latest price
low: lowest price
sell: best ask
unit_amount: contract par value
vol: volume (in last 24 hours)

Request Parameters

Parameter Description

symbol

btc_usd   ltc_usd    eth_usd    etc_usd    bch_usd

contract_type

this_week   next_week   quarter

GET /api/v1/future_depth Get OKEX Contract Market Depth

URL https://www.okex.com/api/v1/future_depth.do

Example

# Request 
GET https://www.okex.com/api/v1/future_depth.do?symbol=btc_usd&contract_type=this_week
# Response
{
	"asks":[
       [411.8,6],
	   [411.75,11],
	   [411.6,22],
	   [411.5,9],
	   [411.3,16]
	],
	"bids":[
       [410.65,12],
	   [410.64,3],
	   [410.19,15],
	   [410.18,40],
	   [410.09,10]
	]
}
  

Return Values

asks: asks depth
bids: bids depth

Request Parameters

Parameter Description

symbol

btc_usd   ltc_usd    eth_usd    etc_usd    bch_usd

contract_type

this_week   next_week   quarter

size

value: 5 - 200

merge

value: 1 (merge depth)

GET /api/v1/future_trades Get Contract Trade History

URL https://www.okex.com/api/v1/future_trades.do

Example

# Request 
GET https://www.okex.com/api/v1/future_trades.do?symbol=btc_usd&contract_type=this_week
# Response
[
    {
        "amount": 11,
        "date_ms": 140807646000,
        "date": 140807646,
        "price": 7.076,
        "tid": 37,
        "type": "buy"
    },
    {
        "amount": 100,
        "date_ms": 140807647000,
        "date": 140807647,
        "price": 7.076,
        "tid": 39,
        "type": "sell"
    }
]

Return Values

amount: quantity, in number of contracts
date_ms: transaction time(ms)
date: transaction time
price: transaction price
tid: transaction ID
type: buy/sell

Request Parameters

Parameter Description

symbol

btc_usd   ltc_usd    eth_usd    etc_usd    bch_usd

contract_type

this_week   next_week   quarter

GET /api/v1/future_index Get OKEX Contract Index Price

URL https://www.okex.com/api/v1/future_index.do

Example

# Request 
GET https://www.okex.com/api/v1/future_index.do?symbol=btc_usd
# Response
{"future_index":471.0817}
  

Return Values

future_index: current futures index price

Request Parameters

Parameter Description

symbol

btc_usd   ltc_usd    eth_usd    etc_usd    bch_usd

GET /api/v1/exchange_rate Get USD-CNY Exchange Rate

URL https://www.okex.com/api/v1/exchange_rate.do

Example

# Request 
GET https://www.okex.com/api/v1/exchange_rate.do
# Response
{"rate":6.1329}
  

Return Values

rate: USD-CNY exchange rate used by OKEX, updated weekly

Request Parameters

none
GET /api/v1/future_estimated_price Get Estimated Delivery Price New

URL https://www.okex.com/api/v1/future_estimated_price.do

Example

# Request 
GET https://www.okex.com/api/v1/future_estimated_price.do?symbol=btc_usd
# Response
{"forecast_price":5.4}

Return Values

forecast_price: estimated delivery price 
Note: only available within 3 hrs before delivery or settlement

Request Parameters

Parameter Description

symbol

btc_usd   ltc_usd    eth_usd    etc_usd    bch_usd

GET /api/v1/future_kline New Get Contract Candlestick Data

URL https://www.okex.com/api/v1/future_kline.do

Example

# Request
GET https://www.okex.com/api/v1/future_kline.do
# Response
[
    [
        1440308700000,
        233.37,
        233.48,
        233.37,
        233.48,
        52,
        22.2810015
    ],
    [
        1440308760000,
        233.38,
        233.38,
        233.27,
        233.37,
        186,
        79.70234956
    ]
]

Return Values

[
    1440308760000,	timestamp
    233.38,		open
    233.38,		high
    233.27,		low
    233.37,		close
    186,		volume
    79.70234956		BTC or LTC amount
]

Request Parameters

Parameter Description

symbol

btc_usd   ltc_usd    eth_usd    etc_usd    bch_usd

type

1min : 1 minute candlestick data
3min : 3 minutes candlestick data
5min : 5 minutes candlestick data
15min : 15 minutes candlestick data
30min : 30 minutes candlestick data
1day : 1 day candlestick data
3day : 3 days candlestick data
1week : 1 week candlestick data
1hour : 1 hour candlestick data
2hour : 2 hours candlestick data
4hour : 4 hours candlestick data
6hour : 6 hours candlestick data
12hour : 12 hours candlestick data

contract_type

contract type: this_week/next_week/quarter

size

specify data size to be acquired

since

timestamp(eg:1417536000000). data after the timestamp will be returned

GET /api/v1/future_hold_amount New Get Total Number Of Current Holding (cont)

URL https://www.okex.com/api/v1/future_hold_amount.do

Example

# Request
GET https://www.okex.com/api/v1/future_hold_amount.do?symbol=btc_usd&contract_type=this_week
# Response
[
    {
        "amount": 106856,
        "contract_name": "BTC0213"
    }
]

Return Values

amount: total number (cont)
contract_name: contract name

Request Parameters

Parameter Description

symbol

btc_usd   ltc_usd    eth_usd    etc_usd    bch_usd (required)

contract_type

contract type: this_week/next_week/quarter

GET /api/v1/future_price_limit New Get upper and lower price limit

URL https://www.okex.com/api/v1/future_price_limit.do

Example

# Request
GET https://www.okex.com/api/v1/future_price_limit.do?symbol=btc_usd&contract_type=this_week
# Response
{"high":443.07,"low":417.09}

Return Values

high: limit high price
low: limit low price

Request Parameters

Parameter Description

symbol

btc_usd   ltc_usd    eth_usd    etc_usd    bch_usd (required)

contract_type

contract type: this_week/next_week/quarter (required)

Contract Trade API

Contract Trading API for placing contract orders on OKEX
Resource Description
POST /api/v1/future_userinfo Get OKEX Contract Account Info(Cross-Margin Mode)

URL https://www.okex.com/api/v1/future_userinfo.do

Example

# Request 
POST https://www.okex.com/api/v1/future_userinfo.do
# Response
{
    "info": {
        "btc": {
            "account_rights": 1,
            "keep_deposit": 0,
            "profit_real": 3.33,
            "profit_unreal": 0,
            "risk_rate": 10000
        },
        "ltc": {
            "account_rights": 2,
            "keep_deposit": 2.22,
            "profit_real": 3.33,
            "profit_unreal": 2,
            "risk_rate": 10000
        }
    },
    "result": true
}
  

Return Values

account_rights: account equity
keep_deposit: margin
profit_real: realized
profit_unreal: unrealized
risk_rate: current margin ratio

Request Parameters

Parameter Description

api_key

apiKey of the user

sign

signature of request parameters

POST /api/v1/future_position Get User Contract Positions (Cross-Margin Mode)

URL https://www.okex.com/api/v1/future_position.do

Example

# Request 
POST https://www.okex.com/api/v1/future_position.do
# Response
{
    "force_liqu_price": "0.07",
    "holding": [
        {
            "buy_amount": 1,
            "buy_available": 0,
            "buy_price_avg": 422.78,
            "buy_price_cost": 422.78,
            "buy_profit_real": -0.00007096,
            "contract_id": 20141219012,
            "contract_type": "this_week",
            "create_date": 1418113356000,
            "lever_rate": 10,
            "sell_amount": 0,
            "sell_available": 0,
            "sell_price_avg": 0,
            "sell_price_cost": 0,
            "sell_profit_real": 0,
            "symbol": "btc_usd"
        }
    ],
    "result": true
}

Return Values

buy_amount(double): long position amount(usd)
buy_available: available long postions that can be closed
buy_price_avg(double): average open price
buy_price_cost(double): cost price
buy_profit_real(double): long position realized gains/losses
contract_id(long): contract ID
create_date(long): open date
lever_rate: lever rate
sell_amount(double): short position amount(usd)
sell_available: available short postions that can be closed
sell_price_avg(double): average open price
sell_price_cost(double): cost price
sell_profit_real(double): short position realized gains/losses
symbol: btc_usd   ltc_usd    eth_usd    etc_usd    bch_usd
contract_type: contract type
force_liqu_price: estimated margin call price

Request Parameters

Parameter Description

symbol

btc_usd   ltc_usd    eth_usd    etc_usd    bch_usd

contract_type

this_week   next_week   quarter

api_key

apiKey of the user

sign

signature of request parameters

POST /api/v1/future_trade Place Orders

URL https://www.okex.com/api/v1/future_trade.do

Request frequency 5 times/s

Example

# Request 
POST https://www.okex.com/api/v1/future_trade.do
# Response
{
   "order_id":986,
   "result":true
}

Return Values

order_id: order ID
result: request result, true means successful

Request Parameters

Parameter Description

symbol

btc_usd   ltc_usd    eth_usd    etc_usd    bch_usd

contract_type

this_week   next_week   quarter

api_key

apiKey of the user

sign

signature of request parameters

price

order price

amount

order quantity

type

1: open long position    2: open short position    3:liquidate long position    4: liquidate short position

match_price

match best counter party price (BBO)? 0: No    1: Yes   If yes, the 'price' field is ignored

lever_rate

leverage rate value: 10 or 20 (10 by default)

POST /api/v1/future_trades_history New Get OKEX Contract Trade History (Not for Personal)

URL https://www.okex.com/api/v1/future_trades_history.do

Example

# Request
POST https://www.okex.com/api/v1/future_trades_history.do
# Response
[
    {
        "amount": 11,
        "date": 140807646000,
        "price": 7.076,
        "tid": 37,
        "type": "buy"
    },
    {
        "amount": 100,
        "date": 1408076464000,
        "price": 7.076,
        "tid": 39,
        "type": "sell"
    }
]

Return Values

amount: quantity, in number of contracts
date:transaction time(ms)
price:transaction price
tid:transaction ID
type:buy/sell

Request Parameters

Parameter Description

api_key

apiKey of the user

sign

signature of request parameters

symbol

btc_usd   ltc_usd    eth_usd    etc_usd    bch_usd

date

contract delivery date, format :yyyy-MM-dd

since

the start of transaction id

POST /api/v1/future_batch_trade Batch Trade

URL https://www.okex.com/api/v1/future_batch_trade.do

Example

# Request 
POST https://www.okex.com/api/v1/future_batch_trade.do
# Response
{
    "order_info":[
        {"error_code":20013,"order_id":-1},
        {"error_code":20013,"order_id":-1},
        {"order_id":161256},
        {"order_id":161257}
	],
    "result":true
}

Return Values

result: order successfully placed or not
order_id: order ID
Note:
     return true if any one order is placed successfully
     returned orders info and 'orders_data' are in same sequence
     if fail to place a specific order, the order_id is -1

Request Parameters

Parameter Description

api_key

apiKey of the user

symbol

btc_usd   ltc_usd    eth_usd    etc_usd    bch_usd

contract_type

this_week   next_week   quarter

contract_type

this_week   next_week   quarter

orders_data

JSON string example: [{price:5,amount:2,type:1,match_price:1},{price:2,amount:3,type:1,match_price:1}]. Max 5 orders per request. For 'price', 'amount', 'type' and 'match_price' parameters, refer to future_trade/API

sign

signature of request parameters

lever_rate

leverage rate value: 10 or 20 (10 by default)

POST /api/v1/future_cancel Cancel Orders

URL https://www.okex.com/api/v1/future_cancel.do

Request frequency 10 times/s

Example

# Request 
POST https://www.okex.com/api/v1/future_cancel.do
# Response
{
   "order_id":986,
   "result":true
}

Return Values

order_id: order ID
result: request result, true is successful

Request Parameters

Parameter Description

symbol

btc_usd   ltc_usd    eth_usd    etc_usd    bch_usd

contract_type

this_week   next_week   quarter

api_key

apiKey of the user

sign

signature of request parameters

order_id

order ID (multiple orders are separated by a comma ',', Max of 3 orders are allowed per request)

contract_type

this_week   next_week   quarter

POST /api/v1/future_order_info Get User Contract Order

URL https://www.okex.com/api/v1/future_order_info.do

Example

# Request 
POST https://www.okex.com/api/v1/future_order_info.do
# Response
{
  "orders":
     [
        {
            "amount":111,
            "contract_name":"LTC0815",
            "create_date":1408076414000,
            "deal_amount":1,
            "fee":0,
            "order_id":106837,
            "price":1111,
            "price_avg":0,
            "status":"0",
            "symbol":"ltc_usd",
            "type":"1",
            "unit_amount":100,
            "lever_rate": 10
        }
     ],
   "result":true
}

Return Values

amount: order quantity
contract_name: contract name
create_date: order time
deal_amount: filled quantity
fee: transaction fee
order_id: order ID
price: order price
price_avg: average price
status: -1 = cancelled, 0 = unfilled, 1 = partially filled, 2 = fully filled, 4 = cancel request in process, 5 = cancelled
symbol: btc_usd   ltc_usd    eth_usd    etc_usd    bch_usd
type: order type 1: open long, 2: open short, 3: close long, 4: close short
unit_amount: contract par value
lever_rate: leverage rate value, 10 or 20

Request Parameters

Parameter Description

api_key

apiKey of the user

symbol

btc_usd   ltc_usd    eth_usd    etc_usd    bch_usd

contract_type

this_week   next_week   quarter

sign

signature of request parameters

status

query by order status 1: unfilled  2: filled

order_id

order ID -1: return the orders of the specified status, otherwise return the order that the ID specified

current_page

current page number

page_length

number of orders per page, maximum 50

POST /api/v1/future_orders_info  New Get User Contract Order in Batch

URL https://www.okex.com/api/v1/future_orders_info.do

Example

# Request 
POST https://www.okex.com/api/v1/future_orders_info.do
# Response
{
    "orders": [
        {
            "amount": 1,
            "contract_name": "BTC0213",
            "create_date": 1424932853000,
            "deal_amount": 0,
            "fee": 0,
            "lever_rate": 20,
            "order_id": 200144,
            "price": 1,
            "price_avg": 0,
            "status": 0,
            "symbol": "btc_usd",
            "type": 1,
            "unit_amount": 100
        },
        {
            "amount": 1,
            "contract_name": "BTC0213",
            "create_date": 1424932903000,
            "deal_amount": 0,
            "fee": 0,
            "lever_rate": 20,
            "order_id": 200146,
            "price": 1,
            "price_avg": 0,
            "status": 0,
            "symbol": "btc_usd",
            "type": 1,
            "unit_amount": 100
        },
        {
            "amount": 1,
            "contract_name": "BTC0213",
            "create_date": 1424932917000,
            "deal_amount": 0,
            "fee": 0,
            "lever_rate": 20,
            "order_id": 200147,
            "price": 1,
            "price_avg": 0,
            "status": 0,
            "symbol": "btc_usd",
            "type": 1,
            "unit_amount": 100
        }
    ],
    "result": true
}

Return Values

amount: order quantity
contract_name: contract name
created_date: order time
deal_amount: filled quantity
fee: transaction fee
order_id: order ID
price: order price
price_avg: average price
status: -1 = cancelled, 0 = unfilled, 1 = partially filled, 2 = fully filled, 4 = cancel request in process
symbol: btc_usd   ltc_usd    eth_usd    etc_usd    bch_usd
type: order type 1: open long, 2: open short, 3: close long, 4: close short
unit_amount: contract par value
lever_rate: leverage rate value, 10 or 20

Request Parameters

Parameter Description

api_key

apiKey of the user

symbol

btc_usd   ltc_usd    eth_usd    etc_usd    bch_usd

contract_type

this_week   next_week   quarter

sign

signature of request parameters

order_id

order ID (multiple orders are separated by a comma ',', Max of 50 orders are allowed per request)

POST /api/v1/future_userinfo_4fix Get User Account Info (Fixed-Margin Mode)

URL https://www.okex.com/api/v1/future_userinfo_4fix.do

Example

# Request 
POST https://www.okex.com/api/v1/future_userinfo_4fix.do
# Response
{
    "info": {
        "btc": {
            "balance": 99.95468925,
            "contracts": [
                {
                    "available": 99.95468925,
                    "balance": 0.03779061,
                    "bond": 0,
                    "contract_id": 20140815012,
                    "contract_type": "this_week",
                    "freeze": 0,
                    "profit": -0.03779061,
                    "unprofit": 0
                }
            ],
            "rights": 99.95468925
        },
        "ltc": {
            "balance": 77,
            "contracts": [
                {
                    "available": 99.95468925,
                    "balance": 0.03779061,
                    "bond": 0,
                    "contract_id": 20140815012,
                    "contract_type": "this_week",
                    "freeze": 0,
                    "profit": -0.03779061,
                    "unprofit": 0
                }
            ],
            "rights": 100
        }
    },
    "result": true
}

Return Values

balance: account balance
available: available fund
balance: account (contract) balance
bond: fixed margin
contract_id: contract ID
contract_type: contract Type
freeze: frozen
profit: realized
unprofit: unrealized
rights: account equity

Request Parameters

Parameter Description

api_key

apiKey of the user

sign

signature of request parameters

POST /api/v1/future_position_4fix Get User Positions (Fixed-Margin Mode)

URL https://www.okex.com/api/v1/future_position_4fix.do

Example

# Request 
POST https://www.okex.com/api/v1/future_position_4fix.do
# Response
{
    "holding": [
        {
            "buy_amount": 10,
            "buy_available": 2,
            "buy_bond": 1.27832803,
            "buy_flatprice": "338.97",
            "buy_price_avg": 555.67966869,
            "buy_price_cost": 555.67966869,
            "buy_profit_lossratio": "13.52",
            "buy_profit_real": 0,
            "contract_id": 20140815012,
            "contract_type": "this_week",
            "create_date": 1408594176000,
            "sell_amount": 8,
            "sell_available": 2,
            "sell_bond": 0.24315591,
            "sell_flatprice": "671.15",
            "sell_price_avg": 567.04644056,
            "sell_price_cost": 567.04644056,
            "sell_profit_lossratio": "-45.04",
            "sell_profit_real": 0,
            "symbol": "btc_usd",
            "lever_rate": 10
        }
    ],
    "result": true
}

Return Values

buy_amount: long position quantity
buy_available: available long postions that can be closed
buy_bond: long position margin
buy_flatprice: long position force liquidation price
buy_profit_lossratio: long position profit ratio
buy_price_avg: average open price
buy_price_cost: cost price
buy_profit_real: long position realized gain/loss
contract_id: contract ID
contract_type: contract Type
create_date: position opened time
sell_amount: short position quantity
sell_available: available short postions that can be closed
sell_bond: short position margin
sell_flatprice: short position force liquidation price
sell_profit_lossratio: short position profit ratio
sell_price_avg: average open price
sell_price_cost: cost price
sell_profit_real: short position realized gain/loss
symbol: btc_usd   ltc_usd    eth_usd    etc_usd    bch_usd
lever_rate: leverage rate 

Request Parameters

Parameter Description

symbol

btc_usd   ltc_usd    eth_usd    etc_usd    bch_usd

contract_type

this_week   next_week   quarter   (if left null, all contracts are returned)

api_key

apiKey of the user

sign

signature of request parameters

type

by default, futures positions with leverage rate 10 are returned. If type = 1, all futures positions are returned

POST /api/v1/future_explosive New Get Forced Liquidation Orders

URL https://www.okex.com/api/v1/future_explosive.do

Example

# Request
POST https://www.okex.com/api/v1/future_explosive.do
# Response
[
    {
        "data": [
            {
                "amount": "42",
                "create_date": "2015-02-27 11:48:07",
                "loss": "-0.54275722",
                "price": "249.02",
                "type": 4
            },
            {
                "amount": "12",
                "create_date": "2015-02-27 11:48:05",
                "loss": "-0.15507349",
                "price": "249.02",
                "type": 4
            },
            {
                "amount": "3",
                "create_date": "2015-02-27 11:48:01",
                "loss": "-0.03896192",
                "price": "248.98",
                "type": 4
            },
            {
                "amount": "1811",
                "create_date": "2015-02-27 11:48:01",
                "loss": "-23.40317457",
                "price": "249.02",
                "type": 4
            },
            {
                "amount": "2",
                "create_date": "2015-02-27 11:48:00",
                "loss": "-0.02655576",
                "price": "248.80",
                "type": 4
            }
        ]
    }
]

Return Values

amount: order quantity(unit: contract)
create_date: create date
loss: user loss due to forced liquidation
price: order price
type:1:open long position; 2:open short position; 3:liquidate long position; 4:liquidate short position

Request Parameters

Parameter Description

api_key

apiKey of the user

sign

signature of request parameters

symbol

btc_usd   ltc_usd    eth_usd    etc_usd    bch_usd

contract_type

contract type: this_week/next_week/quarter

status

0: open liquidation orders of last 7 days; 1: filled liquidation orders of last 7 days

current_page

current page index

page_number

current page number(current_page is invalid when using page_number,don't send current_page )

page_length

number of orders per page, maximum 50

POST /api/v1/future_devolve New Account Fund Transfer

URL https://www.okex.com/api/v1/future_devolve.do

Example

# Request
POST https://www.okex.com/api/v1/future_devolve.do
# Response
{
   "result":true
}
OR
{
    "error_code":20029,
	"result":false
}

Return Values

result: Transfer result. In case of error, returns the error code.

Request Parameters

Parameter Description

api_key

apiKey of the user

sign

signature of request parameters

symbol

btc_usd   ltc_usd    eth_usd    etc_usd    bch_usd

type

1: Spot to futures, 2: Futures to spot

amount

Amount in coins

Spot Price API

Receive the latest OKEx spot market data
Resource Description
GET /api/v1/ticker  New Get Price Ticker

URL https://www.okex.com/api/v1/ticker.do

Example

# Request
GET https://www.okex.com/api/v1/ticker.do?symbol=ltc_btc
# Response
{
    "date": "1410431279",
    "ticker": {
        "buy": "33.15",
        "high": "34.15",
        "last": "33.15",
        "low": "32.05",
        "sell": "33.16",
        "vol": "10532696.39199642"
    }
}
  

Return Values

date: server time for returned data
buy: best bid
high: highest price
last: latest price
low: lowest price
sell: best ask
vol: volume (in the last rolling 24 hours)

Request Parameters

Parameter Description

symbol

ltc_btc eth_btc etc_btc bch_btc btc_usdt eth_usdt ltc_usdt etc_usdt bch_usdt etc_eth bt1_btc bt2_btc btg_btc qtum_btc hsr_btc neo_btc gas_btc qtum_usdt hsr_usdt neo_usdt gas_usdt

GET /api/v1/depth  New Get Market Depth

URL https://www.okex.com/api/v1/depth.do

Example

# Request
GET https://www.okex.com/api/v1/depth.do?symbol=ltc_btc
# Response
{
	"asks": [
		[792, 5],
		[789.68, 0.018],
		[788.99, 0.042],
		[788.43, 0.036],
		[787.27, 0.02]
	],
	"bids": [
		[787.1, 0.35],
		[787, 12.071],
		[786.5, 0.014],
		[786.2, 0.38],
		[786, 3.217],
		[785.3, 5.322],
		[785.04, 5.04]
	]
}
  

Return Values

asks : ask depth
bids : bid depth

Request Parameters

Parameter Description

symbol

ltc_btc eth_btc etc_btc bch_btc btc_usdt eth_usdt ltc_usdt etc_usdt bch_usdt etc_eth bt1_btc bt2_btc btg_btc qtum_btc hsr_btc neo_btc gas_btc qtum_usdt hsr_usdt neo_usdt gas_usdt

size

value: must be between 1 - 200

GET /api/v1/trades  New Get Trade Recently 600

URL https://www.okex.com/api/v1/trades.do

Example

# Request
GET https://www.okex.com/api/v1/trades.do?symbol=ltc_btc&since=7622718804
# Response
[
    {
        "date": "1367130137",
        "date_ms": "1367130137000",
        "price": 787.71,
        "amount": 0.003,
        "tid": "230433",
        "type": "sell"
    },
    {
        "date": "1367130137",
        "date_ms": "1367130137000",
        "price": 787.65,
        "amount": 0.001,
        "tid": "230434",
        "type": "sell"
    },
    {
        "date": "1367130137",
        "date_ms": "1367130137000",
        "price": 787.5,
        "amount": 0.091,
        "tid": "230435",
        "type": "sell"
    }
]
  

Return Values

date: transaction time
date_ms: transaction time in milliseconds
price: transaction price
amount: quantity in BTC (or LTC)
tid: transaction ID
type: buy/sell

Request Parameters

Parameter Description

symbol

ltc_btc eth_btc etc_btc bch_btc btc_usdt eth_usdt ltc_usdt etc_usdt bch_usdt etc_eth bt1_btc bt2_btc btg_btc qtum_btc hsr_btc neo_btc gas_btc qtum_usdt hsr_usdt neo_usdt gas_usdt

since

get recently 600 pieces of data starting from the given tid (optional)

Get /api/v1/kline  New Get Candlestick Data

URL https://www.okex.com/api/v1/kline.do  approximately 2000 pieces of data are returned each cycle

Example

# Request
GET https://www.okex.com/api/v1/kline.do?symbol=ltc_btc&type=1min
# Response
[
    [
        1417478400000,
        380.94,
        387.7,
        378.75,
        384.61,
        6857.31
    ],
    [
        1417564800000,
        384.47,
        387.13,
        383.5,
        387.13,
        1062.04
    ]
]

Return Values

[
	1417564800000,	timestamp
	384.47,		open
	387.13,		high
	383.5,		low
	387.13,		close
	1062.04,	volume
]

Request Parameters

Parameter Description

symbol

ltc_btc eth_btc etc_btc bch_btc btc_usdt eth_usdt ltc_usdt etc_usdt bch_usdt etc_eth bt1_btc bt2_btc btg_btc qtum_btc hsr_btc neo_btc gas_btc qtum_usdt hsr_usdt neo_usdt gas_usdt

type

1min : 1 minute candlestick data
3min : 3 minutes candlestick data
5min : 5 minutes candlestick data
15min : 15 minutes candlestick data
30min : 30 minutes candlestick data
1day : 1 day candlestick data
3day : 3 days candlestick data
1week : 1 week candlestick data
1hour : 1 hour candlestick data
2hour : 2 hours candlestick data
4hour : 4 hours candlestick data
6hour : 6 hours candlestick data
12hour : 12 hours candlestick data

size

specify data size to be acquired

since

timestamp(eg:1417536000000). data after the timestamp will be returned

Spot Trading API

Place spot orders on OKEx
Resource Description
POST /api/v1/userinfo  New Get User Account Info

URL https://www.okex.com/api/v1/userinfo.do

Request frequency 6 times/2s

Example

# Request
POST https://www.okex.com/api/v1/userinfo.do
# Response
{
    "info": {
        "funds": {
            "free": {
                "btc": "0",
                "usd": "0",
                "ltc": "0",
                "eth": "0"
            },
            "freezed": {
                "btc": "0",
                "usd": "0",
                "ltc": "0",
                "eth": "0"

            }
        }
    },
    "result": true
}

Return Values

free: available fund
freezed: frozen fund

Request Parameters

Parameter Description

api_key

apiKey of the user

sign

signature of request parameters

POST /api/v1/trade  New Place Orders

URL https://www.okex.com/api/v1/trade.do

Request frequency 20 times/2s

Example

# Request
POST https://www.okex.com/api/v1/trade.do
# Response
{"result":true,"order_id":123456}
  

Return Values

result: true means order placed successfully
order_id: order ID of the newly placed order

Request Parameters

Parameter Description

api_key

apiKey of the user

symbol

ltc_btc eth_btc etc_btc bch_btc btc_usdt eth_usdt ltc_usdt etc_usdt bch_usdt etc_eth bt1_btc bt2_btc btg_btc qtum_btc hsr_btc neo_btc gas_btc qtum_usdt hsr_usdt neo_usdt gas_usdt

type

order type: limit order(buy/sell) market order(buy_market/sell_market)

price

order price. For limit orders, the price must be between 0~1,000,000. IMPORTANT: for market buy orders, the price is to total amount you want to buy, and it must be higher than the current price of 0.01 BTC (minimum buying unit), 0.1 LTC or 0.01 ETH. For market sell orders, the price is not required

amount

order quantity. Must be higher than 0.01 for BTC, 0.1 for LTC or 0.01 for ETH.For market buy roders, the amount is not required

sign

signature of request parameters

POST /api/v1/batch_trade  New Batch Trade

URL https://www.okex.com/api/v1/batch_trade.do

Request frequency 20 times/2s

Example

# Request
POST https://www.okex.com/api/v1/batch_trade.do
# Response
{
	"order_info":[
		{"order_id":41724206},
		{"error_code":10011,"order_id":-1},
		{"error_code":10014,"order_id":-1}
	],
	"result":true
}
  

Return Values

result: true indicates order successfully placed
order_id: order ID
Note: return true if any one order is placed successfully
     returned orders info and 'orders_data' are in same sequence
     if fail to place order: order_id is -1

Request Parameters

Parameter Description

api_key

apiKey of the user

symbol

ltc_btc eth_btc etc_btc bch_btc btc_usdt eth_usdt ltc_usdt etc_usdt bch_usdt etc_eth bt1_btc bt2_btc btg_btc qtum_btc hsr_btc neo_btc gas_btc qtum_usdt hsr_usdt neo_usdt gas_usdt

type

optional, order type for limit orders (buy/sell)

orders_data

JSON string Example: [{price:3,amount:5,type:'sell'},{price:3,amount:3,type:'buy'},{price:3,amount:3}] max order number is 5,for 'price' and 'amount' parameter, refer to trade/API. Final order type is decided primarily by 'type' field within 'orders_data' and subsequently by 'type' field (if no 'type' is provided within 'orders_data' field)

sign

signature of request parameters

POST /api/v1/cancel_order  New Cancel Orders

URL https://www.okex.com/api/v1/cancel_order.do

Request frequency 20 times/2s

Example

# Request
POST https://www.okex.com/api/v1/cancel_order.do
# Response
# For batch orders, return (success order IDs, failed order IDs)
{"success":"123456,123457","error":"123458,123459"}
  

Return Values

result: true: cancel order request successful, wait to be processed, false: cancel order failed(applicable to single order)
order_id: order ID (applicable to single order)
success: ID of orders whose cancel request are successful, wait to be processed.(applicable to batch orders)
error: ID of orders whose cancel request are unsuccessful.(applicable to batch orders)

Request Parameters

Parameter Description

api_key

apiKey of the user

symbol

ltc_btc eth_btc etc_btc bch_btc btc_usdt eth_usdt ltc_usdt etc_usdt bch_usdt etc_eth bt1_btc bt2_btc btg_btc qtum_btc hsr_btc neo_btc gas_btc qtum_usdt hsr_usdt neo_usdt gas_usdt

order_id

order ID (multiple orders are separated by a comma ',', Max of 3 orders are allowed per request)

sign

signature of request parameters

POST /api/v1/order_info  New Get Order Info

URL https://www.okex.com/api/v1/order_info.do

Request frequency 20 times/2s (unfilled orders)

Example

# Request
POST https://www.okex.com/api/v1/order_info.do
# Response
{
    "result": true,
    "orders": [
        {
            "amount": 0.1,
            "avg_price": 0,
            "create_date": 1418008467000,
            "deal_amount": 0,
            "order_id": 10000591,
            "orders_id": 10000591,
            "price": 500,
            "status": 0,
            "symbol": "btc_usd",
            "type": "sell"
        },
        {
            "amount": 0.2,
            "avg_price": 0,
            "create_date": 1417417957000,
            "deal_amount": 0,
            "order_id": 10000724,
            "orders_id": 10000724,
            "price": 0.1,
            "status": 0,
            "symbol": "btc_usd",
            "type": "buy"
        }
    ]
}
  

Return Values

amount: order quantity
avg_price: average transaction price
create_date: order time
deal_amount: filled quantity
order_id: order ID
orders_id: order ID (Deprecated)
price: order price
status: -1 = cancelled, 0 = unfilled, 1 = partially filled, 2 = fully filled, 3 = cancel request in process
type: buy_market = market buy order, sell_market = market sell order

Request Parameters

Parameter Description

api_key

apiKey of the user

symbol

ltc_btc eth_btc etc_btc bch_btc btc_usdt eth_usdt ltc_usdt etc_usdt bch_usdt etc_eth bt1_btc bt2_btc btg_btc qtum_btc hsr_btc neo_btc gas_btc qtum_usdt hsr_usdt neo_usdt gas_usdt

order_id

if order_id is -1, then return all unfilled orders, otherwise return the order specified

sign

signature of request parameters

POST /api/v1/orders_info  New Get Order Information in Batch

URL https://www.okex.com/api/v1/orders_info.do

Request frequency 20 times/2s

Example

# Request
POST https://www.okex.com/api/v1/orders_info.do
# Response
{
	"result":true,
	"orders":[{
			"order_id":15088,
			"status":0,
			"symbol":"btc_usd",
			"type":"sell",
			"price":811,
			"amount":1.39901357,
			"deal_amount":1,
			"avg_price":811
		} ,
		{
			"order_id":15088,
			"status":-1,
			"symbol":"btc_usd",
			"type":"sell",
			"price":811,
			"amount":1.39901357,
			"deal_amount":1,
			"avg_price":811
		}
	]
}
  

Return Values

amount: for limit orders, returns the order quantity.  For market orders, returns the filled quantity
deal_amount: filled quantity
avg_price: average transaction price
create_date: order time
order_id: order ID
price: for limit orders, return the order price.  For market orders, returns the filled price
status: -1 = cancelled, 0 = unfilled, 1 = partially filled, 2 = fully filled, 4 = cancel request in process
type: buy_market = market buy order, sell_market = market sell order
result: request result

Request Parameters

Parameter Description

api_key

apiKey of the user

type

query type: 0 for unfilled (open) orders, 1 for filled orders

symbol

ltc_btc eth_btc etc_btc bch_btc btc_usdt eth_usdt ltc_usdt etc_usdt bch_usdt etc_eth bt1_btc bt2_btc btg_btc qtum_btc hsr_btc neo_btc gas_btc qtum_usdt hsr_usdt neo_usdt gas_usdt

order_id

order ID (multiple orders are separated by ',', 50 orders at most are allowed per request)

sign

signature of request parameters

POST /api/v1/order_history  New Only the most recent 2 days are returned

URL https://www.okex.com/api/v1/order_history.do

Example

# Request
POST https://www.okex.com/api/v1/order_history.do
# Response
{
	"current_page": 1,
	"orders": [
		{
			"amount": 0,
			"avg_price": 0,
			"create_date": 1405562100000,
			"deal_amount": 0,
			"order_id": 0,
			"price": 0,
			"status": 2,
			"symbol": "btc_usd",
			"type": "sell”
		}
	],
	"page_length": 1,
	"result": true,
	"total": 3
}
]
  

Return Values

current_page: current page number
orders: detailed order information
amount: order quantity
avg_price: average transaction price
create_date: order time
deal_amount: filled quantity
order_id: order ID
price: order price
status: -1 = cancelled, 0 = unfilled, 1 = partially filled, 2 = fully filled, 4 = cancel request in process
type: buy_market = market buy order, sell_market = market sell order
page_length: number of orders per page
result: true means request successfully handled

Request Parameters

Parameter Description

api_key

apiKey of the user

symbol

ltc_btc eth_btc etc_btc bch_btc btc_usdt eth_usdt ltc_usdt etc_usdt bch_usdt etc_eth bt1_btc bt2_btc btg_btc qtum_btc hsr_btc neo_btc gas_btc qtum_usdt hsr_usdt neo_usdt gas_usdt

status

query status: 0 for unfilled orders, 1 for filled orders

current_page

current page number

page_length

number of orders returned per page, maximum 200

sign

signature of request parameters

POST /api/v1/withdraw New BTC/LTC/ETH/ETC/BCH Withdraw

URL https://www.okex.com/api/v1/withdraw.do

Example

# Request
POST https://www.okex.com/api/v1/withdraw.do
# Response
{
    "withdraw_id":301,
    "result":true
}

Return Values

withdraw_id: withdrawal request ID
result: true means request successful

Request Parameters

Parameter Description

api_key

apiKey of the user

sign

signature of request parameters

symbol

btc_usd    ltc_usd    eth_usd    etc_usd    bch_usd

chargefee

network transaction fee. By default, fee is between 0.002 - 0.005 for BTC, and 0.001 - 0.2 for LTC, and ETH is 0.01, and 0.0001 - 0.2 for ETC, and 0.0005 - 0.002 for BCH transaction gets confirmed faster with higher fees. For withdraws to another OKCoin address, chargefee can be 0 and the withdraw will be 0 confirmation as well.

trade_pwd

trade/admin password

withdraw_address

withdraw address

withdraw_amount

BTC>=0.01 LTC>=0.1 ETH>=0.01 ETC>=0.1 BCH>=0.01

target

withdraw address type. okcoin.cn:"okcn" okcoin.com:"okcom" okes.com:"okex" outer address:"address"

POST /api/v1/cancel_withdraw  New Withdrawal Cancellation Request

URL https://www.okex.com/api/v1/cancel_withdraw.do

Example

# Request
POST https://www.okex.com/api/v1/cancel_withdraw.do
# Response
{
    "result":true,
    "withdraw_id":301
}

Return Values

result: true for success, false for error
withdraw_id: withdrawal request ID

Request Parameters

Parameter Description

api_key

apiKey of the user

sign

signature of request parameters

symbol

btc_usd    ltc_usd    eth_usd    etc_usd    bch_usd

withdraw_id

withdrawal request ID

POST /api/v1/withdraw_info  New Get Withdrawal Information

URL https://www.okex.com/api/v1/withdraw_info.do

Example

# Request
POST https://www.okex.com/api/v1/withdraw_info.do
# Response
{
    "result": true,
    "withdraw": [
        {
            "address": "15KGp……",
            "amount": 2.5,
            "created_date": 1447312756190,
            "chargefee": 0.1,
            "status": 0,
            "withdraw_id": 45001
        }
    ]
}

Return Values

result: true for success, false for error
address: withdrawal address
amount: withdrawal amount
created_date: withdrawal time
chargefee: network transaction fee
status: withdrawal status (-3:Revoked;-2:Cancelled;-1:Failure;0:Pending;1:Pending;2:Complete;3:Email Confirmation;4:Verifying5:Wait Confirmation)
withdraw_id: withdrawal request ID

Request Parameters

Parameter Description

api_key

apiKey of the user

sign

signature of request parameters

symbol

btc_usd    ltc_usd    eth_usd    etc_usd    bch_usd

withdraw_id

withdrawal request ID

POST /api/v1/account_records  New Get User Deposits or Withdraw Record

URL https://www.okex.com/api/v1/account_records.do

Example

# Request
POST https://www.okex.com/api/v1/account_records.do
# Response
{
    "records": [
        {
            "addr": "1CWKbfwxSkEWP8W45D76j3BX8vPieoSCyL",
            "account": "12312",
            "amount": 0,
            "bank": "HSBC Hongkong",
            "benificiary_addr": "350541545",
            "transaction_value": 111,
            "fee": 0,
            "date": 1418008467000,
			"status": 1
        }
    ],
    "symbol": "btc"
}

Return Values

addr: address
account: account name
amount: amount
bank: bank
benificiary_addr: benificiary address
transaction_value: withdraw amount after fee deduction
fee: commission fee
date: date
symbol: btc, ltc, eth, etc, bch, usdt
status: recharge status (-1:Failure;0:Wait Confirmation;1:Complete), withdrawal status (-3:Revoked;-2:Cancelled;-1:Failure;0:Pending;1:Pending;2:Complete;3:Email Confirmation;4:Verifying5:Wait Confirmation)

Request Parameters

Parameter Description

api_key

apiKey of the user

symbol

btc, ltc, eth, etc, bch, usdt

type

0:deposits 1 :withdraw

current_page

current page number

page_length

data entries number per page, maximum 50

sign

signature of request parameters

提示

请先登录

客服+852 5808 5768
在线咨询 在线咨询
在线留言 发起提问
聊天室
OKEX聊天室
请遵守聊天室规则!详情>>
客服+852 5808 5768
聊天室规则 X