本文介绍gate io API
所有交易对 API
返回所有系统支持的交易对
URL: https://data.gateio.io/api2/1/pairs
# Request
GET: https://data.gateio.io/api2/1/pairs
# Response
[
"eth_btc","etc_btc","etc_eth","zec_btc","dash_btc","ltc_btc","bcc_btc","qtum_btc",
"qtum_eth","xrp_btc","zrx_btc","zrx_eth","dnt_eth","dpy_eth","oax_eth","lrc_eth",
"lrc_btc","pst_eth","tnt_eth","snt_eth","snt_btc","omg_eth","omg_btc","pay_eth",
"pay_btc","bat_eth","cvc_eth","storj_eth","storj_btc","eos_eth","eos_btc"
]
eth_btc: 以太币对比特币交易
etc_btc: 以太经典对比特币
etc_eth: 以太经典对以太币
xrp_btc: 瑞波币对比特币
zec_btc: ZCash对比特币
……
所有市场订单参数 API
返回所有系统支持的交易市场的参数信息,包括交易费,最小下单量,价格精度等。
URL: https://data.gateio.io/api2/1/marketinfo
# Request
GET: https://data.gateio.io/api2/1/marketinfo
# Response
{
"result": "true",
"pairs": [
{
"eth_btc": {
"decimal_places": 6,
"min_amount": 0.0001,
"min_amount_a": 0.001,
"min_amount_b": 0.0001,
"fee": 0.2,
"trade_disabled ": 0
}
},
{
"zec_btc": {
"decimal_places": 4,
"min_amount": 0.0001,
"min_amount_a": 0.0001,
"min_amount_b": 0.0001,
"fee": 0.2,
"trade_disabled ": 0
}
}
]
}
decimal_places: 价格精度
min_amount : 最小下单量
min_amount_a : 幣種a [CURR_A]的最小下單量
min_amount_b : 幣種b [CURR_B]的最小下單量
fee : 交易费
trade_disabled : 0表示未暂停交易,1表示已经暂停交易
币种状态
返回所有系统支持的币种状态信息,包括充值、提现、交易状态等。
URL: https://data.gateio.io/api2/1/coininfo
# Request
GET: https://data.gateio.io/api2/1/coininfo
# Response
{
"result": "true",
"pairs": [
{
"USDT": {
"delisted": 0,
"withdraw_disabled": 0,
"withdraw_delayed ": 0,
"deposit_disabled": 0,
"trade_disabled": 0,
}
}
]
}
delisted : 0表示未下架,1表示已经下架
withdraw_disabled : 0表示未暂停提现,1表示已经暂停提现
withdraw_delayed : 0表示未提现没有延迟,1表示提现存在延迟
deposit_disabled : 0表示未暂停充值,1表示已经暂停充值
trade_disabled : 0表示未暂停交易,1表示已经暂停交易
交易市场详细行情 API
返回所有系统支持的交易市场的详细行情和币种信息,包括币种名,市值,供应量,最新价格,涨跌趋势,价格曲线等。
URL: https://data.gateio.io/api2/1/marketlist
# Request
GET: https://data.gateio.io/api2/1/marketlist
# Response
{
"result": "true",
"data": [
{
"no": 1,
"symbol": "LTC",
"name": "Litecoin",
"name_en": "Litecoin",
"name_cn": "莱特币",
"pair": "ltc_btc",
"rate": "418.00",
"vol_a": 168120.2,
"vol_b": "65,616,561",
"curr_a": "LTC",
"curr_b": "BTC",
"curr_suffix": " BTC",
"rate_percent": "19.73",
"trend": "up",
"supply": 25760300,
"marketcap": "10,767,805,404",
"plot": null
},
{
"no": 2,
"symbol": "ETH",
"name": "ETH",
"name_en": "ETH",
"name_cn": "以太币",
"pair": "etc_eth",
"rate": "0.7450",
"vol_a": 65227328.3,
"vol_b": "51,041,999",
"curr_a": "etc",
"curr_b": "eth",
"curr_suffix": " eth",
"rate_percent": "-1.84",
"trend": "up",
"supply": 1050000000,
"marketcap": "782,250,000",
"plot": null
}
]
}
symbol : 币种标识
name: 币种名称
name_en: 英文名称
name_cn: 中文名称
pair: 交易对
rate: 当前价格
vol_a: 被兑换货币交易量
vol_b: 兑换货币交易量
curr_a: 被兑换货币
curr_b: 兑换货币
curr_suffix: 货币类型后缀
rate_percent: 涨跌百分百
trend: 24小时趋势 up涨 down跌
supply: 币种供应量
marketcap: 总市值
plot: 趋势数据
所有交易行情 API
返回系统支持的所有交易对的 最新,最高,最低 交易行情和交易量,每10秒钟更新:
URL: https://data.gateio.io/api2/1/tickers
# Request
GET: https://data.gateio.io/api2/1/tickers
# Response
{
"eth_btc": {
"result": "true",
"last": 0.1,
"lowestAsk": 0.1,
"highestBid": "0.00000000",
"percentChange": 0,
"baseVolume": 0.001,
"quoteVolume": 0.01,
"high24hr": 0.1,
"low24hr": 0.1
},
"xrp_btc": {
"result": "true",
"last": "0.00004720",
"lowestAsk": "0.00005620",
"highestBid": "0.00004550",
"percentChange": -7.4510907045863,
"baseVolume": 0.5324,
"quoteVolume": 11417.333,
"high24hr": "0.00005580",
"low24hr": "0.00004560"
}
}
baseVolume: 交易量
high24hr:24小时最高价
highestBid:买方最高价
last:最新成交价
low24hr:24小时最低价
lowestAsk:卖方最低价
percentChange:涨跌百分比
quoteVolume: 兑换货币交易量
单项交易行情 API
返回系统支持的所有交易对的 最新,最高,最低 交易行情和交易量,每10秒钟更新:
URL: https://data.gateio.io/api2/1/ticker/[CURR_A]_[CURR_B]
请替换 [CURR_A] and [CURR_B] 为您需要查看的币种.
支持的兑换类型:
# Request
GET: https://data.gateio.io/api2/1/ticker/eth_btc
# Response
{
"result": "true",
"last": 0.1,
"lowestAsk": 0.1,
"highestBid": "0.00000000",
"percentChange": 0,
"baseVolume": 0.001,
"quoteVolume": 0.01,
"high24hr": 0.1,
"low24hr": 0.1
}
baseVolume: 交易量
high24hr:24小时最高价
highestBid:买方最高价
last:最新成交价
low24hr:24小时最低价
lowestAsk:卖方最低价
percentChange:涨跌百分比
quoteVolume: 兑换货币交易量
市场深度 API
返回系统支持的所有交易对的市场深度(委托挂单),其中 asks 是委卖单, bids 是委买单。
URL: https://data.gateio.io/api2/1/orderBooks
返回系统支持的所有交易对的市场深度(委托挂单),其中 asks 是委卖单, bids 是委买单。
URL: https://data.gateio.io/api2/1/orderBook/[CURR_A]_[CURR_B]
请替换 [CURR_A] and [CURR_B] 为您需要查看的币种.
支持的兑换类型:
# Request
GET: https://data.gateio.io/api2/1/orderBook/eth_btc
# Response
{
"result": "true",
"asks": [
[29500, 4.07172355],
[29499, 0.00203397],
[29495, 1],
[29488, 0.0672],
[29475, 0.001]
],
"bids": [
[28001, 0.0477],
[28000, 0.35714018],
[28000, 2.56222976],
[27800, 0.0015],
[27777, 0.1]
]
}
asks :卖方深度
bids :买方深度
历史成交记录 API
返回最新80条历史成交记录:
URL: https://data.gateio.io/api2/1/tradeHistory/[CURR_A]_[CURR_B]
# Request
GET: https://data.gateio.io/api2/1/tradeHistory/eth_btc
# Response
{
"result": "true",
"data": [
{
"tradeID": "27734287",
"date": "2017-09-29 11:52:05",
"timestamp": "1506657125",
"type": "buy",
"rate": 0.1,
"amount": 0.01,
"total": 0.001
}
],
"elapsed": "6.901ms"
}
返回从[TID]往后的最多1000历史成交记录:
URL: https://data.gateio.io/api2/1/tradeHistory/[CURR_A]_[CURR_B]/[TID]
请替换 [CURR_A] and [CURR_B] 为您需要查看的币种.
支持的兑换类型:
# Request
GET: https://data.gateio.io/api2/1/tradeHistory/eth_btc/3275876
# Response
{
"result": "true",
"data": [
{
"tradeID": 3175762,
"date": "2017-08-25 07:24:28",
"type": "sell",
"rate": 29011,
"amount": 0.0019,
"total": 55.1209
},
{
"tradeID": 3175771,
"date": "2017-08-25 07:24:41",
"type": "sell",
"rate": 29011,
"amount": 0.0032,
"total": 92.8352
}
],
"elapsed": "31.518ms"
}
amount: 成交币种数量
date: 订单时间
rate: 币种单价
total: 订单总额
tradeID: tradeID
type: 买卖类型, buy买 sell卖
交易市场K线数据
返回市场最近时间段内的K先数据:
URL: https://data.gateio.io/api2/1/candlestick2/[CURR_A]_[CURR_B]?group_sec=[GROUP_SEC]&range_hour=[RANGE_HOUR]
# Request
https://data.gateio.io/api2/1/candlestick2/btc_usdt?group_sec=60&range_hour=1
# Response
{
"result": "true",
"data": [
[1524556800000, 12.8756391686, 9266.02, 9266.21, 9231.01, 9233.99],
[1524558600000, 18.3153691562, 9255.79, 9284, 9251.01, 9252],
[1524560400000, 17.5693326481, 9255, 9290.37, 9238.89, 9255.79],
[1524562200000, 13.0314933662, 9281.92, 9295, 9239, 9255.4],
[1524564000000, 26.0352948098, 9290.92, 9327.46, 9282, 9282],
[1524565800000, 24.5813921079, 9300, 9340, 9290, 9297.5],
[1524567600000, 27.8742949471, 9345, 9348.99, 9291.91, 9300],
[1524569400000, 29.3344591996, 9299.99, 9349.99, 9290, 9343.93],
[1524571200000, 28.4720072519, 9305, 9327.99, 9286.32, 9290.02],
...
]
}
返回[range_hour]范围内的K线数据:
URL: https://data.gateio.io/api2/1/candlestick2/[CURR_A]_[CURR_B]?group_sec=[GROUP_SEC]&range_hour=[RANGE_HOUR]
请替换 [CURR_A] 和 [CURR_B] 为您需要查看的币种,GROUP_SEC 和 RANGE_HOUR 替换为需要获取的时间区域.
支持的兑换类型:
# Request
GET: https://data.gateio.io/api2/1/candlestick2/btc_usdt?group_sec=60&range_hour=1
# Response
{
"result": "true",
"data": [
[1524556800000, 12.8756391686, 9266.02, 9266.21, 9231.01, 9233.99],
[1524558600000, 18.3153691562, 9255.79, 9284, 9251.01, 9252],
[1524560400000, 17.5693326481, 9255, 9290.37, 9238.89, 9255.79],
[1524562200000, 13.0314933662, 9281.92, 9295, 9239, 9255.4],
[1524564000000, 26.0352948098, 9290.92, 9327.46, 9282, 9282],
[1524565800000, 24.5813921079, 9300, 9340, 9290, 9297.5],
[1524567600000, 27.8742949471, 9345, 9348.99, 9291.91, 9300],
[1524569400000, 29.3344591996, 9299.99, 9349.99, 9290, 9343.93],
[1524571200000, 28.4720072519, 9305, 9327.99, 9286.32, 9290.02],
...
]
}
time: 时间戳
volume: 交易量
close: 收盘价
high: 最高价
low: 最低价
open: 开盘价
自动交易 API
系统返回错误码对应说明
用户首先要通过这个链接获取API接口身份认证用到的Key和Secret。然后在程序中用Secret作为密码,通过SHA512加密方式签名需要POST给服务器的数据得到Sign,并在HTTPS请求的Header部分传回Key和Sign。请参考以下接口说明和例子程序进行设置。
获取帐号资金余额API
API URL: https://api.gateio.io/api2/1/private/balances
参数数据提交方式:POST
参数:无
返回数据格式:JSON
# Request
POST: https://api.gateio.io/api2/1/private/balances
# Response
{
"result": "true",
"available": {
"BTC": "1000",
"ETH": "968.8",
"ETC": "0",
},
"locked": {
"ETH": "1"
}
}
available: 可用各币种资金余额
locked : 冻结币种金额
获取杠杆帐号资金余额API
API URL: https://api.gateio.io/api2/1/private/marginbalances
参数数据提交方式:POST
参数:无
返回数据格式:JSON
# Request
POST: https://api.gateio.io/api2/1/private/marginbalances
# Response
{
"result": "true",
"datas": [
{
"market": "BTC_USDT",
"curr_a": "BTC",
"curr_b": "USDT",
"available_a": "99.993214",
"available_b": "9994.000035",
"frozen_a": "0.000000",
"frozen_b": "0.000000",
"borrowed_a": "0.000000",
"borrowed_b": "0.000000"
}
]
}
market: 交易对
curr_a: 交易货币
curr_b: 计价货币
available_a: 交易货币可用额度
available_b: 计价货币可用额度
frozen_a: 交易货币冻结资金
frozen_b: 计价货币冻结资金
borrowed_a: 交易货币借入资金
borrowed_b: 计价货币借入资金
获取理财帐号资金余额API
API URL: https://api.gateio.io/api2/1/private/fundingbalances
参数数据提交方式:POST
参数:无
返回数据格式:JSON
# Request
POST: https://api.gateio.io/api2/1/private/fundingbalances
# Response
{
"result": "true",
"datas": [
{
"asset": "BTC",
"available": "0.000000",
"freeze": "10.000000",
"lent": "0.000000",
"total_lend": "10.000000"
},
{
"asset": "USDT",
"available": "0.000000",
"freeze": "0.000000",
"lent": "0.000000",
"total_lend": "0.000000"
},
{
"asset": "ETH",
"available": "99987.911780",
"freeze": "0.000000",
"lent": "0.000000",
"total_lend": "0.000000"
}
]
}
asset: 币种,
available: 可用资产
freeze: 冻结资产
lent: 借出金额
total_lend: 理财总计
获取充值地址API
API URL: https://api.gateio.io/api2/1/private/depositAddress
参数数据提交方式:POST
返回数据格式:JSON
参数名 | 参数类型 | 必填 | 描述 |
currency | String | 是 | 币种 如(BTC, LTC) |
# Request
POST: https://api.gateio.io/api2/1/private/depositAddress
# Response
{
"result": "true",
"addr": "LPXtk1kWHioP62SzfqwKbYE3Z7Wt2ujYEc",
"message": "Sucess",
"code": 0
}
addr: 钱包地址
获取充值提现历史API
API URL: https://api.gateio.io/api2/1/private/depositsWithdrawals
参数数据提交方式:POST
返回数据格式:JSON
参数名 | 参数类型 | 必填 | 描述 |
start | String | 否 | 起始UNIX时间(如 1469092370) |
end | String | 否 | 终止UNIX时间(如 1469713981) |
# Request
POST: https://api.gateio.io/api2/1/private/depositsWithdrawals
# Response
{
"result": "true",
"deposits": [
{
"id": "c204730",
"currency": "ETH",
"address": "1111 1111 1111 1111 1111 1",
"amount": "222.61",
"txid": "210496",
"timestamp": "1474962729",
"status": "DONE"
}
],
"withdraws": [
{
"currency": "ETC",
"address": "addr2",
"amount": "600000000",
"txid": "2104963",
"timestamp": "1469092378",
"status": "DONE"
}
],
"message": "Success"
}
deposits: 充值
withdraws: 提现
currency: 币种
address: 充值/提现地址
amount: 金额
timestamp: 发起时间戳
status: 记录状态 DONE:完成; CANCEL:取消; REQUEST:请求中
下单交易买入API
API URL: https://api.gateio.io/api2/1/private/buy
参数数据提交方式:POST
返回数据格式:JSON
参数名 | 参数类型 | 必填 | 描述 | 示例: |
currencyPair | String | 是 | 交易币种对(如ltc_btc,ltc_btc) | ltc_btc |
rate | String | 是 | 价格 | 1000 |
amount | String | 是 | 最近30天交易量 | 800 |
orderType | String | 否 | 订单类型(“”:普通订单(默认);“ioc”:立即执行否则取消订单(Immediate-Or-Cancel,IOC)) | ioc |
# Request
POST: https://api.gateio.io/api2/1/private/buy
# Response
{
"result":"true",
"orderNumber":"123456",
"rate":"1000",
"leftAmount":"0",
"filledAmount":"0.1",
"filledRate":"800.00",
"message":"Success"
}
orderNumber: 订单单号
rate: 下单价格
leftAmount: 剩余数量
filledAmount: 成交数量
filledRate: 成交价格
注:返回的orderNumber可用于查询,取消订单。
下单交易卖出API
API URL: https://api.gateio.io/api2/1/private/sell
参数数据提交方式:POST
返回数据格式:JSON
参数名 | 参数类型 | 必填 | 描述 | 示例: |
currencyPair | String | 是 | 交易币种对(如ltc_btc,ltc_btc) | ltc_btc |
rate | String | 是 | 价格 | 1000 |
amount | String | 是 | 交易量 | 800 |
orderType | String | 否 | 订单类型(“”:普通订单(默认);“ioc”:立即执行否则取消订单(Immediate-Or-Cancel,IOC)) | ioc |
# Request
POST: https://api.gateio.io/api2/1/private/sell
# Response
{
"result":"true",
"orderNumber":"123456",
"rate":"1000",
"leftAmount":"0",
"filledAmount":"0.1",
"filledRate":"800.00",
"message":"Success"
}
orderNumber: 订单单号
rate: 下单价格
leftAmount: 剩余数量
filledAmount: 成交数量
filledRate: 成交价格
注:返回的orderNumber可用于查询,取消订单。
取消下单API
API URL: https://api.gateio.io/api2/1/private/cancelOrder
参数数据提交方式:POST
返回数据格式:JSON
参数名 | 参数类型 | 必填 | 描述 |
orderNumber | String | 是 | 下单单号 |
currencyPair | String | 是 | 交易币种对(如 ltc_btc) |
# Request
POST: https://api.gateio.io/api2/1/private/cancelOrder
# Response
{"result":"true","message":"Success"}
result: 是否成功 true成功 false失败
message: 提示消息
取消多个下单API
API URL: https://api.gateio.io/api2/1/private/cancelOrders
参数数据提交方式:POST
返回数据格式:JSON
参数名 | 参数类型 | 必填 | 描述 |
orders_json | String | 是 | 下单单号和pair的json数据; 示例:[ { "orderNumber":"7942422" "currencyPair":"ltc_btc" }, { "orderNumber":"7942423" "currencyPair":"ltc_btc" } ] |
# Request
POST: https://api.gateio.io/api2/1/private/cancelOrders
# Response
{"result":"true","message":"Success"}
result: 是否成功 true成功 false失败
message: 提示消息
取消所有下单API
API URL: https://api.gateio.io/api2/1/private/cancelAllOrders
参数数据提交方式:POST
返回数据格式:JSON
参数名 | 参数类型 | 必填 | 描述 |
type | int | 是 | 下单类型(0:卖出,1:买入,-1:不限制) |
currencyPair | String | 是 | 交易币种对 (示例:ltc_btc) |
# Request
POST: https://api.gateio.io/api2/1/private/cancelAllOrders
# Response
{"result":"true","message":"Success"}
result: 是否成功 true成功 false失败
message: 提示消息
获取下单状态API
API URL: https://api.gateio.io/api2/1/private/getOrder
参数数据提交方式:POST
返回数据格式:JSON
参数名 | 参数类型 | 必填 | 描述 |
orderNumber | String | 是 | 下单单号 |
currencyPair | String | 是 | 交易币种对(如:eth_btc) |
# Request
POST: https://api.gateio.io/api2/1/private/getOrder
# Response
{
"result":"true",
"order":{
"id":"15088",
"status":"cancelled",
"currencyPair":"eth_btc",
"type":"sell",
"rate":811,
"amount":"0.39901357",
"initialRate":811,
"initialAmount":"1"
},
"message":"Success"
}
status: 订单状态 open已挂单 cancelled已取消 closed已完成
currencyPair: 交易对
type: 买卖类型 sell卖出, buy买入
rate: 价格
amount:买卖数量
initialRate:下单价格
initialAmount: 下单量
获取我的当前挂单列表API
API URL: https://api.gateio.io/api2/1/private/openOrders
参数数据提交方式:POST
参数名 | 参数类型 | 必填 | 描述 |
currencyPair | String | 否 | 交易币种对(如:eth_btc) |
currencyPair参数为空时,返回所有交易市场挂单
返回数据格式:JSON
# Request
POST: https://api.gateio.io/api2/1/private/openOrders
# Response
{
"result": "true", "message": "Success", "code": 0,"elapsed": "6.262ms",
"orders": [
{
"orderNumber": "30032151",
"type": "buy",
"rate": 21367.521367521,
"amount": "0.0936",
"total": "2000",
"initialRate": 21367.521367521,
"initialAmount": "0.0936",
"filledRate": 0,
"filledAmount": 0,
"currencyPair": "eth_btc",
"timestamp": "1407828913",
"status": "open"
}
]
}
amount: 订单总数量 剩余未成交数量
currencyPair: 订单交易对
filledAmount: 已成交量
filledRate: 成交价格
initialAmount: 下单量
initialRate:下单价格
orderNumber: 订单号
rate:交易单价
status: 订单状态
timestamp: 时间戳
total2
type: 买卖类型 buy:买入;sell:卖出
获取我的24小时内成交记录API
API URL: https://api.gateio.io/api2/1/private/tradeHistory
参数数据提交方式:POST
返回数据格式:JSON
参数:
参数名 | 参数类型 | 必填 | 描述 |
currencyPair | String | 是 | 交易币种对 |
orderNumber | String | 否 | 订单号 |
# Request
POST: https://api.gateio.io/api2/1/private/tradeHistory
# Response
{
"result": "true",
"message": "Success",
"trades": [
{
"id": "7942422",
"orderid": "38100491",
"pair": "ltc_btc",
"type": "buy",
"rate": "0.01719",
"amount": "0.0588",
"time": "06-12 02:49:11",
"time_unix": "1402512551"
}
]
}
orderid: 订单id
pair: 交易对
type: 买卖类型
rate: 买卖价格
amount: 订单买卖币种数量
time: 订单时间
time_unix: 订单unix时间戳
提现API
API URL: https://api.gateio.io/api2/1/private/withdraw
参数数据提交方式:POST
返回数据格式:JSON
参数名 | 参数类型 | 必填 | 描述 |
currency | String | 是 | 提现币种(如:btc) |
amount | String | 是 | 提现数量 |
address | String | 是 | 提现地址 |
# Request
POST: https://api.gateio.io/api2/1/private/withdraw
# Response
{ "result": "true", "message": "Success"}
result: 是否成功 true成功 false失败
message: 提示消息
错误代码说明
系统返回错误码对应说明
错误代码 | 详细描述 |
---|---|
1 | 无效请求 |
2 | 无效版本 |
3 | 无效请求 |
4 | 没有访问权限 |
5,6 | Key或签名无效,请重新创建 |
7 | 币种对不支持 |
8,9 | 币种不支持 |
10 | 验证错误 |
11 | 地址获取失败 |
12 | 参数为空 |
13 | 系统错误,联系管理员 |
14 | 无效用户 |
15 | 撤单太频繁,一分钟后再试 |
16 | 无效单号,或挂单已撤销 |
17 | 无效单号 |
18 | 无效挂单量 |
19 | 交易已暂停 |
20 | 挂单量太小 |
21 | 资金不足 |
40 | 请求太频繁,稍后再试 |