简介
API 简介
欢迎使用DigiFinex API。
此文档是DigiFinex API的唯一官方文档,DigiFinex API提供的能力会在此持续更新,请大家及时关注。
你可以通过点击右上方的语言按钮来切换文档语言(You can switch different language by clicking language button in the top right.)。
做市商项目
DigiFinex欢迎有优秀 maker 策略且交易量大的用户参与长期做市商项目。合作做市商可在交易手续费(返佣)、API频率与交易规则限制、服务器资源等方面得到D网的支持。
如果您意向成为DigiFinex的做市商,请提供以下信息发送邮件至:[email protected]
(现货 / 杠杆)做市商申请,请提供一下信息:
1.提供 UID (需不存在返佣关系的 UID);
2.提供其他交易平台 maker 交易量截图证明(比如30天内成交量,或者 VIP/专业用户等级等);
3.请简要阐述做市方法,不需要细节。
联系我们
使用过程中如有问题或者建议,您可选择以下任一方式联系我们:
加入官方telegram群:https://t.me/digifinex_api
发送邮件至:[email protected]
接入说明
DigiFinex API交易规则说明
为提供更好的交易环境,避免恶意操作与异常API用户影响市场的正常交易秩序,DigiFinex对API交易行为制定了以下反操作交易规则。
量化指标
指标考察范围为一定时间周期内同一交易对的交易。
- 成交率(FR) 成交率=成交笔数/委托笔数
- 成交权重(FW)
成交权重=成交总金额/委托总金额 - 撤单率(CR) 撤单率=无效撤单笔数/委托笔数 其中无效撤单指撤单时间与下单时间间隔小于5秒且成交数为0的委托
指标参考触发值
指标 | 指标触发值 | 触发条件 | 计算周期 |
---|---|---|---|
成交率(FR) | <0.01 | 委托单数量 > 99 | 每10分钟 |
成交权重(FW) | <0.01 | 委托单数量 > 49 | 每10分钟 |
撤单率(CR) | >0.95 | 委托单数量 > 99 | 每10分钟 |
风控与禁用
API交易指标超过风控阈值后将被限制30分钟,若三小时内被限制次数达到或超过3次,限制时间将延长为24小时,被API风控系统限制期间,用户无法创建新的API及使用API在任意交易对挂单,其他客户端挂撤单以及API撤单不受影响。
交易接口列表
接口列表
权限类型 | 接口数据类型 | 请求方法 | 类型 | 描述 | 需要验签 |
---|---|---|---|---|---|
读取 | 基础行情接口 | /ping | GET | ping服务器 | 否 |
读取 | 基础行情接口 | /time | GET | 服务器时间 | 否 |
读取 | 公共行情接口 | /markets | GET | 所有交易市场描述 | 否 |
读取 | 公共行情接口 | /ticker | GET | /ticker | 否 |
读取 | 公共行情接口 | /order_book | GET | 获取买卖盘 | 否 |
读取 | 公共行情接口 | /trades | GET | 获取最近成交记录 | 否 |
读取 | 公共行情接口 | /kline | GET | 获取交易对K线信息 | 否 |
读取 | 公共行情接口 | /spot/symbols | GET | 现货交易对 | 否 |
读取 | 公共行情接口 | /margin/currencies | GET | 保证金币种列表 | 否 |
读取 | 公共行情接口 | /margin/symbols | GET | 保证金交易对 | 否 |
读取 | 公共行情接口 | /trades/symbols | GET | 交易对是否开通API交易功能 | 否 |
交易 | 账户接口 | /{market}/financelog | GET | 现货、保证金、场外财务日志 | 是 |
交易 | 账户接口 | /{market}/order | GET | 查询订单状态 | 是 |
交易 | 账户接口 | /{market}/order/detail | GET | 查询订单成交详情 | 是 |
交易 | 账户接口 | /{market}/order/current | GET | 当前活跃挂单 | 是 |
交易 | 账户接口 | /{market}/order/history | GET | 查询所有订单(包括历史订单) | 是 |
交易 | 账户接口 | /{market}/mytrades | GET | 成交记录 | 是 |
交易 | 账户接口 | /spot/assets | GET | 现货账户资产 | 是 |
交易 | 账户接口 | /margin/positions | GET | 保证金持仓 | 是 |
交易 | 账户接口 | /margin/assets | GET | 保证金账户资产 | 是 |
交易 | 账户接口 | /{market}/order/new | POST | 下单 | 是 |
交易 | 账户接口 | /{market}/order/batch_new | POST | 批量下单 | 是 |
交易 | 账户接口 | /{market}/order/cancel | POST | 撤销订单 | 是 |
交易 | 账户接口 | /transfer | POST | 资金划转 | 是 |
交易 | 账户接口 | /margin/position/close | POST | 平仓 | 是 |
访问地址
访问地址 | 适用站点 | 适用功能 | 适用交易对 |
---|---|---|---|
https://openapi.digifinex.com/v3 | digifinex | API | digifinex 交易对 |
安全认证
目前关于apikey申请和修改,请在“账户 - API管理”页面进行相关操作。其中AccessKey为API 访问密钥,SecretKey为用户对请求进行签名的密钥(仅申请时可见)。
重要提示:这两个密钥与账号安全紧密相关,无论何时都请勿向其它人透露。
合法请求结构
POST请求采用:content-type: application/x-www-form-urlencoded
参数可同时使用query string和request body,参数重复则以query string优先
所有接口被分类为2个级别:
public 公共接口,无需签名,无需请求时间戳
private 私有接口,需要签名,需要请求时间戳
签名接口必需带请求头:
ACCESS-KEY 用户API-KEY
ACCESS-SIGN 签名结果
ACCESS-TIMESTAMP 请求时间戳,秒为单位
服务器收到签名接口时会判断请求中的时间戳,如果是5秒之前发出的,则请求会被认为无效。这个时间窗口值可以通过发送可选请求头ACCESS-RECV-WINDOW 来自定义,另外,如果服务器计算得出客户端时间戳在服务器时间的‘未来’1秒以上,也会拒绝请求
所有请求都会消耗服务器资源,基于负载考虑,所有请求都有一个权重,所有[IP|API-KEY|用户]每分钟请求权重之和不得超过1200,超过1200,24小时内前三次将会禁用2分钟,超过3次将会禁用10分钟,超过6次将会禁用30分钟
签名算法
签名使用HMAC SHA256算法
API-KEY所对应的API-Secret作为 HMAC SHA256 的密钥,其他所有参数作为HMAC SHA256的操作对象,得到的输出即为签名
签名大小写不敏感
当同时使用query string和request body时,HMAC SHA256的输入query string在前,request body在后,query string和request body中间拼接'&'
签名对应ACCESS-KEY,签名结果ACCESS-SIGN放在请求头里
签名运算
签名说明
API 请求在通过 Internet 发送的过程中极有可能被篡改。为了确保请求未被更改,我们会要求用户在每个请求中带上签名(行情 API 除外),来校验参数或参数值在传输途中是否发生了更改。
计算签名所需的步骤:
规范要计算签名的请求 因为使用 HMAC 进行签名计算时,使用不同内容计算得到的结果会完全不同。所以在进行签名计算前,请先对请求进行规范化处理。下面以下单请求为例进行说明
- 下单参数。
{'symbol': 'trx_usdt', 'price': 0.01, 'amount': 1, 'type': 'buy'}
- 将字典里面所有的键值转化为query-string格式,并使用UTF-8编码。
symbol=trx_usdt&price=0.01&amount=1&type=buy
- 使用api secret进行HmacSHA256计算签名(例Secret:01234567890123456789abcd),计算签名后得到:
7e2d0636cab21fd41c828b8c6ce8f77e643febecdeaeab0771c01dc4d7dbef38
- 将ACCESS-KEY,ACCESS-TIMESTAMP,ACCESS-SIGN(上一步加密得到)加入请求header里。
{'ACCESS-KEY': '0123456789abcd', 'ACCESS-TIMESTAMP': '1589872188', 'ACCESS-SIGN': '7e2d0636cab21fd41c828b8c6ce8f77e643febecdeaeab0771c01dc4d7dbef38'}
- 请求下单。
Method: Post
url: https://openapi.digifinex.com/v3/spot/order/new
headers: {'ACCESS-KEY': '0123456789abcd', 'ACCESS-TIMESTAMP': '1589872188', 'ACCESS-SIGN': '7e2d0636cab21fd41c828b8c6ce8f77e643febecdeaeab0771c01dc4d7dbef38'}
body: {'symbol': 'trx_usdt', 'price': 0.01, 'amount': 1, 'type': 'buy'}
错误码详情
错误代码 | 错误描述 |
---|---|
0 | 成功 |
10001 | 请求method错误 |
10002 | ApiKey错误 |
10003 | 签名错误 |
10004 | 参数错误 |
10005 | 频率限制 |
10006 | 无权限 |
10007 | 访问者IP不在白名单内 |
10008 | 时间戳不在指定范围内 |
10009 | 没有该方法或未附带ACCESS-KEY |
10011 | 该apikey已经过期,不能使用,为了安全请创建新的api |
20002 | 该币种对暂时不允许交易 |
20007 | 价格精度限制 |
20008 | 数量精度限制 |
20009 | 最小交易数量限制 |
20010 | 最小交易额限制 |
20011 | 账户余额不足 |
20012 | 无效的交易类型(buy/sell) |
20013 | 没有找到该订单 |
20014 | 日期格式不对,例:2018-07-25 |
20015 | 查询的订单日期超过限制 |
20018 | 您的交易权限已被系统限制 |
20019 | 交易对错误,注意交易币在前,基础币在后 |
20020 | 违反了操作交易规则,暂时禁止交易。目前对成交率、成交权重、撤单率等有限制 |
20021 | 币种错误 |
20022 | 结束时间应该大于或等于开始时间 |
20023 | 无效的划转类型 |
20024 | 无效的数量 |
20025 | 该币种当前无法划转 |
20026 | 划转余额不足 |
20027 | 账户当前异常 |
20028 | 划转黑名单 |
20029 | 超出每日限额 |
20030 | 该交易对当前无持仓 |
20031 | 批量下单限制 |
20032 | 限制提币 |
20033 | 提币ID错误 |
20034 | 该币种已关闭提币 |
20035 | 提币数量限制 |
20036 | 撤销提币失败 |
20037 | 提币地址、Tag或链类型不在提币管理列表内 |
20038 | 提币地址不在白名单内 |
20039 | 该状态不能撤销 |
20040 | 提币超过频率限制,一分钟3次,一天100次 |
20041 | 超过当日提币额度 |
20042 | 该交易对暂不支持API交易 |
50000 | 系统错误(新增) |
基础行情接口
ping服务器
HTTP 请求
- GET
https://openapi.digifinex.com/v3/ping
请求参数
此接口不接受任何参数。
Response:
{
"msg": "pong",
"code": 0
}
返回参数
参数名称 | 是否必须 | 类型 | 描述 |
---|---|---|---|
msg | true | string | 请求结果 |
code | true | int | 状态 |
服务器时间
HTTP 请求
- GET
https://openapi.digifinex.com/v3/time
请求参数
此接口不接受任何参数。
Response:
{
"server_time": 1589873762,
"code": 0
}
返回参数
参数名称 | 是否必须 | 类型 | 描述 |
---|---|---|---|
server_time | true | int | 服务器时间 |
code | true | int | 状态 |
公共行情接口
所有交易市场描述
HTTP 请求
- GET
https://openapi.digifinex.com/v3/markets
请求参数
此接口不接受任何参数。
Response:
{
"data": [{
"volume_precision": 4,
"price_precision": 2,
"market": "btc_usdt",
"min_amount": 2,
"min_volume": 0.0001
}],
"date": 1589873858,
"code": 0
}
返回参数
参数名称 | 是否必须 | 类型 | 描述 |
---|---|---|---|
data | true | object | 交易对信息 |
volume_precision | true | int | 交易量精度 |
price_precision | true | int | 价格精度 |
market | true | string | 市场交易对名称 |
min_amount | true | float | 最小交易金额 |
min_volume | true | float | 最小交易量 |
date | true | int | 时间戳 |
code | true | int | 状态 |
获取行情数据
HTTP 请求
- GET
https://openapi.digifinex.com/v3/ticker
请求参数
参数名称 | 参数类型 | 必填 | 描述 |
---|---|---|---|
symbol | string | false | "btc_usdt" |
Response:
{
"ticker": [{
"vol": 40717.4461,
"change": -1.91,
"base_vol": 392447999.65374,
"sell": 9592.23,
"last": 9592.22,
"symbol": "btc_usdt",
"low": 9476.24,
"buy": 9592.03,
"high": 9793.87
}],
"date": 1589874294,
"code": 0
}
返回参数
参数名称 | 是否必须 | 类型 | 描述 |
---|---|---|---|
ticker | true | object | 交易对信息 |
vol | true | float | 24h成交量(交易币计) |
change | true | float | 24h涨跌幅百分比(当前价格与24h前价格相比), 取值0.0108表示价格上涨1.08% |
base_vol | true | float | 24h成交额(以计价币种计) |
sell | true | float | 卖一价 |
last | true | float | 最新成交价 |
symbol | true | string | 交易对 |
low | true | string | 24h最低价 |
buy | true | float | 买一价 |
high | true | float | 24h最高价 |
date | true | int | 时间戳 |
code | true | int | 状态 |
获取买卖盘
HTTP 请求
- GET
https://openapi.digifinex.com/v3/order_book
请求参数
参数名称 | 参数类型 | 必填 | 描述 |
---|---|---|---|
symbol | string | true | "btc_usdt" |
limit | int | false | 数量,没有该字段返回10条,最长150条 |
Response:
{
"bids": [
[9559.45, 1.3766],
[9559.04, 0.0127],
..
],
"asks": [
[9563.45, 0.6312],
[9563.34, 0.0087],
..
],
"date": 1589874953,
"code": 0
}
返回参数
参数名称 | 是否必须 | 类型 | 描述 |
---|---|---|---|
bids | true | object | 当前的所有买单 [price, size] |
asks | true | object | 当前的所有卖单 [price, size] |
date | true | int | 时间戳 |
code | true | int | 状态 |
获取最近成交记录
HTTP 请求
- GET
https://openapi.digifinex.com/v3/trades
请求参数
参数名称 | 参数类型 | 必填 | 描述 |
---|---|---|---|
symbol | string | true | "btc_usdt" |
limit | int | false | 数量,没有该字段默认返回100条,最长500条 |
Response:
{
"data": [{
"date": 1589875415,
"id": 2989995478,
"amount": 0.001,
"type": "buy",
"price": 9661.05
}, {
"date": 1589875415,
"id": 2989995473,
"amount": 0.0005,
"type": "buy",
"price": 9659.99
},
...
],
"date": 1589875415,
"code": 0
}
返回参数
参数名称 | 是否必须 | 类型 | 描述 |
---|---|---|---|
data | true | object | 成交记录 |
date | true | int | 时间戳 |
id | true | int | 交易ID |
amount | true | float | 成交量 |
type | true | str | 订单类型 |
price | true | float | 成交价 |
code | true | int | 状态 |
获取交易对K线信息
HTTP 请求
- GET
https://openapi.digifinex.com/v3/kline
请求参数
参数名称 | 参数类型 | 必填 | 描述 |
---|---|---|---|
symbol | string | true | "btc_usdt" |
period | str | true | K线类型,1,5,15,30,60,240,720,1D,1W |
start_time | int | false | K线开始时间,有效时间戳。缺省,则返回end_time之前的200根k线 |
end_time | int | false | K线结束时间,有效时间戳,⼤于start_time。缺省为当前时间戳 |
获取交易对K线信息,一次最多获取500条
Response:
{
"data": [
[1589426100, 621.4565, 9342.7, 9349.99, 9305.86, 9307.96],
[1589427000, 378.1678, 9333.71, 9344.25, 9318.26, 9342.23],
...,
],
"code": 0
}
返回参数
参数名称 | 是否必须 | 类型 | 描述 |
---|---|---|---|
data | true | object | K线信息[timestamp,vol,close,high,low,open],最后一组数据为当前K线数据 |
code | true | int | 状态 |
交易对是否开通API交易功能
HTTP 请求
- GET
https://openapi.digifinex.com/v3/trades/symbols
请求参数
此接口不接受任何参数。
Response:
{
"code": 0,
"symbol_list": [
{
"status": "TRADING",
"symbol": "LTC_USDT",
"quote_asset": "USDT",
"base_asset": "LTC",
"amount_precision": 4,
"price_precision": 2,
"minimum_amount": 0.001,
"minimum_value": 2,
"zone": "MAIN",
"is_allow": "1",
"order_types": [
"LIMIT",
"MARKET"
]
}
]
}
返回参数
参数名称 | 是否必须 | 类型 | 描述 |
---|---|---|---|
symbol_list | true | object | 交易对信息 |
order_types | true | list | 订单类型 |
quote_asset | true | str | 基础币种 |
minimum_value | true | int | 最小价值 |
amount_precision | true | int | 数量精度 |
status | true | str | 状态 |
minimum_amount | true | float | 最小额度 |
symbol | true | str | 交易对 |
zone | true | str | 板块 |
base_asset | true | str | 交易币种 |
price_precision | true | int | 价格精度 |
code | true | int | 状态 |
is_allow | true | int | 1允许 0不允许 |
现货交易对
HTTP 请求
- GET
https://openapi.digifinex.com/v3/spot/symbols
请求参数
此接口不接受任何参数。
Response:
{
"code": 0,
"symbol_list": [
{
"status": "TRADING",
"symbol": "LTC_USDT",
"quote_asset": "USDT",
"base_asset": "LTC",
"amount_precision": 4,
"price_precision": 2,
"minimum_amount": 0.001,
"minimum_value": 2,
"zone": "MAIN",
"order_types": [
"LIMIT",
"MARKET"
]
}
]
}
返回参数
参数名称 | 是否必须 | 类型 | 描述 |
---|---|---|---|
symbol_list | true | object | 交易对信息 |
order_types | true | list | 订单类型 |
quote_asset | true | str | 基础币种 |
minimum_value | true | int | 最小价值 |
amount_precision | true | int | 数量精度 |
status | true | str | 状态 |
minimum_amount | true | float | 最小额度 |
symbol | true | str | 交易对 |
zone | true | str | 板块 |
base_asset | true | str | 交易币种 |
price_precision | true | int | 价格精度 |
code | true | int | 状态 |
保证金币种列表
HTTP 请求
- GET
https://openapi.digifinex.com/v3/margin/currencies
请求参数
此接口不接受任何参数。
Response:
{
"code": 0,
"funding_time": "GMT+8 10:00:00",
"currencys": [
"BTC",
"USDT",
"ETH",
"XRP"
],
"margin_fees": [
{
"currency_mark": "USDT",
"level": 2,
"range": "[8-14]",
"loan_fees": 0.001
}
]
}
返回参数
参数名称 | 是否必须 | 类型 | 描述 |
---|---|---|---|
currencys | true | list | 币种 |
margin_fees | true | object | 保证金币种信息 |
currency_mark | true | str | 币种 |
loan_fees | true | float | 保证金费用 |
range | true | str | 范围 |
level | true | int | 级别 |
code | true | int | 状态 |
funding_time | true | str | 时间 |
保证金交易对
HTTP 请求
- GET
https://openapi.digifinex.com/v3/margin/symbols
请求参数
此接口不接受任何参数。
Response:
{
"code": 0,
"symbol_list": [
{
"status": "TRADING",
"symbol": "LTC_USDT",
"quote_asset": "USDT",
"base_asset": "LTC",
"amount_precision": 4,
"price_precision": 2,
"minimum_amount": 0.001,
"minimum_value": 2,
"zone": "MAIN",
"liquidation_rate": 0.3,
"order_types": [
"LIMIT",
"MARKET"
]
}
]
}
返回参数
参数名称 | 是否必须 | 类型 | 描述 |
---|---|---|---|
symbol_list | true | object | 保证金交易对 |
order_types | true | list | 订单类型 |
quote_asset | true | str | 基础币种 |
minimum_value | true | int | 最小价值 |
amount_precision | true | int | 数量精度 |
status | true | str | 状态 |
minimum_amount | true | float | 最小额度 |
liquidation_rate | true | float | 流动率 |
symbol | true | str | 交易对 |
zone | true | str | 板块 |
base_asset | true | str | 交易币种 |
price_precision | true | int | 价格精度 |
code | true | int | 状态 |
获取币种充提信息
HTTP 请求
- GET
https://openapi.digifinex.com/v3/currencies
请求参数
参数名称 | 是否必须 | 类型 | 描述 | 默认值 | 取值范围 |
---|---|---|---|---|---|
currency | false | string | 币种 | 缺省时,默认值为空,返回所有币种 | btc, ltc, bch, eth, etc ... |
Response:
{
"code": 200,
"data":
[
{
"currency": "xrp",
"chain":"",
"min_deposit_amount": 0.01,
"min_withdraw_amount": 0.02,
"deposit_status":1,
"withdraw_status":1,
"withdraw_fee_currency":"eth",
"min_withdraw_fee":0.006,
"withdraw_fee_rate":0.02,
},
...
]
}
返回参数
参数名称 | 是否必须 | 数据类型 | 描述 | 取值范围 |
---|---|---|---|---|
currency | true | string | 币种 | |
chain | true | string | 链名称 | 链名称,默认为空,USDT有两个链:ERC20和OMNI |
min_deposit_amount | true | float | 最小充币额 | |
min_withdraw_amount | true | float | 最小提币额 | |
deposit_status | true | int | 充币状态:1是开启,0是关闭 | |
withdraw_status | true | int | 提币状态:1是开启,0是关闭 | |
withdraw_fee_currency | true | string | 提币手续费币种 | |
min_withdraw_fee | true | float | 最小提币手续费 | |
withdraw_fee_rate | true | float | 提币手续费比例。注:如果金额小于最小手续费,则取最小手续费;否则取该提币手续费 |
账户接口
现货账户资产
HTTP 请求
- GET
https://openapi.digifinex.com/v3/spot/assets
请求参数
此接口不接受任何参数。
Response:
{
"code": 0,
"list": [
{
"currency": "BTC",
"free": 4723846.89208129,
"total": 0
}
]
}
返回参数
参数名称 | 是否必须 | 类型 | 描述 |
---|---|---|---|
list | true | object | 账户列表 |
currency | true | string | 资产币种名称 |
free | true | float | 可用量 |
total | true | float | 总量 |
code | true | int | 状态 |
保证金账户资产
HTTP 请求
- GET
https://openapi.digifinex.com/v3/margin/assets
请求参数
此接口不接受任何参数。
Response:
{
"code": 0,
"total": 0,
"free": 0,
"unrealized_pnl": 0,
"list": [
{
"currency": "BTC",
"free": 4723846.89208129,
"total": 0
}
]
}
返回参数
参数名称 | 是否必须 | 类型 | 描述 |
---|---|---|---|
list | true | object | 账户列表 |
currency | true | string | 资产币种名称 |
free | true | float | 可用量 |
total | true | float | 总量 |
code | true | int | 状态 |
现货、保证金、场外财务日志
HTTP 请求
- GET
https://openapi.digifinex.com/v3/{market}/financelog
请求参数
market:spot-现货,margin-保证金
参数名称 | 参数类型 | 必填 | 描述 |
---|---|---|---|
market | str | true | "spot","margin" |
currency_mark | str | false | |
start_time | int | false | |
end_time | int | false | |
limit | int | false | 默认 100; 最大 1000 |
Response:
{
"code": 0,
"total": 0,
"free": 0,
"unrealized_pnl": 0,
"list": [
{
"currency": "BTC",
"free": 4723846.89208129,
"total": 0
}
]
}
返回参数
参数名称 | 是否必须 | 类型 | 描述 |
---|---|---|---|
list | true | object | 账户列表 |
currency | true | string | 资产币种名称 |
free | true | float | 可用量 |
total | true | float | 总量 |
code | true | int | 状态 |
查询订单状态
HTTP 请求
- GET
https://openapi.digifinex.com/v3/{market}/order
请求参数
market:spot-现货,margin-保证金
参数名称 | 参数类型 | 必填 | 描述 |
---|---|---|---|
market | str | true | "spot","margin" |
order_id | str | true | 订单ID列表,多个订单以逗号隔开 |
Response:
{
"code": 0,
"data": [
{
"symbol": "BTC_USDT",
"order_id": "dd3164b333a4afa9d5730bb87f6db8b3",
"created_date": 1562303547,
"finished_date": 0,
"price": 0.1,
"amount": 1,
"cash_amount": 1,
"executed_amount": 0,
"avg_price": 0,
"status": 1,
"type": "buy",
"kind": "margin"
}
]
}
返回参数
参数名称 | 是否必须 | 类型 | 描述 |
---|---|---|---|
data | true | object | 订单状态列表 |
symbol | true | string | 交易对 |
order_id | true | string | 订单ID |
created_date | true | int | 订单创建时间 |
finished_date | true | int | 订单完成时间 |
price | true | float | 下单价 |
amount | true | float | 下单量 |
cash_amount | true | float | 市价单委托金额,未委托金额则为0 |
executed_amount | true | float | 已成交量 |
avg_price | true | float | 成交均价 |
status | true | int | 订单状态,0-未成交,1-部分成交,2-完全成交,3-已撤销未成交,4-已撤销部分成交 |
type | true | string | 订单类型,buy-限价卖单,sell-限价卖单,buy_market-市价卖单,sell_market-市价卖单 |
kind | true | string | 订单种类,spot-现货订单,margin-保证金杠杆订单 |
code | true | int | 状态 |
查询订单成交详情
HTTP 请求
- GET
https://openapi.digifinex.com/v3/{market}/order/detail
请求参数
market:spot-现货,margin-保证金
参数名称 | 参数类型 | 必填 | 描述 |
---|---|---|---|
market | str | true | "spot","margin" |
order_id | str | true | 订单ID |
Response:
{
"code": 0,
"data": {
"symbol": "BTC_USDT",
"order_id": "dd3164b333a4afa9d5730bb87f6db8b3",
"created_date": 1562303547,
"finished_date": 1574665459,
"price": 6000,
"amount": 0.58,
"cash_amount": 0,
"executed_amount": 0.58,
"avg_price": 6000,
"status": 2,
"type": "buy",
"kind": "margin",
"detail": {
"tid": 63194988,
"date": 1574665459,
"executed_amount": 0.58,
"executed_price": 6000
}
}
}
返回参数
参数名称 | 是否必须 | 类型 | 描述 |
---|---|---|---|
data | true | object | 订单状态列表 |
symbol | true | string | 交易对 |
order_id | true | string | 订单ID |
created_date | true | int | 订单创建时间 |
finished_date | true | int | 订单完成时间 |
price | true | float | 下单价 |
amount | true | float | 下单量 |
cash_amount | true | float | 市价单委托金额,未委托金额则为0 |
executed_amount | true | float | 已成交量 |
avg_price | true | float | 成交均价 |
status | true | int | 订单状态,0-未成交,1-部分成交,2-完全成交,3-已撤销未成交,4-已撤销部分成交 |
type | true | string | 订单类型,buy-限价卖单,sell-限价卖单,buy_market-市价卖单,sell_market-市价卖单 |
kind | true | string | 订单种类,spot-现货订单,margin-保证金杠杆订单 |
detail | true | object | 订单详情列表 |
tid | true | int | 交易ID |
date | true | int | 成交时间 |
executed_amount | true | float | 成交数量 |
executed_price | true | float | 成交价格 |
code | true | int | 状态 |
当前活跃挂单
HTTP 请求
- GET
https://openapi.digifinex.com/v3/{market}/order/current
请求参数
market:spot-现货,margin-保证金
参数名称 | 参数类型 | 必填 | 描述 |
---|---|---|---|
market | str | true | "spot","margin" |
symbol | str | false | 交易对 |
Response:
{
"code": 0,
"data": [
{
"symbol": "BTC_USDT",
"order_id": "dd3164b333a4afa9d5730bb87f6db8b3",
"created_date": 1562303547,
"finished_date": 0,
"price": 0.1,
"amount": 1,
"cash_amount": 1,
"executed_amount": 0,
"avg_price": 0,
"status": 1,
"type": "buy",
"kind": "margin"
}
]
}
返回参数
参数名称 | 是否必须 | 类型 | 描述 |
---|---|---|---|
data | true | object | 活跃挂单列表 |
symbol | true | string | 交易对 |
order_id | true | string | 订单ID |
created_date | true | int | 订单创建时间 |
finished_date | true | int | 订单完成时间 |
price | true | float | 下单价 |
amount | true | float | 下单量 |
cash_amount | true | float | 市价单委托金额,未委托金额则为0 |
executed_amount | true | float | 已成交量 |
avg_price | true | float | 成交均价 |
status | true | int | 订单状态,0-未成交,1-部分成交,2-完全成交,3-已撤销未成交,4-已撤销部分成交 |
type | true | string | 订单类型,buy-限价卖单,sell-限价卖单,buy_market-市价卖单,sell_market-市价卖单 |
kind | true | string | 订单种类,spot-现货订单,margin-保证金杠杆订单 |
code | true | int | 状态 |
查询所有订单(包括历史订单)
HTTP 请求
- GET
https://openapi.digifinex.com/v3/{market}/order/history
请求参数
market:spot-现货,margin-保证金
参数名称 | 参数类型 | 必填 | 描述 |
---|---|---|---|
market | str | true | "spot","margin" |
symbol | str | false | 交易对 |
limit | int | false | 默认10,最大100 |
start_time | int | false | 开始时间,默认结束前溯3天,最多查询30天以内的数据 |
end_time | int | false | 结束时间,默认当前时间戳 |
Response:
{
"code": 0,
"data": [
{
"symbol": "BTC_USDT",
"order_id": "dd3164b333a4afa9d5730bb87f6db8b3",
"created_date": 1562303547,
"finished_date": 0,
"price": 0.1,
"amount": 1,
"cash_amount": 1,
"executed_amount": 0,
"avg_price": 0,
"status": 1,
"type": "buy",
"kind": "margin"
}
]
}
返回参数
参数名称 | 是否必须 | 类型 | 描述 |
---|---|---|---|
data | true | object | 所有订单列表 |
symbol | true | string | 交易对 |
order_id | true | string | 订单ID |
created_date | true | int | 订单创建时间 |
finished_date | true | int | 订单完成时间 |
price | true | float | 下单价 |
amount | true | float | 下单量 |
cash_amount | true | float | 市价单委托金额,未委托金额则为0 |
executed_amount | true | float | 已成交量 |
avg_price | true | float | 成交均价 |
status | true | int | 订单状态,0-未成交,1-部分成交,2-完全成交,3-已撤销未成交,4-已撤销部分成交 |
type | true | string | 订单类型,buy-限价卖单,sell-限价卖单,buy_market-市价卖单,sell_market-市价卖单 |
kind | true | string | 订单种类,spot-现货订单,margin-保证金杠杆订单 |
code | true | int | 状态 |
成交记录
HTTP 请求
- GET
https://openapi.digifinex.com/v3/{market}/mytrades
请求参数
market:spot-现货,margin-保证金
参数名称 | 参数类型 | 必填 | 描述 |
---|---|---|---|
market | str | true | "spot","margin" |
symbol | str | false | 交易对 |
limit | int | false | 默认 50; 最大 500 |
start_time | int | false | 开始时间,默认结束前溯3天,最多查询30天以内的数据 |
end_time | int | false | 结束时间,默认当前时间戳 |
Response:
{
"code": 0,
"list": [
{
"symbol": "BTC_USDT",
"order_id": "6707cbdcda0edfaa7f4ab509e4cbf966",
"id": 28457,
"price": 0.1,
"amount": 0,
"fee": 0.096,
"fee_currency": "USDT",
"timestamp": 1499865549,
"side": "buy",
"is_maker": true
}
]
}
返回参数
参数名称 | 是否必须 | 类型 | 描述 |
---|---|---|---|
list | true | object | 成交记录列表 |
symbol | true | string | 交易对 |
order_id | true | string | 订单ID |
id | true | int | 交易ID |
price | true | float | 成交价 |
amount | true | float | 成交量 |
fee | true | float | 手续费 |
fee_currency | true | string | 手续费币种 |
timestamp | true | int | 时间戳 |
side | true | string | 订单类型,buy,sell,buy_market,sell_market |
is_maker | true | bool | maker or taker |
code | true | int | 状态 |
保证金持仓
HTTP 请求
- GET
https://openapi.digifinex.com/v3/margin/positions
请求参数
参数名称 | 参数类型 | 必填 | 描述 |
---|---|---|---|
symbol | str | false | 交易对 |
Response:
{
"code": 0,
"margin": "20",
"margin_rate": 1,
"unrealized_pnl": "55",
"positions": [
{
"symbol": "BTC_USDT",
"leverage_ratio": "3.0",
"side": "long",
"amount": "3.0",
"entry_price": "40",
"unrealized_pnl": "55",
"liquidation_price": "25.999999999999996",
"liquidation_rate": "0.3"
}
]
}
返回参数
参数名称 | 是否必须 | 类型 | 描述 |
---|---|---|---|
margin | true | str | 保证金 |
margin_rate | true | int | 保证金率 |
unrealized_pnl | true | str | 未实现盈亏 |
positions | true | object | 持仓列表 |
symbol | true | string | 交易对 |
leverage_ratio | true | float | 杠杆倍数 |
side | true | string | go_long 多仓;go_short 空仓;empty 无持仓 |
amount | true | float | 持仓数量 |
entry_price | true | float | 持仓基价 |
unrealized_pnl | true | float | 未实现盈亏 |
liquidation_price | true | float | 预估强评价 |
liquidation_rate | true | float | 强平保证金率 |
code | true | int | 状态 |
下单
HTTP 请求
- POST
https://openapi.digifinex.com/v3/{market}/order/new
请求参数
market:spot-现货,margin-保证金
参数名称 | 参数类型 | 必填 | 描述 |
---|---|---|---|
market | str | true | "spot","margin" |
symbol | str | true | 交易对 |
type | str | true | 订单类型,buy-限价卖单,sell-限价卖单,buy_market-市价卖单,sell_market-市价卖单 |
amount | float | true | 下单量,市价买单表示下单金额,其他表示下单数量 |
price | float | false | 下单价格,限价单必传 |
post_only | int | false | 1:使用,0:不使用。post_only订单将保证该订单总是支付maker手续费,该订单如果不能进入买卖盘则会自动取消 |
Response:
{
"code": 0,
"order_id": "198361cecdc65f9c8c9bb2fa68faec40"
}
返回参数
参数名称 | 是否必须 | 类型 | 描述 |
---|---|---|---|
order_id | true | str | 订单ID |
code | true | int | 状态 |
批量下单
HTTP 请求
- POST
https://openapi.digifinex.com/v3/{market}/order/batch_new
请求参数
market:spot-现货,margin-保证金 一次最多10单,要么全部成功,要么全部失败
参数名称 | 参数类型 | 必填 | 描述 |
---|---|---|---|
market | str | true | "spot","margin" |
symbol | str | true | 交易对 |
list | str | true | 下单列表,json格式化的订单列表,例:[{"type":"buy","amount":0.1,"price":6000,"post_only":1},{"type":"sell","amount":0.1,"price":6100,"post_only":0}] |
Response:
{
"code": 0,
"order_ids": [
"198361cecdc65f9c8c9bb2fa68faec40",
"3fb0d98e51c18954f10d439a9cf57de0"
]
}
返回参数
参数名称 | 是否必须 | 类型 | 描述 |
---|---|---|---|
order_ids | true | object | 订单ID列表 |
code | true | int | 状态 |
撤销订单
HTTP 请求
- POST
https://openapi.digifinex.com/v3/{market}/order/cancel
请求参数
market:spot-现货,margin-保证金
参数名称 | 参数类型 | 必填 | 描述 |
---|---|---|---|
market | str | true | "spot","margin" |
order_id | str | true | 订单ID列表,多个订单以逗号隔开 |
Response:
{
"code": 0,
"success": [
"198361cecdc65f9c8c9bb2fa68faec40",
"3fb0d98e51c18954f10d439a9cf57de0"
],
"error": [
"78a7104e3c65cc0c5a212a53e76d0205"
]
}
返回参数
参数名称 | 是否必须 | 类型 | 描述 |
---|---|---|---|
success | true | object | 撤销成功订单 |
error | true | object | 撤销失败订单 |
code | true | int | 状态 |
资金划转
HTTP 请求
- POST
https://openapi.digifinex.com/v3/transfer
请求参数
说明:现货账户,杠杆账户,场外账户等不同账户间资金划转,1:币币账户,2:保证金账户,3:场外账户 注意:目前不支持从保证金账户划转到场外账户以及场外账户划转到保证金账户
参数名称 | 参数类型 | 必填 | 描述 |
---|---|---|---|
currency_mark | str | true | 币种 |
num | str | true | 划转数量 |
from | int | true | 划转源账户(1:币币账户,2:保证金账户,3:场外账户) |
to | int | true | 划转目标账户(1:币币账户,2:保证金账户,3:场外账户) |
Response:
{
"code": 0
}
返回参数
参数名称 | 是否必须 | 类型 | 描述 |
---|---|---|---|
code | true | int | 状态 |
平仓
HTTP 请求
- POST
https://openapi.digifinex.com/v3/margin/position/close
请求参数
说明:以市场价格平掉仓位
参数名称 | 参数类型 | 必填 | 描述 |
---|---|---|---|
symbol | str | true | 交易对 |
Response:
{
"code": 0
}
返回参数
参数名称 | 是否必须 | 类型 | 描述 |
---|---|---|---|
code | true | int | 状态 |
充币地址查询
HTTP 请求
- GET.
https://openapi.digifinex.com/v3/deposit/address
请求参数
说明:此节点用于查询特定币种充币地址
字段名称 | 是否必需 | 类型 | 字段描述 | 取值范围 |
---|---|---|---|---|
currency | true | string | 币种 | btc, ltc, bch, eth, etc ... |
Response:
{
"code": 200,
"data": [
{
"currency": "btc",
"address": "1PSRjPg53cX7hMRYAXGJnL8mqHtzmQgPUs",
"addressTag": "",
"chain": ""
}
]
}
返回参数
字段名称 | 是否必需 | 数据类型 | 字段描述 | 取值范围 |
---|---|---|---|---|
currency | true | string | 币种 | |
address | true | string | 充币地址 | |
addressTag | true | string | 充币地址标签 | |
chain | true | string | 链名称,默认为空,USDT有两个链:ERC20和OMNI |
示例代码
Shell
curl "https://openapi.digifinex.com/v3/deposit/address?currency=btc"
充币记录
HTTP 请求
- GET.
https://openapi.digifinex.com/v3/deposit/history
请求参数
说明:查询充币记录
参数名称 | 是否必须 | 类型 | 描述 | 默认值 | 取值范围 |
---|---|---|---|---|---|
currency | false | string | 币种 | 缺省时,默认值为空,返回所有币种 | btc, ltc, bch, eth, etc ... |
from | false | int | 查询起始 ID | 缺省时,默认值direct相关。当direct为‘prev’时,from 为1 ,从旧到新升序返回;当direct为’next‘时,from为最新的一条记录的ID,从新到旧降序返回 | |
size | false | int | 查询记录大小 | 100 | 1-500 |
direct | false | string | 返回记录排序方向 | 缺省时,默认为“prev” (升序) | “prev” (升序)or “next” (降序) |
Response:
{
"code": 200,
"data":
[
{
"id": 1171,
"currency": "xrp",
"hash": "ed03094b84eafbe4bc16e7ef766ee959885ee5bcb265872baaa9c64e1cf86c2b",
"chain":"",
"amount": 7.457467,
"address": "rae93V8d2mdoUQHwBDBdM4NHCMehRJAsbm",
"state": 3,
"created_date": "2020-04-20 11:23:00",
"finished_date": "2020-04-20 13:23:00"
},
...
]
}
返回参数
参数名称 | 是否必须 | 数据类型 | 描述 | 取值范围 |
---|---|---|---|---|
id | true | long | ||
currency | true | string | 币种 | |
hash | true | string | 交易哈希 | |
chain | true | string | 链名称 | |
amount | true | float | 个数 | |
address | true | string | 地址 | |
memo | true | string | 地址标签 | |
fee | true | float | 手续费 | |
state | true | int | 状态 | 提币状态包括:1(申请中), 2(待确认), 3(已完成),4(已驳回) |
created_date | true | string | 发起时间 | |
finished_date | true | string | 最后更新时间 |
示例代码
Shell
curl "https://openapi.digifinex.com/v3/deposit/address?currency=btc"
请求提币
HTTP 请求
- POST.
https://openapi.digifinex.com/v3/withdraw/new
{
"currency": "eth",
"chain": "",
"address": "0xde709f2102306220921060314715629080e2fb77",
"amount": "0.05",
"memo": "",
}
请求参数
参数名称 | 是否必须 | 类型 | 描述 | 取值范围 |
---|---|---|---|---|
currency | true | string | 资产币种 | btc, ltc, bch, eth, etc ... |
chain | false | string | 链类型 | usdt必填(ERC20或者OMNI),其他币种为空 |
address | true | string | 提币地址 | 必须在用户设置的提币地址白名单中 |
amount | true | float | 提币数量 | |
memo | false | string | 提币tag,适用于xrp,xem,bts,steem,eos,xmr | 字符串 |
Response:
{
"code": 200,
"withdraw_id": 700
}
返回参数
参数名称 | 是否必须 | 数据类型 | 描述 | 取值范围 |
---|---|---|---|---|
withdraw_id | true | long | 提币 ID |
取消提币
HTTP 请求
- POST.
https://openapi.digifinex.com/v3//withdraw/cancel
请求参数
参数名称 | 是否必须 | 类型 | 描述 | 默认值 | 取值范围 |
---|---|---|---|---|---|
withdraw_id | true | long | 提币 ID,填在 path 中 |
Response:
{
"code": 200,
"withdraw_id": 700
}
返回参数
参数名称 | 是否必须 | 数据类型 | 描述 | 取值范围 |
---|---|---|---|---|
withdraw_id | true | long | 提币 ID |
示例代码
PHP
<?php
class digifinex
{
protected $baseUrl = "https://openapi.digifinex.com/v3";
protected $appKey;
protected $appSecret;
public function __construct($data) {
$this->appKey = $data['appKey'];
$this->appSecret = $data['appSecret'];
}
private function calc_sign($data = []) {
$query = http_build_query($data, '', '&');
$sign = hash_hmac("sha256", $query, $this->appSecret);
echo 'query: ' . $query . "\r\n";
echo 'sign: ' . $sign . "\r\n";
return $sign;
}
public function do_request($method, $path, $data = [], $needSign=false) {
$curl = curl_init();
$query = http_build_query($data, '', '&');
if ($method == "POST") {
curl_setopt($curl, CURLOPT_URL, $this->baseUrl . $path);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, $query);
} else {
if(!empty($data)){
curl_setopt($curl, CURLOPT_URL, $this->baseUrl . $path . '?' . $query);
} else {
curl_setopt($curl, CURLOPT_URL, $this->baseUrl . $path);
}
}
if($needSign){
curl_setopt($curl, CURLOPT_HTTPHEADER, array(
'ACCESS-KEY: ' . $this->appKey,
'ACCESS-TIMESTAMP: ' . time(),
'ACCESS-SIGN: ' . $this->calc_sign($data),
));
}
curl_setopt($curl, CURLOPT_USERAGENT, "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_2) AppleWebKit/537.17 (KHTML, like Gecko) Chrome/24.0.1312.52 Safari/537.17");
curl_setopt($curl, CURLOPT_HEADER, false);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_TIMEOUT, 10);
$content = curl_exec($curl) ;
curl_close($curl);
return $content;
}
}
$coin = new digifinex([
'appKey' => 'your-api-key',
'appSecret' => 'your-api-secret',
]);
echo 'assets => ' . $coin->do_request('GET', '/margin/assets', [], true) . "\r\n";
echo 'place_order => ' . $coin->do_request('POST', '/margin/order/new', [
'symbol' => 'btc_usdt',
'price' => 5000,
'amount' => 0.01,
'type' => 'buy',
], true) . "\r\n";
JS
var https = require('https');
var crypto = require('crypto')
var querystring = require('querystring');
const baseUrl = "openapi.digifinex.com"
const appKey = "your-api-key"
const appSecret = "your-api-secret"
calc_sign = function(data) {
var content = querystring.stringify(data);
return crypto.createHmac('sha256', appSecret).update(content).digest('hex')
}
do_request = function(method, path, data = {}, needSign = false) {
var content = querystring.stringify(data);
var options = {
hostname: baseUrl,
port: 443,
path: '/v3' + path,
method: method,
headers: {
'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_2) AppleWebKit/537.17 (KHTML, like Gecko) Chrome/24.0.1312.52 Safari/537.17',
}
};
if (method == "GET" && content != "") {
options.path += '?' + content;
}
if (needSign) {
options.headers['ACCESS-KEY'] = appKey;
options.headers['ACCESS-TIMESTAMP'] = parseInt(Date.now() / 1000);
options.headers['ACCESS-SIGN'] = calc_sign(data);
}
console.log('request: ' + JSON.stringify(options));
var req = https.request(options, function (res) {
console.log('STATUS: ' + res.statusCode);
console.log('HEADERS: ' + JSON.stringify(res.headers));
res.setEncoding('utf8');
res.on('data', function (chunk) {
console.log('BODY: ' + chunk);
});
});
req.on('error', function (e) {
console.log('problem with request: ' + e.message);
});
if (method != 'GET') {
req.write(content);
}
req.end();
}
do_request('GET', '/margin/symbols', {}, false)
do_request('POST', '/margin/order/new', {
symbol: 'btc_usdt',
price: 5000,
amount: 0.01,
type: 'buy',
}, true)
Python
#!/bin/python
# -*-coding=utf-8-*-
import requests
import time
import hmac
import hashlib
import urllib
baseUrl = "https://openapi.digifinex.com/v3"
class digifinex():
def __init__(self, data):
self.appKey = data["appKey"]
self.appSecret = data["appSecret"]
def _generate_accesssign(self, data):
query_string = urllib.urlencode(data)
m = hmac.new(self.appSecret.encode('utf-8'), query_string.encode('utf-8'), hashlib.sha256)
s = m.hexdigest()
print("data-origin:", data)
print("query_string:", query_string)
print("sign:", s)
return s
def do_request(self, method, path, data, needSign=False):
if needSign:
headers = {
"ACCESS-KEY": self.appKey,
"ACCESS-TIMESTAMP": str(int(time.time())),
"ACCESS-SIGN": self._generate_accesssign(data),
}
else:
headers = {}
if method == "POST":
response = requests.request(method, baseUrl+path, data=data, headers=headers)
else:
response = requests.request(method, baseUrl+path, params=data, headers=headers)
print('response.text:',response.text)
print('----------------------------------')
coin = digifinex({"appKey":"your-api-key", "appSecret":"your-api-secret"})
coin.do_request("POST", "/margin/order/new", {
"symbol": "btc_usdt",
"price": 5000,
"amount": 0.01,
"type": "buy"
}, True)
GO
package main
import (
"crypto/hmac"
"crypto/sha256"
"encoding/hex"
"fmt"
"io/ioutil"
"net/http"
"net/url"
"strconv"
"strings"
"time"
)
const (
dfxRestURI = "https://openapi.digifinex.com/v3"
)
type digifinex struct {
appKey string
appSecret string
deafultTimeout time.Duration
}
func parseToString(val interface{}) string {
switch t := val.(type) {
case int, int8, int16, int32, int64:
return fmt.Sprintf("%d", t)
case uint, uint8, uint16, uint32, uint64:
return fmt.Sprintf("%d", t)
case float32, float64:
return fmt.Sprintf("%.8f", t)
case string:
return t
default:
panic(fmt.Errorf("invalid value type", t))
}
}
func hmacSha256(key []byte, msg []byte) string {
mac := hmac.New(sha256.New, key)
mac.Write(msg)
return hex.EncodeToString(mac.Sum(nil))
}
func (coin *digifinex) doRequest(method string, path string, params map[string]interface{}, sign bool) (*http.Response, error) {
inputParam := url.Values{}
for key, val := range params {
inputParam.Add(key, parseToString(val))
}
encodedParams := inputParam.Encode()
var (
req *http.Request
err error
)
if method == "GET" {
if encodedParams != "" {
req, err = http.NewRequest(method, dfxRestURI+path+"?"+encodedParams, nil)
} else {
req, err = http.NewRequest(method, dfxRestURI+path, nil)
}
} else {
req, err = http.NewRequest(method, dfxRestURI+path, strings.NewReader(encodedParams))
}
if err != nil {
return nil, fmt.Errorf("unable to create request " + err.Error())
}
// header
req.Header.Add("ACCESS-TIMESTAMP", strconv.Itoa(int(time.Now().Unix())))
if sign {
req.Header.Add("ACCESS-KEY", coin.appKey)
req.Header.Add("ACCESS-SIGN", hmacSha256([]byte(coin.appSecret), []byte(encodedParams)))
fmt.Println(req.Header.Get("ACCESS-SIGN"))
}
client := &http.Client{
Transport: &http.Transport{},
Timeout: coin.deafultTimeout,
}
resp, err := client.Do(req)
if err != nil {
return nil, err
}
return resp, nil
}
const (
appKey = "your-api-key"
appSecret = "your-api-secret"
)
func main() {
app := digifinex{
appKey: appKey,
appSecret: appSecret,
}
response, err := app.doRequest("POST", "/spot/order/new", map[string]interface{}{
"symbol": "btc_usdt"
"type": "buy",
"amount": 1,
"price": "8100",
"post_only": 0,
}, true)
if err != nil {
panic(err)
}
textRes, err := ioutil.ReadAll(response.Body)
if err != nil {
panic(err)
}
defer response.Body.Close()
if response.StatusCode != 200 {
panic(fmt.Errorf(string(textRes)))
}
fmt.Println(string(textRes))
}
Websocket
Websoket API
创建APIKey请点击 https://github.com/DigiFinex/api/blob/master/Websocket_API_cn.md