API加速器
加速器简介
Bibox API Booster (以下简称 API Booster) 是 Bibox 为交易者推出的快捷开发工具. 使用 API Booster 可以大大降低交易系统的开发难度, 并获得稳定可靠的实时数据.
如何使用 API Booster
要使用 API Booster, 交易者只需下载 API Booster 到自己的电脑并启动它. API Booster 会自动连接 Bibox, 并持续同步行情数据和账户委托数据. 交易者开发或修改自己的交易系统, 使其与 API Booster 提供的 HTTP RESTFul 接口连接, 而不再与 Bibox API 直接连接.
为什么使用 API Booster
console.log('Bibox javascript 代码示例');
# -*- coding:utf-8 -*-
if __name__ == '__main__':
print('Bibox python 代码示例')
Console.WriteLine("Bibox c# 代码示例");
使用 API Booster 要比直接使用 Bibox API 简单得多, 只需很少的时间, 交易者就可以完成与 API Booster 的连接. 交易者只需专注于策略的编写, 而维护实时数据的工作交由 API Booster 自动完成.
以下我们将列举 API Booster 的主要优势.
纯 HTTP RESTFul 接口, 开发更简单
API Booster 仅提供 HTTP RESTFul 接口, 这简化了开发工作. 过去开发者使用 Websocket 接口来获取实时数据, 现在由 API Booster 自动完成. 通过 API Booster HTTP RESTFul 接口获取的数据, 在实时性方面没有任何损失.
接口更少, 更清晰
API Booster 比 Bibox API 提供的接口更少, 更清晰. 这是因为 API Booster 自动完成了多种数据的组装, 使得单一接口提供的数据内容更多, 结构更清晰.
无需签名
使用 API Booster 不需要进行签名, 只要把账户的 API Key 保存入 API Booster 即可.
无频率限制
使用 API Booster 接口获取行情或账户数据没有频率限制, 而下单撤单操作由 API Booster 自动完成频率控制.
安装
安装 API Booster 分为两个步骤, 首先安装 JAVA 环境, 然后安装 API Booster.
安装 JAVA 环境
请访问以下链接, 并按页面提示安装 JAVA 环境.
https://java.com/zh-CN/download/
安装 API Booster
要安装 API Booster, 请从 Bibox 官网下载 API Booster 可执行 JAR 文件.
bibox-spot-apibooster-x.x.x.jar
注:x.x.x为版本号,运行时请修改为您下载的对应版本的版本号。
请在您的计算机中新建一个目录, 并将以上 JAR 文件移至该目录中. 在运行时, API Booster 会在该目录中创建一些必要的数据文件, 请确认该目录中没有其他文件.
启动 API Booster
console.log('Bibox javascript 代码示例');
# -*- coding:utf-8 -*-
if __name__ == '__main__':
print('Bibox python 代码示例')
Console.WriteLine("Bibox c# 代码示例");
要启动 API Booster, 只需在命令行工具中输入以下命令.
java -jar bibox-spot-apibooster-x.x.x.jar
具体方法如下:
平台 | 启动方法 | ||
Linux | 进入命令行模式, 或者在图形模式中启动 "Terminal" 应用 使用 cd 命令进入 bibox-spot-apibooster-x.x.x.jar 所在目录 输入以上命令 |
||
MacOS | 单击快捷菜单中的 "Launchpad" 火箭图标 找到并单击 "终端" 图标 使用 cd 命令进入 bibox-spot-apibooster-x.x.x.jar 所在目录 输入以上命令 |
||
Windows | 打开 "文件资源管理器" 找到并进入 bibox-spot-apibooster-x.x.x.jar 所在目录 按住 Shift 键, 并在 "文件资源管理器" 中的空白位置单击鼠标右键 在弹出的菜单中单击 "在此处打开 Powershell 窗口" 在 "Powershell" 窗口中输入以上命令 |
服务端口
API Booster 默认使用 8080 端口提供 HTTP 服务, 如果在您的系统中已经存在使用该端口的其他服务, 您可以通过 "port" 命令行参数来指定 API Booster 的服务端口.
java -jar bibox-spot-apibooster-x.x.x.jar --port 8081
其中的 8081 可以是任何未被使用的端口.
停止方法
要停止 API Booster, 关闭命令行工具, 或者使用进程管理工具关闭 API Booster 进程即可.
API Booster 接口文档
console.log('Bibox javascript 代码示例');
# -*- coding:utf-8 -*-
if __name__ == '__main__':
print('Bibox python 代码示例')
Console.WriteLine("Bibox c# 代码示例");
要阅读 API Booster 详细的接口文档, 请在启动 API Booster 后, 在浏览器中输入 localhost:8080 即可.
API简介
备用api域名列表
https://api.bibox.tel/v1/public/queryApiDomain
SDK与代码示例
Bibox为开发人员提供了多种语言版本的合约SDK。 这些SDK基于Bibox合约API开发,并自动完成以下功能:
- 数据签名
- 数据合成,例如:自动根据增量数据合成完整的深度
因此,使用SDK开发访问Bibox的程序比使用API更便捷,开发周期更短。
如果需要下载或者阅读更多信息,请点击以下链接:
签名接口请求方式
完整例子
let CryptoJS = require("crypto-js");
let request = require("request");
let timestamp = Date.now(); // 1.当前时间戳
let param = { // 2.请求的参数
select: 1
};
let strParam = JSON.stringify(param); // 2.格式化参数
let strToSign = '' + timestamp + strParam; // 3.这就是需要签名的字符串
let apikey = "900625568558820892a8c833c33ebc8fd2701efe"; //your apikey
let secret = "c708ac3e70d115ec29efbee197330627d7edf842"; //你的 apikey 密码
let sign = CryptoJS.HmacMD5(strToSign, secret).toString();//4.签名后的结果
let url = "https://api.bibox.com/v3.1/transfer/mainAssets";
request.post({
url: url,//请求路径
method: "POST",//请求方式
headers: {//5.设置请求头
'content-type': 'application/json',
'bibox-api-key': apikey,
'bibox-api-sign': sign,
'bibox-timestamp': timestamp
},
body: strParam // 6.格式化参数
},
function optionalCallback(err, httpResponse, body) {
if (err) {
return console.error('upload failed:', err);
}
console.log(body) // 7.返回值
});
# -*- coding:utf-8 -*-
import hashlib
import hmac
import json
import time
import requests
import sys, getopt
API_KEY = '900625568558820892a8c833c33ebc8fd2701efe'
SECRET_KEY = 'c708ac3e70d115ec29efbee197330627d7edf842'
BASE_URL = 'https://api.bibox.com' # 'https://api.bibox.tel' #
def do_sign(body):
timestamp = int(time.time()) * 1000
# to_sign = str(timestamp)+json.dumps(body,separators=(',',':'))
to_sign = str(timestamp) + json.dumps(body)
sign = hmac.new(SECRET_KEY.encode("utf-8"), to_sign.encode("utf-8"), hashlib.md5).hexdigest()
print(to_sign)
headers = {
'bibox-api-key': API_KEY,
'bibox-api-sign': sign,
'bibox-timestamp': str(timestamp)
}
return headers
def do_request():
path = '/v3.1/transfer/mainAssets'
body = {
}
headers = do_sign(body)
resp = requests.post(BASE_URL + path, json=body, headers=headers)
print(resp.text)
if __name__ == '__main__':
do_request()
using System;
using System.Net.Http;
using System.Text;
using System.Security.Cryptography;
using Newtonsoft.Json;
using Newtonsoft.Json.Serialization;
namespace ConsoleProgram
{
public class SortContractResolver : DefaultContractResolver
{
protected override IList<JsonProperty> CreateProperties(Type type, MemberSerialization memberSerialization)
{
IList<JsonProperty> properties = base.CreateProperties(type, memberSerialization);
return properties.OrderBy(x=>x.PropertyName).ToList();
}
}
public class Class1
{
// HttpClient is intended to be instantiated once per application, rather than per-use. See Remarks.
static readonly HttpClient client = new HttpClient();
static string GetTimeStamp()
{
TimeSpan ts = DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0, 0);
return Convert.ToInt64(ts.TotalMilliseconds).ToString();
}
static string HmacMD5(string source, string key)
{
HMACMD5 hmacmd = new HMACMD5(Encoding.Default.GetBytes(key));
byte[] inArray = hmacmd.ComputeHash(Encoding.Default.GetBytes(source));
StringBuilder sb = new StringBuilder();
for (int i = 0; i < inArray.Length; i++)
{
sb.Append(inArray[i].ToString("X2"));
}
hmacmd.Clear();
return sb.ToString().ToLower();
}
static async Task Main()
{
// Call asynchronous network methods in a try/catch block to handle exceptions.
try
{
string uri = "https://api.bibox.com/v3.1/transfer/mainAssets";
string apikey = "900625568558820892a8c833c33ebc8fd2701efe";
string secret = "c708ac3e70d115ec29efbee197330627d7edf842";
string timestamp = GetTimeStamp();
var myobj = new {
};
string payload = JsonConvert.SerializeObject(myobj, new JsonSerializerSettings { ContractResolver = new SortContractResolver() });
string source = timestamp + payload;
string sign = HmacMD5(source, secret);
Console.WriteLine(source);
Console.WriteLine(sign);
client.DefaultRequestHeaders.Add("bibox-api-key", apikey);
client.DefaultRequestHeaders.Add("bibox-api-sign", sign);
client.DefaultRequestHeaders.Add("bibox-timestamp", timestamp);
HttpContent content = new StringContent(payload, Encoding.UTF8, "application/json");
HttpResponseMessage response = await client.PostAsync(uri, content);
response.EnsureSuccessStatusCode();
string responseBody = await response.Content.ReadAsStringAsync();
Console.WriteLine(responseBody);
}
catch(HttpRequestException e)
{
Console.WriteLine("\nException Caught!");
Console.WriteLine("Message :{0} ",e.Message);
}
}
}
}
1.获取当前时间戳timestamp
2.了解接口请求需要的参数param,并格式化参数,得出strParam
3.根据生成需要签名的字符串strToSign
4.用apikey的密码secret,对需要签名的字符串strToSign进行 HmacMD5 加密签名
5.请求的时候,设置http headers 的以下字段
字段名 | 类型 | 描述 | 取值 |
---|---|---|---|
content-type | string | 'application/json' | |
bibox-api-key | string | 你的apikey | |
bibox-timestamp | long | 当前时间戳,用毫秒表示 | timestamp |
bibox-api-sign | string | 签名结果 | sign |
6.请求的时候,设置 http body 为格式化后的请求参数 strParam
7.返回值含有字段state, 0表示成功, 其他错误码, 表示失败。成功的结果会有对应的字段result,失败的结果会有对应的字段msg。
网络测试
Request
let request = require("request");
let url = "https://api.bibox.com/v3/mdata/ping";
request.get(url,
function optionalCallback(err, httpResponse, body) {
if (err) {
return console.error('upload failed:', err);
}
console.log(body)
});
# -*- coding:utf-8 -*-
import requests
BASE_URL = 'https://api.bibox.com' # 'https://api.bibox.tel' #
def do_request():
path = '/v3/mdata/ping'
resp = requests.get(BASE_URL + path)
print(resp.text)
if __name__ == '__main__':
do_request()
using System;
using System.Net.Http;
namespace ConsoleProgram
{
public class Class1
{
static readonly HttpClient client = new HttpClient();
static async Task Main()
{
try
{
String uri = "https://api.bibox.tel/v3/mdata/ping";
string responseBody = await client.GetStringAsync(uri);
Console.WriteLine(responseBody);
}
catch(HttpRequestException e)
{
Console.WriteLine("\nException Caught!");
Console.WriteLine("Message :{0} ",e.Message);
}
}
}
}
- 1.请求路径
GET https://api.bibox.com/v3/mdata/ping
- 2.请求参数
参数名称 | 是否必须 | 类型 | 描述 | 默认值 | 取值范围 |
---|
Response
{
"state":0,
"result":1604319540420,
"cmd":"ping",
"ver":"3"
}
- 3.返回字段
名称 | 描述 |
---|---|
state | 0代表成功,否则代表失败 |
result | 服务器时间戳 |
其它字段 | 忽略 |
市场行情
查询交易对
Request
let request = require("request");
let url = "https://api.bibox.com/v3/mdata/pairList";
request.get(url,
function optionalCallback(err, httpResponse, body) {
if (err) {
return console.error('upload failed:', err);
}
console.log(body)
});
# -*- coding:utf-8 -*-
import requests
BASE_URL = 'https://api.bibox.com' # 'https://api.bibox.tel' #
def do_request():
path = '/v3/mdata/pairList'
resp = requests.get(BASE_URL + path)
print(resp.text)
if __name__ == '__main__':
do_request()
using System;
using System.Net.Http;
namespace ConsoleProgram
{
public class Class1
{
static readonly HttpClient client = new HttpClient();
static async Task Main()
{
try
{
String uri = "https://api.bibox.tel/v3/mdata/pairList";
string responseBody = await client.GetStringAsync(uri);
Console.WriteLine(responseBody);
}
catch(HttpRequestException e)
{
Console.WriteLine("\nException Caught!");
Console.WriteLine("Message :{0} ",e.Message);
}
}
}
}
- 1.请求路径
GET https://api.bibox.com/v3/mdata/pairList
- 2.请求参数
参数名称 | 是否必须 | 类型 | 描述 | 默认值 | 取值范围 |
---|
Response
{
"state":0,
"result":[
{
"id":1,
"pair":"BIX_BTC",
"pair_type":0,
"area_id":7,
"is_hide":0,
"decimal":8
},
{
"id":2,
"pair":"BIX_ETH",
"pair_type":0,
"area_id":8,
"is_hide":0,
"decimal":8
}
],
"cmd":"pairList",
"ver":"3"
}
- 3.返回字段
名称 | 描述 |
---|---|
state | 0代表成功,否则代表失败 |
id | 交易对id |
pair | 交易对symbol |
decimal | 价格精度 |
其它字段 | 忽略 |
查询k线
Request
let request = require("request");
let url = "https://api.bibox.com/v3/mdata/kline?pair=BTC_USDT&period=1min&size=2";
request.get(url,
function optionalCallback(err, httpResponse, body) {
if (err) {
return console.error('upload failed:', err);
}
console.log(body)
});
# -*- coding:utf-8 -*-
import requests
BASE_URL = 'https://api.bibox.com' # 'https://api.bibox.tel' #
def do_request():
path = '/v3/mdata/kline?pair=BTC_USDT&period=1min&size=2'
resp = requests.get(BASE_URL + path)
print(resp.text)
if __name__ == '__main__':
do_request()
using System;
using System.Net.Http;
namespace ConsoleProgram
{
public class Class1
{
static readonly HttpClient client = new HttpClient();
static async Task Main()
{
try
{
String uri = "https://api.bibox.tel/v3/mdata/kline?pair=BTC_USDT&period=1min&size=2";
string responseBody = await client.GetStringAsync(uri);
Console.WriteLine(responseBody);
}
catch(HttpRequestException e)
{
Console.WriteLine("\nException Caught!");
Console.WriteLine("Message :{0} ",e.Message);
}
}
}
}
- 1.请求路径
GET https://api.bibox.com/v3/mdata/kline?pair=BTC_USDT&period=1min&size=10
- 2.请求参数
参数名称 | 是否必须 | 类型 | 描述 | 默认值 | 取值范围 |
---|---|---|---|---|---|
pair | true | string | 交易对 | BIX_BTC, ETH_BTC, ... | |
period | true | string | k线周期 | '1min', '3min', '5min', '15min', '30min', '1hour', '2hour', '4hour', '6hour', '12hour', 'day', 'week' | |
size | false | integer | 数量 | 1000 | 1-1000 |
Response
{
"state":0,
"result":[
{
"time":1604319840000,
"open":"11700.00000000",
"high":"11700.00000000",
"low":"11700.00000000",
"close":"11700.00000000",
"vol":"0.00000000"
},
{
"time":1604319900000,
"open":"11700.00000000",
"high":"11700.00000000",
"low":"11700.00000000",
"close":"11700.00000000",
"vol":"0.00000000"
}
],
"cmd":"kline",
"ver":"3"
}
- 3.返回字段
名称 | 描述 |
---|---|
state | 0代表成功,否则代表失败 |
time | 时间戳 |
open | 开盘价 |
high | 最高价 |
low | 最低价 |
close | 收盘价 |
vol | 成交量 |
其它字段 | 忽略 |
查询全币种市场行情
Request
let request = require("request");
let url = "https://api.bibox.com/v3/mdata/marketAll";
request.get(url,
function optionalCallback(err, httpResponse, body) {
if (err) {
return console.error('upload failed:', err);
}
console.log(body)
});
# -*- coding:utf-8 -*-
import requests
BASE_URL = 'https://api.bibox.com' # 'https://api.bibox.tel' #
def do_request():
path = '/v3/mdata/marketAll'
resp = requests.get(BASE_URL + path)
print(resp.text)
if __name__ == '__main__':
do_request()
using System;
using System.Net.Http;
namespace ConsoleProgram
{
public class Class1
{
static readonly HttpClient client = new HttpClient();
static async Task Main()
{
try
{
String uri = "https://api.bibox.tel/v3/mdata/marketAll";
string responseBody = await client.GetStringAsync(uri);
Console.WriteLine(responseBody);
}
catch(HttpRequestException e)
{
Console.WriteLine("\nException Caught!");
Console.WriteLine("Message :{0} ",e.Message);
}
}
}
}
- 1.请求路径
GET https://api.bibox.com/v3/mdata/marketAll
- 2.请求参数
参数名称 | 是否必须 | 类型 | 描述 | 默认值 | 取值范围 |
---|
Response
{
"state":0,
"result":[
{
"is_hide":0,
"high_cny":"0.3668",
"amount":"380746.08",
"coin_symbol":"BIX",
"last":"0.053142",
"currency_symbol":"USDT",
"change":"+0.000460",
"low_cny":"0.3470",
"base_last_cny":"0.35286384",
"area_id":15,
"percent":"+0.87%",
"last_cny":"0.3529",
"high":"0.055248",
"low":"0.052253",
"pair_type":0,
"last_usd":"0.0531",
"vol24H":"7059898",
"id":90,
"high_usd":"0.0552",
"low_usd":"0.0522"
},
{
"is_hide":0,
"high_cny":"92032.3103",
"amount":"392242739.20",
"coin_symbol":"BTC",
"last":"13328.9300",
"currency_symbol":"USDT",
"change":"-437.5799",
"low_cny":"87735.6210",
"base_last_cny":"88504.33592048",
"area_id":15,
"percent":"-3.17%",
"last_cny":"88504.3359",
"high":"13860.2500",
"low":"13213.1600",
"pair_type":0,
"last_usd":"13318.9290",
"vol24H":"28728",
"id":36,
"high_usd":"13849.8503",
"low_usd":"13203.2459"
}
],
"cmd":"marketAll",
"ver":"3"
}
- 3.返回字段
名称 | 描述 |
---|---|
state | 0代表成功,否则代表失败 |
id | 交易对id |
coin_symbol | 交易币种 |
currency_symbol | 定价币种 |
last | 24h最新价 |
high | 24h最高价 |
low | 24h最低价 |
change | 24h涨跌 |
percent | 24h涨跌幅 |
vol24H | 24h成交量 |
amount | 24h成交额 |
last_cny | 24h最新价折算cny |
high_cny | 24h最高价折算cny |
low_cny | 24h最低价折算cny |
last_usd | 24h最新价折算usd |
high_usd | 24h最高价折算usd |
low_usd | 24h最低价折算usd |
其它字段 | 忽略 |
查询单币种市场行情
Request
let request = require("request");
let url = "https://api.bibox.com/v3/mdata/market?pair=BIX_USDT";
request.get(url,
function optionalCallback(err, httpResponse, body) {
if (err) {
return console.error('upload failed:', err);
}
console.log(body)
});
# -*- coding:utf-8 -*-
import requests
BASE_URL = 'https://api.bibox.com' # 'https://api.bibox.tel' #
def do_request():
path = '/v3/mdata/market?pair=BIX_USDT'
resp = requests.get(BASE_URL + path)
print(resp.text)
if __name__ == '__main__':
do_request()
using System;
using System.Net.Http;
namespace ConsoleProgram
{
public class Class1
{
static readonly HttpClient client = new HttpClient();
static async Task Main()
{
try
{
String uri = "https://api.bibox.tel/v3/mdata/market?pair=BIX_USDT";
string responseBody = await client.GetStringAsync(uri);
Console.WriteLine(responseBody);
}
catch(HttpRequestException e)
{
Console.WriteLine("\nException Caught!");
Console.WriteLine("Message :{0} ",e.Message);
}
}
}
}
- 1.请求路径
GET https://api.bibox.com/v3/mdata/market?pair=BIX_USDT
- 2.请求参数
参数名称 | 是否必须 | 类型 | 描述 | 默认值 | 取值范围 |
---|---|---|---|---|---|
pair | true | string | 交易对 | BIX_BTC, ETH_BTC, ... |
Response
{
"state":0,
"result":{
"is_hide":0,
"high_cny":"0.3668",
"amount":"380746.08",
"coin_symbol":"BIX",
"last":"0.053142",
"currency_symbol":"USDT",
"change":"+0.000460",
"low_cny":"0.3470",
"base_last_cny":"0.35286384",
"area_id":15,
"percent":"+0.87%",
"last_cny":"0.3529",
"high":"0.055248",
"low":"0.052253",
"pair_type":0,
"last_usd":"0.0531",
"vol24H":"7059898",
"id":90,
"high_usd":"0.0552",
"low_usd":"0.0522"
},
"cmd":"market",
"ver":"3"
}
- 3.返回字段
名称 | 描述 |
---|---|
state | 0代表成功,否则代表失败 |
id | 交易对id |
coin_symbol | 交易币种 |
currency_symbol | 定价币种 |
last | 24h最新价 |
high | 24h最高价 |
low | 24h最低价 |
change | 24h涨跌 |
percent | 24h涨跌幅 |
vol24H | 24h成交量 |
amount | 24h成交额 |
last_cny | 24h最新价折算cny |
high_cny | 24h最高价折算cny |
low_cny | 24h最低价折算cny |
last_usd | 24h最新价折算usd |
high_usd | 24h最高价折算usd |
low_usd | 24h最低价折算usd |
其它字段 | 忽略 |
查询市场深度
Request
let request = require("request");
let url = "https://api.bibox.com/v3/mdata/depth?pair=BTC_USDT&size=2";
request.get(url,
function optionalCallback(err, httpResponse, body) {
if (err) {
return console.error('upload failed:', err);
}
console.log(body)
});
# -*- coding:utf-8 -*-
import requests
BASE_URL = 'https://api.bibox.com' # 'https://api.bibox.tel' #
def do_request():
path = '/v3/mdata/depth?pair=BTC_USDT&size=2'
resp = requests.get(BASE_URL + path)
print(resp.text)
if __name__ == '__main__':
do_request()
using System;
using System.Net.Http;
namespace ConsoleProgram
{
public class Class1
{
static readonly HttpClient client = new HttpClient();
static async Task Main()
{
try
{
String uri = "https://api.bibox.tel/v3/mdata/depth?pair=BTC_USDT&size=2";
string responseBody = await client.GetStringAsync(uri);
Console.WriteLine(responseBody);
}
catch(HttpRequestException e)
{
Console.WriteLine("\nException Caught!");
Console.WriteLine("Message :{0} ",e.Message);
}
}
}
}
- 1.请求路径
GET https://api.bibox.com/v3/mdata/depth?pair=BIX_BTC&size=10
- 2.请求参数
参数名称 | 是否必须 | 类型 | 描述 | 默认值 | 取值范围 |
---|---|---|---|---|---|
pair | true | string | 交易对 | BIX_BTC, ETH_BTC, ... | |
size | false | integer | 数量 | 200 | 1-200 |
Response
{
"state":0,
"result":{
"pair":"BTC_USDT",
"update_time":1604316939377,
"asks":[
{
"volume":"0.00320000",
"price":"11739.1407"
},
{
"volume":"0.00320000",
"price":"11762.6189"
}
],
"bids":[
{
"volume":"0.00640000",
"price":"11692.3246"
},
{
"volume":"0.00490000",
"price":"11668.9866"
}
]
},
"cmd":"depth",
"ver":"3"
}
- 3.返回字段
名称 | 描述 |
---|---|
state | 0代表成功,否则代表失败 |
pair | 交易对 |
update_time | 时间戳 |
asks | 卖方深度 |
bids | 买方深度 |
price | 委托价格 |
volume | 委托数量 |
其它字段 | 忽略 |
查询成交记录
Request
let request = require("request");
let url = "https://api.bibox.com/v3/mdata/deals?pair=BTC_USDT&size=2";
request.get(url,
function optionalCallback(err, httpResponse, body) {
if (err) {
return console.error('upload failed:', err);
}
console.log(body)
});
# -*- coding:utf-8 -*-
import requests
BASE_URL = 'https://api.bibox.com' # 'https://api.bibox.tel' #
def do_request():
path = '/v3/mdata/deals?pair=BTC_USDT&size=2'
resp = requests.get(BASE_URL + path)
print(resp.text)
if __name__ == '__main__':
do_request()
using System;
using System.Net.Http;
namespace ConsoleProgram
{
public class Class1
{
static readonly HttpClient client = new HttpClient();
static async Task Main()
{
try
{
String uri = "https://api.bibox.tel/v3/mdata/deals?pair=BTC_USDT&size=2";
string responseBody = await client.GetStringAsync(uri);
Console.WriteLine(responseBody);
}
catch(HttpRequestException e)
{
Console.WriteLine("\nException Caught!");
Console.WriteLine("Message :{0} ",e.Message);
}
}
}
}
- 1.请求路径
GET https://api.bibox.com/v3/mdata/deals?pair=BTC_USDT&size=10
- 2.请求参数
参数名称 | 是否必须 | 类型 | 描述 | 默认值 | 取值范围 |
---|---|---|---|---|---|
pair | true | string | 交易对 | BIX_BTC, ETH_BTC, ... | |
size | false | integer | 数量 | 200 | 1-200 |
Response
{
"state":0,
"result":[
{
"pair":"BTC_USDT",
"price":"11700.0000",
"amount":"0.01000000",
"time":1604316939377,
"side":2
},
{
"pair":"BTC_USDT",
"price":"11857.0026",
"amount":"0.00160000",
"time":1604308219643,
"side":2
}
],
"cmd":"deals",
"ver":"3"
}
- 3.返回字段
名称 | 描述 |
---|---|
state | 0代表成功,否则代表失败 |
pair | 交易对 |
price | 成交价格 |
volume | 成交数量 |
time | 成交时间 |
side | taker成交方向,1-买,2-卖 |
其它字段 | 忽略 |
查询市场ticker
Request
let request = require("request");
let url = "https://api.bibox.com/v3/mdata/ticker?pair=BTC_USDT";
request.get(url,
function optionalCallback(err, httpResponse, body) {
if (err) {
return console.error('upload failed:', err);
}
console.log(body)
});
# -*- coding:utf-8 -*-
import requests
BASE_URL = 'https://api.bibox.com' # 'https://api.bibox.tel' #
def do_request():
path = '/v3/mdata/ticker?pair=BTC_USDT'
resp = requests.get(BASE_URL + path)
print(resp.text)
if __name__ == '__main__':
do_request()
using System;
using System.Net.Http;
namespace ConsoleProgram
{
public class Class1
{
static readonly HttpClient client = new HttpClient();
static async Task Main()
{
try
{
String uri = "https://api.bibox.tel/v3/mdata/ticker?pair=BTC_USDT";
string responseBody = await client.GetStringAsync(uri);
Console.WriteLine(responseBody);
}
catch(HttpRequestException e)
{
Console.WriteLine("\nException Caught!");
Console.WriteLine("Message :{0} ",e.Message);
}
}
}
}
- 1.请求路径
GET https://api.bibox.com/v3/mdata/ticker?pair=BTC_USDT
- 2.请求参数
参数名称 | 是否必须 | 类型 | 描述 | 默认值 | 取值范围 |
---|---|---|---|---|---|
pair | true | string | 交易对 | BIX_BTC, ETH_BTC, ... |
Response
{
"state":0,
"result":{
"pair":"BTC_USDT",
"last":"11700.0000",
"last_usd":"11700.00",
"last_cny":"78287.05",
"high":"11880.0000",
"low":"11700.0000",
"buy":"11692.3246",
"buy_amount":"0.00640000",
"sell":"11739.1407",
"sell_amount":"0.00320000",
"vol":"0.02160000",
"percent":"-1.51%",
"timestamp":1604316939377,
"base_last_cny":"78287.05250000"
},
"cmd":"ticker",
"ver":"3"
}
- 3.返回字段
名称 | 描述 |
---|---|
state | 0代表成功,否则代表失败 |
pair | 交易对symbol |
buy | 最新买一价 |
buy_amount | 买一量 |
sell | 最新卖一价 |
sell_amount | 卖一量 |
high | 24h最高价 |
last | 最新成交价 |
low | 24h最低价 |
timestamp | 时间戳 |
vol | 24h成交量 |
percent | 24h涨跌幅 |
last_cny | 最新成交价,cny计价 |
last_usd | 最新成交价,usd计价 |
其它字段 | 忽略 |
下单限制信息
Request
let request = require("request");
let url = "https://api.bibox.com/v3.1/orderpending/tradeLimit";
request.get(url,
function optionalCallback(err, httpResponse, body) {
if (err) {
return console.error('upload failed:', err);
}
console.log(body)
});
# -*- coding:utf-8 -*-
import requests
BASE_URL = 'https://api.bibox.com' # 'https://api.bibox.tel' #
def do_request():
path = '/v3.1/orderpending/tradeLimit'
resp = requests.get(BASE_URL + path)
print(resp.text)
if __name__ == '__main__':
do_request()
using System;
using System.Net.Http;
namespace ConsoleProgram
{
public class Class1
{
static readonly HttpClient client = new HttpClient();
static async Task Main()
{
try
{
String uri = "https://api.bibox.tel/v3.1/orderpending/tradeLimit";
string responseBody = await client.GetStringAsync(uri);
Console.WriteLine(responseBody);
}
catch(HttpRequestException e)
{
Console.WriteLine("\nException Caught!");
Console.WriteLine("Message :{0} ",e.Message);
}
}
}
}
- 1.请求路径
GET https://api.bibox.com/v3.1/orderpending/tradeLimit
- 2.请求参数
参数名称 | 是否必须 | 类型 | 描述 | 默认值 | 取值范围 |
---|
Response
{
"result":{
"min_trade_price":{
"default":"0.00000001",
"USDT":"0.0001",
"DAI":"0.0001"
},
"min_trade_amount":{
"default":"0.0001"
},
"min_trade_money":{
"USDT":"1",
"DAI":"1",
"GUSD":"1",
"BIX":"3",
"BTC":"0.0002",
"ETH":"0.005"
}
},
"cmd":"tradeLimit",
"state":0
}
- 3.返回字段
名称 | 描述 |
---|---|
state | 0代表成功,否则代表失败 |
min_trade_price | 最小下单价格栏 |
- default | 普通交易对最小下单价格限制0.00000001 |
- USDT | USDT交易区最下下单价格限制0.0001,超过0.0001的小数部分会自动舍弃,适用于所有以USDT计价的交易对 |
- DAI | DAI交易区最小下单价格限制0.0001,超过0.0001的小数部分会自动舍弃,适用于所有以DAI计价的交易对 |
min_trade_amount | 最小下单数量栏 |
- default | 最小下单数量限制0.0001,超过0.0001的小数部分会自动舍弃,适用于所有交易对 |
min_trade_money | 最小下单金额栏 |
- USDT | USDT交易区最小下单金额限制为1,以此类推 |
资产信息(需要ApiKey)
钱包账户资产
Request
let CryptoJS = require("crypto-js");
let request = require("request");
let url = "https://api.bibox.com/v3.1/transfer/mainAssets";
let apikey = "900625568558820892a8c833c33ebc8fd2701efe"; //your apikey
let secret = "c708ac3e70d115ec29efbee197330627d7edf842"; //your apikey secret
let param = {
select: 1
};
let cmd = JSON.stringify(param); //format param
let timestamp = '' + (Date.now());
let sign = CryptoJS.HmacMD5(timestamp + cmd, secret).toString();//sign cmds
request.post({
url: url,//请求路径
method: "POST",//请求方式
headers: {//设置请求头
'content-type': 'application/json',
'bibox-api-key': apikey,
'bibox-api-sign': sign,
'bibox-timestamp': timestamp
},
body: cmd//post参数字符串
},
function optionalCallback(err, httpResponse, body) {
if (err) {
return console.error('upload failed:', err);
}
console.log(body)
});
# -*- coding:utf-8 -*-
import hashlib
import hmac
import json
import time
import requests
import sys, getopt
API_KEY = '900625568558820892a8c833c33ebc8fd2701efe'
SECRET_KEY = 'c708ac3e70d115ec29efbee197330627d7edf842'
BASE_URL = 'https://api.bibox.com' # 'https://api.bibox.tel' #
def do_sign(body):
timestamp = int(time.time()) * 1000
# to_sign = str(timestamp)+json.dumps(body,separators=(',',':'))
to_sign = str(timestamp) + json.dumps(body)
sign = hmac.new(SECRET_KEY.encode("utf-8"), to_sign.encode("utf-8"), hashlib.md5).hexdigest()
print(to_sign)
headers = {
'bibox-api-key': API_KEY,
'bibox-api-sign': sign,
'bibox-timestamp': str(timestamp)
}
return headers
def do_request():
path = '/v3.1/transfer/mainAssets'
body = {
}
headers = do_sign(body)
resp = requests.post(BASE_URL + path, json=body, headers=headers)
print(resp.text)
if __name__ == '__main__':
do_request()
using System;
using System.Net.Http;
using System.Text;
using System.Security.Cryptography;
using Newtonsoft.Json;
using Newtonsoft.Json.Serialization;
namespace ConsoleProgram
{
public class SortContractResolver : DefaultContractResolver
{
protected override IList<JsonProperty> CreateProperties(Type type, MemberSerialization memberSerialization)
{
IList<JsonProperty> properties = base.CreateProperties(type, memberSerialization);
return properties.OrderBy(x=>x.PropertyName).ToList();
}
}
public class Class1
{
// HttpClient is intended to be instantiated once per application, rather than per-use. See Remarks.
static readonly HttpClient client = new HttpClient();
static string GetTimeStamp()
{
TimeSpan ts = DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0, 0);
return Convert.ToInt64(ts.TotalMilliseconds).ToString();
}
static string HmacMD5(string source, string key)
{
HMACMD5 hmacmd = new HMACMD5(Encoding.Default.GetBytes(key));
byte[] inArray = hmacmd.ComputeHash(Encoding.Default.GetBytes(source));
StringBuilder sb = new StringBuilder();
for (int i = 0; i < inArray.Length; i++)
{
sb.Append(inArray[i].ToString("X2"));
}
hmacmd.Clear();
return sb.ToString().ToLower();
}
static async Task Main()
{
// Call asynchronous network methods in a try/catch block to handle exceptions.
try
{
string uri = "https://api.bibox.com/v3.1/transfer/mainAssets";
string apikey = "900625568558820892a8c833c33ebc8fd2701efe";
string secret = "c708ac3e70d115ec29efbee197330627d7edf842";
string timestamp = GetTimeStamp();
var myobj = new {
};
string payload = JsonConvert.SerializeObject(myobj, new JsonSerializerSettings { ContractResolver = new SortContractResolver() });
string source = timestamp + payload;
string sign = HmacMD5(source, secret);
Console.WriteLine(source);
Console.WriteLine(sign);
client.DefaultRequestHeaders.Add("bibox-api-key", apikey);
client.DefaultRequestHeaders.Add("bibox-api-sign", sign);
client.DefaultRequestHeaders.Add("bibox-timestamp", timestamp);
HttpContent content = new StringContent(payload, Encoding.UTF8, "application/json");
HttpResponseMessage response = await client.PostAsync(uri, content);
response.EnsureSuccessStatusCode();
string responseBody = await response.Content.ReadAsStringAsync();
Console.WriteLine(responseBody);
}
catch(HttpRequestException e)
{
Console.WriteLine("\nException Caught!");
Console.WriteLine("Message :{0} ",e.Message);
}
}
}
}
- 1.请求路径
POST https://api.bibox.com/v3.1/transfer/mainAssets
- 2.请求参数
参数名称 | 是否必须 | 类型 | 描述 | 默认值 | 取值范围 |
---|---|---|---|---|---|
select | false | integer | 是否查询资产明细 | 0-各币种总资产合计,1-请求所有币种资产明细 |
Response
{
"result":{
"total_btc":"0.01373280",
"total_cny":"1253.48",
"total_usd":"188.63",
"assets_list":[
{
"coin_symbol":"BTC",
"BTCValue":"0.00149188",
"CNYValue":"136.17",
"USDValue":"20.49",
"balance":"0.00149188",
"freeze":"0.00000000"
},
{
"coin_symbol":"BIX",
"BTCValue":"0.00098407",
"CNYValue":"89.82",
"USDValue":"13.52",
"balance":"247.87570000",
"freeze":"0.00000000"
}
]
},
"cmd":"assets",
"state":0
}
- 3.返回字段
名称 | 描述 |
---|---|
state | 0代表成功,否则代表失败 |
total_btc | 各币种资产总和,btc计价 |
total_cny | 各币种资产总和,cny计价 |
total_usd | 各币种资产总和,usd计价 |
assets_list | 币种资产列表 |
coin_symbol | 币种 |
balance | 可用资产 |
freeze | 冻结资产 |
BTCValue | btc估值 |
CNYValue | cny估值 |
USDValue | usd估值 |
其它字段 | 忽略 |
币币账户资产
Request
let CryptoJS = require("crypto-js");
let request = require("request");
let url = "https://api.bibox.com/v3.1/spot/account/assets";
let apikey = "900625568558820892a8c833c33ebc8fd2701efe"; //your apikey
let secret = "c708ac3e70d115ec29efbee197330627d7edf842"; //your apikey secret
let param = {
select: 1
};
let cmd = JSON.stringify(param); //format param
let timestamp = '' + (Date.now());
let sign = CryptoJS.HmacMD5(timestamp + cmd, secret).toString();//sign cmds
request.post({
url: url,//请求路径
method: "POST",//请求方式
headers: {//设置请求头
'content-type': 'application/json',
'bibox-api-key': apikey,
'bibox-api-sign': sign,
'bibox-timestamp': timestamp
},
body: cmd//post参数字符串
},
function optionalCallback(err, httpResponse, body) {
if (err) {
return console.error('upload failed:', err);
}
console.log(body)
});
# -*- coding:utf-8 -*-
import hashlib
import hmac
import json
import time
import requests
API_KEY = '900625568558820892a8c833c33ebc8fd2701efe'
SECRET_KEY = 'c708ac3e70d115ec29efbee197330627d7edf842'
BASE_URL = 'https://api.bibox.com' # 'https://api.bibox.tel' #
def do_sign(body):
timestamp = int(time.time()) * 1000
# to_sign = str(timestamp)+json.dumps(body,separators=(',',':'))
to_sign = str(timestamp) + json.dumps(body)
sign = hmac.new(SECRET_KEY.encode("utf-8"), to_sign.encode("utf-8"), hashlib.md5).hexdigest()
print(to_sign)
headers = {
'bibox-api-key': API_KEY,
'bibox-api-sign': sign,
'bibox-timestamp': str(timestamp)
}
return headers
def do_request():
path = '/v3.1/spot/account/assets'
body = {
'select': 1
}
headers = do_sign(body)
resp = requests.post(BASE_URL + path, json=body, headers=headers)
print(resp.text)
if __name__ == '__main__':
do_request()
using System;
using System.Net.Http;
using System.Text;
using System.Security.Cryptography;
using Newtonsoft.Json;
using Newtonsoft.Json.Serialization;
namespace ConsoleProgram
{
public class SortContractResolver : DefaultContractResolver
{
protected override IList<JsonProperty> CreateProperties(Type type, MemberSerialization memberSerialization)
{
IList<JsonProperty> properties = base.CreateProperties(type, memberSerialization);
return properties.OrderBy(x=>x.PropertyName).ToList();
}
}
public class Class1
{
// HttpClient is intended to be instantiated once per application, rather than per-use. See Remarks.
static readonly HttpClient client = new HttpClient();
static string GetTimeStamp()
{
TimeSpan ts = DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0, 0);
return Convert.ToInt64(ts.TotalMilliseconds).ToString();
}
static string HmacMD5(string source, string key)
{
HMACMD5 hmacmd = new HMACMD5(Encoding.Default.GetBytes(key));
byte[] inArray = hmacmd.ComputeHash(Encoding.Default.GetBytes(source));
StringBuilder sb = new StringBuilder();
for (int i = 0; i < inArray.Length; i++)
{
sb.Append(inArray[i].ToString("X2"));
}
hmacmd.Clear();
return sb.ToString().ToLower();
}
static async Task Main()
{
// Call asynchronous network methods in a try/catch block to handle exceptions.
try
{
string uri = "https://api.bibox.com/v3.1/spot/account/assets";
string apikey = "900625568558820892a8c833c33ebc8fd2701efe";
string secret = "c708ac3e70d115ec29efbee197330627d7edf842";
string timestamp = GetTimeStamp();
var myobj = new {
select = 1,
};
string payload = JsonConvert.SerializeObject(myobj, new JsonSerializerSettings { ContractResolver = new SortContractResolver() });
string source = timestamp + payload;
string sign = HmacMD5(source, secret);
Console.WriteLine(source);
Console.WriteLine(sign);
client.DefaultRequestHeaders.Add("bibox-api-key", apikey);
client.DefaultRequestHeaders.Add("bibox-api-sign", sign);
client.DefaultRequestHeaders.Add("bibox-timestamp", timestamp);
HttpContent content = new StringContent(payload, Encoding.UTF8, "application/json");
HttpResponseMessage response = await client.PostAsync(uri, content);
response.EnsureSuccessStatusCode();
string responseBody = await response.Content.ReadAsStringAsync();
Console.WriteLine(responseBody);
}
catch(HttpRequestException e)
{
Console.WriteLine("\nException Caught!");
Console.WriteLine("Message :{0} ",e.Message);
}
}
}
}
- 1.请求路径
POST https://api.bibox.com/v3.1/spot/account/assets
- 2.请求参数
参数名称 | 是否必须 | 类型 | 描述 | 默认值 | 取值范围 |
---|---|---|---|---|---|
select | false | integer | 是否查询资产明细 | 0-各币种总资产合计,1-请求所有币种资产明细 |
Response
{
"result":{
"total_btc":"0.01373280",
"total_cny":"1253.48",
"total_usd":"188.63",
"assets_list":[
{
"coin_symbol":"BTC",
"BTCValue":"0.00149188",
"CNYValue":"136.17",
"USDValue":"20.49",
"balance":"0.00149188",
"freeze":"0.00000000"
},
{
"coin_symbol":"BIX",
"BTCValue":"0.00098407",
"CNYValue":"89.82",
"USDValue":"13.52",
"balance":"247.87570000",
"freeze":"0.00000000"
}
]
},
"cmd":"assets",
"state":0
}
- 3.返回字段
名称 | 描述 |
---|---|
state | 0代表成功,否则代表失败 |
total_btc | 各币种资产总和,btc计价 |
total_cny | 各币种资产总和,cny计价 |
total_usd | 各币种资产总和,usd计价 |
assets_list | 币种资产列表 |
coin_symbol | 币种 |
balance | 可用资产 |
freeze | 冻结资产 |
BTCValue | btc估值 |
CNYValue | cny估值 |
USDValue | usd估值 |
其它字段 | 忽略 |
充值
Request
let CryptoJS = require("crypto-js");
let request = require("request");
let url = "https://api.bibox.com/v3.1/transfer/transferIn";
let apikey = "900625568558820892a8c833c33ebc8fd2701efe"; //your apikey
let secret = "c708ac3e70d115ec29efbee197330627d7edf842"; //your apikey secret
let param = {
coin_symbol: 'BTC'
};
let cmd = JSON.stringify(param); //format param
let timestamp = '' + (Date.now());
let sign = CryptoJS.HmacMD5(timestamp + cmd, secret).toString();//sign cmds
request.post({
url: url,//请求路径
method: "POST",//请求方式
headers: {//设置请求头
'content-type': 'application/json',
'bibox-api-key': apikey,
'bibox-api-sign': sign,
'bibox-timestamp': timestamp
},
body: cmd//post参数字符串
},
function optionalCallback(err, httpResponse, body) {
if (err) {
return console.error('upload failed:', err);
}
console.log(body)
});
# -*- coding:utf-8 -*-
import hashlib
import hmac
import json
import time
import requests
import sys, getopt
API_KEY = '900625568558820892a8c833c33ebc8fd2701efe'
SECRET_KEY = 'c708ac3e70d115ec29efbee197330627d7edf842'
BASE_URL = 'https://api.bibox.com' # 'https://api.bibox.tel' #
def do_sign(body):
timestamp = int(time.time()) * 1000
# to_sign = str(timestamp)+json.dumps(body,separators=(',',':'))
to_sign = str(timestamp) + json.dumps(body)
sign = hmac.new(SECRET_KEY.encode("utf-8"), to_sign.encode("utf-8"), hashlib.md5).hexdigest()
print(to_sign)
headers = {
'bibox-api-key': API_KEY,
'bibox-api-sign': sign,
'bibox-timestamp': str(timestamp)
}
return headers
def do_request():
path = '/v3.1/transfer/transferIn'
body = {
'coin_symbol': 'BTC'
}
headers = do_sign(body)
resp = requests.post(BASE_URL + path, json=body, headers=headers)
print(resp.text)
if __name__ == '__main__':
do_request()
using System;
using System.Net.Http;
using System.Text;
using System.Security.Cryptography;
using Newtonsoft.Json;
using Newtonsoft.Json.Serialization;
namespace ConsoleProgram
{
public class SortContractResolver : DefaultContractResolver
{
protected override IList<JsonProperty> CreateProperties(Type type, MemberSerialization memberSerialization)
{
IList<JsonProperty> properties = base.CreateProperties(type, memberSerialization);
return properties.OrderBy(x=>x.PropertyName).ToList();
}
}
public class Class1
{
// HttpClient is intended to be instantiated once per application, rather than per-use. See Remarks.
static readonly HttpClient client = new HttpClient();
static string GetTimeStamp()
{
TimeSpan ts = DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0, 0);
return Convert.ToInt64(ts.TotalMilliseconds).ToString();
}
static string HmacMD5(string source, string key)
{
HMACMD5 hmacmd = new HMACMD5(Encoding.Default.GetBytes(key));
byte[] inArray = hmacmd.ComputeHash(Encoding.Default.GetBytes(source));
StringBuilder sb = new StringBuilder();
for (int i = 0; i < inArray.Length; i++)
{
sb.Append(inArray[i].ToString("X2"));
}
hmacmd.Clear();
return sb.ToString().ToLower();
}
static async Task Main()
{
// Call asynchronous network methods in a try/catch block to handle exceptions.
try
{
string uri = "https://api.bibox.com/v3.1/transfer/transferIn";
string apikey = "900625568558820892a8c833c33ebc8fd2701efe";
string secret = "c708ac3e70d115ec29efbee197330627d7edf842";
string timestamp = GetTimeStamp();
var myobj = new {
coin_symbol = "BTC",
};
string payload = JsonConvert.SerializeObject(myobj, new JsonSerializerSettings { ContractResolver = new SortContractResolver() });
string source = timestamp + payload;
string sign = HmacMD5(source, secret);
Console.WriteLine(source);
Console.WriteLine(sign);
client.DefaultRequestHeaders.Add("bibox-api-key", apikey);
client.DefaultRequestHeaders.Add("bibox-api-sign", sign);
client.DefaultRequestHeaders.Add("bibox-timestamp", timestamp);
HttpContent content = new StringContent(payload, Encoding.UTF8, "application/json");
HttpResponseMessage response = await client.PostAsync(uri, content);
response.EnsureSuccessStatusCode();
string responseBody = await response.Content.ReadAsStringAsync();
Console.WriteLine(responseBody);
}
catch(HttpRequestException e)
{
Console.WriteLine("\nException Caught!");
Console.WriteLine("Message :{0} ",e.Message);
}
}
}
}
- 1.请求路径
POST https://api.bibox.com/v3.1/transfer/transferIn
- 2.请求参数
参数名称 | 是否必须 | 类型 | 描述 | 默认值 | 取值范围 |
---|---|---|---|---|---|
coin_symbol | true | string | 充值币种 | BIX, BTC, ... |
Response
{
"result":"13f2LpNAdsKuxdTt2bKFLaSZL7toeyieGE",
"cmd":"transferIn",
"state":0
}
- 3.返回字段
名称 | 描述 |
---|---|
state | 0代表成功,否则代表失败 |
result | 充值地址 |
其它字段 | 忽略 |
提现
Request
let CryptoJS = require("crypto-js");
let request = require("request");
let url = "https://api.bibox.com/v3.1/transfer/transferOut";
let apikey = "900625568558820892a8c833c33ebc8fd2701efe"; //your apikey
let secret = "c708ac3e70d115ec29efbee197330627d7edf842"; //your apikey secret
let param = {
coin_symbol: 'BTC',
amount: 0.1,
addr: '13f2LpNAdsKuxdTt2bKFLaSZL7toeyieGExxx',
memo: ''
};
let cmd = JSON.stringify(param); //format param
let timestamp = '' + (Date.now());
let sign = CryptoJS.HmacMD5(timestamp + cmd, secret).toString();//sign cmds
request.post({
url: url,//请求路径
method: "POST",//请求方式
headers: {//设置请求头
'content-type': 'application/json',
'bibox-api-key': apikey,
'bibox-api-sign': sign,
'bibox-timestamp': timestamp
},
body: cmd//post参数字符串
},
function optionalCallback(err, httpResponse, body) {
if (err) {
return console.error('upload failed:', err);
}
console.log(body)
});
# -*- coding:utf-8 -*-
import hashlib
import hmac
import json
import time
import requests
import sys, getopt
API_KEY = '900625568558820892a8c833c33ebc8fd2701efe'
SECRET_KEY = 'c708ac3e70d115ec29efbee197330627d7edf842'
BASE_URL = 'https://api.bibox.com' # 'https://api.bibox.tel' #
def do_sign(body):
timestamp = int(time.time()) * 1000
# to_sign = str(timestamp)+json.dumps(body,separators=(',',':'))
to_sign = str(timestamp) + json.dumps(body)
sign = hmac.new(SECRET_KEY.encode("utf-8"), to_sign.encode("utf-8"), hashlib.md5).hexdigest()
print(to_sign)
headers = {
'bibox-api-key': API_KEY,
'bibox-api-sign': sign,
'bibox-timestamp': str(timestamp)
}
return headers
def do_request():
path = '/v3.1/transfer/transferOut'
body = {
'coin_symbol': 'BTC',
'amount': 0.1,
'addr': '13f2LpNAdsKuxdTt2bKFLaSZL7toeyieGExxx',
'memo': ''
}
headers = do_sign(body)
resp = requests.post(BASE_URL + path, json=body, headers=headers)
print(resp.text)
if __name__ == '__main__':
do_request()
using System;
using System.Net.Http;
using System.Text;
using System.Security.Cryptography;
using Newtonsoft.Json;
using Newtonsoft.Json.Serialization;
namespace ConsoleProgram
{
public class SortContractResolver : DefaultContractResolver
{
protected override IList<JsonProperty> CreateProperties(Type type, MemberSerialization memberSerialization)
{
IList<JsonProperty> properties = base.CreateProperties(type, memberSerialization);
return properties.OrderBy(x=>x.PropertyName).ToList();
}
}
public class Class1
{
// HttpClient is intended to be instantiated once per application, rather than per-use. See Remarks.
static readonly HttpClient client = new HttpClient();
static string GetTimeStamp()
{
TimeSpan ts = DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0, 0);
return Convert.ToInt64(ts.TotalMilliseconds).ToString();
}
static string HmacMD5(string source, string key)
{
HMACMD5 hmacmd = new HMACMD5(Encoding.Default.GetBytes(key));
byte[] inArray = hmacmd.ComputeHash(Encoding.Default.GetBytes(source));
StringBuilder sb = new StringBuilder();
for (int i = 0; i < inArray.Length; i++)
{
sb.Append(inArray[i].ToString("X2"));
}
hmacmd.Clear();
return sb.ToString().ToLower();
}
static async Task Main()
{
// Call asynchronous network methods in a try/catch block to handle exceptions.
try
{
string uri = "https://api.bibox.com/v3.1/transfer/transferOut";
string apikey = "900625568558820892a8c833c33ebc8fd2701efe";
string secret = "c708ac3e70d115ec29efbee197330627d7edf842";
string timestamp = GetTimeStamp();
var myobj = new {
coin_symbol = "BTC",
amount = "0.1",
addr = "13f2LpNAdsKuxdTt2bKFLaSZL7toeyieGExxx",
memo = "",
};
string payload = JsonConvert.SerializeObject(myobj, new JsonSerializerSettings { ContractResolver = new SortContractResolver() });
string source = timestamp + payload;
string sign = HmacMD5(source, secret);
Console.WriteLine(source);
Console.WriteLine(sign);
client.DefaultRequestHeaders.Add("bibox-api-key", apikey);
client.DefaultRequestHeaders.Add("bibox-api-sign", sign);
client.DefaultRequestHeaders.Add("bibox-timestamp", timestamp);
HttpContent content = new StringContent(payload, Encoding.UTF8, "application/json");
HttpResponseMessage response = await client.PostAsync(uri, content);
response.EnsureSuccessStatusCode();
string responseBody = await response.Content.ReadAsStringAsync();
Console.WriteLine(responseBody);
}
catch(HttpRequestException e)
{
Console.WriteLine("\nException Caught!");
Console.WriteLine("Message :{0} ",e.Message);
}
}
}
}
- 1.请求路径
POST https://api.bibox.com/v3.1/transfer/transferOut
- 2.请求参数
参数名称 | 是否必须 | 类型 | 描述 | 默认值 | 取值范围 |
---|---|---|---|---|---|
coin_symbol | true | string | 提现币种 | BIX, BTC, ... | |
amount | true | double | 提现数量 | 需大于各币种最小提现数量 | |
addr | true | string | 提现地址 | 币种合法地址 | |
memo | false | string | 提现标签 | 一些币种提现必须指定标签,与地址组合标识唯一性,比如EOS |
Response
{
"state":0,
"result":228,
"cmd":"transfer/transferOut"
}
- 3.返回字段
名称 | 描述 |
---|---|
state | 0代表成功,否则代表失败 |
result | 提现id |
其它字段 | 忽略 |
查询充值记录
Request
let CryptoJS = require("crypto-js");
let request = require("request");
let url = "https://api.bibox.com/v3.1/transfer/transferInList";
let apikey = "900625568558820892a8c833c33ebc8fd2701efe"; //your apikey
let secret = "c708ac3e70d115ec29efbee197330627d7edf842"; //your apikey secret
let param = {
coin_symbol: 'USDT',
filter_type: 0,
page: 1,
size: 10
};
let cmd = JSON.stringify(param); //format param
let timestamp = '' + (Date.now());
let sign = CryptoJS.HmacMD5(timestamp + cmd, secret).toString();//sign cmds
request.post({
url: url,//请求路径
method: "POST",//请求方式
headers: {//设置请求头
'content-type': 'application/json',
'bibox-api-key': apikey,
'bibox-api-sign': sign,
'bibox-timestamp': timestamp
},
body: cmd//post参数字符串
},
function optionalCallback(err, httpResponse, body) {
if (err) {
return console.error('upload failed:', err);
}
console.log(body)
});
# -*- coding:utf-8 -*-
import hashlib
import hmac
import json
import time
import requests
API_KEY = '900625568558820892a8c833c33ebc8fd2701efe'
SECRET_KEY = 'c708ac3e70d115ec29efbee197330627d7edf842'
BASE_URL = 'https://api.bibox.com' # 'https://api.bibox.tel' #
def do_sign(body):
timestamp = int(time.time()) * 1000
# to_sign = str(timestamp)+json.dumps(body,separators=(',',':'))
to_sign = str(timestamp) + json.dumps(body)
sign = hmac.new(SECRET_KEY.encode("utf-8"), to_sign.encode("utf-8"), hashlib.md5).hexdigest()
print(to_sign)
headers = {
'bibox-api-key': API_KEY,
'bibox-api-sign': sign,
'bibox-timestamp': str(timestamp)
}
return headers
def do_request():
path = '/v3.1/transfer/transferInList'
body = {
'coin_symbol': 'USDT',
'filter_type': 0,
'page': 1,
'size': 10
}
headers = do_sign(body)
resp = requests.post(BASE_URL + path, json=body, headers=headers)
print(resp.text)
if __name__ == '__main__':
do_request()
using System;
using System.Net.Http;
using System.Text;
using System.Security.Cryptography;
using Newtonsoft.Json;
using Newtonsoft.Json.Serialization;
namespace ConsoleProgram
{
public class SortContractResolver : DefaultContractResolver
{
protected override IList<JsonProperty> CreateProperties(Type type, MemberSerialization memberSerialization)
{
IList<JsonProperty> properties = base.CreateProperties(type, memberSerialization);
return properties.OrderBy(x=>x.PropertyName).ToList();
}
}
public class Class1
{
// HttpClient is intended to be instantiated once per application, rather than per-use. See Remarks.
static readonly HttpClient client = new HttpClient();
static string GetTimeStamp()
{
TimeSpan ts = DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0, 0);
return Convert.ToInt64(ts.TotalMilliseconds).ToString();
}
static string HmacMD5(string source, string key)
{
HMACMD5 hmacmd = new HMACMD5(Encoding.Default.GetBytes(key));
byte[] inArray = hmacmd.ComputeHash(Encoding.Default.GetBytes(source));
StringBuilder sb = new StringBuilder();
for (int i = 0; i < inArray.Length; i++)
{
sb.Append(inArray[i].ToString("X2"));
}
hmacmd.Clear();
return sb.ToString().ToLower();
}
static async Task Main()
{
// Call asynchronous network methods in a try/catch block to handle exceptions.
try
{
string uri = "https://api.bibox.com/v3.1/transfer/transferInList";
string apikey = "900625568558820892a8c833c33ebc8fd2701efe";
string secret = "c708ac3e70d115ec29efbee197330627d7edf842";
string timestamp = GetTimeStamp();
var myobj = new {
coin_symbol = "USDT",
filter_type = 0,
page = 1,
size = 10,
};
string payload = JsonConvert.SerializeObject(myobj, new JsonSerializerSettings { ContractResolver = new SortContractResolver() });
string source = timestamp + payload;
string sign = HmacMD5(source, secret);
Console.WriteLine(source);
Console.WriteLine(sign);
client.DefaultRequestHeaders.Add("bibox-api-key", apikey);
client.DefaultRequestHeaders.Add("bibox-api-sign", sign);
client.DefaultRequestHeaders.Add("bibox-timestamp", timestamp);
HttpContent content = new StringContent(payload, Encoding.UTF8, "application/json");
HttpResponseMessage response = await client.PostAsync(uri, content);
response.EnsureSuccessStatusCode();
string responseBody = await response.Content.ReadAsStringAsync();
Console.WriteLine(responseBody);
}
catch(HttpRequestException e)
{
Console.WriteLine("\nException Caught!");
Console.WriteLine("Message :{0} ",e.Message);
}
}
}
}
- 1.请求路径
POST https://api.bibox.com/v3.1/transfer/transferInList
- 2.请求参数
参数名称 | 是否必须 | 类型 | 描述 | 默认值 | 取值范围 |
---|---|---|---|---|---|
filter_type | false | integer | 充值记录筛选 | 0 | 0-全部,1-充值进行中,2-充值到账,3-充值失败 |
coin_symbol | false | string | 充值币种 | BIX, ETH, ... | |
page | true | integer | 第几页 | 从1开始 | |
size | true | integer | 每页数量 | 1-50 |
Response
{
"result":{
"count":1,
"page":1,
"items":[
{
"id":1682192,
"to":"TXLhYFsWu84vU5ngs8J88yphTPdv69zrqoD",
"tx_id":"a8f77b3a20758d85f71f2d993766c9b6c2daf1b1f34992e409e1a47247e5a5e45",
"coin_symbol":"USDT",
"chain_type":"TRC20",
"confirmCount":"20",
"amount":"0.00094400",
"createdAt":1596876872000,
"status":2
}
]
},
"cmd":"transferInList",
"state":0
}
- 3.返回字段
名称 | 描述 |
---|---|
state | 0代表成功,否则代表失败 |
count | 当前页记录数,若存在下页,count=当前页记录数+1 |
page | 第几页,从1开始 |
items | 记录列表 |
coin_symbol | 币种 |
to_address | 充值地址 |
amount | 充值数量 |
confirmCount | 充值确认数 |
createdAt | 充值时间 |
status | 状态, 1-充值进行中,2-充值到账,3-充值失败 |
其它字段 | 忽略 |
查询提现记录
Request
let CryptoJS = require("crypto-js");
let request = require("request");
let url = "https://api.bibox.com/v3.1/transfer/transferOutList";
let apikey = "900625568558820892a8c833c33ebc8fd2701efe"; //your apikey
let secret = "c708ac3e70d115ec29efbee197330627d7edf842"; //your apikey secret
let param = {
coin_symbol: 'USDT',
filter_type: 2,
page: 1,
size: 10
};
let cmd = JSON.stringify(param); //format param
let timestamp = '' + (Date.now());
let sign = CryptoJS.HmacMD5(timestamp + cmd, secret).toString();//sign cmds
request.post({
url: url,//请求路径
method: "POST",//请求方式
headers: {//设置请求头
'content-type': 'application/json',
'bibox-api-key': apikey,
'bibox-api-sign': sign,
'bibox-timestamp': timestamp
},
body: cmd//post参数字符串
},
function optionalCallback(err, httpResponse, body) {
if (err) {
return console.error('upload failed:', err);
}
console.log(body)
});
# -*- coding:utf-8 -*-
import hashlib
import hmac
import json
import time
import requests
API_KEY = '900625568558820892a8c833c33ebc8fd2701efe'
SECRET_KEY = 'c708ac3e70d115ec29efbee197330627d7edf842'
BASE_URL = 'https://api.bibox.com' # 'https://api.bibox.tel' #
def do_sign(body):
timestamp = int(time.time()) * 1000
# to_sign = str(timestamp)+json.dumps(body,separators=(',',':'))
to_sign = str(timestamp) + json.dumps(body)
sign = hmac.new(SECRET_KEY.encode("utf-8"), to_sign.encode("utf-8"), hashlib.md5).hexdigest()
print(to_sign)
headers = {
'bibox-api-key': API_KEY,
'bibox-api-sign': sign,
'bibox-timestamp': str(timestamp)
}
return headers
def do_request():
path = '/v3.1/transfer/transferOutList'
body = {
'coin_symbol': 'USDT',
'filter_type': 2,
'page': 1,
'size': 10
}
headers = do_sign(body)
resp = requests.post(BASE_URL + path, json=body, headers=headers)
print(resp.text)
if __name__ == '__main__':
do_request()
using System;
using System.Net.Http;
using System.Text;
using System.Security.Cryptography;
using Newtonsoft.Json;
using Newtonsoft.Json.Serialization;
namespace ConsoleProgram
{
public class SortContractResolver : DefaultContractResolver
{
protected override IList<JsonProperty> CreateProperties(Type type, MemberSerialization memberSerialization)
{
IList<JsonProperty> properties = base.CreateProperties(type, memberSerialization);
return properties.OrderBy(x=>x.PropertyName).ToList();
}
}
public class Class1
{
// HttpClient is intended to be instantiated once per application, rather than per-use. See Remarks.
static readonly HttpClient client = new HttpClient();
static string GetTimeStamp()
{
TimeSpan ts = DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0, 0);
return Convert.ToInt64(ts.TotalMilliseconds).ToString();
}
static string HmacMD5(string source, string key)
{
HMACMD5 hmacmd = new HMACMD5(Encoding.Default.GetBytes(key));
byte[] inArray = hmacmd.ComputeHash(Encoding.Default.GetBytes(source));
StringBuilder sb = new StringBuilder();
for (int i = 0; i < inArray.Length; i++)
{
sb.Append(inArray[i].ToString("X2"));
}
hmacmd.Clear();
return sb.ToString().ToLower();
}
static async Task Main()
{
// Call asynchronous network methods in a try/catch block to handle exceptions.
try
{
string uri = "https://api.bibox.com/v3.1/transfer/transferOutList";
string apikey = "900625568558820892a8c833c33ebc8fd2701efe";
string secret = "c708ac3e70d115ec29efbee197330627d7edf842";
string timestamp = GetTimeStamp();
var myobj = new {
coin_symbol = "USDT",
filter_type = 2,
page = 1,
size = 10,
};
string payload = JsonConvert.SerializeObject(myobj, new JsonSerializerSettings { ContractResolver = new SortContractResolver() });
string source = timestamp + payload;
string sign = HmacMD5(source, secret);
Console.WriteLine(source);
Console.WriteLine(sign);
client.DefaultRequestHeaders.Add("bibox-api-key", apikey);
client.DefaultRequestHeaders.Add("bibox-api-sign", sign);
client.DefaultRequestHeaders.Add("bibox-timestamp", timestamp);
HttpContent content = new StringContent(payload, Encoding.UTF8, "application/json");
HttpResponseMessage response = await client.PostAsync(uri, content);
response.EnsureSuccessStatusCode();
string responseBody = await response.Content.ReadAsStringAsync();
Console.WriteLine(responseBody);
}
catch(HttpRequestException e)
{
Console.WriteLine("\nException Caught!");
Console.WriteLine("Message :{0} ",e.Message);
}
}
}
}
- 1.请求路径
POST https://api.bibox.com/v3.1/transfer/transferOutList
- 2.请求参数
参数名称 | 是否必须 | 类型 | 描述 | 默认值 | 取值范围 |
---|---|---|---|---|---|
filter_type | false | integer | 提现记录筛选 | -2:审核不通过;-1: 用户撤销;0:待审核; 1:审核通过(待发币); 2: 发币中; 3:发币完成 | |
coin_symbol | false | string | 提现币种 | BIX, ETH, ... | |
page | true | integer | 第几页 | 从1开始 | |
size | true | integer | 每页数量 | 1-50 |
Response
{
"result":{
"count":1,
"page":1,
"items":[
{
"id":809022,
"to_address":"0x606a84A14307418F47C6ad538b5E73C93Ff9C8Cf",
"tx_id":"0xd3cf26d514c1e62f85de84b4e24fbd219084dd078daa7e639844c33cdf81bd62b",
"coin_symbol":"USDT",
"chain_type":"ERC20",
"amount_real":"1000.00000000",
"amount":"1003.00000000",
"createdAt":1596876972000,
"memo":"",
"status":2
}
]
},
"cmd":"transferOutList",
"state":0
}
- 3.返回字段
名称 | 描述 |
---|---|
state | 0代表成功,否则代表失败 |
count | 当前页记录数,若存在下页,count=当前页记录数+1 |
page | 第几页,从1开始 |
items | 记录列表 |
coin_symbol | 币种 |
to_address | 提现地址 |
amount | 提现数量 |
fee | 提现手续费 |
createdAt | 充值时间 |
memo | memo |
status | 状态, 1-进行中,2-提现成功,3-提现失败,4-提现被撤销 |
其它字段 | 忽略 |
获取币种配置
Request
let CryptoJS = require("crypto-js");
let request = require("request");
let url = "https://api.bibox.com/v3.1/transfer/coinConfig";
let apikey = "900625568558820892a8c833c33ebc8fd2701efe"; //your apikey
let secret = "c708ac3e70d115ec29efbee197330627d7edf842"; //your apikey secret
let param = {
};
let cmd = JSON.stringify(param); //format param
let timestamp = '' + (Date.now());
let sign = CryptoJS.HmacMD5(timestamp + cmd, secret).toString();//sign cmds
request.post({
url: url,//请求路径
method: "POST",//请求方式
headers: {//设置请求头
'content-type': 'application/json',
'bibox-api-key': apikey,
'bibox-api-sign': sign,
'bibox-timestamp': timestamp
},
body: cmd//post参数字符串
},
function optionalCallback(err, httpResponse, body) {
if (err) {
return console.error('upload failed:', err);
}
console.log(body)
});
# -*- coding:utf-8 -*-
import hashlib
import hmac
import json
import time
import requests
API_KEY = '900625568558820892a8c833c33ebc8fd2701efe'
SECRET_KEY = 'c708ac3e70d115ec29efbee197330627d7edf842'
BASE_URL = 'https://api.bibox.com' # 'https://api.bibox.tel' #
def do_sign(body):
timestamp = int(time.time()) * 1000
# to_sign = str(timestamp)+json.dumps(body,separators=(',',':'))
to_sign = str(timestamp) + json.dumps(body)
sign = hmac.new(SECRET_KEY.encode("utf-8"), to_sign.encode("utf-8"), hashlib.md5).hexdigest()
print(to_sign)
headers = {
'bibox-api-key': API_KEY,
'bibox-api-sign': sign,
'bibox-timestamp': str(timestamp)
}
return headers
def do_request():
path = '/v3.1/transfer/coinConfig'
body = {
}
headers = do_sign(body)
resp = requests.post(BASE_URL + path, json=body, headers=headers)
print(resp.text)
if __name__ == '__main__':
do_request()
using System;
using System.Net.Http;
using System.Text;
using System.Security.Cryptography;
using Newtonsoft.Json;
using Newtonsoft.Json.Serialization;
namespace ConsoleProgram
{
public class SortContractResolver : DefaultContractResolver
{
protected override IList<JsonProperty> CreateProperties(Type type, MemberSerialization memberSerialization)
{
IList<JsonProperty> properties = base.CreateProperties(type, memberSerialization);
return properties.OrderBy(x=>x.PropertyName).ToList();
}
}
public class Class1
{
// HttpClient is intended to be instantiated once per application, rather than per-use. See Remarks.
static readonly HttpClient client = new HttpClient();
static string GetTimeStamp()
{
TimeSpan ts = DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0, 0);
return Convert.ToInt64(ts.TotalMilliseconds).ToString();
}
static string HmacMD5(string source, string key)
{
HMACMD5 hmacmd = new HMACMD5(Encoding.Default.GetBytes(key));
byte[] inArray = hmacmd.ComputeHash(Encoding.Default.GetBytes(source));
StringBuilder sb = new StringBuilder();
for (int i = 0; i < inArray.Length; i++)
{
sb.Append(inArray[i].ToString("X2"));
}
hmacmd.Clear();
return sb.ToString().ToLower();
}
static async Task Main()
{
// Call asynchronous network methods in a try/catch block to handle exceptions.
try
{
string uri = "https://api.bibox.com/v3.1/transfer/coinConfig";
string apikey = "900625568558820892a8c833c33ebc8fd2701efe";
string secret = "c708ac3e70d115ec29efbee197330627d7edf842";
string timestamp = GetTimeStamp();
var myobj = new {
};
string payload = JsonConvert.SerializeObject(myobj, new JsonSerializerSettings { ContractResolver = new SortContractResolver() });
string source = timestamp + payload;
string sign = HmacMD5(source, secret);
Console.WriteLine(source);
Console.WriteLine(sign);
client.DefaultRequestHeaders.Add("bibox-api-key", apikey);
client.DefaultRequestHeaders.Add("bibox-api-sign", sign);
client.DefaultRequestHeaders.Add("bibox-timestamp", timestamp);
HttpContent content = new StringContent(payload, Encoding.UTF8, "application/json");
HttpResponseMessage response = await client.PostAsync(uri, content);
response.EnsureSuccessStatusCode();
string responseBody = await response.Content.ReadAsStringAsync();
Console.WriteLine(responseBody);
}
catch(HttpRequestException e)
{
Console.WriteLine("\nException Caught!");
Console.WriteLine("Message :{0} ",e.Message);
}
}
}
}
- 1.请求路径
POST https://api.bibox.com/v3.1/transfer/coinConfig
- 2.请求参数
参数名称 | 是否必须 | 类型 | 描述 | 默认值 | 取值范围 |
---|---|---|---|---|---|
coin_symbol | false | string | 币种 | BIX, ETH... |
Response
{
"result":[
{
"coin_symbol":"BTC",
"is_active":1,
"original_decimals":8,
"enable_deposit":1,
"enable_withdraw":1,
"withdraw_fee":0.0008,
"withdraw_min":0.005
}
],
"cmd":"coinConfig",
"state":0
}
- 3.返回字段
名称 | 描述 |
---|---|
state | 0代表成功,否则代表失败 |
coin_symbol | 币种 |
original_decimals | 币种原值精度 |
enable_deposit | 是否可充值,0-禁止,1-可以 |
enable_withdraw | 是否可提现,0-禁止,1-可以 |
withdraw_fee | 提现手续费 |
withdraw_min | 最小提现数量 |
其它字段 | 忽略 |
查询某一条提现记录
Request
let CryptoJS = require("crypto-js");
let request = require("request");
let url = "https://api.bibox.com/v3.1/transfer/withdrawInfo";
let apikey = "900625568558820892a8c833c33ebc8fd2701efe"; //your apikey
let secret = "c708ac3e70d115ec29efbee197330627d7edf842"; //your apikey secret
let param = {
id: 228
};
let cmd = JSON.stringify(param); //format param
let timestamp = '' + (Date.now());
let sign = CryptoJS.HmacMD5(timestamp + cmd, secret).toString();//sign cmds
request.post({
url: url,//请求路径
method: "POST",//请求方式
headers: {//设置请求头
'content-type': 'application/json',
'bibox-api-key': apikey,
'bibox-api-sign': sign,
'bibox-timestamp': timestamp
},
body: cmd//post参数字符串
},
function optionalCallback(err, httpResponse, body) {
if (err) {
return console.error('upload failed:', err);
}
console.log(body)
});
# -*- coding:utf-8 -*-
import hashlib
import hmac
import json
import time
import requests
API_KEY = '900625568558820892a8c833c33ebc8fd2701efe'
SECRET_KEY = 'c708ac3e70d115ec29efbee197330627d7edf842'
BASE_URL = 'https://api.bibox.com' # 'https://api.bibox.tel' #
def do_sign(body):
timestamp = int(time.time()) * 1000
# to_sign = str(timestamp)+json.dumps(body,separators=(',',':'))
to_sign = str(timestamp) + json.dumps(body)
sign = hmac.new(SECRET_KEY.encode("utf-8"), to_sign.encode("utf-8"), hashlib.md5).hexdigest()
print(to_sign)
headers = {
'bibox-api-key': API_KEY,
'bibox-api-sign': sign,
'bibox-timestamp': str(timestamp)
}
return headers
def do_request():
path = '/v3.1/transfer/withdrawInfo'
body = {
'id': 228
}
headers = do_sign(body)
resp = requests.post(BASE_URL + path, json=body, headers=headers)
print(resp.text)
if __name__ == '__main__':
do_request()
using System;
using System.Net.Http;
using System.Text;
using System.Security.Cryptography;
using Newtonsoft.Json;
using Newtonsoft.Json.Serialization;
namespace ConsoleProgram
{
public class SortContractResolver : DefaultContractResolver
{
protected override IList<JsonProperty> CreateProperties(Type type, MemberSerialization memberSerialization)
{
IList<JsonProperty> properties = base.CreateProperties(type, memberSerialization);
return properties.OrderBy(x=>x.PropertyName).ToList();
}
}
public class Class1
{
// HttpClient is intended to be instantiated once per application, rather than per-use. See Remarks.
static readonly HttpClient client = new HttpClient();
static string GetTimeStamp()
{
TimeSpan ts = DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0, 0);
return Convert.ToInt64(ts.TotalMilliseconds).ToString();
}
static string HmacMD5(string source, string key)
{
HMACMD5 hmacmd = new HMACMD5(Encoding.Default.GetBytes(key));
byte[] inArray = hmacmd.ComputeHash(Encoding.Default.GetBytes(source));
StringBuilder sb = new StringBuilder();
for (int i = 0; i < inArray.Length; i++)
{
sb.Append(inArray[i].ToString("X2"));
}
hmacmd.Clear();
return sb.ToString().ToLower();
}
static async Task Main()
{
// Call asynchronous network methods in a try/catch block to handle exceptions.
try
{
string uri = "https://api.bibox.com/v3.1/transfer/withdrawInfo";
string apikey = "900625568558820892a8c833c33ebc8fd2701efe";
string secret = "c708ac3e70d115ec29efbee197330627d7edf842";
string timestamp = GetTimeStamp();
var myobj = new {
id = 228,
};
string payload = JsonConvert.SerializeObject(myobj, new JsonSerializerSettings { ContractResolver = new SortContractResolver() });
string source = timestamp + payload;
string sign = HmacMD5(source, secret);
Console.WriteLine(source);
Console.WriteLine(sign);
client.DefaultRequestHeaders.Add("bibox-api-key", apikey);
client.DefaultRequestHeaders.Add("bibox-api-sign", sign);
client.DefaultRequestHeaders.Add("bibox-timestamp", timestamp);
HttpContent content = new StringContent(payload, Encoding.UTF8, "application/json");
HttpResponseMessage response = await client.PostAsync(uri, content);
response.EnsureSuccessStatusCode();
string responseBody = await response.Content.ReadAsStringAsync();
Console.WriteLine(responseBody);
}
catch(HttpRequestException e)
{
Console.WriteLine("\nException Caught!");
Console.WriteLine("Message :{0} ",e.Message);
}
}
}
}
- 1.请求路径
POST https://api.bibox.com/v3.1/transfer/withdrawInfo
- 2.请求参数
参数名称 | 是否必须 | 类型 | 描述 | 默认值 | 取值范围 |
---|---|---|---|---|---|
id | true | integer | 提现id |
Response
{
"state":0,
"result":{
"id":228,
"createdAt": 1512756997000,
"coin_symbol":"LTC",
"to_address":"xxxxxxxxxxxxxxxxxxxxxxxxxx",
"status":3,
"amount":"1.00000000",
"fee":0.1
},
"cmd":"withdrawInfo"
}
- 3.返回字段
名称 | 描述 |
---|---|
state | 0代表成功,否则代表失败 |
id | 提现id |
coin_symbol | 币种 |
createdAt | 提现时间 |
to_address | 提现地址 |
status | 状态, -2:审核不通过;-1: 用户撤销;0:待审核; 1:审核通过(待发币); 2: 发币中; 3:发币完成 |
amount | 提现数量 |
fee | 提现手续费 |
其它字段 | 忽略 |
查询钱包账户账单
- 1.请求路径
POST https://api.bibox.com/v3.1/transfer/bills
- 2.请求参数
参数名称 | 是否必须 | 类型 | 描述 | 默认值 | 取值范围 |
---|---|---|---|---|---|
account_type | true | integer | 0钱包账户 1杠杆账户 | 1 | |
page | true | integer | 第几页 | 1,2,... | |
size | true | integer | 多少条 | 1,2,... | |
begin_time | false | integer | 开始时间 | ||
end_time | false | integer | 结束时间 | ||
type | false | integer | 账单类型 | 0充值,2提现, 130钱包账户转现货, 131现货转钱包, 21钱包转杠杆, 22杠杆转钱包 |
Response
{
"result":{
"count":11,
"page":1,
"items":[
{
"id":"1125899906850284004",
"coin_symbol":"USDT",
"bill_type":12,
"comment":"",
"change_amount":"6.9553",
"change_result":"182461.2621",
"createdAt":"2020-11-23T00:00:00.000Z",
"updatedAt":"2020-11-23T00:00:00.000Z"
}
]
}
}
- 3.返回字段
名称 | 描述 |
---|---|
id | 账单id |
coin_symbol | 币种符号 |
bill_type | 账单类型 |
comment | 账单描述 |
change_amount | 资产改变量 |
change_result | 资产改变结果 |
createdAt | 账单时间 |
其它字段 | 忽略 |
币币交易(需要ApiKey)
下单
Request
let CryptoJS = require("crypto-js");
let request = require("request");
let url = "https://api.bibox.com/v3/spot/order/trade";
let apikey = "900625568558820892a8c833c33ebc8fd2701efe"; //your apikey
let secret = "c708ac3e70d115ec29efbee197330627d7edf842"; //your apikey secret
let param = {
pair: 'BIX_USDT',
order_side: 2,
order_type: 2,
price: 0.05458,
amount: 100
};
let cmd = JSON.stringify(param); //format param
let timestamp = '' + (Date.now());
let sign = CryptoJS.HmacMD5(timestamp + cmd, secret).toString();//sign cmds
request.post({
url: url,//请求路径
method: "POST",//请求方式
headers: {//设置请求头
'content-type': 'application/json',
'bibox-api-key': apikey,
'bibox-api-sign': sign,
'bibox-timestamp': timestamp
},
body: cmd//post参数字符串
},
function optionalCallback(err, httpResponse, body) {
if (err) {
return console.error('upload failed:', err);
}
console.log(body)
});
# -*- coding:utf-8 -*-
import hashlib
import hmac
import json
import time
import requests
API_KEY = '900625568558820892a8c833c33ebc8fd2701efe'
SECRET_KEY = 'c708ac3e70d115ec29efbee197330627d7edf842'
BASE_URL = 'https://api.bibox.com' # 'https://api.bibox.tel' #
def do_sign(body):
timestamp = int(time.time()) * 1000
# to_sign = str(timestamp)+json.dumps(body,separators=(',',':'))
to_sign = str(timestamp) + json.dumps(body)
sign = hmac.new(SECRET_KEY.encode("utf-8"), to_sign.encode("utf-8"), hashlib.md5).hexdigest()
print(to_sign)
headers = {
'bibox-api-key': API_KEY,
'bibox-api-sign': sign,
'bibox-timestamp': str(timestamp)
}
return headers
def do_request():
path = '/v3/spot/order/trade'
body = {
'pair': 'BIX_USDT',
'order_side': 2,
'order_type': 2,
'price': 0.05458,
'amount': 100
}
headers = do_sign(body)
resp = requests.post(BASE_URL + path, json=body, headers=headers)
print(resp.text)
if __name__ == '__main__':
do_request()
using System;
using System.Net.Http;
using System.Text;
using System.Security.Cryptography;
using Newtonsoft.Json;
using Newtonsoft.Json.Serialization;
namespace ConsoleProgram
{
public class SortContractResolver : DefaultContractResolver
{
protected override IList<JsonProperty> CreateProperties(Type type, MemberSerialization memberSerialization)
{
IList<JsonProperty> properties = base.CreateProperties(type, memberSerialization);
return properties.OrderBy(x=>x.PropertyName).ToList();
}
}
public class Class1
{
// HttpClient is intended to be instantiated once per application, rather than per-use. See Remarks.
static readonly HttpClient client = new HttpClient();
static string GetTimeStamp()
{
TimeSpan ts = DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0, 0);
return Convert.ToInt64(ts.TotalMilliseconds).ToString();
}
static string HmacMD5(string source, string key)
{
HMACMD5 hmacmd = new HMACMD5(Encoding.Default.GetBytes(key));
byte[] inArray = hmacmd.ComputeHash(Encoding.Default.GetBytes(source));
StringBuilder sb = new StringBuilder();
for (int i = 0; i < inArray.Length; i++)
{
sb.Append(inArray[i].ToString("X2"));
}
hmacmd.Clear();
return sb.ToString().ToLower();
}
static async Task Main()
{
// Call asynchronous network methods in a try/catch block to handle exceptions.
try
{
string uri = "https://api.bibox.com/v3/spot/order/trade";
string apikey = "900625568558820892a8c833c33ebc8fd2701efe";
string secret = "c708ac3e70d115ec29efbee197330627d7edf842";
string timestamp = GetTimeStamp();
var myobj = new {
pair = "BIX_USDT",
order_side = 2,
order_type = 2,
price = "0.05458",
amount = "100",
};
string payload = JsonConvert.SerializeObject(myobj, new JsonSerializerSettings { ContractResolver = new SortContractResolver() });
string source = timestamp + payload;
string sign = HmacMD5(source, secret);
Console.WriteLine(source);
Console.WriteLine(sign);
client.DefaultRequestHeaders.Add("bibox-api-key", apikey);
client.DefaultRequestHeaders.Add("bibox-api-sign", sign);
client.DefaultRequestHeaders.Add("bibox-timestamp", timestamp);
HttpContent content = new StringContent(payload, Encoding.UTF8, "application/json");
HttpResponseMessage response = await client.PostAsync(uri, content);
response.EnsureSuccessStatusCode();
string responseBody = await response.Content.ReadAsStringAsync();
Console.WriteLine(responseBody);
}
catch(HttpRequestException e)
{
Console.WriteLine("\nException Caught!");
Console.WriteLine("Message :{0} ",e.Message);
}
}
}
}
- 1.请求路径
POST https://api.bibox.com/v3/spot/order/trade
- 2.请求参数
参数名称 | 是否必须 | 类型 | 描述 | 默认值 | 取值范围 |
---|---|---|---|---|---|
pair | true | string | 交易对 | BIX_BTC, ETH_BTC, ... | |
order_type | true | integer | 交易类型 | 2-限价单 | |
order_side | true | integer | 交易方向 | 1-买,2-卖 | |
price | true | double | 委托价格 | 最小值 0.00000001 | |
amount | true | double | 委托数量 | 最小值 0.0001 | |
client_oid | false | long to string | 用户自定义id | '110011223344' |
Response
{
"order_id":"12845594488036185",
"state":0
}
- 3.返回字段
名称 | 描述 |
---|---|
state | 0代表成功,否则代表失败 |
order_id | 订单id |
status | 状态,-1 失败,0或1-待成交,2-部分成交,3-完全成交,4-部分撤销,5-完全撤销 |
其它字段 | 忽略 |
撤单
Request
let CryptoJS = require("crypto-js");
let request = require("request");
let url = "https://api.bibox.com/v3/spot/order/cancel";
let apikey = "900625568558820892a8c833c33ebc8fd2701efe"; //your apikey
let secret = "c708ac3e70d115ec29efbee197330627d7edf842"; //your apikey secret
let param = {
order_id:"12845594488036185"
};
let cmd = JSON.stringify(param); //format param
let timestamp = '' + (Date.now());
let sign = CryptoJS.HmacMD5(timestamp + cmd, secret).toString();//sign cmds
request.post({
url: url,//请求路径
method: "POST",//请求方式
headers: {//设置请求头
'content-type': 'application/json',
'bibox-api-key': apikey,
'bibox-api-sign': sign,
'bibox-timestamp': timestamp
},
body: cmd//post参数字符串
},
function optionalCallback(err, httpResponse, body) {
if (err) {
return console.error('upload failed:', err);
}
console.log(body)
});
# -*- coding:utf-8 -*-
import hashlib
import hmac
import json
import time
import requests
API_KEY = '900625568558820892a8c833c33ebc8fd2701efe'
SECRET_KEY = 'c708ac3e70d115ec29efbee197330627d7edf842'
BASE_URL = 'https://api.bibox.com' # 'https://api.bibox.tel' #
def do_sign(body):
timestamp = int(time.time()) * 1000
# to_sign = str(timestamp)+json.dumps(body,separators=(',',':'))
to_sign = str(timestamp) + json.dumps(body)
sign = hmac.new(SECRET_KEY.encode("utf-8"), to_sign.encode("utf-8"), hashlib.md5).hexdigest()
print(to_sign)
headers = {
'bibox-api-key': API_KEY,
'bibox-api-sign': sign,
'bibox-timestamp': str(timestamp)
}
return headers
def do_request():
path = '/v3/spot/order/cancel'
body = {
'order_id': "12845594488036185"
}
headers = do_sign(body)
resp = requests.post(BASE_URL + path, json=body, headers=headers)
print(resp.text)
if __name__ == '__main__':
do_request()
using System;
using System.Net.Http;
using System.Text;
using System.Security.Cryptography;
using Newtonsoft.Json;
using Newtonsoft.Json.Serialization;
namespace ConsoleProgram
{
public class SortContractResolver : DefaultContractResolver
{
protected override IList<JsonProperty> CreateProperties(Type type, MemberSerialization memberSerialization)
{
IList<JsonProperty> properties = base.CreateProperties(type, memberSerialization);
return properties.OrderBy(x=>x.PropertyName).ToList();
}
}
public class Class1
{
// HttpClient is intended to be instantiated once per application, rather than per-use. See Remarks.
static readonly HttpClient client = new HttpClient();
static string GetTimeStamp()
{
TimeSpan ts = DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0, 0);
return Convert.ToInt64(ts.TotalMilliseconds).ToString();
}
static string HmacMD5(string source, string key)
{
HMACMD5 hmacmd = new HMACMD5(Encoding.Default.GetBytes(key));
byte[] inArray = hmacmd.ComputeHash(Encoding.Default.GetBytes(source));
StringBuilder sb = new StringBuilder();
for (int i = 0; i < inArray.Length; i++)
{
sb.Append(inArray[i].ToString("X2"));
}
hmacmd.Clear();
return sb.ToString().ToLower();
}
static async Task Main()
{
// Call asynchronous network methods in a try/catch block to handle exceptions.
try
{
string uri = "https://api.bibox.com/v3/spot/order/cancel";
string apikey = "900625568558820892a8c833c33ebc8fd2701efe";
string secret = "c708ac3e70d115ec29efbee197330627d7edf842";
string timestamp = GetTimeStamp();
var myobj = new {
order_id = "12845594488036185",
};
string payload = JsonConvert.SerializeObject(myobj, new JsonSerializerSettings { ContractResolver = new SortContractResolver() });
string source = timestamp + payload;
string sign = HmacMD5(source, secret);
Console.WriteLine(source);
Console.WriteLine(sign);
client.DefaultRequestHeaders.Add("bibox-api-key", apikey);
client.DefaultRequestHeaders.Add("bibox-api-sign", sign);
client.DefaultRequestHeaders.Add("bibox-timestamp", timestamp);
HttpContent content = new StringContent(payload, Encoding.UTF8, "application/json");
HttpResponseMessage response = await client.PostAsync(uri, content);
response.EnsureSuccessStatusCode();
string responseBody = await response.Content.ReadAsStringAsync();
Console.WriteLine(responseBody);
}
catch(HttpRequestException e)
{
Console.WriteLine("\nException Caught!");
Console.WriteLine("Message :{0} ",e.Message);
}
}
}
}
- 1.请求路径
POST https://api.bibox.com/v3/spot/order/cancel
- 2.请求参数
参数名称 | 是否必须 | 类型 | 描述 | 默认值 | 取值范围 |
---|---|---|---|---|---|
order_id | true | string | 委托单id |
Response
{
"result":"success",
"state":0
}
- 3.返回字段
名称 | 描述 |
---|---|
state | 0代表成功,否则代表失败 |
result | 注意:该结果只表示服务器接收到撤单请求,撤销结果可查询订单记录 |
其它字段 | 忽略 |
批量撤单
Request
let CryptoJS = require("crypto-js");
let request = require("request");
let url = "https://api.bibox.com/v3/spot/order/cancelBatch";
let apikey = "900625568558820892a8c833c33ebc8fd2701efe"; //your apikey
let secret = "c708ac3e70d115ec29efbee197330627d7edf842"; //your apikey secret
let param = {
order_ids:["12845594488036185","12845594488036186"]
};
let cmd = JSON.stringify(param); //format param
let timestamp = '' + (Date.now());
let sign = CryptoJS.HmacMD5(timestamp + cmd, secret).toString();//sign cmds
request.post({
url: url,//请求路径
method: "POST",//请求方式
headers: {//设置请求头
'content-type': 'application/json',
'bibox-api-key': apikey,
'bibox-api-sign': sign,
'bibox-timestamp': timestamp
},
body: cmd//post参数字符串
},
function optionalCallback(err, httpResponse, body) {
if (err) {
return console.error('upload failed:', err);
}
console.log(body)
});
# -*- coding:utf-8 -*-
import hashlib
import hmac
import json
import time
import requests
API_KEY = '900625568558820892a8c833c33ebc8fd2701efe'
SECRET_KEY = 'c708ac3e70d115ec29efbee197330627d7edf842'
BASE_URL = 'https://api.bibox.com' # 'https://api.bibox.tel' #
def do_sign(body):
timestamp = int(time.time()) * 1000
# to_sign = str(timestamp)+json.dumps(body,separators=(',',':'))
to_sign = str(timestamp) + json.dumps(body)
sign = hmac.new(SECRET_KEY.encode("utf-8"), to_sign.encode("utf-8"), hashlib.md5).hexdigest()
print(to_sign)
headers = {
'bibox-api-key': API_KEY,
'bibox-api-sign': sign,
'bibox-timestamp': str(timestamp)
}
return headers
def do_request():
path = '/v3/spot/order/cancelBatch'
body = {
'order_ids': ["12845594488036185","12845594488036186"]
}
headers = do_sign(body)
resp = requests.post(BASE_URL + path, json=body, headers=headers)
print(resp.text)
if __name__ == '__main__':
do_request()
using System;
using System.Net.Http;
using System.Text;
using System.Security.Cryptography;
using Newtonsoft.Json;
using Newtonsoft.Json.Serialization;
namespace ConsoleProgram
{
public class SortContractResolver : DefaultContractResolver
{
protected override IList<JsonProperty> CreateProperties(Type type, MemberSerialization memberSerialization)
{
IList<JsonProperty> properties = base.CreateProperties(type, memberSerialization);
return properties.OrderBy(x=>x.PropertyName).ToList();
}
}
public class Class1
{
// HttpClient is intended to be instantiated once per application, rather than per-use. See Remarks.
static readonly HttpClient client = new HttpClient();
static string GetTimeStamp()
{
TimeSpan ts = DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0, 0);
return Convert.ToInt64(ts.TotalMilliseconds).ToString();
}
static string HmacMD5(string source, string key)
{
HMACMD5 hmacmd = new HMACMD5(Encoding.Default.GetBytes(key));
byte[] inArray = hmacmd.ComputeHash(Encoding.Default.GetBytes(source));
StringBuilder sb = new StringBuilder();
for (int i = 0; i < inArray.Length; i++)
{
sb.Append(inArray[i].ToString("X2"));
}
hmacmd.Clear();
return sb.ToString().ToLower();
}
static async Task Main()
{
// Call asynchronous network methods in a try/catch block to handle exceptions.
try
{
string uri = "https://api.bibox.com/v3/spot/order/cancelBatch";
string apikey = "900625568558820892a8c833c33ebc8fd2701efe";
string secret = "c708ac3e70d115ec29efbee197330627d7edf842";
string timestamp = GetTimeStamp();
var myobj = new {
order_ids = new [] {"12845594488036185", "12845594488036186"},
};
string payload = JsonConvert.SerializeObject(myobj, new JsonSerializerSettings { ContractResolver = new SortContractResolver() });
string source = timestamp + payload;
string sign = HmacMD5(source, secret);
Console.WriteLine(source);
Console.WriteLine(sign);
client.DefaultRequestHeaders.Add("bibox-api-key", apikey);
client.DefaultRequestHeaders.Add("bibox-api-sign", sign);
client.DefaultRequestHeaders.Add("bibox-timestamp", timestamp);
HttpContent content = new StringContent(payload, Encoding.UTF8, "application/json");
HttpResponseMessage response = await client.PostAsync(uri, content);
response.EnsureSuccessStatusCode();
string responseBody = await response.Content.ReadAsStringAsync();
Console.WriteLine(responseBody);
}
catch(HttpRequestException e)
{
Console.WriteLine("\nException Caught!");
Console.WriteLine("Message :{0} ",e.Message);
}
}
}
}
- 1.请求路径
POST https://api.bibox.com/v3/spot/order/cancelBatch
- 2.请求参数
参数名称 | 是否必须 | 类型 | 描述 | 默认值 | 取值范围 |
---|---|---|---|---|---|
order_ids | true | string 数组 | 委托单id数组 |
Response
{
"result":"success",
"state":0
}
- 3.返回字段
名称 | 描述 |
---|---|
state | 0代表成功,否则代表失败 |
result | 注意:该结果只表示服务器接收到撤单请求,撤销结果可查询订单记录 |
其它字段 | 忽略 |
全部撤单
Request
let CryptoJS = require("crypto-js");
let request = require("request");
let url = "https://api.bibox.com/v3/spot/order/cancelAll";
let apikey = "900625568558820892a8c833c33ebc8fd2701efe"; //your apikey
let secret = "c708ac3e70d115ec29efbee197330627d7edf842"; //your apikey secret
let param = {
"pair": "BTC_USDT"
};
let cmd = JSON.stringify(param); //format param
let timestamp = '' + (Date.now());
let sign = CryptoJS.HmacMD5(timestamp + cmd, secret).toString();//sign cmds
request.post({
url: url,//请求路径
method: "POST",//请求方式
headers: {//设置请求头
'content-type': 'application/json',
'bibox-api-key': apikey,
'bibox-api-sign': sign,
'bibox-timestamp': timestamp
},
body: cmd//post参数字符串
},
function optionalCallback(err, httpResponse, body) {
if (err) {
return console.error('upload failed:', err);
}
console.log(body)
});
# -*- coding:utf-8 -*-
import hashlib
import hmac
import json
import time
import requests
API_KEY = '900625568558820892a8c833c33ebc8fd2701efe'
SECRET_KEY = 'c708ac3e70d115ec29efbee197330627d7edf842'
BASE_URL = 'https://api.bibox.com' # 'https://api.bibox.tel' #
def do_sign(body):
timestamp = int(time.time()) * 1000
# to_sign = str(timestamp)+json.dumps(body,separators=(',',':'))
to_sign = str(timestamp) + json.dumps(body)
sign = hmac.new(SECRET_KEY.encode("utf-8"), to_sign.encode("utf-8"), hashlib.md5).hexdigest()
print(to_sign)
headers = {
'bibox-api-key': API_KEY,
'bibox-api-sign': sign,
'bibox-timestamp': str(timestamp)
}
return headers
def do_request():
path = '/v3/spot/order/cancelAll'
body = {
"pair": "BTC_USDT"
}
headers = do_sign(body)
resp = requests.post(BASE_URL + path, json=body, headers=headers)
print(resp.text)
if __name__ == '__main__':
do_request()
using System;
using System.Net.Http;
using System.Text;
using System.Security.Cryptography;
using Newtonsoft.Json;
using Newtonsoft.Json.Serialization;
namespace ConsoleProgram
{
public class SortContractResolver : DefaultContractResolver
{
protected override IList<JsonProperty> CreateProperties(Type type, MemberSerialization memberSerialization)
{
IList<JsonProperty> properties = base.CreateProperties(type, memberSerialization);
return properties.OrderBy(x=>x.PropertyName).ToList();
}
}
public class Class1
{
// HttpClient is intended to be instantiated once per application, rather than per-use. See Remarks.
static readonly HttpClient client = new HttpClient();
static string GetTimeStamp()
{
TimeSpan ts = DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0, 0);
return Convert.ToInt64(ts.TotalMilliseconds).ToString();
}
static string HmacMD5(string source, string key)
{
HMACMD5 hmacmd = new HMACMD5(Encoding.Default.GetBytes(key));
byte[] inArray = hmacmd.ComputeHash(Encoding.Default.GetBytes(source));
StringBuilder sb = new StringBuilder();
for (int i = 0; i < inArray.Length; i++)
{
sb.Append(inArray[i].ToString("X2"));
}
hmacmd.Clear();
return sb.ToString().ToLower();
}
static async Task Main()
{
// Call asynchronous network methods in a try/catch block to handle exceptions.
try
{
string uri = "https://api.bibox.com/v3/spot/order/cancelAll";
string apikey = "900625568558820892a8c833c33ebc8fd2701efe";
string secret = "c708ac3e70d115ec29efbee197330627d7edf842";
string timestamp = GetTimeStamp();
var myobj = new {
pair = "BTC_USDT"
};
string payload = JsonConvert.SerializeObject(myobj, new JsonSerializerSettings { ContractResolver = new SortContractResolver() });
string source = timestamp + payload;
string sign = HmacMD5(source, secret);
Console.WriteLine(source);
Console.WriteLine(sign);
client.DefaultRequestHeaders.Add("bibox-api-key", apikey);
client.DefaultRequestHeaders.Add("bibox-api-sign", sign);
client.DefaultRequestHeaders.Add("bibox-timestamp", timestamp);
HttpContent content = new StringContent(payload, Encoding.UTF8, "application/json");
HttpResponseMessage response = await client.PostAsync(uri, content);
response.EnsureSuccessStatusCode();
string responseBody = await response.Content.ReadAsStringAsync();
Console.WriteLine(responseBody);
}
catch(HttpRequestException e)
{
Console.WriteLine("\nException Caught!");
Console.WriteLine("Message :{0} ",e.Message);
}
}
}
}
- 1.请求路径
POST https://api.bibox.com/v3/spot/order/cancelAll
- 2.请求参数
参数名称 | 是否必须 | 类型 | 描述 | 默认值 | 取值范围 |
---|---|---|---|---|---|
pair | true | string | 交易对 | BIX_BTC, ETH_BTC, ... |
Response
{
"result":"success",
"state":0
}
- 3.返回字段
名称 | 描述 |
---|---|
state | 0代表成功,否则代表失败 |
result | 注意:该结果只表示服务器接收到撤单请求,撤销结果可查询订单记录 |
其它字段 | 忽略 |
当前委托
Request
let CryptoJS = require("crypto-js");
let request = require("request");
let url = "https://api.bibox.com/v3.1/orderpending/orderPendingList";
let apikey = "900625568558820892a8c833c33ebc8fd2701efe"; //your apikey
let secret = "c708ac3e70d115ec29efbee197330627d7edf842"; //your apikey secret
let param = {
pair: 'BIX_USDT',
account_type: 0,
page: 1,
size: 10
};
let cmd = JSON.stringify(param); //format param
let timestamp = '' + (Date.now());
let sign = CryptoJS.HmacMD5(timestamp + cmd, secret).toString();//sign cmds
request.post({
url: url,//请求路径
method: "POST",//请求方式
headers: {//设置请求头
'content-type': 'application/json',
'bibox-api-key': apikey,
'bibox-api-sign': sign,
'bibox-timestamp': timestamp
},
body: cmd//post参数字符串
},
function optionalCallback(err, httpResponse, body) {
if (err) {
return console.error('upload failed:', err);
}
console.log(body)
});
# -*- coding:utf-8 -*-
import hashlib
import hmac
import json
import time
import requests
API_KEY = '900625568558820892a8c833c33ebc8fd2701efe'
SECRET_KEY = 'c708ac3e70d115ec29efbee197330627d7edf842'
BASE_URL = 'https://api.bibox.com' # 'https://api.bibox.tel' #
def do_sign(body):
timestamp = int(time.time()) * 1000
# to_sign = str(timestamp)+json.dumps(body,separators=(',',':'))
to_sign = str(timestamp) + json.dumps(body)
sign = hmac.new(SECRET_KEY.encode("utf-8"), to_sign.encode("utf-8"), hashlib.md5).hexdigest()
print(to_sign)
headers = {
'bibox-api-key': API_KEY,
'bibox-api-sign': sign,
'bibox-timestamp': str(timestamp)
}
return headers
def do_request():
path = '/v3.1/orderpending/orderPendingList'
body = {
'pair': 'BIX_USDT',
'account_type': 0,
'page': 1,
'size': 10
}
headers = do_sign(body)
resp = requests.post(BASE_URL + path, json=body, headers=headers)
print(resp.text)
if __name__ == '__main__':
do_request()
using System;
using System.Net.Http;
using System.Text;
using System.Security.Cryptography;
using Newtonsoft.Json;
using Newtonsoft.Json.Serialization;
namespace ConsoleProgram
{
public class SortContractResolver : DefaultContractResolver
{
protected override IList<JsonProperty> CreateProperties(Type type, MemberSerialization memberSerialization)
{
IList<JsonProperty> properties = base.CreateProperties(type, memberSerialization);
return properties.OrderBy(x=>x.PropertyName).ToList();
}
}
public class Class1
{
// HttpClient is intended to be instantiated once per application, rather than per-use. See Remarks.
static readonly HttpClient client = new HttpClient();
static string GetTimeStamp()
{
TimeSpan ts = DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0, 0);
return Convert.ToInt64(ts.TotalMilliseconds).ToString();
}
static string HmacMD5(string source, string key)
{
HMACMD5 hmacmd = new HMACMD5(Encoding.Default.GetBytes(key));
byte[] inArray = hmacmd.ComputeHash(Encoding.Default.GetBytes(source));
StringBuilder sb = new StringBuilder();
for (int i = 0; i < inArray.Length; i++)
{
sb.Append(inArray[i].ToString("X2"));
}
hmacmd.Clear();
return sb.ToString().ToLower();
}
static async Task Main()
{
// Call asynchronous network methods in a try/catch block to handle exceptions.
try
{
string uri = "https://api.bibox.com/v3.1/orderpending/orderPendingList";
string apikey = "900625568558820892a8c833c33ebc8fd2701efe";
string secret = "c708ac3e70d115ec29efbee197330627d7edf842";
string timestamp = GetTimeStamp();
var myobj = new {
pair = "BIX_USDT",
account_type = 0,
page = 1,
size = 10,
};
string payload = JsonConvert.SerializeObject(myobj, new JsonSerializerSettings { ContractResolver = new SortContractResolver() });
string source = timestamp + payload;
string sign = HmacMD5(source, secret);
Console.WriteLine(source);
Console.WriteLine(sign);
client.DefaultRequestHeaders.Add("bibox-api-key", apikey);
client.DefaultRequestHeaders.Add("bibox-api-sign", sign);
client.DefaultRequestHeaders.Add("bibox-timestamp", timestamp);
HttpContent content = new StringContent(payload, Encoding.UTF8, "application/json");
HttpResponseMessage response = await client.PostAsync(uri, content);
response.EnsureSuccessStatusCode();
string responseBody = await response.Content.ReadAsStringAsync();
Console.WriteLine(responseBody);
}
catch(HttpRequestException e)
{
Console.WriteLine("\nException Caught!");
Console.WriteLine("Message :{0} ",e.Message);
}
}
}
}
- 1.请求路径
POST https://api.bibox.com/v3.1/orderpending/orderPendingList
- 2.请求参数
参数名称 | 是否必须 | 类型 | 描述 | 默认值 | 取值范围 |
---|---|---|---|---|---|
pair | false | string | 交易对 | BIX_BTC, ETH_BTC, ... | |
account_type | true | integer | 账户类型 | 0-币币账户 | |
order_side | false | integer | 交易方向 | 1-买,2-卖 | |
coin_symbol | false | string | 交易币种 | BIX, EOS, ... | |
currency_symbol | false | string | 定价币种 | BTC, USDT, ... | |
page | true | integer | 第几页 | 从1开始 | |
size | true | integer | 每页数量 | 1-50 |
Response
{
"result":{
"count":1,
"page":1,
"items":[
{
"id":"12874181782731851",
"createdAt":1604309861000,
"account_type":0,
"pair":"BIX_USDT",
"coin_symbol":"BIX",
"currency_symbol":"USDT",
"order_side":2,
"order_type":2,
"price":"0.054330",
"deal_price":"0.000000",
"amount":"100.0000",
"money":"5.43300000",
"deal_amount":"0.0000",
"deal_percent":"0.00%",
"deal_money":"0.00000000",
"deal_count":0,
"status":1,
"unexecuted":"100.0000",
"client_oid":"0",
"order_from":1
}
]
},
"cmd":"orderPendingList",
"state":0
}
- 3.返回字段
名称 | 描述 |
---|---|
state | 0代表成功,否则代表失败 |
count | 当前页记录数,若存在下页,count=当前页记录数+1 |
page | 第几页,从1开始 |
items | 记录列表 |
id | 订单id |
client_oid | 用户自定义id |
createdAt | 创建时间 |
account_type | 账户类型 0-币币账户 |
coin_symbol | 交易币种 |
currency_symbol | 定价币种 |
order_side | 交易方向,1-买,2-卖 |
order_type | 订单类型,1-市价单,2-限价单 |
price | 委托价格 |
amount | 委托数量 |
money | 委托金额 |
deal_amount | 成交数量 |
deal_price | 成交均价 |
deal_percent | 成交百分比 |
deal_count | 成交笔数 |
unexecuted | 未成交数量 |
status | 状态,-1 失败,0或1-待成交,2-部分成交,3-完全成交,4-部分撤销,5-完全撤销 |
order_from | 订单来源 |
其它字段 | 忽略 |
历史委托
Request
let CryptoJS = require("crypto-js");
let request = require("request");
let url = "https://api.bibox.com/v3.1/orderpending/pendingHistoryList";
let apikey = "900625568558820892a8c833c33ebc8fd2701efe"; //your apikey
let secret = "c708ac3e70d115ec29efbee197330627d7edf842"; //your apikey secret
let param = {
pair: 'BIX_USDT',
account_type: 0,
page: 1,
size: 10
};
let cmd = JSON.stringify(param); //format param
let timestamp = '' + (Date.now());
let sign = CryptoJS.HmacMD5(timestamp + cmd, secret).toString();//sign cmds
request.post({
url: url,//请求路径
method: "POST",//请求方式
headers: {//设置请求头
'content-type': 'application/json',
'bibox-api-key': apikey,
'bibox-api-sign': sign,
'bibox-timestamp': timestamp
},
body: cmd//post参数字符串
},
function optionalCallback(err, httpResponse, body) {
if (err) {
return console.error('upload failed:', err);
}
console.log(body)
});
# -*- coding:utf-8 -*-
import hashlib
import hmac
import json
import time
import requests
API_KEY = '900625568558820892a8c833c33ebc8fd2701efe'
SECRET_KEY = 'c708ac3e70d115ec29efbee197330627d7edf842'
BASE_URL = 'https://api.bibox.com' # 'https://api.bibox.tel' #
def do_sign(body):
timestamp = int(time.time()) * 1000
# to_sign = str(timestamp)+json.dumps(body,separators=(',',':'))
to_sign = str(timestamp) + json.dumps(body)
sign = hmac.new(SECRET_KEY.encode("utf-8"), to_sign.encode("utf-8"), hashlib.md5).hexdigest()
print(to_sign)
headers = {
'bibox-api-key': API_KEY,
'bibox-api-sign': sign,
'bibox-timestamp': str(timestamp)
}
return headers
def do_request():
path = '/v3.1/orderpending/pendingHistoryList'
body = {
'pair': 'BIX_USDT',
'account_type': 0,
'page': 1,
'size': 10
}
headers = do_sign(body)
resp = requests.post(BASE_URL + path, json=body, headers=headers)
print(resp.text)
if __name__ == '__main__':
do_request()
using System;
using System.Net.Http;
using System.Text;
using System.Security.Cryptography;
using Newtonsoft.Json;
using Newtonsoft.Json.Serialization;
namespace ConsoleProgram
{
public class SortContractResolver : DefaultContractResolver
{
protected override IList<JsonProperty> CreateProperties(Type type, MemberSerialization memberSerialization)
{
IList<JsonProperty> properties = base.CreateProperties(type, memberSerialization);
return properties.OrderBy(x=>x.PropertyName).ToList();
}
}
public class Class1
{
// HttpClient is intended to be instantiated once per application, rather than per-use. See Remarks.
static readonly HttpClient client = new HttpClient();
static string GetTimeStamp()
{
TimeSpan ts = DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0, 0);
return Convert.ToInt64(ts.TotalMilliseconds).ToString();
}
static string HmacMD5(string source, string key)
{
HMACMD5 hmacmd = new HMACMD5(Encoding.Default.GetBytes(key));
byte[] inArray = hmacmd.ComputeHash(Encoding.Default.GetBytes(source));
StringBuilder sb = new StringBuilder();
for (int i = 0; i < inArray.Length; i++)
{
sb.Append(inArray[i].ToString("X2"));
}
hmacmd.Clear();
return sb.ToString().ToLower();
}
static async Task Main()
{
// Call asynchronous network methods in a try/catch block to handle exceptions.
try
{
string uri = "https://api.bibox.com/v3.1/orderpending/pendingHistoryList";
string apikey = "900625568558820892a8c833c33ebc8fd2701efe";
string secret = "c708ac3e70d115ec29efbee197330627d7edf842";
string timestamp = GetTimeStamp();
var myobj = new {
pair = "BIX_USDT",
account_type = 0,
page = 1,
size = 10,
};
string payload = JsonConvert.SerializeObject(myobj, new JsonSerializerSettings { ContractResolver = new SortContractResolver() });
string source = timestamp + payload;
string sign = HmacMD5(source, secret);
Console.WriteLine(source);
Console.WriteLine(sign);
client.DefaultRequestHeaders.Add("bibox-api-key", apikey);
client.DefaultRequestHeaders.Add("bibox-api-sign", sign);
client.DefaultRequestHeaders.Add("bibox-timestamp", timestamp);
HttpContent content = new StringContent(payload, Encoding.UTF8, "application/json");
HttpResponseMessage response = await client.PostAsync(uri, content);
response.EnsureSuccessStatusCode();
string responseBody = await response.Content.ReadAsStringAsync();
Console.WriteLine(responseBody);
}
catch(HttpRequestException e)
{
Console.WriteLine("\nException Caught!");
Console.WriteLine("Message :{0} ",e.Message);
}
}
}
}
- 1.请求路径
POST https://api.bibox.com/v3.1/orderpending/pendingHistoryList
- 2.请求参数
参数名称 | 是否必须 | 类型 | 描述 | 默认值 | 取值范围 |
---|---|---|---|---|---|
pair | false | string | 交易对 | BIX_BTC, ETH_BTC, ... | |
account_type | true | integer | 账户类型 | 0-币币账户 | |
order_side | false | integer | 交易方向 | 1-买,2-卖 | |
coin_symbol | false | string | 交易币种 | BIX, EOS, ... | |
currency_symbol | false | string | 定价币种 | BTC, USDT, ... | |
hide_cancel | false | integer | 隐藏已撤销订单 | 0-不隐藏,1-隐藏 | |
page | true | integer | 第几页 | 从1开始 | |
size | true | integer | 每页数量 | 1-50 |
Response
{
"result":{
"count":11,
"page":1,
"items":[
{
"id":"12845594488036185",
"createdAt":1604305967000,
"account_type":0,
"coin_symbol":"BIX",
"currency_symbol":"USDT",
"order_side":2,
"order_type":2,
"price":"0.054580",
"amount":"100.0000",
"money":"5.45800000",
"deal_price":"0.000000",
"deal_amount":"0.0000",
"deal_money":"0.00000000",
"status":5
}
]
},
"cmd":"pendingHistoryList",
"state":0
}
- 3.返回字段
名称 | 描述 |
---|---|
state | 0代表成功,否则代表失败 |
count | 当前页记录数,若存在下页,count=当前页记录数+1 |
page | 第几页,从1开始 |
items | 记录列表 |
id | 订单id |
createdAt | 创建时间 |
account_type | 账户类型 0-币币账户 |
coin_symbol | 交易币种 |
currency_symbol | 定价币种 |
order_side | 交易方向,1-买,2-卖 |
order_type | 订单类型,1-市价单,2-限价单 |
price | 委托价格 |
amount | 委托数量 |
money | 委托金额 |
deal_price | 成交均价 |
deal_amount | 成交数量 |
deal_money | 成交金额 |
status | 状态,-1 失败,0或1-待成交,2-部分成交,3-完全成交,4-部分撤销,5-完全撤销 |
其它字段 | 忽略 |
成交记录
Request
let CryptoJS = require("crypto-js");
let request = require("request");
let url = "https://api.bibox.com/v3.1/orderpending/orderDetail";
let apikey = "900625568558820892a8c833c33ebc8fd2701efe"; //your apikey
let secret = "c708ac3e70d115ec29efbee197330627d7edf842"; //your apikey secret
let param = {
id: "12826902662624234",
account_type: 0
};
let cmd = JSON.stringify(param); //format param
let timestamp = '' + (Date.now());
let sign = CryptoJS.HmacMD5(timestamp + cmd, secret).toString();//sign cmds
request.post({
url: url,//请求路径
method: "POST",//请求方式
headers: {//设置请求头
'content-type': 'application/json',
'bibox-api-key': apikey,
'bibox-api-sign': sign,
'bibox-timestamp': timestamp
},
body: cmd//post参数字符串
},
function optionalCallback(err, httpResponse, body) {
if (err) {
return console.error('upload failed:', err);
}
console.log(body)
});
# -*- coding:utf-8 -*-
import hashlib
import hmac
import json
import time
import requests
API_KEY = '900625568558820892a8c833c33ebc8fd2701efe'
SECRET_KEY = 'c708ac3e70d115ec29efbee197330627d7edf842'
BASE_URL = 'https://api.bibox.com' # 'https://api.bibox.tel' #
def do_sign(body):
timestamp = int(time.time()) * 1000
# to_sign = str(timestamp)+json.dumps(body,separators=(',',':'))
to_sign = str(timestamp) + json.dumps(body)
sign = hmac.new(SECRET_KEY.encode("utf-8"), to_sign.encode("utf-8"), hashlib.md5).hexdigest()
print(to_sign)
headers = {
'bibox-api-key': API_KEY,
'bibox-api-sign': sign,
'bibox-timestamp': str(timestamp)
}
return headers
def do_request():
path = '/v3.1/orderpending/orderDetail'
body = {
'id': '12826902662624234',
'account_type': 0,
}
headers = do_sign(body)
resp = requests.post(BASE_URL + path, json=body, headers=headers)
print(resp.text)
if __name__ == '__main__':
do_request()
using System;
using System.Net.Http;
using System.Text;
using System.Security.Cryptography;
using Newtonsoft.Json;
using Newtonsoft.Json.Serialization;
namespace ConsoleProgram
{
public class SortContractResolver : DefaultContractResolver
{
protected override IList<JsonProperty> CreateProperties(Type type, MemberSerialization memberSerialization)
{
IList<JsonProperty> properties = base.CreateProperties(type, memberSerialization);
return properties.OrderBy(x=>x.PropertyName).ToList();
}
}
public class Class1
{
// HttpClient is intended to be instantiated once per application, rather than per-use. See Remarks.
static readonly HttpClient client = new HttpClient();
static string GetTimeStamp()
{
TimeSpan ts = DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0, 0);
return Convert.ToInt64(ts.TotalMilliseconds).ToString();
}
static string HmacMD5(string source, string key)
{
HMACMD5 hmacmd = new HMACMD5(Encoding.Default.GetBytes(key));
byte[] inArray = hmacmd.ComputeHash(Encoding.Default.GetBytes(source));
StringBuilder sb = new StringBuilder();
for (int i = 0; i < inArray.Length; i++)
{
sb.Append(inArray[i].ToString("X2"));
}
hmacmd.Clear();
return sb.ToString().ToLower();
}
static async Task Main()
{
// Call asynchronous network methods in a try/catch block to handle exceptions.
try
{
string uri = "https://api.bibox.com/v3.1/orderpending/orderDetail";
string apikey = "900625568558820892a8c833c33ebc8fd2701efe";
string secret = "c708ac3e70d115ec29efbee197330627d7edf842";
string timestamp = GetTimeStamp();
var myobj = new {
id = "12826902662624234",
account_type = 0,
};
string payload = JsonConvert.SerializeObject(myobj, new JsonSerializerSettings { ContractResolver = new SortContractResolver() });
string source = timestamp + payload;
string sign = HmacMD5(source, secret);
Console.WriteLine(source);
Console.WriteLine(sign);
client.DefaultRequestHeaders.Add("bibox-api-key", apikey);
client.DefaultRequestHeaders.Add("bibox-api-sign", sign);
client.DefaultRequestHeaders.Add("bibox-timestamp", timestamp);
HttpContent content = new StringContent(payload, Encoding.UTF8, "application/json");
HttpResponseMessage response = await client.PostAsync(uri, content);
response.EnsureSuccessStatusCode();
string responseBody = await response.Content.ReadAsStringAsync();
Console.WriteLine(responseBody);
}
catch(HttpRequestException e)
{
Console.WriteLine("\nException Caught!");
Console.WriteLine("Message :{0} ",e.Message);
}
}
}
}
- 1.请求路径
POST https://api.bibox.com/v3.1/orderpending/orderDetail
- 2.请求参数
参数名称 | 是否必须 | 类型 | 描述 | 默认值 | 取值范围 |
---|---|---|---|---|---|
id | true | string | 委托单id | ||
account_type | true | integer | 账户类型 | 0-币币账户 |
Response
{
"result":{
"sum":"3.57490350",
"orderList":[
{
"id":"2251799823470863898",
"createdAt":1599730918000,
"account_type":0,
"coin_symbol":"BIX",
"currency_symbol":"USDT",
"order_side":1,
"order_type":2,
"price":"0.071300",
"amount":"0.4825",
"money":"0.03440225",
"pay_bix":0,
"fee_symbol":"BIX",
"fee":"0.00000000",
"is_maker":0,
"relay_id":"12826902662624234"
},
{
"id":"2251799823470863900",
"createdAt":1599730918000,
"account_type":0,
"coin_symbol":"BIX",
"currency_symbol":"USDT",
"order_side":1,
"order_type":2,
"price":"0.071500",
"amount":"39.8408",
"money":"2.84861720",
"pay_bix":0,
"fee_symbol":"BIX",
"fee":"0.00000000",
"is_maker":0,
"relay_id":"12826902662624234"
},
{
"id":"2251799823470863902",
"createdAt":1599730918000,
"account_type":0,
"coin_symbol":"BIX",
"currency_symbol":"USDT",
"order_side":1,
"order_type":2,
"price":"0.071500",
"amount":"9.6767",
"money":"0.69188405",
"pay_bix":0,
"fee_symbol":"BIX",
"fee":"0.00000000",
"is_maker":0,
"relay_id":"12826902662624234"
}
]
},
"cmd":"orderDetail",
"state":0
}
- 3.返回字段
名称 | 描述 |
---|---|
state | 0代表成功,否则代表失败 |
sum | 成交总额 |
orderList | 成交记录列表 |
id | 成交记录id |
createdAt | 成交时间 |
account_type | 账户类型 0-币币账户 |
coin_symbol | 交易币种 |
currency_symbol | 定价币种 |
order_side | 交易方向,1-买,2-卖 |
order_type | 订单类型,1-市价单,2-限价单 |
price | 成交价格 |
amount | 成交数量 |
money | 成交金额 |
pay_bix | bix抵扣,0-未开启 1-开启 |
fee_symbol | 手续费币种 |
fee | 手续费 |
is_maker | 是否maker,0-否,1-是 |
relay_id | 关联订单id |
其它字段 | 忽略 |
委托单详情
Request
let CryptoJS = require("crypto-js");
let request = require("request");
let url = "https://api.bibox.com/v3.1/orderpending/order";
let apikey = "900625568558820892a8c833c33ebc8fd2701efe"; //your apikey
let secret = "c708ac3e70d115ec29efbee197330627d7edf842"; //your apikey secret
let param = {
id: "12845594488036185",
account_type: 0
};
let cmd = JSON.stringify(param); //format param
let timestamp = '' + (Date.now());
let sign = CryptoJS.HmacMD5(timestamp + cmd, secret).toString();//sign cmds
request.post({
url: url,//请求路径
method: "POST",//请求方式
headers: {//设置请求头
'content-type': 'application/json',
'bibox-api-key': apikey,
'bibox-api-sign': sign,
'bibox-timestamp': timestamp
},
body: cmd//post参数字符串
},
function optionalCallback(err, httpResponse, body) {
if (err) {
return console.error('upload failed:', err);
}
console.log(body)
});
# -*- coding:utf-8 -*-
import hashlib
import hmac
import json
import time
import requests
API_KEY = '900625568558820892a8c833c33ebc8fd2701efe'
SECRET_KEY = 'c708ac3e70d115ec29efbee197330627d7edf842'
BASE_URL = 'https://api.bibox.com' # 'https://api.bibox.tel' #
def do_sign(body):
timestamp = int(time.time()) * 1000
# to_sign = str(timestamp)+json.dumps(body,separators=(',',':'))
to_sign = str(timestamp) + json.dumps(body)
sign = hmac.new(SECRET_KEY.encode("utf-8"), to_sign.encode("utf-8"), hashlib.md5).hexdigest()
print(to_sign)
headers = {
'bibox-api-key': API_KEY,
'bibox-api-sign': sign,
'bibox-timestamp': str(timestamp)
}
return headers
def do_request():
path = '/v3.1/orderpending/order'
body = {
'id': '12845594488036185',
'account_type': 0,
}
headers = do_sign(body)
resp = requests.post(BASE_URL + path, json=body, headers=headers)
print(resp.text)
if __name__ == '__main__':
do_request()
using System;
using System.Net.Http;
using System.Text;
using System.Security.Cryptography;
using Newtonsoft.Json;
using Newtonsoft.Json.Serialization;
namespace ConsoleProgram
{
public class SortContractResolver : DefaultContractResolver
{
protected override IList<JsonProperty> CreateProperties(Type type, MemberSerialization memberSerialization)
{
IList<JsonProperty> properties = base.CreateProperties(type, memberSerialization);
return properties.OrderBy(x=>x.PropertyName).ToList();
}
}
public class Class1
{
// HttpClient is intended to be instantiated once per application, rather than per-use. See Remarks.
static readonly HttpClient client = new HttpClient();
static string GetTimeStamp()
{
TimeSpan ts = DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0, 0);
return Convert.ToInt64(ts.TotalMilliseconds).ToString();
}
static string HmacMD5(string source, string key)
{
HMACMD5 hmacmd = new HMACMD5(Encoding.Default.GetBytes(key));
byte[] inArray = hmacmd.ComputeHash(Encoding.Default.GetBytes(source));
StringBuilder sb = new StringBuilder();
for (int i = 0; i < inArray.Length; i++)
{
sb.Append(inArray[i].ToString("X2"));
}
hmacmd.Clear();
return sb.ToString().ToLower();
}
static async Task Main()
{
// Call asynchronous network methods in a try/catch block to handle exceptions.
try
{
string uri = "https://api.bibox.com/v3.1/orderpending/order";
string apikey = "900625568558820892a8c833c33ebc8fd2701efe";
string secret = "c708ac3e70d115ec29efbee197330627d7edf842";
string timestamp = GetTimeStamp();
var myobj = new {
id = "12845594488036185",
account_type = 0,
};
string payload = JsonConvert.SerializeObject(myobj, new JsonSerializerSettings { ContractResolver = new SortContractResolver() });
string source = timestamp + payload;
string sign = HmacMD5(source, secret);
Console.WriteLine(source);
Console.WriteLine(sign);
client.DefaultRequestHeaders.Add("bibox-api-key", apikey);
client.DefaultRequestHeaders.Add("bibox-api-sign", sign);
client.DefaultRequestHeaders.Add("bibox-timestamp", timestamp);
HttpContent content = new StringContent(payload, Encoding.UTF8, "application/json");
HttpResponseMessage response = await client.PostAsync(uri, content);
response.EnsureSuccessStatusCode();
string responseBody = await response.Content.ReadAsStringAsync();
Console.WriteLine(responseBody);
}
catch(HttpRequestException e)
{
Console.WriteLine("\nException Caught!");
Console.WriteLine("Message :{0} ",e.Message);
}
}
}
}
- 1.请求路径
POST https://api.bibox.com/v3.1/orderpending/order
- 2.请求参数
参数名称 | 是否必须 | 类型 | 描述 | 默认值 | 取值范围 |
---|---|---|---|---|---|
id | true | string | 委托单id | ||
account_type | true | integer | 账户类型 | 0-币币账户 |
Response
{
"result":{
"id":"12845594488036185",
"createdAt":1604305967000,
"account_type":0,
"pair":"BIX_USDT",
"coin_symbol":"BIX",
"currency_symbol":"USDT",
"order_side":2,
"order_type":2,
"price":"0.054580",
"deal_price":"0.000000",
"amount":"100.0000",
"money":"5.45800000",
"deal_amount":"0.0000",
"deal_percent":"0.00%",
"deal_money":"0.00000000",
"deal_count":0,
"status":5,
"unexecuted":"100.0000"
},
"cmd":"order",
"state":0
}
- 3.返回字段
名称 | 描述 |
---|---|
state | 0代表成功,否则代表失败 |
id | 订单id |
createdAt | 创建时间 |
account_type | 账户类型 0-币币账户 |
pair | 交易对 |
coin_symbol | 交易币种 |
currency_symbol | 定价币种 |
order_side | 交易方向,1-买,2-卖 |
order_type | 订单类型,1-市价单,2-限价单 |
price | 委托价格 |
amount | 委托数量 |
money | 委托金额 |
deal_amount | 已成交数量 |
deal_percent | 成交百分比 |
unexecuted | 未成交数量 |
status | 状态,-1 失败,0或1-待成交,2-部分成交,3-完全成交,4-部分撤销,5-完全撤销 |
其它字段 | 忽略 |
成交明细
Request
let CryptoJS = require("crypto-js");
let request = require("request");
let url = "https://api.bibox.com/v3.1/orderpending/orderHistoryList";
let apikey = "900625568558820892a8c833c33ebc8fd2701efe"; //your apikey
let secret = "c708ac3e70d115ec29efbee197330627d7edf842"; //your apikey secret
let param = {
pair: 'BIX_USDT',
account_type: 0,
page: 1,
size: 10
};
let cmd = JSON.stringify(param); //format param
let timestamp = '' + (Date.now());
let sign = CryptoJS.HmacMD5(timestamp + cmd, secret).toString();//sign cmds
request.post({
url: url,//请求路径
method: "POST",//请求方式
headers: {//设置请求头
'content-type': 'application/json',
'bibox-api-key': apikey,
'bibox-api-sign': sign,
'bibox-timestamp': timestamp
},
body: cmd//post参数字符串
},
function optionalCallback(err, httpResponse, body) {
if (err) {
return console.error('upload failed:', err);
}
console.log(body)
});
# -*- coding:utf-8 -*-
import hashlib
import hmac
import json
import time
import requests
API_KEY = '900625568558820892a8c833c33ebc8fd2701efe'
SECRET_KEY = 'c708ac3e70d115ec29efbee197330627d7edf842'
BASE_URL = 'https://api.bibox.com' # 'https://api.bibox.tel' #
def do_sign(body):
timestamp = int(time.time()) * 1000
# to_sign = str(timestamp)+json.dumps(body,separators=(',',':'))
to_sign = str(timestamp) + json.dumps(body)
sign = hmac.new(SECRET_KEY.encode("utf-8"), to_sign.encode("utf-8"), hashlib.md5).hexdigest()
print(to_sign)
headers = {
'bibox-api-key': API_KEY,
'bibox-api-sign': sign,
'bibox-timestamp': str(timestamp)
}
return headers
def do_request():
path = '/v3.1/orderpending/orderHistoryList'
body = {
'pair': 'BIX_USDT',
'account_type': 0,
'page': 1,
'size': 10
}
headers = do_sign(body)
resp = requests.post(BASE_URL + path, json=body, headers=headers)
print(resp.text)
if __name__ == '__main__':
do_request()
using System;
using System.Net.Http;
using System.Text;
using System.Security.Cryptography;
using Newtonsoft.Json;
using Newtonsoft.Json.Serialization;
namespace ConsoleProgram
{
public class SortContractResolver : DefaultContractResolver
{
protected override IList<JsonProperty> CreateProperties(Type type, MemberSerialization memberSerialization)
{
IList<JsonProperty> properties = base.CreateProperties(type, memberSerialization);
return properties.OrderBy(x=>x.PropertyName).ToList();
}
}
public class Class1
{
// HttpClient is intended to be instantiated once per application, rather than per-use. See Remarks.
static readonly HttpClient client = new HttpClient();
static string GetTimeStamp()
{
TimeSpan ts = DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0, 0);
return Convert.ToInt64(ts.TotalMilliseconds).ToString();
}
static string HmacMD5(string source, string key)
{
HMACMD5 hmacmd = new HMACMD5(Encoding.Default.GetBytes(key));
byte[] inArray = hmacmd.ComputeHash(Encoding.Default.GetBytes(source));
StringBuilder sb = new StringBuilder();
for (int i = 0; i < inArray.Length; i++)
{
sb.Append(inArray[i].ToString("X2"));
}
hmacmd.Clear();
return sb.ToString().ToLower();
}
static async Task Main()
{
// Call asynchronous network methods in a try/catch block to handle exceptions.
try
{
string uri = "https://api.bibox.com/v3.1/orderpending/orderHistoryList";
string apikey = "900625568558820892a8c833c33ebc8fd2701efe";
string secret = "c708ac3e70d115ec29efbee197330627d7edf842";
string timestamp = GetTimeStamp();
var myobj = new {
pair = "BIX_USDT",
account_type = 0,
page = 1,
size = 10,
};
string payload = JsonConvert.SerializeObject(myobj, new JsonSerializerSettings { ContractResolver = new SortContractResolver() });
string source = timestamp + payload;
string sign = HmacMD5(source, secret);
Console.WriteLine(source);
Console.WriteLine(sign);
client.DefaultRequestHeaders.Add("bibox-api-key", apikey);
client.DefaultRequestHeaders.Add("bibox-api-sign", sign);
client.DefaultRequestHeaders.Add("bibox-timestamp", timestamp);
HttpContent content = new StringContent(payload, Encoding.UTF8, "application/json");
HttpResponseMessage response = await client.PostAsync(uri, content);
response.EnsureSuccessStatusCode();
string responseBody = await response.Content.ReadAsStringAsync();
Console.WriteLine(responseBody);
}
catch(HttpRequestException e)
{
Console.WriteLine("\nException Caught!");
Console.WriteLine("Message :{0} ",e.Message);
}
}
}
}
- 1.请求路径
POST https://api.bibox.com/v3.1/orderpending/orderHistoryList
- 2.请求参数
参数名称 | 是否必须 | 类型 | 描述 | 默认值 | 取值范围 |
---|---|---|---|---|---|
pair | false | string | 交易对 | BIX_BTC, ETH_BTC, ... | |
account_type | true | integer | 账户类型 | 0-币币账户 | |
order_side | false | integer | 交易方向 | 1-买,2-卖 | |
coin_symbol | false | string | 交易币种 | BIX, EOS, ... | |
currency_symbol | false | string | 定价币种 | BTC, USDT, ... | |
page | true | integer | 第几页 | 从1开始 | |
size | true | integer | 每页数量 | 1-50 |
Response
{
"result":{
"count":1,
"page":1,
"items":[
{
"id":"2251799823470863902",
"createdAt":1599730918000,
"account_type":0,
"coin_symbol":"BIX",
"currency_symbol":"USDT",
"order_side":1,
"order_type":2,
"price":"0.071500",
"amount":"9.6767",
"money":"0.69188405",
"pay_bix":0,
"fee_symbol":"BIX",
"fee":"0.00000000",
"is_maker":0,
"relay_id":"12826902662624234"
}
]
},
"cmd":"orderHistoryList",
"state":0
}
- 3.返回字段
名称 | 描述 |
---|---|
state | 0代表成功,否则代表失败 |
count | 当前页记录数,若存在下页,count=当前页记录数+1 |
page | 第几页 |
items | 记录列表 |
id | 订单id |
createdAt | 成交时间 |
account_type | 账户类型 0-币币账户 |
coin_symbol | 交易币种 |
currency_symbol | 定价币种 |
order_side | 交易方向,1-买,2-卖 |
order_type | 订单类型,1-市价单,2-限价单 |
price | 成交价格 |
amount | 成交数量 |
money | 成交金额 |
fee | 手续费 |
pay_bix | bix抵扣,0-未开启 1-开启 |
fee_symbol | 手续费币种 |
is_maker | 是否maker |
relay_id | 关联订单id |
其它字段 | 忽略 |
最新成交明细
查询指定id号之后的成交记录,分页返回1000条
Request
let CryptoJS = require("crypto-js");
let request = require("request");
let url = "https://api.bibox.com/v3.1/orderpending/orderDetailsLast";
let apikey = "900625568558820892a8c833c33ebc8fd2701efe"; //your apikey
let secret = "c708ac3e70d115ec29efbee197330627d7edf842"; //your apikey secret
let param = {
pair: 'BIX_USDT',
account_type: 0,
page: 1,
id:"2251799823470863900"
};
let cmd = JSON.stringify(param); //format param
let timestamp = '' + (Date.now());
let sign = CryptoJS.HmacMD5(timestamp + cmd, secret).toString();//sign cmds
request.post({
url: url,//请求路径
method: "POST",//请求方式
headers: {//设置请求头
'content-type': 'application/json',
'bibox-api-key': apikey,
'bibox-api-sign': sign,
'bibox-timestamp': timestamp
},
body: cmd//post参数字符串
},
function optionalCallback(err, httpResponse, body) {
if (err) {
return console.error('upload failed:', err);
}
console.log(body)
});
# -*- coding:utf-8 -*-
import hashlib
import hmac
import json
import time
import requests
API_KEY = '900625568558820892a8c833c33ebc8fd2701efe'
SECRET_KEY = 'c708ac3e70d115ec29efbee197330627d7edf842'
BASE_URL = 'https://api.bibox.com' # 'https://api.bibox.tel' #
def do_sign(body):
timestamp = int(time.time()) * 1000
# to_sign = str(timestamp)+json.dumps(body,separators=(',',':'))
to_sign = str(timestamp) + json.dumps(body)
sign = hmac.new(SECRET_KEY.encode("utf-8"), to_sign.encode("utf-8"), hashlib.md5).hexdigest()
print(to_sign)
headers = {
'bibox-api-key': API_KEY,
'bibox-api-sign': sign,
'bibox-timestamp': str(timestamp)
}
return headers
def do_request():
path = '/v3.1/orderpending/orderDetailsLast'
body = {
'pair': 'BIX_USDT',
'account_type': 0,
'page': 1,
'id': "2251799823470863900"
}
headers = do_sign(body)
resp = requests.post(BASE_URL + path, json=body, headers=headers)
print(resp.text)
if __name__ == '__main__':
do_request()
using System;
using System.Net.Http;
using System.Text;
using System.Security.Cryptography;
using Newtonsoft.Json;
using Newtonsoft.Json.Serialization;
namespace ConsoleProgram
{
public class SortContractResolver : DefaultContractResolver
{
protected override IList<JsonProperty> CreateProperties(Type type, MemberSerialization memberSerialization)
{
IList<JsonProperty> properties = base.CreateProperties(type, memberSerialization);
return properties.OrderBy(x=>x.PropertyName).ToList();
}
}
public class Class1
{
// HttpClient is intended to be instantiated once per application, rather than per-use. See Remarks.
static readonly HttpClient client = new HttpClient();
static string GetTimeStamp()
{
TimeSpan ts = DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0, 0);
return Convert.ToInt64(ts.TotalMilliseconds).ToString();
}
static string HmacMD5(string source, string key)
{
HMACMD5 hmacmd = new HMACMD5(Encoding.Default.GetBytes(key));
byte[] inArray = hmacmd.ComputeHash(Encoding.Default.GetBytes(source));
StringBuilder sb = new StringBuilder();
for (int i = 0; i < inArray.Length; i++)
{
sb.Append(inArray[i].ToString("X2"));
}
hmacmd.Clear();
return sb.ToString().ToLower();
}
static async Task Main()
{
// Call asynchronous network methods in a try/catch block to handle exceptions.
try
{
string uri = "https://api.bibox.com/v3.1/orderpending/orderDetailsLast";
string apikey = "900625568558820892a8c833c33ebc8fd2701efe";
string secret = "c708ac3e70d115ec29efbee197330627d7edf842";
string timestamp = GetTimeStamp();
var myobj = new {
pair = "BIX_USDT",
account_type = 0,
page = 1,
id = "2251799823470863900",
};
string payload = JsonConvert.SerializeObject(myobj, new JsonSerializerSettings { ContractResolver = new SortContractResolver() });
string source = timestamp + payload;
string sign = HmacMD5(source, secret);
Console.WriteLine(source);
Console.WriteLine(sign);
client.DefaultRequestHeaders.Add("bibox-api-key", apikey);
client.DefaultRequestHeaders.Add("bibox-api-sign", sign);
client.DefaultRequestHeaders.Add("bibox-timestamp", timestamp);
HttpContent content = new StringContent(payload, Encoding.UTF8, "application/json");
HttpResponseMessage response = await client.PostAsync(uri, content);
response.EnsureSuccessStatusCode();
string responseBody = await response.Content.ReadAsStringAsync();
Console.WriteLine(responseBody);
}
catch(HttpRequestException e)
{
Console.WriteLine("\nException Caught!");
Console.WriteLine("Message :{0} ",e.Message);
}
}
}
}
- 1.请求路径
POST https://api.bibox.com/v3.1/orderpending/orderDetailsLast
- 2.请求参数
参数名称 | 是否必须 | 类型 | 描述 | 默认值 | 取值范围 |
---|---|---|---|---|---|
pair | false | string | 交易对 | BIX_BTC, ETH_BTC, ... | |
account_type | true | integer | 账户类型 | 0-币币账户 | |
id | true | string | 成交记录开始的id号 | 大于"1000000000" | |
page | true | integer | 第几页 | 从1开始 |
Response
{
"result":{
"count":2,
"page":1,
"items":[
{
"id":"2251799823470863902",
"createdAt":1599730918000,
"account_type":0,
"coin_symbol":"BIX",
"currency_symbol":"USDT",
"order_side":1,
"order_type":2,
"price":"0.071500",
"amount":"9.6767",
"money":"0.69188405",
"pay_bix":0,
"fee_symbol":"BIX",
"fee":"0.00000000",
"is_maker":0,
"relay_id":"12826902662624234"
},
{
"id":"2251799825448005865",
"createdAt":1604312287000,
"account_type":0,
"coin_symbol":"BIX",
"currency_symbol":"USDT",
"order_side":2,
"order_type":2,
"price":"0.054330",
"amount":"100.0000",
"money":"5.43300000",
"pay_bix":0,
"fee_symbol":"USDT",
"fee":"0.00000000",
"is_maker":1,
"relay_id":"12874181782731851"
}
]
},
"cmd":"orderDetailsLast",
"state":0
}
- 3.返回字段
名称 | 描述 |
---|---|
state | 0代表成功,否则代表失败 |
count | 当前页记录数,若存在下页,count=当前页记录数+1 |
page | 第几页 |
items | 记录列表 |
id | 订单id |
createdAt | 成交时间 |
account_type | 账户类型 0-币币账户 |
coin_symbol | 交易币种 |
currency_symbol | 定价币种 |
order_side | 交易方向,1-买,2-卖 |
order_type | 订单类型,1-市价单,2-限价单 |
price | 成交价格 |
amount | 成交数量 |
money | 成交金额 |
pay_bix | bix抵扣,0-未开启 1-开启 |
fee_symbol | 手续费币种 |
fee | 手续费 |
is_maker | 是否maker,0-否,1-是 |
relay_id | 关联订单id |
其它字段 | 忽略 |
查询现货账单
- 1.请求路径
POST https://api.bibox.com/v3.1/spot/account/bills
- 2.请求参数
参数名称 | 是否必须 | 类型 | 描述 | 默认值 | 取值范围 |
---|---|---|---|---|---|
page | true | integer | 第几页 | 1,2,... | |
size | true | integer | 多少条 | 1,2,... | |
begin_time | false | integer | 开始时间 | ||
end_time | false | integer | 结束时间 | ||
type | false | integer | 账单类型 | 130钱包转现货, 131现货转钱包 3卖 5买 |
Response
{
"result":{
"count":11,
"page":1,
"items":[
{
"id":"1125899906850284004",
"coin_symbol":"USDT",
"bill_type":12,
"comment":"",
"change_amount":"6.9553",
"change_result":"182461.2621",
"createdAt":"2020-11-23T00:00:00.000Z",
"updatedAt":"2020-11-23T00:00:00.000Z"
}
]
}
}
- 3.返回字段
名称 | 描述 |
---|---|
id | 账单id |
coin_symbol | 币种符号 |
bill_type | 账单类型 |
comment | 账单描述 |
change_amount | 资产改变量 |
change_result | 资产改变结果 |
createdAt | 账单时间 |
其它字段 | 忽略 |
资金划转(需要ApiKey)
钱包划转到币币
Request
let CryptoJS = require("crypto-js");
let request = require("request");
let timestamp = Date.now(); // 1.当前时间戳
let param = {
"type": 0,
"amount": "100",
"symbol": 'USDT'
};
let strParam = JSON.stringify(param); // 2.格式化参数
let strToSign = '' + timestamp + strParam; // 3.这就是需要签名的字符串
let apikey = "900625568558820892a8c833c33ebc8fd2701efe"; //your apikey
let secret = "c708ac3e70d115ec29efbee197330627d7edf842"; //你的 apikey 密码
let sign = CryptoJS.HmacMD5(strToSign, secret).toString();//4.签名后的结果
let url = "https://api.bibox.com/v3/assets/transfer/spot";
request.post({
url: url,//请求路径
method: "POST",//请求方式
headers: {//5.设置请求头
'content-type': 'application/json',
'bibox-api-key': apikey,
'bibox-api-sign': sign,
'bibox-timestamp': timestamp
},
body: strParam // 6.格式化参数
},
function optionalCallback(err, httpResponse, body) {
if (err) {
return console.error('upload failed:', err);
}
console.log(body) // 7.返回值
});
# -*- coding:utf-8 -*-
import hashlib
import hmac
import json
import time
import requests
API_KEY = '900625568558820892a8c833c33ebc8fd2701efe'
SECRET_KEY = 'c708ac3e70d115ec29efbee197330627d7edf842'
BASE_URL = 'https://api.bibox.com' # 'https://api.bibox.tel' #
def do_sign(body):
timestamp = int(time.time()) * 1000
# to_sign = str(timestamp)+json.dumps(body,separators=(',',':'))
to_sign = str(timestamp) + json.dumps(body)
sign = hmac.new(SECRET_KEY.encode("utf-8"), to_sign.encode("utf-8"), hashlib.md5).hexdigest()
print(to_sign)
headers = {
'bibox-api-key': API_KEY,
'bibox-api-sign': sign,
'bibox-timestamp': str(timestamp)
}
return headers
def do_reqeust():
path = '/v3/assets/transfer/spot'
body = {
"type": 0,
"amount": "100",
"symbol": 'USDT'
}
headers = do_sign(body)
resp = requests.post(BASE_URL + path, json=body, headers=headers)
print(resp.text)
if __name__ == '__main__':
do_reqeust()
using System;
using System.Net.Http;
using System.Text;
using System.Security.Cryptography;
using Newtonsoft.Json;
using Newtonsoft.Json.Serialization;
namespace ConsoleProgram
{
public class SortContractResolver : DefaultContractResolver
{
protected override IList<JsonProperty> CreateProperties(Type type, MemberSerialization memberSerialization)
{
IList<JsonProperty> properties = base.CreateProperties(type, memberSerialization);
return properties.OrderBy(x=>x.PropertyName).ToList();
}
}
public class Class1
{
// HttpClient is intended to be instantiated once per application, rather than per-use. See Remarks.
static readonly HttpClient client = new HttpClient();
static string GetTimeStamp()
{
TimeSpan ts = DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0, 0);
return Convert.ToInt64(ts.TotalMilliseconds).ToString();
}
static string HmacMD5(string source, string key)
{
HMACMD5 hmacmd = new HMACMD5(Encoding.Default.GetBytes(key));
byte[] inArray = hmacmd.ComputeHash(Encoding.Default.GetBytes(source));
StringBuilder sb = new StringBuilder();
for (int i = 0; i < inArray.Length; i++)
{
sb.Append(inArray[i].ToString("X2"));
}
hmacmd.Clear();
return sb.ToString().ToLower();
}
static async Task Main()
{
// Call asynchronous network methods in a try/catch block to handle exceptions.
try
{
string uri = "https://api.bibox.com/v3/assets/transfer/spot";
string apikey = "900625568558820892a8c833c33ebc8fd2701efe";
string secret = "c708ac3e70d115ec29efbee197330627d7edf842";
string timestamp = GetTimeStamp();
var myobj = new {
type = 0,
amount = "100",
symbol = "USDT",
};
string payload = JsonConvert.SerializeObject(myobj, new JsonSerializerSettings { ContractResolver = new SortContractResolver() });
string source = timestamp + payload;
string sign = HmacMD5(source, secret);
Console.WriteLine(source);
Console.WriteLine(sign);
client.DefaultRequestHeaders.Add("bibox-api-key", apikey);
client.DefaultRequestHeaders.Add("bibox-api-sign", sign);
client.DefaultRequestHeaders.Add("bibox-timestamp", timestamp);
HttpContent content = new StringContent(payload, Encoding.UTF8, "application/json");
HttpResponseMessage response = await client.PostAsync(uri, content);
response.EnsureSuccessStatusCode();
string responseBody = await response.Content.ReadAsStringAsync();
Console.WriteLine(responseBody);
}
catch(HttpRequestException e)
{
Console.WriteLine("\nException Caught!");
Console.WriteLine("Message :{0} ",e.Message);
}
}
}
}
- 1.请求路径
POST https://api.bibox.com/v3/assets/transfer/spot
- 2.请求参数
参数名称 | 是否必须 | 类型 | 描述 | 默认值 | 取值范围 |
---|---|---|---|---|---|
symbol | true | string | 币种 | ||
amount | true | string | 数量 | ||
type | false | int | 0钱包转币币; 1币币转钱包 |
Response
{}
钱包划转到杠杆
Request
let CryptoJS = require("crypto-js");
let request = require("request");
let timestamp = Date.now(); // 1.当前时间戳
let param = {
"pair": "*_USDT",
"amount": 100,
"symbol": 'USDT'
};
let strParam = JSON.stringify(param); // 2.格式化参数
let strToSign = '' + timestamp + strParam; // 3.这就是需要签名的字符串
let apikey = "900625568558820892a8c833c33ebc8fd2701efe"; //your apikey
let secret = "c708ac3e70d115ec29efbee197330627d7edf842"; //你的 apikey 密码
let sign = CryptoJS.HmacMD5(strToSign, secret).toString();//4.签名后的结果
let url = "https://api.bibox.com/v3.1/credit/transferAssets/base2credit";
request.post({
url: url,//请求路径
method: "POST",//请求方式
headers: {//5.设置请求头
'content-type': 'application/json',
'bibox-api-key': apikey,
'bibox-api-sign': sign,
'bibox-timestamp': timestamp
},
body: strParam // 6.格式化参数
},
function optionalCallback(err, httpResponse, body) {
if (err) {
return console.error('upload failed:', err);
}
console.log(body) // 7.返回值
});
# -*- coding:utf-8 -*-
import hashlib
import hmac
import json
import time
import requests
API_KEY = '900625568558820892a8c833c33ebc8fd2701efe'
SECRET_KEY = 'c708ac3e70d115ec29efbee197330627d7edf842'
BASE_URL = 'https://api.bibox.com' # 'https://api.bibox.tel' #
def do_sign(body):
timestamp = int(time.time()) * 1000
# to_sign = str(timestamp)+json.dumps(body,separators=(',',':'))
to_sign = str(timestamp) + json.dumps(body)
sign = hmac.new(SECRET_KEY.encode("utf-8"), to_sign.encode("utf-8"), hashlib.md5).hexdigest()
print(to_sign)
headers = {
'bibox-api-key': API_KEY,
'bibox-api-sign': sign,
'bibox-timestamp': str(timestamp)
}
return headers
def do_request():
path = '/v3.1/credit/transferAssets/base2credit'
body = {
"pair": "*_USDT",
"amount": 100,
"symbol": 'USDT'
}
headers = do_sign(body)
resp = requests.post(BASE_URL + path, json=body, headers=headers)
print(resp.text)
if __name__ == '__main__':
do_request()
using System;
using System.Net.Http;
using System.Text;
using System.Security.Cryptography;
using Newtonsoft.Json;
using Newtonsoft.Json.Serialization;
namespace ConsoleProgram
{
public class SortContractResolver : DefaultContractResolver
{
protected override IList<JsonProperty> CreateProperties(Type type, MemberSerialization memberSerialization)
{
IList<JsonProperty> properties = base.CreateProperties(type, memberSerialization);
return properties.OrderBy(x=>x.PropertyName).ToList();
}
}
public class Class1
{
// HttpClient is intended to be instantiated once per application, rather than per-use. See Remarks.
static readonly HttpClient client = new HttpClient();
static string GetTimeStamp()
{
TimeSpan ts = DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0, 0);
return Convert.ToInt64(ts.TotalMilliseconds).ToString();
}
static string HmacMD5(string source, string key)
{
HMACMD5 hmacmd = new HMACMD5(Encoding.Default.GetBytes(key));
byte[] inArray = hmacmd.ComputeHash(Encoding.Default.GetBytes(source));
StringBuilder sb = new StringBuilder();
for (int i = 0; i < inArray.Length; i++)
{
sb.Append(inArray[i].ToString("X2"));
}
hmacmd.Clear();
return sb.ToString().ToLower();
}
static async Task Main()
{
// Call asynchronous network methods in a try/catch block to handle exceptions.
try
{
string uri = "https://api.bibox.com/v3.1/credit/transferAssets/base2credit";
string apikey = "900625568558820892a8c833c33ebc8fd2701efe";
string secret = "c708ac3e70d115ec29efbee197330627d7edf842";
string timestamp = GetTimeStamp();
var myobj = new {
pair = "*_USDT",
amount = "100",
symbol = "USDT",
};
string payload = JsonConvert.SerializeObject(myobj, new JsonSerializerSettings { ContractResolver = new SortContractResolver() });
string source = timestamp + payload;
string sign = HmacMD5(source, secret);
Console.WriteLine(source);
Console.WriteLine(sign);
client.DefaultRequestHeaders.Add("bibox-api-key", apikey);
client.DefaultRequestHeaders.Add("bibox-api-sign", sign);
client.DefaultRequestHeaders.Add("bibox-timestamp", timestamp);
HttpContent content = new StringContent(payload, Encoding.UTF8, "application/json");
HttpResponseMessage response = await client.PostAsync(uri, content);
response.EnsureSuccessStatusCode();
string responseBody = await response.Content.ReadAsStringAsync();
Console.WriteLine(responseBody);
}
catch(HttpRequestException e)
{
Console.WriteLine("\nException Caught!");
Console.WriteLine("Message :{0} ",e.Message);
}
}
}
}
- 1.请求路径
POST https://api.bibox.com/v3.1/credit/transferAssets/base2credit
- 2.请求参数
参数名称 | 是否必须 | 类型 | 描述 | 默认值 | 取值范围 |
---|---|---|---|---|---|
coin_symbol | true | string | 币种 | ||
amount | true | double | 数量 | ||
pair | true | string | 仓位 | EOS_USDT,BTC_USDT, *_USDT... |
Response
{}
杠杆划转到钱包
Request
let CryptoJS = require("crypto-js");
let request = require("request");
let timestamp = Date.now(); // 1.当前时间戳
let param = {
"pair": "BTC_USDT",
"amount": 100,
"symbol": 'USDT'
};
let strParam = JSON.stringify(param); // 2.格式化参数
let strToSign = '' + timestamp + strParam; // 3.这就是需要签名的字符串
let apikey = "900625568558820892a8c833c33ebc8fd2701efe"; //your apikey
let secret = "c708ac3e70d115ec29efbee197330627d7edf842"; //你的 apikey 密码
let sign = CryptoJS.HmacMD5(strToSign, secret).toString();//4.签名后的结果
let url = "https://api.bibox.com/v3.1/credit/transferAssets/credit2base";
request.post({
url: url,//请求路径
method: "POST",//请求方式
headers: {//5.设置请求头
'content-type': 'application/json',
'bibox-api-key': apikey,
'bibox-api-sign': sign,
'bibox-timestamp': timestamp
},
body: strParam // 6.格式化参数
},
function optionalCallback(err, httpResponse, body) {
if (err) {
return console.error('upload failed:', err);
}
console.log(body) // 7.返回值
});
# -*- coding:utf-8 -*-
import hashlib
import hmac
import json
import time
import requests
API_KEY = '900625568558820892a8c833c33ebc8fd2701efe'
SECRET_KEY = 'c708ac3e70d115ec29efbee197330627d7edf842'
BASE_URL = 'https://api.bibox.com' # 'https://api.bibox.tel' #
def do_sign(body):
timestamp = int(time.time()) * 1000
# to_sign = str(timestamp)+json.dumps(body,separators=(',',':'))
to_sign = str(timestamp) + json.dumps(body)
sign = hmac.new(SECRET_KEY.encode("utf-8"), to_sign.encode("utf-8"), hashlib.md5).hexdigest()
print(to_sign)
headers = {
'bibox-api-key': API_KEY,
'bibox-api-sign': sign,
'bibox-timestamp': str(timestamp)
}
return headers
def do_request():
path = '/v3.1/credit/transferAssets/credit2base'
body = {
"pair": "BTC_USDT",
"amount": 100,
"symbol": 'USDT'
}
headers = do_sign(body)
resp = requests.post(BASE_URL + path, json=body, headers=headers)
print(resp.text)
if __name__ == '__main__':
do_request()
using System;
using System.Net.Http;
using System.Text;
using System.Security.Cryptography;
using Newtonsoft.Json;
using Newtonsoft.Json.Serialization;
namespace ConsoleProgram
{
public class SortContractResolver : DefaultContractResolver
{
protected override IList<JsonProperty> CreateProperties(Type type, MemberSerialization memberSerialization)
{
IList<JsonProperty> properties = base.CreateProperties(type, memberSerialization);
return properties.OrderBy(x=>x.PropertyName).ToList();
}
}
public class Class1
{
// HttpClient is intended to be instantiated once per application, rather than per-use. See Remarks.
static readonly HttpClient client = new HttpClient();
static string GetTimeStamp()
{
TimeSpan ts = DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0, 0);
return Convert.ToInt64(ts.TotalMilliseconds).ToString();
}
static string HmacMD5(string source, string key)
{
HMACMD5 hmacmd = new HMACMD5(Encoding.Default.GetBytes(key));
byte[] inArray = hmacmd.ComputeHash(Encoding.Default.GetBytes(source));
StringBuilder sb = new StringBuilder();
for (int i = 0; i < inArray.Length; i++)
{
sb.Append(inArray[i].ToString("X2"));
}
hmacmd.Clear();
return sb.ToString().ToLower();
}
static async Task Main()
{
// Call asynchronous network methods in a try/catch block to handle exceptions.
try
{
string uri = "https://api.bibox.com/v3.1/credit/transferAssets/credit2base";
string apikey = "900625568558820892a8c833c33ebc8fd2701efe";
string secret = "c708ac3e70d115ec29efbee197330627d7edf842";
string timestamp = GetTimeStamp();
var myobj = new {
pair = "BTC_USDT",
amount = "100",
symbol = "USDT",
};
string payload = JsonConvert.SerializeObject(myobj, new JsonSerializerSettings { ContractResolver = new SortContractResolver() });
string source = timestamp + payload;
string sign = HmacMD5(source, secret);
Console.WriteLine(source);
Console.WriteLine(sign);
client.DefaultRequestHeaders.Add("bibox-api-key", apikey);
client.DefaultRequestHeaders.Add("bibox-api-sign", sign);
client.DefaultRequestHeaders.Add("bibox-timestamp", timestamp);
HttpContent content = new StringContent(payload, Encoding.UTF8, "application/json");
HttpResponseMessage response = await client.PostAsync(uri, content);
response.EnsureSuccessStatusCode();
string responseBody = await response.Content.ReadAsStringAsync();
Console.WriteLine(responseBody);
}
catch(HttpRequestException e)
{
Console.WriteLine("\nException Caught!");
Console.WriteLine("Message :{0} ",e.Message);
}
}
}
}
- 1.请求路径
POST https://api.bibox.com/v3.1/credit/transferAssets/credit2base
- 2.请求参数
参数名称 | 是否必须 | 类型 | 描述 | 默认值 | 取值范围 |
---|---|---|---|---|---|
coin_symbol | true | string | 币种 | ||
amount | true | double | 数量 | ||
pair | true | string | 仓位 | EOS_USDT,BTC_USDT, *_USDT... |
Response
{}
杠杆交易(需要ApiKey)
获取放贷信息
示例
let CryptoJS = require("crypto-js");
let request = require("request");
let timestamp = Date.now(); // 1.当前时间戳
let param = {
"page":1,
"status":[
0,
1
],
"coin_symbol":"USDT",
"size":1
};
let strParam = JSON.stringify(param); // 2.格式化参数
let strToSign = '' + timestamp + strParam; // 3.这就是需要签名的字符串
let apikey = "900625568558820892a8c833c33ebc8fd2701efe"; //your apikey
let secret = "c708ac3e70d115ec29efbee197330627d7edf842"; //你的 apikey 密码
let sign = CryptoJS.HmacMD5(strToSign, secret).toString();//4.签名后的结果
let url = "https://api.bibox.com/v3.1/credit/lendOrder/get";
request.post({
url: url,//请求路径
method: "POST",//请求方式
headers: {//5.设置请求头
'content-type': 'application/json',
'bibox-api-key': apikey,
'bibox-api-sign': sign,
'bibox-timestamp': timestamp
},
body: strParam // 6.格式化参数
},
function optionalCallback(err, httpResponse, body) {
if (err) {
return console.error('upload failed:', err);
}
console.log(body) // 7.返回值
});
# -*- coding:utf-8 -*-
import hashlib
import hmac
import json
import time
import requests
API_KEY = '900625568558820892a8c833c33ebc8fd2701efe'
SECRET_KEY = 'c708ac3e70d115ec29efbee197330627d7edf842'
BASE_URL = 'https://api.bibox.com' # 'https://api.bibox.tel' #
def do_sign(body):
timestamp = int(time.time()) * 1000
# to_sign = str(timestamp)+json.dumps(body,separators=(',',':'))
to_sign = str(timestamp) + json.dumps(body)
sign = hmac.new(SECRET_KEY.encode("utf-8"), to_sign.encode("utf-8"), hashlib.md5).hexdigest()
print(to_sign)
headers = {
'bibox-api-key': API_KEY,
'bibox-api-sign': sign,
'bibox-timestamp': str(timestamp)
}
return headers
def do_request():
path = '/v3.1/credit/lendOrder/get'
body = {
"page": 1,
"status": [
0,
1
],
"coin_symbol": "USDT",
"size": 1
}
headers = do_sign(body)
resp = requests.post(BASE_URL + path, json=body, headers=headers)
print(resp.text)
if __name__ == '__main__':
do_request()
using System;
using System.Net.Http;
using System.Text;
using System.Security.Cryptography;
using Newtonsoft.Json;
using Newtonsoft.Json.Serialization;
namespace ConsoleProgram
{
public class SortContractResolver : DefaultContractResolver
{
protected override IList<JsonProperty> CreateProperties(Type type, MemberSerialization memberSerialization)
{
IList<JsonProperty> properties = base.CreateProperties(type, memberSerialization);
return properties.OrderBy(x=>x.PropertyName).ToList();
}
}
public class Class1
{
// HttpClient is intended to be instantiated once per application, rather than per-use. See Remarks.
static readonly HttpClient client = new HttpClient();
static string GetTimeStamp()
{
TimeSpan ts = DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0, 0);
return Convert.ToInt64(ts.TotalMilliseconds).ToString();
}
static string HmacMD5(string source, string key)
{
HMACMD5 hmacmd = new HMACMD5(Encoding.Default.GetBytes(key));
byte[] inArray = hmacmd.ComputeHash(Encoding.Default.GetBytes(source));
StringBuilder sb = new StringBuilder();
for (int i = 0; i < inArray.Length; i++)
{
sb.Append(inArray[i].ToString("X2"));
}
hmacmd.Clear();
return sb.ToString().ToLower();
}
static async Task Main()
{
// Call asynchronous network methods in a try/catch block to handle exceptions.
try
{
string uri = "https://api.bibox.com/v3.1/credit/lendOrder/get";
string apikey = "900625568558820892a8c833c33ebc8fd2701efe";
string secret = "c708ac3e70d115ec29efbee197330627d7edf842";
string timestamp = GetTimeStamp();
var myobj = new {
coin_symbol = "USDT",
size = 1,
page = 1,
status = new [] {0, 1},
};
string payload = JsonConvert.SerializeObject(myobj, new JsonSerializerSettings { ContractResolver = new SortContractResolver() });
string source = timestamp + payload;
string sign = HmacMD5(source, secret);
Console.WriteLine(source);
Console.WriteLine(sign);
client.DefaultRequestHeaders.Add("bibox-api-key", apikey);
client.DefaultRequestHeaders.Add("bibox-api-sign", sign);
client.DefaultRequestHeaders.Add("bibox-timestamp", timestamp);
HttpContent content = new StringContent(payload, Encoding.UTF8, "application/json");
HttpResponseMessage response = await client.PostAsync(uri, content);
response.EnsureSuccessStatusCode();
string responseBody = await response.Content.ReadAsStringAsync();
Console.WriteLine(responseBody);
}
catch(HttpRequestException e)
{
Console.WriteLine("\nException Caught!");
Console.WriteLine("Message :{0} ",e.Message);
}
}
}
}
- 1.请求路径
POST https://api.bibox.com/v3.1/credit/lendOrder/get
- 2.请求参数
参数名称 | 是否必须 | 类型 | 描述 | 默认值 | 取值范围 |
---|---|---|---|---|---|
coin_symbol | true | string | 币种 | ||
status | false | int | 0-借出 1-部分收回 2-完成 | ||
page | false | int | 页码 | ||
size | false | int | 每页数量 |
Response
{
"count": 2,
"page": 1,
"items": [
{
"id": 14,
"user_id": 8114202916,
"coin_id": 60,
"coin_symbol": "USDT",
"amount": "1000.00000000",
"amount_receipt": "0.00000000",
"interest_rate": "0.00200000",
"insurance_rate": "0.10000000",
"fee": "0.00000000",
"insurance": "0.00000000",
"interest": "2.33333324",
"interest_receipt": "0.00000000",
"period": 7,
"expireAt": "2019-11-18T03:00:00.000Z",
"status": 0,
"createdAt": "2019-11-11T03:50:47.000Z",
"days": 1
}
],
"validSymbols": [
"USDT"
]
}
- 3.返回字段
名称 | 描述 |
---|---|
coin_symbol | 币种 |
amount | 已放款数量 |
amount_receipt | 已收回放款 |
interest_rate | 利率 |
insurance_rate | 保险费率 |
fee | 已收回放款 |
insurance | 保险 |
interest | 利息 |
status | 0:已借出,1部分收回,2全部收回 |
获取借款信息
示例
let CryptoJS = require("crypto-js");
let request = require("request");
let timestamp = Date.now(); // 1.当前时间戳
let param = {
"page":1,
"status":[
1,
2
],
"size":10,
"pair":"BTC_USDT"
};
let strParam = JSON.stringify(param); // 2.格式化参数
let strToSign = '' + timestamp + strParam; // 3.这就是需要签名的字符串
let apikey = "900625568558820892a8c833c33ebc8fd2701efe"; //your apikey
let secret = "c708ac3e70d115ec29efbee197330627d7edf842"; //你的 apikey 密码
let sign = CryptoJS.HmacMD5(strToSign, secret).toString();//4.签名后的结果
let url = "https://api.bibox.com/v3.1/credit/borrowOrder/get";
request.post({
url: url,//请求路径
method: "POST",//请求方式
headers: {//5.设置请求头
'content-type': 'application/json',
'bibox-api-key': apikey,
'bibox-api-sign': sign,
'bibox-timestamp': timestamp
},
body: strParam // 6.格式化参数
},
function optionalCallback(err, httpResponse, body) {
if (err) {
return console.error('upload failed:', err);
}
console.log(body) // 7.返回值
});
# -*- coding:utf-8 -*-
import hashlib
import hmac
import json
import time
import requests
API_KEY = '900625568558820892a8c833c33ebc8fd2701efe'
SECRET_KEY = 'c708ac3e70d115ec29efbee197330627d7edf842'
BASE_URL = 'https://api.bibox.com' # 'https://api.bibox.tel' #
def do_sign(body):
timestamp = int(time.time()) * 1000
# to_sign = str(timestamp)+json.dumps(body,separators=(',',':'))
to_sign = str(timestamp) + json.dumps(body)
sign = hmac.new(SECRET_KEY.encode("utf-8"), to_sign.encode("utf-8"), hashlib.md5).hexdigest()
print(to_sign)
headers = {
'bibox-api-key': API_KEY,
'bibox-api-sign': sign,
'bibox-timestamp': str(timestamp)
}
return headers
def do_request():
path = '/v3.1/credit/borrowOrder/get'
body = {
"page": 1,
"status": [
1,
2
],
"size": 10,
"pair": "BTC_USDT"
}
headers = do_sign(body)
resp = requests.post(BASE_URL + path, json=body, headers=headers)
print(resp.text)
if __name__ == '__main__':
do_request()
using System;
using System.Net.Http;
using System.Text;
using System.Security.Cryptography;
using Newtonsoft.Json;
using Newtonsoft.Json.Serialization;
namespace ConsoleProgram
{
public class SortContractResolver : DefaultContractResolver
{
protected override IList<JsonProperty> CreateProperties(Type type, MemberSerialization memberSerialization)
{
IList<JsonProperty> properties = base.CreateProperties(type, memberSerialization);
return properties.OrderBy(x=>x.PropertyName).ToList();
}
}
public class Class1
{
// HttpClient is intended to be instantiated once per application, rather than per-use. See Remarks.
static readonly HttpClient client = new HttpClient();
static string GetTimeStamp()
{
TimeSpan ts = DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0, 0);
return Convert.ToInt64(ts.TotalMilliseconds).ToString();
}
static string HmacMD5(string source, string key)
{
HMACMD5 hmacmd = new HMACMD5(Encoding.Default.GetBytes(key));
byte[] inArray = hmacmd.ComputeHash(Encoding.Default.GetBytes(source));
StringBuilder sb = new StringBuilder();
for (int i = 0; i < inArray.Length; i++)
{
sb.Append(inArray[i].ToString("X2"));
}
hmacmd.Clear();
return sb.ToString().ToLower();
}
static async Task Main()
{
// Call asynchronous network methods in a try/catch block to handle exceptions.
try
{
string uri = "https://api.bibox.com/v3.1/credit/borrowOrder/get";
string apikey = "900625568558820892a8c833c33ebc8fd2701efe";
string secret = "c708ac3e70d115ec29efbee197330627d7edf842";
string timestamp = GetTimeStamp();
var myobj = new {
pair = "BTC_USDT",
size = 10,
page = 1,
status = new [] {1, 2},
};
string payload = JsonConvert.SerializeObject(myobj, new JsonSerializerSettings { ContractResolver = new SortContractResolver() });
string source = timestamp + payload;
string sign = HmacMD5(source, secret);
Console.WriteLine(source);
Console.WriteLine(sign);
client.DefaultRequestHeaders.Add("bibox-api-key", apikey);
client.DefaultRequestHeaders.Add("bibox-api-sign", sign);
client.DefaultRequestHeaders.Add("bibox-timestamp", timestamp);
HttpContent content = new StringContent(payload, Encoding.UTF8, "application/json");
HttpResponseMessage response = await client.PostAsync(uri, content);
response.EnsureSuccessStatusCode();
string responseBody = await response.Content.ReadAsStringAsync();
Console.WriteLine(responseBody);
}
catch(HttpRequestException e)
{
Console.WriteLine("\nException Caught!");
Console.WriteLine("Message :{0} ",e.Message);
}
}
}
}
- 1.请求路径
POST https://api.bibox.com/v3.1/credit/borrowOrder/get
- 2.请求参数
参数名称 | 是否必须 | 类型 | 描述 | 默认值 | 取值范围 |
---|---|---|---|---|---|
coin_symbol | true | string | 交易币种 | USDT, EOS... | |
pair | true | string | 仓位 | BTC_USDT, ETH_USDT, *_USDT-全仓 | |
status | true | int或Array | 订单状态 | 0未成交, 1借款成功, 2部分还款, 3-6已完成 | |
page | true | integer | 第几页 | 从1开始 | |
size | true | integer | 每页数量 | 1-50 |
Response
{
"count": 2,
"page": 1,
"items": [
{
"id": 539354,
"user_id": 8114202916,
"coin_id": 60,
"coin_symbol": "USDT",
"pair": "BTC_USDT",
"amount": "406.00000000",
"amount_refund": "0.00000000",
"interest_rate": "0.00010000",
"interest_rate_hour": "0.00000417",
"interest": "0.26559180",
"interest_refund": "0.00000000",
"period": 7,
"expireAt": "2019-11-15T11:00:00.000Z",
"status": 1,
"createdAt": "2019-11-08T11:53:15.000Z"
}
],
"validSymbols": [
{
"coin_symbol": "USDT",
"pair": "BTC_USDT"
}
]
}
- 3.返回字段
名称 | 描述 |
---|---|
coin_symbol | 币种 |
pair | 仓位信息 |
amount | 借款数量 |
amount_refund | 已还款数量 |
interest_rate | 日利率 |
interest | 未还利息 |
interest_refund | 已还利息 |
status | 1借款成功,2部分还款,3还款成功 |
获取放贷未成交信息
示例
let CryptoJS = require("crypto-js");
let request = require("request");
let timestamp = Date.now(); // 1.当前时间戳
let param = {
"page":1,
"status":[
0,
1
],
"coin_symbol":"EOS",
"size":50
}
let strParam = JSON.stringify(param); // 2.格式化参数
let strToSign = '' + timestamp + strParam; // 3.这就是需要签名的字符串
let apikey = "900625568558820892a8c833c33ebc8fd2701efe"; //your apikey
let secret = "c708ac3e70d115ec29efbee197330627d7edf842"; //你的 apikey 密码
let sign = CryptoJS.HmacMD5(strToSign, secret).toString();//4.签名后的结果
let url = "https://api.bibox.com/v3.1/credit/lendOrderbook/get";
request.post({
url: url,//请求路径
method: "POST",//请求方式
headers: {//5.设置请求头
'content-type': 'application/json',
'bibox-api-key': apikey,
'bibox-api-sign': sign,
'bibox-timestamp': timestamp
},
body: strParam // 6.格式化参数
},
function optionalCallback(err, httpResponse, body) {
if (err) {
return console.error('upload failed:', err);
}
console.log(body) // 7.返回值
});
# -*- coding:utf-8 -*-
import hashlib
import hmac
import json
import time
import requests
API_KEY = '900625568558820892a8c833c33ebc8fd2701efe'
SECRET_KEY = 'c708ac3e70d115ec29efbee197330627d7edf842'
BASE_URL = 'https://api.bibox.com' # 'https://api.bibox.tel' #
def do_sign(body):
timestamp = int(time.time()) * 1000
# to_sign = str(timestamp)+json.dumps(body,separators=(',',':'))
to_sign = str(timestamp) + json.dumps(body)
sign = hmac.new(SECRET_KEY.encode("utf-8"), to_sign.encode("utf-8"), hashlib.md5).hexdigest()
print(to_sign)
headers = {
'bibox-api-key': API_KEY,
'bibox-api-sign': sign,
'bibox-timestamp': str(timestamp)
}
return headers
def do_request():
path = '/v3.1/credit/lendOrderbook/get'
body = {
"page": 1,
"status": [
0,
1
],
"coin_symbol": "EOS",
"size": 50
}
headers = do_sign(body)
resp = requests.post(BASE_URL + path, json=body, headers=headers)
print(resp.text)
if __name__ == '__main__':
do_request()
using System;
using System.Net.Http;
using System.Text;
using System.Security.Cryptography;
using Newtonsoft.Json;
using Newtonsoft.Json.Serialization;
namespace ConsoleProgram
{
public class SortContractResolver : DefaultContractResolver
{
protected override IList<JsonProperty> CreateProperties(Type type, MemberSerialization memberSerialization)
{
IList<JsonProperty> properties = base.CreateProperties(type, memberSerialization);
return properties.OrderBy(x=>x.PropertyName).ToList();
}
}
public class Class1
{
// HttpClient is intended to be instantiated once per application, rather than per-use. See Remarks.
static readonly HttpClient client = new HttpClient();
static string GetTimeStamp()
{
TimeSpan ts = DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0, 0);
return Convert.ToInt64(ts.TotalMilliseconds).ToString();
}
static string HmacMD5(string source, string key)
{
HMACMD5 hmacmd = new HMACMD5(Encoding.Default.GetBytes(key));
byte[] inArray = hmacmd.ComputeHash(Encoding.Default.GetBytes(source));
StringBuilder sb = new StringBuilder();
for (int i = 0; i < inArray.Length; i++)
{
sb.Append(inArray[i].ToString("X2"));
}
hmacmd.Clear();
return sb.ToString().ToLower();
}
static async Task Main()
{
// Call asynchronous network methods in a try/catch block to handle exceptions.
try
{
string uri = "https://api.bibox.com/v3.1/credit/lendOrderbook/get";
string apikey = "900625568558820892a8c833c33ebc8fd2701efe";
string secret = "c708ac3e70d115ec29efbee197330627d7edf842";
string timestamp = GetTimeStamp();
var myobj = new {
coin_symbol = "EOS",
size = 50,
page = 1,
status = new [] {0, 1},
};
string payload = JsonConvert.SerializeObject(myobj, new JsonSerializerSettings { ContractResolver = new SortContractResolver() });
string source = timestamp + payload;
string sign = HmacMD5(source, secret);
Console.WriteLine(source);
Console.WriteLine(sign);
client.DefaultRequestHeaders.Add("bibox-api-key", apikey);
client.DefaultRequestHeaders.Add("bibox-api-sign", sign);
client.DefaultRequestHeaders.Add("bibox-timestamp", timestamp);
HttpContent content = new StringContent(payload, Encoding.UTF8, "application/json");
HttpResponseMessage response = await client.PostAsync(uri, content);
response.EnsureSuccessStatusCode();
string responseBody = await response.Content.ReadAsStringAsync();
Console.WriteLine(responseBody);
}
catch(HttpRequestException e)
{
Console.WriteLine("\nException Caught!");
Console.WriteLine("Message :{0} ",e.Message);
}
}
}
}
- 1.请求路径
POST https://api.bibox.com/v3.1/credit/lendOrderbook/get
- 2.请求参数
参数名称 | 是否必须 | 类型 | 描述 | 默认值 | 取值范围 |
---|---|---|---|---|---|
coin_symbol | true | string | 交易币种 | USDT, EOS, ... | |
status | true | integer或integerArray | 订单状态 | 0未成交, 1部分成交, 2已完成 | |
page | true | integer | 第几页 | 从1开始 | |
size | true | integer | 每页数量 | 1-50 |
Response
{
"count":1,
"page":1,
"items":[
{
"id":1,
"user_id":10000000,
"coin_id":61,
"coin_symbol":"EOS",
"amount":5,
"amount_finish":0,
"interest_rate":0.001,
"period":7,
"expireAt":"2018-12-29T10:59:18.000Z",
"status":0,
"createdAt":"2018-12-22T10:59:18.000Z"
}
],
"validSymbols":[
"EOS"
]
}
- 3.返回字段
名称 | 描述 |
---|---|
coin_symbol | 币种 |
amount | 待成交数量 |
amount_finish | 已成交数量 |
interest_rate | 利率 |
获取放贷资产信息
示例
let CryptoJS = require("crypto-js");
let request = require("request");
let timestamp = Date.now(); // 1.当前时间戳
let param = {
"coin_symbol":"EOS"
};
let strParam = JSON.stringify(param); // 2.格式化参数
let strToSign = '' + timestamp + strParam; // 3.这就是需要签名的字符串
let apikey = "900625568558820892a8c833c33ebc8fd2701efe"; //your apikey
let secret = "c708ac3e70d115ec29efbee197330627d7edf842"; //你的 apikey 密码
let sign = CryptoJS.HmacMD5(strToSign, secret).toString();//4.签名后的结果
let url = "https://api.bibox.com/v3.1/credit/transferAssets/lendAssets";
request.post({
url: url,//请求路径
method: "POST",//请求方式
headers: {//5.设置请求头
'content-type': 'application/json',
'bibox-api-key': apikey,
'bibox-api-sign': sign,
'bibox-timestamp': timestamp
},
body: strParam // 6.格式化参数
},
function optionalCallback(err, httpResponse, body) {
if (err) {
return console.error('upload failed:', err);
}
console.log(body) // 7.返回值
});
# -*- coding:utf-8 -*-
import hashlib
import hmac
import json
import time
import requests
API_KEY = '900625568558820892a8c833c33ebc8fd2701efe'
SECRET_KEY = 'c708ac3e70d115ec29efbee197330627d7edf842'
BASE_URL = 'https://api.bibox.com' # 'https://api.bibox.tel' #
def do_sign(body):
timestamp = int(time.time()) * 1000
# to_sign = str(timestamp)+json.dumps(body,separators=(',',':'))
to_sign = str(timestamp) + json.dumps(body)
sign = hmac.new(SECRET_KEY.encode("utf-8"), to_sign.encode("utf-8"), hashlib.md5).hexdigest()
print(to_sign)
headers = {
'bibox-api-key': API_KEY,
'bibox-api-sign': sign,
'bibox-timestamp': str(timestamp)
}
return headers
def do_request():
path = '/v3.1/credit/transferAssets/lendAssets'
body = {
"coin_symbol": "EOS"
}
headers = do_sign(body)
resp = requests.post(BASE_URL + path, json=body, headers=headers)
print(resp.text)
if __name__ == '__main__':
do_request()
using System;
using System.Net.Http;
using System.Text;
using System.Security.Cryptography;
using Newtonsoft.Json;
using Newtonsoft.Json.Serialization;
namespace ConsoleProgram
{
public class SortContractResolver : DefaultContractResolver
{
protected override IList<JsonProperty> CreateProperties(Type type, MemberSerialization memberSerialization)
{
IList<JsonProperty> properties = base.CreateProperties(type, memberSerialization);
return properties.OrderBy(x=>x.PropertyName).ToList();
}
}
public class Class1
{
// HttpClient is intended to be instantiated once per application, rather than per-use. See Remarks.
static readonly HttpClient client = new HttpClient();
static string GetTimeStamp()
{
TimeSpan ts = DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0, 0);
return Convert.ToInt64(ts.TotalMilliseconds).ToString();
}
static string HmacMD5(string source, string key)
{
HMACMD5 hmacmd = new HMACMD5(Encoding.Default.GetBytes(key));
byte[] inArray = hmacmd.ComputeHash(Encoding.Default.GetBytes(source));
StringBuilder sb = new StringBuilder();
for (int i = 0; i < inArray.Length; i++)
{
sb.Append(inArray[i].ToString("X2"));
}
hmacmd.Clear();
return sb.ToString().ToLower();
}
static async Task Main()
{
// Call asynchronous network methods in a try/catch block to handle exceptions.
try
{
string uri = "https://api.bibox.com/v3.1/credit/transferAssets/lendAssets";
string apikey = "900625568558820892a8c833c33ebc8fd2701efe";
string secret = "c708ac3e70d115ec29efbee197330627d7edf842";
string timestamp = GetTimeStamp();
var myobj = new {
coin_symbol = "EOS",
};
string payload = JsonConvert.SerializeObject(myobj, new JsonSerializerSettings { ContractResolver = new SortContractResolver() });
string source = timestamp + payload;
string sign = HmacMD5(source, secret);
Console.WriteLine(source);
Console.WriteLine(sign);
client.DefaultRequestHeaders.Add("bibox-api-key", apikey);
client.DefaultRequestHeaders.Add("bibox-api-sign", sign);
client.DefaultRequestHeaders.Add("bibox-timestamp", timestamp);
HttpContent content = new StringContent(payload, Encoding.UTF8, "application/json");
HttpResponseMessage response = await client.PostAsync(uri, content);
response.EnsureSuccessStatusCode();
string responseBody = await response.Content.ReadAsStringAsync();
Console.WriteLine(responseBody);
}
catch(HttpRequestException e)
{
Console.WriteLine("\nException Caught!");
Console.WriteLine("Message :{0} ",e.Message);
}
}
}
}
- 1.请求路径
POST https://api.bibox.com/v3.1/credit/transferAssets/lendAssets
- 2.请求参数
参数名称 | 是否必须 | 类型 | 描述 | 默认值 | 取值范围 |
---|---|---|---|---|---|
coin_symbol | true | string | 币种 |
Response
{
"balance":"1.52319980",
"lend":"0.00000000",
"lend_book":"0.00000000",
"interest":"0.00000000",
"lend_receipt":"1.44000000",
"interest_receipt":"0.16115200"
}
- 3.返回字段
名称 | 描述 |
---|---|
balance | 可用余额 |
lend | 待收贷款数量 |
lend_book | 预订贷款数量 |
interest | 待收利息 |
lend_receipt | 已收贷款数量 |
interest_receipt | 已收利息 |
获取借款资产信息
示例
let CryptoJS = require("crypto-js");
let request = require("request");
let timestamp = Date.now(); // 1.当前时间戳
let param = {
"pair":"BTC_USDT",
};
let strParam = JSON.stringify(param); // 2.格式化参数
let strToSign = '' + timestamp + strParam; // 3.这就是需要签名的字符串
let apikey = "900625568558820892a8c833c33ebc8fd2701efe"; //your apikey
let secret = "c708ac3e70d115ec29efbee197330627d7edf842"; //你的 apikey 密码
let sign = CryptoJS.HmacMD5(strToSign, secret).toString();//4.签名后的结果
let url = "https://api.bibox.com/v3.1/credit/transferAssets/borrowAsset";
request.post({
url: url,//请求路径
method: "POST",//请求方式
headers: {//5.设置请求头
'content-type': 'application/json',
'bibox-api-key': apikey,
'bibox-api-sign': sign,
'bibox-timestamp': timestamp
},
body: strParam // 6.格式化参数
},
function optionalCallback(err, httpResponse, body) {
if (err) {
return console.error('upload failed:', err);
}
console.log(body) // 7.返回值
});
# -*- coding:utf-8 -*-
import hashlib
import hmac
import json
import time
import requests
API_KEY = '900625568558820892a8c833c33ebc8fd2701efe'
SECRET_KEY = 'c708ac3e70d115ec29efbee197330627d7edf842'
BASE_URL = 'https://api.bibox.com' # 'https://api.bibox.tel' #
def do_sign(body):
timestamp = int(time.time()) * 1000
# to_sign = str(timestamp)+json.dumps(body,separators=(',',':'))
to_sign = str(timestamp) + json.dumps(body)
sign = hmac.new(SECRET_KEY.encode("utf-8"), to_sign.encode("utf-8"), hashlib.md5).hexdigest()
print(to_sign)
headers = {
'bibox-api-key': API_KEY,
'bibox-api-sign': sign,
'bibox-timestamp': str(timestamp)
}
return headers
def do_request():
path = '/v3.1/credit/transferAssets/borrowAsset'
body = {
"pair": "BTC_USDT",
}
headers = do_sign(body)
resp = requests.post(BASE_URL + path, json=body, headers=headers)
print(resp.text)
if __name__ == '__main__':
do_request()
using System;
using System.Net.Http;
using System.Text;
using System.Security.Cryptography;
using Newtonsoft.Json;
using Newtonsoft.Json.Serialization;
namespace ConsoleProgram
{
public class SortContractResolver : DefaultContractResolver
{
protected override IList<JsonProperty> CreateProperties(Type type, MemberSerialization memberSerialization)
{
IList<JsonProperty> properties = base.CreateProperties(type, memberSerialization);
return properties.OrderBy(x=>x.PropertyName).ToList();
}
}
public class Class1
{
// HttpClient is intended to be instantiated once per application, rather than per-use. See Remarks.
static readonly HttpClient client = new HttpClient();
static string GetTimeStamp()
{
TimeSpan ts = DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0, 0);
return Convert.ToInt64(ts.TotalMilliseconds).ToString();
}
static string HmacMD5(string source, string key)
{
HMACMD5 hmacmd = new HMACMD5(Encoding.Default.GetBytes(key));
byte[] inArray = hmacmd.ComputeHash(Encoding.Default.GetBytes(source));
StringBuilder sb = new StringBuilder();
for (int i = 0; i < inArray.Length; i++)
{
sb.Append(inArray[i].ToString("X2"));
}
hmacmd.Clear();
return sb.ToString().ToLower();
}
static async Task Main()
{
// Call asynchronous network methods in a try/catch block to handle exceptions.
try
{
string uri = "https://api.bibox.com/v3.1/credit/transferAssets/borrowAsset";
string apikey = "900625568558820892a8c833c33ebc8fd2701efe";
string secret = "c708ac3e70d115ec29efbee197330627d7edf842";
string timestamp = GetTimeStamp();
var myobj = new {
pair = "BTC_USDT",
};
string payload = JsonConvert.SerializeObject(myobj, new JsonSerializerSettings { ContractResolver = new SortContractResolver() });
string source = timestamp + payload;
string sign = HmacMD5(source, secret);
Console.WriteLine(source);
Console.WriteLine(sign);
client.DefaultRequestHeaders.Add("bibox-api-key", apikey);
client.DefaultRequestHeaders.Add("bibox-api-sign", sign);
client.DefaultRequestHeaders.Add("bibox-timestamp", timestamp);
HttpContent content = new StringContent(payload, Encoding.UTF8, "application/json");
HttpResponseMessage response = await client.PostAsync(uri, content);
response.EnsureSuccessStatusCode();
string responseBody = await response.Content.ReadAsStringAsync();
Console.WriteLine(responseBody);
}
catch(HttpRequestException e)
{
Console.WriteLine("\nException Caught!");
Console.WriteLine("Message :{0} ",e.Message);
}
}
}
}
- 1.请求路径
POST https://api.bibox.com/v3.1/credit/transferAssets/borrowAssets
- 2.请求参数
参数名称 | 是否必须 | 类型 | 描述 | 默认值 | 取值范围 |
---|---|---|---|---|---|
pair | true | string | 仓位 | BTC_USDT, ETH_USDT, *_USDT-全仓 |
Response
{
"pair": "BTC_USDT",
"currency_deposit": "8406.00000000",
"currency_borrow": "506.34642529",
"currency_can_borrow": "70590.53574710",
"margin_radio": "1660.13",
"max_leverage_ratio": 10,
"current_leverage_radio": "2",
"force_deal_radio": 110,
"force_price": "0",
"items": [
{
"coin_symbol": "BTC",
"coin_id": 42,
"balance": "0.00000000",
"freeze": "0.00000000",
"borrow": "0",
"can_transfer_credit": "0.00000000",
"can_transfer_main": "0",
"can_borrow": "8.82381696",
"borrow_book": "0",
"force_price": "0",
"bust_price": "0",
"price": "8000",
"interest": "0",
"total": "0.00000000"
},
{
"coin_symbol": "USDT",
"coin_id": 60,
"balance": "8406.00000000",
"freeze": "0.00000000",
"borrow": "506.34642529",
"can_transfer_credit": "7494.57643447",
"can_transfer_main": "5000.00000000",
"can_borrow": "70590.53574710",
"borrow_book": "0",
"force_price": "0",
"bust_price": "0",
"price": "1",
"interest": "0.34642529",
"total": "8406.00000000"
}
]
}
- 3.返回字段
名称 | 描述 |
---|---|
pair | 仓位 |
currency_deposit | 折合成计价币余额 |
currency_borrow | 折合成计价币已借 |
currency_can_borrow | 折合成计价币可借 |
margin_radio | 保证金率 |
current_leverage_radio | 当前杠杆倍数 |
force_deal_radio | 爆仓保证金率 |
force_price | 爆仓价(逐仓) |
balance | 单个币种余额 |
freeze | 币种冻结 |
borrow | 币种借款 |
interest | 产生利息 |
借款
示例
let CryptoJS = require("crypto-js");
let request = require("request");
let timestamp = Date.now(); // 1.当前时间戳
let param = {
"coin_symbol": "BTC",
"pair": "BTC_USDT",
"amount":"5.0036"
};
let strParam = JSON.stringify(param); // 2.格式化参数
let strToSign = '' + timestamp + strParam; // 3.这就是需要签名的字符串
let apikey = "900625568558820892a8c833c33ebc8fd2701efe"; //your apikey
let secret = "c708ac3e70d115ec29efbee197330627d7edf842"; //你的 apikey 密码
let sign = CryptoJS.HmacMD5(strToSign, secret).toString();//4.签名后的结果
let url = "https://api.bibox.com/v3.1/credit/borrowOrder/autobook";
request.post({
url: url,//请求路径
method: "POST",//请求方式
headers: {//5.设置请求头
'content-type': 'application/json',
'bibox-api-key': apikey,
'bibox-api-sign': sign,
'bibox-timestamp': timestamp
},
body: strParam // 6.格式化参数
},
function optionalCallback(err, httpResponse, body) {
if (err) {
return console.error('upload failed:', err);
}
console.log(body) // 7.返回值
});
# -*- coding:utf-8 -*-
import hashlib
import hmac
import json
import time
import requests
API_KEY = '900625568558820892a8c833c33ebc8fd2701efe'
SECRET_KEY = 'c708ac3e70d115ec29efbee197330627d7edf842'
BASE_URL = 'https://api.bibox.com' # 'https://api.bibox.tel' #
def do_sign(body):
timestamp = int(time.time()) * 1000
# to_sign = str(timestamp)+json.dumps(body,separators=(',',':'))
to_sign = str(timestamp) + json.dumps(body)
sign = hmac.new(SECRET_KEY.encode("utf-8"), to_sign.encode("utf-8"), hashlib.md5).hexdigest()
print(to_sign)
headers = {
'bibox-api-key': API_KEY,
'bibox-api-sign': sign,
'bibox-timestamp': str(timestamp)
}
return headers
def do_request():
path = '/v3.1/credit/borrowOrder/autobook'
body = {
"coin_symbol": "BTC",
"pair": "BTC_USDT",
"amount": "5.0036"
}
headers = do_sign(body)
resp = requests.post(BASE_URL + path, json=body, headers=headers)
print(resp.text)
if __name__ == '__main__':
do_request()
using System;
using System.Net.Http;
using System.Text;
using System.Security.Cryptography;
using Newtonsoft.Json;
using Newtonsoft.Json.Serialization;
namespace ConsoleProgram
{
public class SortContractResolver : DefaultContractResolver
{
protected override IList<JsonProperty> CreateProperties(Type type, MemberSerialization memberSerialization)
{
IList<JsonProperty> properties = base.CreateProperties(type, memberSerialization);
return properties.OrderBy(x=>x.PropertyName).ToList();
}
}
public class Class1
{
// HttpClient is intended to be instantiated once per application, rather than per-use. See Remarks.
static readonly HttpClient client = new HttpClient();
static string GetTimeStamp()
{
TimeSpan ts = DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0, 0);
return Convert.ToInt64(ts.TotalMilliseconds).ToString();
}
static string HmacMD5(string source, string key)
{
HMACMD5 hmacmd = new HMACMD5(Encoding.Default.GetBytes(key));
byte[] inArray = hmacmd.ComputeHash(Encoding.Default.GetBytes(source));
StringBuilder sb = new StringBuilder();
for (int i = 0; i < inArray.Length; i++)
{
sb.Append(inArray[i].ToString("X2"));
}
hmacmd.Clear();
return sb.ToString().ToLower();
}
static async Task Main()
{
// Call asynchronous network methods in a try/catch block to handle exceptions.
try
{
string uri = "https://api.bibox.com/v3.1/credit/borrowOrder/autobook";
string apikey = "900625568558820892a8c833c33ebc8fd2701efe";
string secret = "c708ac3e70d115ec29efbee197330627d7edf842";
string timestamp = GetTimeStamp();
var myobj = new {
coin_symbol = "BTC",
pair = "BTC_USDT",
amount = "5.0036",
};
string payload = JsonConvert.SerializeObject(myobj, new JsonSerializerSettings { ContractResolver = new SortContractResolver() });
string source = timestamp + payload;
string sign = HmacMD5(source, secret);
Console.WriteLine(source);
Console.WriteLine(sign);
client.DefaultRequestHeaders.Add("bibox-api-key", apikey);
client.DefaultRequestHeaders.Add("bibox-api-sign", sign);
client.DefaultRequestHeaders.Add("bibox-timestamp", timestamp);
HttpContent content = new StringContent(payload, Encoding.UTF8, "application/json");
HttpResponseMessage response = await client.PostAsync(uri, content);
response.EnsureSuccessStatusCode();
string responseBody = await response.Content.ReadAsStringAsync();
Console.WriteLine(responseBody);
}
catch(HttpRequestException e)
{
Console.WriteLine("\nException Caught!");
Console.WriteLine("Message :{0} ",e.Message);
}
}
}
}
- 1.请求路径
POST https://api.bibox.com/v3.1/credit/borrowOrder/autobook
- 2.请求参数
参数名称 | 是否必须 | 类型 | 描述 | 默认值 | 取值范围 |
---|---|---|---|---|---|
coin_symbol | true | string | 需要借款的币种 | EOS, BTC, USDT | |
pair | true | string | 需要借款的仓位 | BTC_USDT, *_USDT | |
amount | true | double | 借款数量 |
Response
{}
还款
示例
let CryptoJS = require("crypto-js");
let request = require("request");
let timestamp = Date.now(); // 1.当前时间戳
let param = {
"coin_symbol": "BTC",
"pair": "BTC_USDT",
"amount":"5.0036"
};
let strParam = JSON.stringify(param); // 2.格式化参数
let strToSign = '' + timestamp + strParam; // 3.这就是需要签名的字符串
let apikey = "900625568558820892a8c833c33ebc8fd2701efe"; //your apikey
let secret = "c708ac3e70d115ec29efbee197330627d7edf842"; //你的 apikey 密码
let sign = CryptoJS.HmacMD5(strToSign, secret).toString();//4.签名后的结果
let url = "https://api.bibox.com/v3.1/credit/borrowOrder/refund";
request.post({
url: url,//请求路径
method: "POST",//请求方式
headers: {//5.设置请求头
'content-type': 'application/json',
'bibox-api-key': apikey,
'bibox-api-sign': sign,
'bibox-timestamp': timestamp
},
body: strParam // 6.格式化参数
},
function optionalCallback(err, httpResponse, body) {
if (err) {
return console.error('upload failed:', err);
}
console.log(body) // 7.返回值
});
# -*- coding:utf-8 -*-
import hashlib
import hmac
import json
import time
import requests
API_KEY = '900625568558820892a8c833c33ebc8fd2701efe'
SECRET_KEY = 'c708ac3e70d115ec29efbee197330627d7edf842'
BASE_URL = 'https://api.bibox.com' # 'https://api.bibox.tel' #
def do_sign(body):
timestamp = int(time.time()) * 1000
# to_sign = str(timestamp)+json.dumps(body,separators=(',',':'))
to_sign = str(timestamp) + json.dumps(body)
sign = hmac.new(SECRET_KEY.encode("utf-8"), to_sign.encode("utf-8"), hashlib.md5).hexdigest()
print(to_sign)
headers = {
'bibox-api-key': API_KEY,
'bibox-api-sign': sign,
'bibox-timestamp': str(timestamp)
}
return headers
def do_request():
path = '/v3.1/credit/borrowOrder/refund'
body = {
"coin_symbol": "BTC",
"pair": "BTC_USDT",
"amount": "5.0036"
}
headers = do_sign(body)
resp = requests.post(BASE_URL + path, json=body, headers=headers)
print(resp.text)
if __name__ == '__main__':
do_request()
using System;
using System.Net.Http;
using System.Text;
using System.Security.Cryptography;
using Newtonsoft.Json;
using Newtonsoft.Json.Serialization;
namespace ConsoleProgram
{
public class SortContractResolver : DefaultContractResolver
{
protected override IList<JsonProperty> CreateProperties(Type type, MemberSerialization memberSerialization)
{
IList<JsonProperty> properties = base.CreateProperties(type, memberSerialization);
return properties.OrderBy(x=>x.PropertyName).ToList();
}
}
public class Class1
{
// HttpClient is intended to be instantiated once per application, rather than per-use. See Remarks.
static readonly HttpClient client = new HttpClient();
static string GetTimeStamp()
{
TimeSpan ts = DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0, 0);
return Convert.ToInt64(ts.TotalMilliseconds).ToString();
}
static string HmacMD5(string source, string key)
{
HMACMD5 hmacmd = new HMACMD5(Encoding.Default.GetBytes(key));
byte[] inArray = hmacmd.ComputeHash(Encoding.Default.GetBytes(source));
StringBuilder sb = new StringBuilder();
for (int i = 0; i < inArray.Length; i++)
{
sb.Append(inArray[i].ToString("X2"));
}
hmacmd.Clear();
return sb.ToString().ToLower();
}
static async Task Main()
{
// Call asynchronous network methods in a try/catch block to handle exceptions.
try
{
string uri = "https://api.bibox.com/v3.1/credit/borrowOrder/refund";
string apikey = "900625568558820892a8c833c33ebc8fd2701efe";
string secret = "c708ac3e70d115ec29efbee197330627d7edf842";
string timestamp = GetTimeStamp();
var myobj = new {
coin_symbol = "BTC",
pair = "BTC_USDT",
amount = "5.0036",
};
string payload = JsonConvert.SerializeObject(myobj, new JsonSerializerSettings { ContractResolver = new SortContractResolver() });
string source = timestamp + payload;
string sign = HmacMD5(source, secret);
Console.WriteLine(source);
Console.WriteLine(sign);
client.DefaultRequestHeaders.Add("bibox-api-key", apikey);
client.DefaultRequestHeaders.Add("bibox-api-sign", sign);
client.DefaultRequestHeaders.Add("bibox-timestamp", timestamp);
HttpContent content = new StringContent(payload, Encoding.UTF8, "application/json");
HttpResponseMessage response = await client.PostAsync(uri, content);
response.EnsureSuccessStatusCode();
string responseBody = await response.Content.ReadAsStringAsync();
Console.WriteLine(responseBody);
}
catch(HttpRequestException e)
{
Console.WriteLine("\nException Caught!");
Console.WriteLine("Message :{0} ",e.Message);
}
}
}
}
- 1.请求路径
POST https://api.bibox.com/v3.1/credit/borrowOrder/refund
- 2.请求参数
参数名称 | 是否必须 | 类型 | 描述 | 默认值 | 取值范围 |
---|---|---|---|---|---|
coin_symbol | true | string | 需要还款的币种 | EOS, BTC, USDT | |
pair | true | string | 需要还款的仓位 | BTC_USDT, *_USDT | |
amount | true | double | 还款数量 |
Response
{}
发布放贷单
示例
let CryptoJS = require("crypto-js");
let request = require("request");
let timestamp = Date.now(); // 1.当前时间戳
let param = {
"coin_symbol":"EOS",
"amount":"5",
"interest_rate":0.001,
"is_insurance":1,
"force":1
};
let strParam = JSON.stringify(param); // 2.格式化参数
let strToSign = '' + timestamp + strParam; // 3.这就是需要签名的字符串
let apikey = "900625568558820892a8c833c33ebc8fd2701efe"; //your apikey
let secret = "c708ac3e70d115ec29efbee197330627d7edf842"; //你的 apikey 密码
let sign = CryptoJS.HmacMD5(strToSign, secret).toString();//4.签名后的结果
let url = "https://api.bibox.com/v3.1/credit/lendOrderbook/publish";
request.post({
url: url,//请求路径
method: "POST",//请求方式
headers: {//5.设置请求头
'content-type': 'application/json',
'bibox-api-key': apikey,
'bibox-api-sign': sign,
'bibox-timestamp': timestamp
},
body: strParam // 6.格式化参数
},
function optionalCallback(err, httpResponse, body) {
if (err) {
return console.error('upload failed:', err);
}
console.log(body) // 7.返回值
});
# -*- coding:utf-8 -*-
import hashlib
import hmac
import json
import time
import requests
API_KEY = '900625568558820892a8c833c33ebc8fd2701efe'
SECRET_KEY = 'c708ac3e70d115ec29efbee197330627d7edf842'
BASE_URL = 'https://api.bibox.com' # 'https://api.bibox.tel' #
def do_sign(body):
timestamp = int(time.time()) * 1000
# to_sign = str(timestamp)+json.dumps(body,separators=(',',':'))
to_sign = str(timestamp) + json.dumps(body)
sign = hmac.new(SECRET_KEY.encode("utf-8"), to_sign.encode("utf-8"), hashlib.md5).hexdigest()
print(to_sign)
headers = {
'bibox-api-key': API_KEY,
'bibox-api-sign': sign,
'bibox-timestamp': str(timestamp)
}
return headers
def do_request():
path = '/v3.1/credit/lendOrderbook/publish'
body = {
"coin_symbol": "EOS",
"amount": "5",
"interest_rate": 0.001,
"is_insurance": 1,
"force": 1
}
headers = do_sign(body)
resp = requests.post(BASE_URL + path, json=body, headers=headers)
print(resp.text)
if __name__ == '__main__':
do_request()
using System;
using System.Net.Http;
using System.Text;
using System.Security.Cryptography;
using Newtonsoft.Json;
using Newtonsoft.Json.Serialization;
namespace ConsoleProgram
{
public class SortContractResolver : DefaultContractResolver
{
protected override IList<JsonProperty> CreateProperties(Type type, MemberSerialization memberSerialization)
{
IList<JsonProperty> properties = base.CreateProperties(type, memberSerialization);
return properties.OrderBy(x=>x.PropertyName).ToList();
}
}
public class Class1
{
// HttpClient is intended to be instantiated once per application, rather than per-use. See Remarks.
static readonly HttpClient client = new HttpClient();
static string GetTimeStamp()
{
TimeSpan ts = DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0, 0);
return Convert.ToInt64(ts.TotalMilliseconds).ToString();
}
static string HmacMD5(string source, string key)
{
HMACMD5 hmacmd = new HMACMD5(Encoding.Default.GetBytes(key));
byte[] inArray = hmacmd.ComputeHash(Encoding.Default.GetBytes(source));
StringBuilder sb = new StringBuilder();
for (int i = 0; i < inArray.Length; i++)
{
sb.Append(inArray[i].ToString("X2"));
}
hmacmd.Clear();
return sb.ToString().ToLower();
}
static async Task Main()
{
// Call asynchronous network methods in a try/catch block to handle exceptions.
try
{
string uri = "https://api.bibox.com/v3.1/credit/lendOrderbook/publish";
string apikey = "900625568558820892a8c833c33ebc8fd2701efe";
string secret = "c708ac3e70d115ec29efbee197330627d7edf842";
string timestamp = GetTimeStamp();
var myobj = new {
coin_symbol = "EOS",
amount = "5",
interest_rate = "0.001",
is_insurance = 1,
force = 1,
};
string payload = JsonConvert.SerializeObject(myobj, new JsonSerializerSettings { ContractResolver = new SortContractResolver() });
string source = timestamp + payload;
string sign = HmacMD5(source, secret);
Console.WriteLine(source);
Console.WriteLine(sign);
client.DefaultRequestHeaders.Add("bibox-api-key", apikey);
client.DefaultRequestHeaders.Add("bibox-api-sign", sign);
client.DefaultRequestHeaders.Add("bibox-timestamp", timestamp);
HttpContent content = new StringContent(payload, Encoding.UTF8, "application/json");
HttpResponseMessage response = await client.PostAsync(uri, content);
response.EnsureSuccessStatusCode();
string responseBody = await response.Content.ReadAsStringAsync();
Console.WriteLine(responseBody);
}
catch(HttpRequestException e)
{
Console.WriteLine("\nException Caught!");
Console.WriteLine("Message :{0} ",e.Message);
}
}
}
}
- 1.请求路径
POST https://api.bibox.com/v3.1/credit/lendOrderbook/publish
- 2.请求参数
参数名称 | 是否必须 | 类型 | 描述 | 默认值 | 取值范围 |
---|---|---|---|---|---|
coin_symbol | true | string | 交易币种 | USDT, EOS, ... | |
amount | true | double | 放款数量 | ||
interest_rate | true | double | 放款利率 | ||
is_insurance | true | integer | 是否开启保险 | 0或1 | |
force | true | integer | 1 |
Response
{}
撤销放贷单
示例
let CryptoJS = require("crypto-js");
let request = require("request");
let timestamp = Date.now(); // 1.当前时间戳
let param = {
"orderbook_id":9064
};
let strParam = JSON.stringify(param); // 2.格式化参数
let strToSign = '' + timestamp + strParam; // 3.这就是需要签名的字符串
let apikey = "900625568558820892a8c833c33ebc8fd2701efe"; //your apikey
let secret = "c708ac3e70d115ec29efbee197330627d7edf842"; //你的 apikey 密码
let sign = CryptoJS.HmacMD5(strToSign, secret).toString();//4.签名后的结果
let url = "https://api.bibox.com/v3.1/credit/lendOrderbook/cancel";
request.post({
url: url,//请求路径
method: "POST",//请求方式
headers: {//5.设置请求头
'content-type': 'application/json',
'bibox-api-key': apikey,
'bibox-api-sign': sign,
'bibox-timestamp': timestamp
},
body: strParam // 6.格式化参数
},
function optionalCallback(err, httpResponse, body) {
if (err) {
return console.error('upload failed:', err);
}
console.log(body) // 7.返回值
});
# -*- coding:utf-8 -*-
import hashlib
import hmac
import json
import time
import requests
API_KEY = '900625568558820892a8c833c33ebc8fd2701efe'
SECRET_KEY = 'c708ac3e70d115ec29efbee197330627d7edf842'
BASE_URL = 'https://api.bibox.com' # 'https://api.bibox.tel' #
def do_sign(body):
timestamp = int(time.time()) * 1000
# to_sign = str(timestamp)+json.dumps(body,separators=(',',':'))
to_sign = str(timestamp) + json.dumps(body)
sign = hmac.new(SECRET_KEY.encode("utf-8"), to_sign.encode("utf-8"), hashlib.md5).hexdigest()
print(to_sign)
headers = {
'bibox-api-key': API_KEY,
'bibox-api-sign': sign,
'bibox-timestamp': str(timestamp)
}
return headers
def do_request():
path = '/v3.1/credit/lendOrderbook/cancel'
body = {
"orderbook_id": 9064
}
headers = do_sign(body)
resp = requests.post(BASE_URL + path, json=body, headers=headers)
print(resp.text)
if __name__ == '__main__':
do_request()
using System;
using System.Net.Http;
using System.Text;
using System.Security.Cryptography;
using Newtonsoft.Json;
using Newtonsoft.Json.Serialization;
namespace ConsoleProgram
{
public class SortContractResolver : DefaultContractResolver
{
protected override IList<JsonProperty> CreateProperties(Type type, MemberSerialization memberSerialization)
{
IList<JsonProperty> properties = base.CreateProperties(type, memberSerialization);
return properties.OrderBy(x=>x.PropertyName).ToList();
}
}
public class Class1
{
// HttpClient is intended to be instantiated once per application, rather than per-use. See Remarks.
static readonly HttpClient client = new HttpClient();
static string GetTimeStamp()
{
TimeSpan ts = DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0, 0);
return Convert.ToInt64(ts.TotalMilliseconds).ToString();
}
static string HmacMD5(string source, string key)
{
HMACMD5 hmacmd = new HMACMD5(Encoding.Default.GetBytes(key));
byte[] inArray = hmacmd.ComputeHash(Encoding.Default.GetBytes(source));
StringBuilder sb = new StringBuilder();
for (int i = 0; i < inArray.Length; i++)
{
sb.Append(inArray[i].ToString("X2"));
}
hmacmd.Clear();
return sb.ToString().ToLower();
}
static async Task Main()
{
// Call asynchronous network methods in a try/catch block to handle exceptions.
try
{
string uri = "https://api.bibox.com/v3.1/credit/lendOrderbook/cancel";
string apikey = "900625568558820892a8c833c33ebc8fd2701efe";
string secret = "c708ac3e70d115ec29efbee197330627d7edf842";
string timestamp = GetTimeStamp();
var myobj = new {
orderbook_id = "9064",
};
string payload = JsonConvert.SerializeObject(myobj, new JsonSerializerSettings { ContractResolver = new SortContractResolver() });
string source = timestamp + payload;
string sign = HmacMD5(source, secret);
Console.WriteLine(source);
Console.WriteLine(sign);
client.DefaultRequestHeaders.Add("bibox-api-key", apikey);
client.DefaultRequestHeaders.Add("bibox-api-sign", sign);
client.DefaultRequestHeaders.Add("bibox-timestamp", timestamp);
HttpContent content = new StringContent(payload, Encoding.UTF8, "application/json");
HttpResponseMessage response = await client.PostAsync(uri, content);
response.EnsureSuccessStatusCode();
string responseBody = await response.Content.ReadAsStringAsync();
Console.WriteLine(responseBody);
}
catch(HttpRequestException e)
{
Console.WriteLine("\nException Caught!");
Console.WriteLine("Message :{0} ",e.Message);
}
}
}
}
- 1.请求路径
POST https://api.bibox.com/v3.1/credit/lendOrderbook/cancel
- 2.请求参数
参数名称 | 是否必须 | 类型 | 描述 | 默认值 | 取值范围 |
---|---|---|---|---|---|
orderbook_id | true | integer | 订单id |
Response
{}
信用账户下单
示例
let CryptoJS = require("crypto-js");
let request = require("request");
let timestamp = Date.now(); // 1.当前时间戳
let param = {
"account_type":1,
"pair":"BTC_USDT",
"order_type":2,
"price":"100",
"amount":"1",
"money":"100.0000",
"order_side":1
};
let strParam = JSON.stringify(param); // 2.格式化参数
let strToSign = '' + timestamp + strParam; // 3.这就是需要签名的字符串
let apikey = "900625568558820892a8c833c33ebc8fd2701efe"; //your apikey
let secret = "c708ac3e70d115ec29efbee197330627d7edf842"; //你的 apikey 密码
let sign = CryptoJS.HmacMD5(strToSign, secret).toString();//4.签名后的结果
let url = "https://api.bibox.com/v3.1/credit/trade/trade";
request.post({
url: url,//请求路径
method: "POST",//请求方式
headers: {//5.设置请求头
'content-type': 'application/json',
'bibox-api-key': apikey,
'bibox-api-sign': sign,
'bibox-timestamp': timestamp
},
body: strParam // 6.格式化参数
},
function optionalCallback(err, httpResponse, body) {
if (err) {
return console.error('upload failed:', err);
}
console.log(body) // 7.返回值
});
# -*- coding:utf-8 -*-
import hashlib
import hmac
import json
import time
import requests
API_KEY = '900625568558820892a8c833c33ebc8fd2701efe'
SECRET_KEY = 'c708ac3e70d115ec29efbee197330627d7edf842'
BASE_URL = 'https://api.bibox.com' # 'https://api.bibox.tel' #
def do_sign(body):
timestamp = int(time.time()) * 1000
# to_sign = str(timestamp)+json.dumps(body,separators=(',',':'))
to_sign = str(timestamp) + json.dumps(body)
sign = hmac.new(SECRET_KEY.encode("utf-8"), to_sign.encode("utf-8"), hashlib.md5).hexdigest()
print(to_sign)
headers = {
'bibox-api-key': API_KEY,
'bibox-api-sign': sign,
'bibox-timestamp': str(timestamp)
}
return headers
def do_request():
path = '/v3.1/credit/trade/trade'
body = {
"account_type": 1,
"pair": "BTC_USDT",
"order_type": 2,
"price": "100",
"amount": "1",
"money": "100.0000",
"order_side": 1
}
headers = do_sign(body)
resp = requests.post(BASE_URL + path, json=body, headers=headers)
print(resp.text)
if __name__ == '__main__':
do_request()
using System;
using System.Net.Http;
using System.Text;
using System.Security.Cryptography;
using Newtonsoft.Json;
using Newtonsoft.Json.Serialization;
namespace ConsoleProgram
{
public class SortContractResolver : DefaultContractResolver
{
protected override IList<JsonProperty> CreateProperties(Type type, MemberSerialization memberSerialization)
{
IList<JsonProperty> properties = base.CreateProperties(type, memberSerialization);
return properties.OrderBy(x=>x.PropertyName).ToList();
}
}
public class Class1
{
// HttpClient is intended to be instantiated once per application, rather than per-use. See Remarks.
static readonly HttpClient client = new HttpClient();
static string GetTimeStamp()
{
TimeSpan ts = DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0, 0);
return Convert.ToInt64(ts.TotalMilliseconds).ToString();
}
static string HmacMD5(string source, string key)
{
HMACMD5 hmacmd = new HMACMD5(Encoding.Default.GetBytes(key));
byte[] inArray = hmacmd.ComputeHash(Encoding.Default.GetBytes(source));
StringBuilder sb = new StringBuilder();
for (int i = 0; i < inArray.Length; i++)
{
sb.Append(inArray[i].ToString("X2"));
}
hmacmd.Clear();
return sb.ToString().ToLower();
}
static async Task Main()
{
// Call asynchronous network methods in a try/catch block to handle exceptions.
try
{
string uri = "https://api.bibox.com/v3.1/credit/trade/trade";
string apikey = "900625568558820892a8c833c33ebc8fd2701efe";
string secret = "c708ac3e70d115ec29efbee197330627d7edf842";
string timestamp = GetTimeStamp();
var myobj = new {
account_type = 1,
pair = "BTC_USDT",
order_type = 2,
price = "100",
amount = "1",
money = "100.0000",
order_side = 1,
};
string payload = JsonConvert.SerializeObject(myobj, new JsonSerializerSettings { ContractResolver = new SortContractResolver() });
string source = timestamp + payload;
string sign = HmacMD5(source, secret);
Console.WriteLine(source);
Console.WriteLine(sign);
client.DefaultRequestHeaders.Add("bibox-api-key", apikey);
client.DefaultRequestHeaders.Add("bibox-api-sign", sign);
client.DefaultRequestHeaders.Add("bibox-timestamp", timestamp);
HttpContent content = new StringContent(payload, Encoding.UTF8, "application/json");
HttpResponseMessage response = await client.PostAsync(uri, content);
response.EnsureSuccessStatusCode();
string responseBody = await response.Content.ReadAsStringAsync();
Console.WriteLine(responseBody);
}
catch(HttpRequestException e)
{
Console.WriteLine("\nException Caught!");
Console.WriteLine("Message :{0} ",e.Message);
}
}
}
}
- 1.请求路径
POST https://api.bibox.com/v3.1/credit/trade/trade
- 2.请求参数
参数名称 | 是否必须 | 类型 | 描述 | 默认值 | 取值范围 |
---|---|---|---|---|---|
pair | string | 交易对 | |||
account_type | integer | 账户类型 1-逐仓账户 257-全仓账户 | |||
order_type | integer | 交易类型 2-限价单 | |||
order_side | integer | 交易方向 1-买,2-卖 | |||
price | string | 委托价格 最小值 0.00000001 | |||
amount | string | 委托数量 最小值 0.0001 | |||
money | string | 委托金额 |
Response
{}
- 3.返回字段
名称 | 描述 |
---|---|
orders_id | 订单id |
信用账户撤单
示例
let CryptoJS = require("crypto-js");
let request = require("request");
let timestamp = Date.now(); // 1.当前时间戳
let param = {
"orders_id": "4631142976192513" //委托单id
};
let strParam = JSON.stringify(param); // 2.格式化参数
let strToSign = '' + timestamp + strParam; // 3.这就是需要签名的字符串
let apikey = "900625568558820892a8c833c33ebc8fd2701efe"; //your apikey
let secret = "c708ac3e70d115ec29efbee197330627d7edf842"; //你的 apikey 密码
let sign = CryptoJS.HmacMD5(strToSign, secret).toString();//4.签名后的结果
let url = "https://api.bibox.com/v3.1/credit/trade/cancel";
request.post({
url: url,//请求路径
method: "POST",//请求方式
headers: {//5.设置请求头
'content-type': 'application/json',
'bibox-api-key': apikey,
'bibox-api-sign': sign,
'bibox-timestamp': timestamp
},
body: strParam // 6.格式化参数
},
function optionalCallback(err, httpResponse, body) {
if (err) {
return console.error('upload failed:', err);
}
console.log(body) // 7.返回值
});
# -*- coding:utf-8 -*-
import hashlib
import hmac
import json
import time
import requests
API_KEY = '900625568558820892a8c833c33ebc8fd2701efe'
SECRET_KEY = 'c708ac3e70d115ec29efbee197330627d7edf842'
BASE_URL = 'https://api.bibox.com' # 'https://api.bibox.tel' #
def do_sign(body):
timestamp = int(time.time()) * 1000
# to_sign = str(timestamp)+json.dumps(body,separators=(',',':'))
to_sign = str(timestamp) + json.dumps(body)
sign = hmac.new(SECRET_KEY.encode("utf-8"), to_sign.encode("utf-8"), hashlib.md5).hexdigest()
print(to_sign)
headers = {
'bibox-api-key': API_KEY,
'bibox-api-sign': sign,
'bibox-timestamp': str(timestamp)
}
return headers
def do_request():
path = '/v3.1/credit/trade/cancel'
body = {
"orders_id": "4631142976192513"
}
headers = do_sign(body)
resp = requests.post(BASE_URL + path, json=body, headers=headers)
print(resp.text)
if __name__ == '__main__':
do_request()
using System;
using System.Net.Http;
using System.Text;
using System.Security.Cryptography;
using Newtonsoft.Json;
using Newtonsoft.Json.Serialization;
namespace ConsoleProgram
{
public class SortContractResolver : DefaultContractResolver
{
protected override IList<JsonProperty> CreateProperties(Type type, MemberSerialization memberSerialization)
{
IList<JsonProperty> properties = base.CreateProperties(type, memberSerialization);
return properties.OrderBy(x=>x.PropertyName).ToList();
}
}
public class Class1
{
// HttpClient is intended to be instantiated once per application, rather than per-use. See Remarks.
static readonly HttpClient client = new HttpClient();
static string GetTimeStamp()
{
TimeSpan ts = DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0, 0);
return Convert.ToInt64(ts.TotalMilliseconds).ToString();
}
static string HmacMD5(string source, string key)
{
HMACMD5 hmacmd = new HMACMD5(Encoding.Default.GetBytes(key));
byte[] inArray = hmacmd.ComputeHash(Encoding.Default.GetBytes(source));
StringBuilder sb = new StringBuilder();
for (int i = 0; i < inArray.Length; i++)
{
sb.Append(inArray[i].ToString("X2"));
}
hmacmd.Clear();
return sb.ToString().ToLower();
}
static async Task Main()
{
// Call asynchronous network methods in a try/catch block to handle exceptions.
try
{
string uri = "https://api.bibox.com/v3.1/credit/trade/cancel";
string apikey = "900625568558820892a8c833c33ebc8fd2701efe";
string secret = "c708ac3e70d115ec29efbee197330627d7edf842";
string timestamp = GetTimeStamp();
var myobj = new {
orders_id = "4631142976192513",
};
string payload = JsonConvert.SerializeObject(myobj, new JsonSerializerSettings { ContractResolver = new SortContractResolver() });
string source = timestamp + payload;
string sign = HmacMD5(source, secret);
Console.WriteLine(source);
Console.WriteLine(sign);
client.DefaultRequestHeaders.Add("bibox-api-key", apikey);
client.DefaultRequestHeaders.Add("bibox-api-sign", sign);
client.DefaultRequestHeaders.Add("bibox-timestamp", timestamp);
HttpContent content = new StringContent(payload, Encoding.UTF8, "application/json");
HttpResponseMessage response = await client.PostAsync(uri, content);
response.EnsureSuccessStatusCode();
string responseBody = await response.Content.ReadAsStringAsync();
Console.WriteLine(responseBody);
}
catch(HttpRequestException e)
{
Console.WriteLine("\nException Caught!");
Console.WriteLine("Message :{0} ",e.Message);
}
}
}
}
- 1.请求路径
POST https://api.bibox.com/v3.1/credit/trade/cancel
- 2.请求参数
参数名称 | 是否必须 | 类型 | 描述 | 默认值 | 取值范围 |
---|---|---|---|---|---|
orders_id | true | string | 委托单id |
Response
{}
查询杠杆账单
- 1.请求路径
POST https://api.bibox.com/v3.1/transfer/bills
- 2.请求参数
参数名称 | 是否必须 | 类型 | 描述 | 默认值 | 取值范围 |
---|---|---|---|---|---|
account_type | true | integer | 0钱包账户 1杠杆账户 | 1 | |
page | true | integer | 第几页 | 1,2,... | |
size | true | integer | 多少条 | 1,2,... | |
begin_time | false | integer | 开始时间 | ||
end_time | false | integer | 结束时间 | ||
type | false | integer | 账单类型 | 21钱包转杠杆, 22杠杆转钱包, 3卖, 5买, 10借贷, 15还款 |
Response
{
"result":{
"count":11,
"page":1,
"items":[
{
"id":"1125899906850284004",
"coin_symbol":"USDT",
"bill_type":12,
"comment":"",
"change_amount":"6.9553",
"change_result":"182461.2621",
"createdAt":"2020-11-23T00:00:00.000Z",
"updatedAt":"2020-11-23T00:00:00.000Z"
},
]
}
}
- 3.返回字段
名称 | 描述 |
---|---|
id | 账单id |
coin_symbol | 币种符号 |
bill_type | 账单类型 |
comment | 账单描述 |
change_amount | 资产改变量 |
change_result | 资产改变结果 |
createdAt | 账单时间 |
其它字段 | 忽略 |
WebSocket
订阅 Kline 数据
完整例子
'use strict'
const WebSocket = require('ws');
const zlib = require('zlib');
const biboxws = 'wss://npush.bibox360.com';
let wsClass = function () {
};
wsClass.prototype._decodeMsg = function (data) {
let data1 = data.slice(1, data.length);
zlib.unzip(data1, (err, buffer) => {
if (err) {
console.log(err);
} else {
try {
let res = JSON.parse(buffer.toString());
console.log(new Date(), buffer.toString());
} catch (e) {
console.log(e);
}
}
});
};
wsClass.prototype._initWs = async function () {
let that = this;
console.log(biboxws)
let ws = new WebSocket(biboxws);
that.ws = ws;
ws.on('open', function open() {
console.log(new Date(), 'open')
ws.send(JSON.stringify({
sub: 'BTC_USDT_kline_1min',
}));
});
ws.on('close', err => {
console.log('close, ', err);
});
ws.on('error', err => {
console.log('error', err);
});
ws.on('ping', err => {
console.log('ping ', err.toString('utf8'));
});
ws.on('pong', err => {
console.log('pong ', err.toString('utf8'));
});
ws.on('message', data => {
if (data[0] == '1') {
that._decodeMsg(data);
} else if (data[0] == '0') {
console.log(1, new Date(), JSON.parse(data.slice(1)));
} else {
console.log(2, new Date(), data);
}
});
};
let instance = new wsClass();
instance._initWs().catch(err => {
console.log(err);
});
# /usr/bin/env python
# -*- coding: UTF-8 -*-
import websocket # websocket-client
import json
import zlib
ws_url = 'wss://npush.bibox360.com'
def stringify(obj):
return json.dumps(obj, sort_keys=True).replace("\'", "\"").replace(" ", "")
def get_sub_str():
subdata = {
'sub': 'BTC_USDT_kline_1min',
}
# print(stringify(subdata))
return stringify(subdata)
def get_unsub_str():
subdata = {
'unsub': 'BTC_USDT_kline_1min',
}
return stringify(subdata)
def decode_data(message):
if message[0] == '\x01' or message[0] == 1:
message = message[1:]
data = zlib.decompress(message, zlib.MAX_WBITS | 32)
jmsgs = json.loads(data)
print(jmsgs)
print(type(jmsgs))
elif message[0] == '\x00' or message[0] == 0:
message = message[1:]
jmsgs = json.loads(message)
print(jmsgs)
print(type(jmsgs))
else:
jmsgs = json.loads(message)
print(jmsgs)
print(type(jmsgs))
def on_message(ws, message):
# print(message)
decode_data(message)
def on_error(ws, error):
print(error)
def on_close(ws):
print("### closed ###")
def on_open(ws):
ws.send(get_sub_str())
def connect():
websocket.enableTrace(True)
ws = websocket.WebSocketApp(ws_url,
on_message=on_message,
on_error=on_error,
on_close=on_close)
ws.on_open = on_open
ws.run_forever(ping_interval=30, ping_timeout=5)
if __name__ == "__main__":
connect()
using System;
using WebSocketSharp;
using System.Net.Http;
using System.Text;
using System.IO.Compression;
using System.Security.Cryptography;
using Newtonsoft.Json;
using Newtonsoft.Json.Serialization;
namespace Example
{
public class SortContractResolver : DefaultContractResolver
{
protected override IList<JsonProperty> CreateProperties(Type type, MemberSerialization memberSerialization)
{
IList<JsonProperty> properties = base.CreateProperties(type, memberSerialization);
return properties.OrderBy(x=>x.PropertyName).ToList();
}
}
public class Program
{
public static string Decompress(byte[] bytes)
{
MemoryStream msIn = new MemoryStream(bytes, 1, bytes.Length - 1);
MemoryStream msOut = new MemoryStream();
GZipStream cprs = new GZipStream(msIn, CompressionMode.Decompress);
cprs.CopyTo(msOut);
cprs.Close();
return Encoding.ASCII.GetString(msOut.ToArray());//转换为普通的字符串
}
public static void Main (string[] args)
{
string wsuri = "wss://npush.bibox360.com";
using (var ws = new WebSocket (wsuri)) {
ws.OnMessage += (sender, e) => {
Console.WriteLine ("recv: " + e.Data);
if (e.IsText) {
Console.WriteLine ("data[0]: {");
} else if (e.IsBinary) {
if (e.RawData[0] == 1) {
Console.WriteLine ("RawData[0]: 1");
string strres = Decompress(e.RawData);
Console.WriteLine (strres);
} else if (e.RawData[0] == 0) {
Console.WriteLine ("RawData[0]: 0");
string strres = Encoding.ASCII.GetString(e.RawData);
Console.WriteLine (strres);
}
}
};
ws.Connect ();
var myobj = new {
sub = "BTC_USDT_kline_1min",
};
string payload = JsonConvert.SerializeObject(myobj, new JsonSerializerSettings { ContractResolver = new SortContractResolver() });
ws.Send (payload);
ConsoleKey key;
do
{
key=Console.ReadKey().Key;
} while (key != ConsoleKey.Q);
}
}
}
}
- 1.订阅路径
wss://npush.bibox360.com
- 2.请求参数
参数名称 | 是否必须 | 类型 | 描述 | 默认值 | 取值范围 |
---|---|---|---|---|---|
pair | true | string | 交易对 | 交易对,BTC_USDT, ETH_USDT | |
period | true | string | K线周期 | 1min, 5min, 15min, 30min, 1hour, 2hour, 4hour, 6hour, 12hour, day, week | |
sub | true | string | ${pair} + '_kline_' + ${period} |
Response
{
"topic":"BTC_USDT_kline_1min",
"t":1,
"d":[
[
"1646705760000",
"38337.1",
"38356.0",
"38303.5",
"38309.2",
"2.180836"
],
[
"1646705820000",
"38309.1",
"38356.6",
"38309.1",
"38355.3",
"2.103583"
]
]
}
- 3.返回字段
[ k线某周期开始时间, 开盘价, 最高价, 最低价, 收盘价, 成交量 ]
订阅 Market 数据
完整例子
'use strict'
const WebSocket = require('ws');
const zlib = require('zlib');
const biboxws = 'wss://npush.bibox360.com';
let wsClass = function () {
};
wsClass.prototype._decodeMsg = function (data) {
let data1 = data.slice(1, data.length);
zlib.unzip(data1, (err, buffer) => {
if (err) {
console.log(err);
} else {
try {
let res = JSON.parse(buffer.toString());
console.log(new Date(), buffer.toString());
} catch (e) {
console.log(e);
}
}
});
};
wsClass.prototype._initWs = async function () {
let that = this;
console.log(biboxws)
let ws = new WebSocket(biboxws);
that.ws = ws;
ws.on('open', function open() {
console.log(new Date(), 'open')
ws.send(JSON.stringify({
sub: 'ALL_ALL_market',
}));
});
ws.on('close', err => {
console.log('close, ', err);
});
ws.on('error', err => {
console.log('error', err);
});
ws.on('ping', err => {
console.log('ping ', err.toString('utf8'));
});
ws.on('pong', err => {
console.log('pong ', err.toString('utf8'));
});
ws.on('message', data => {
if (data[0] == '1') {
that._decodeMsg(data);
} else if (data[0] == '0') {
console.log(1, new Date(), JSON.parse(data.slice(1)));
} else {
console.log(2, new Date(), data);
}
});
};
let instance = new wsClass();
instance._initWs().catch(err => {
console.log(err);
});
# /usr/bin/env python
# -*- coding: UTF-8 -*-
import websocket # websocket-client
import json
import zlib
ws_url = 'wss://npush.bibox360.com'
def stringify(obj):
return json.dumps(obj, sort_keys=True).replace("\'", "\"").replace(" ", "")
def get_sub_str():
subdata = {
'sub': 'ALL_ALL_market',
}
# print(stringify(subdata))
return stringify(subdata)
def get_unsub_str():
subdata = {
'unsub': 'ALL_ALL_market',
}
return stringify(subdata)
def decode_data(message):
if message[0] == '\x01' or message[0] == 1:
message = message[1:]
data = zlib.decompress(message, zlib.MAX_WBITS | 32)
jmsgs = json.loads(data)
print(jmsgs)
print(type(jmsgs))
elif message[0] == '\x00' or message[0] == 0:
message = message[1:]
jmsgs = json.loads(message)
print(jmsgs)
print(type(jmsgs))
else:
jmsgs = json.loads(message)
print(jmsgs)
print(type(jmsgs))
def on_message(ws, message):
# print(message)
decode_data(message)
def on_error(ws, error):
print(error)
def on_close(ws):
print("### closed ###")
def on_open(ws):
ws.send(get_sub_str())
def connect():
websocket.enableTrace(True)
ws = websocket.WebSocketApp(ws_url,
on_message=on_message,
on_error=on_error,
on_close=on_close)
ws.on_open = on_open
ws.run_forever(ping_interval=30, ping_timeout=5)
if __name__ == "__main__":
connect()
using System;
using WebSocketSharp;
using System.Net.Http;
using System.Text;
using System.IO.Compression;
using System.Security.Cryptography;
using Newtonsoft.Json;
using Newtonsoft.Json.Serialization;
namespace Example
{
public class SortContractResolver : DefaultContractResolver
{
protected override IList<JsonProperty> CreateProperties(Type type, MemberSerialization memberSerialization)
{
IList<JsonProperty> properties = base.CreateProperties(type, memberSerialization);
return properties.OrderBy(x=>x.PropertyName).ToList();
}
}
public class Program
{
public static string Decompress(byte[] bytes)
{
MemoryStream msIn = new MemoryStream(bytes, 1, bytes.Length - 1);
MemoryStream msOut = new MemoryStream();
GZipStream cprs = new GZipStream(msIn, CompressionMode.Decompress);
cprs.CopyTo(msOut);
cprs.Close();
return Encoding.ASCII.GetString(msOut.ToArray());//转换为普通的字符串
}
public static void Main (string[] args)
{
string wsuri = "wss://npush.bibox360.com";
using (var ws = new WebSocket (wsuri)) {
ws.OnMessage += (sender, e) => {
Console.WriteLine ("recv: " + e.Data);
if (e.IsText) {
Console.WriteLine ("data[0]: {");
} else if (e.IsBinary) {
if (e.RawData[0] == 1) {
Console.WriteLine ("RawData[0]: 1");
string strres = Decompress(e.RawData);
Console.WriteLine (strres);
} else if (e.RawData[0] == 0) {
Console.WriteLine ("RawData[0]: 0");
string strres = Encoding.ASCII.GetString(e.RawData);
Console.WriteLine (strres);
}
}
};
ws.Connect ();
var myobj = new {
sub = "ALL_ALL_market",
};
string payload = JsonConvert.SerializeObject(myobj, new JsonSerializerSettings { ContractResolver = new SortContractResolver() });
ws.Send (payload);
ConsoleKey key;
do
{
key=Console.ReadKey().Key;
} while (key != ConsoleKey.Q);
}
}
}
}
- 1.订阅路径
wss://npush.bibox360.com
- 2.请求参数
参数名称 | 是否必须 | 类型 | 描述 | 默认值 | 取值范围 |
---|---|---|---|---|---|
sub | true | String | 'ALL_ALL_market' |
Response
{
"topic":"ALL_ALL_market",
"t":1,
"d":[
[
"858",
"0",
"1",
"15",
"AXS",
"USDT",
"46.670500",
"50.185800",
"45.701500",
"-0.768700",
"-1.62%",
"51042",
"2416310.31"
],
[
"100",
"0",
"0",
"8",
"CPC",
"ETH",
"0.00000210",
"0.00000211",
"0.00000173",
"+0.00000000",
"+0.00%",
"12173798",
"25.48"
]
]
}
- 3.返回字段
[ 交易对id, 忽略, 忽略, 忽略, 交易币种, 定价币种, 24h最新价, 24h最高价, 24h最低价, 24h涨跌, 24h涨跌幅, 24h成交量, 24h成交额, ]
订阅 Depth 数据
完整例子
'use strict'
const WebSocket = require('ws');
const zlib = require('zlib');
const biboxws = 'wss://npush.bibox360.com';
let wsClass = function () {
};
wsClass.prototype._decodeMsg = function (data) {
let data1 = data.slice(1, data.length);
zlib.unzip(data1, (err, buffer) => {
if (err) {
console.log(err);
} else {
try {
let res = JSON.parse(buffer.toString());
console.log(new Date(), buffer.toString());
} catch (e) {
console.log(e);
}
}
});
};
wsClass.prototype._initWs = async function () {
let that = this;
console.log(biboxws)
let ws = new WebSocket(biboxws);
that.ws = ws;
ws.on('open', function open() {
console.log(new Date(), 'open')
ws.send(JSON.stringify({
sub: 'BIX_BTC_depth',
}));
});
ws.on('close', err => {
console.log('close, ', err);
});
ws.on('error', err => {
console.log('error', err);
});
ws.on('ping', err => {
console.log('ping ', err.toString('utf8'));
});
ws.on('pong', err => {
console.log('pong ', err.toString('utf8'));
});
ws.on('message', data => {
if (data[0] == '1') {
that._decodeMsg(data);
} else if (data[0] == '0') {
console.log(1, new Date(), JSON.parse(data.slice(1)));
} else {
console.log(2, new Date(), data);
}
});
};
let instance = new wsClass();
instance._initWs().catch(err => {
console.log(err);
});
# /usr/bin/env python
# -*- coding: UTF-8 -*-
import websocket # websocket-client
import json
import zlib
ws_url = 'wss://npush.bibox360.com'
def stringify(obj):
return json.dumps(obj, sort_keys=True).replace("\'", "\"").replace(" ", "")
def get_sub_str():
subdata = {
'sub': 'BTC_USDT_depth',
}
# print(stringify(subdata))
return stringify(subdata)
def get_unsub_str():
subdata = {
'unsub': 'BTC_USDT_depth',
}
return stringify(subdata)
def decode_data(message):
if message[0] == '\x01' or message[0] == 1:
message = message[1:]
data = zlib.decompress(message, zlib.MAX_WBITS | 32)
jmsgs = json.loads(data)
print(jmsgs)
print(type(jmsgs))
elif message[0] == '\x00' or message[0] == 0:
message = message[1:]
jmsgs = json.loads(message)
print(jmsgs)
print(type(jmsgs))
else:
jmsgs = json.loads(message)
print(jmsgs)
print(type(jmsgs))
def on_message(ws, message):
# print(message)
decode_data(message)
def on_error(ws, error):
print(error)
def on_close(ws):
print("### closed ###")
def on_open(ws):
ws.send(get_sub_str())
def connect():
websocket.enableTrace(True)
ws = websocket.WebSocketApp(ws_url,
on_message=on_message,
on_error=on_error,
on_close=on_close)
ws.on_open = on_open
ws.run_forever(ping_interval=30, ping_timeout=5)
if __name__ == "__main__":
connect()
using System;
using WebSocketSharp;
using System.Net.Http;
using System.Text;
using System.IO.Compression;
using System.Security.Cryptography;
using Newtonsoft.Json;
using Newtonsoft.Json.Serialization;
namespace Example
{
public class SortContractResolver : DefaultContractResolver
{
protected override IList<JsonProperty> CreateProperties(Type type, MemberSerialization memberSerialization)
{
IList<JsonProperty> properties = base.CreateProperties(type, memberSerialization);
return properties.OrderBy(x=>x.PropertyName).ToList();
}
}
public class Program
{
public static string Decompress(byte[] bytes)
{
MemoryStream msIn = new MemoryStream(bytes, 1, bytes.Length - 1);
MemoryStream msOut = new MemoryStream();
GZipStream cprs = new GZipStream(msIn, CompressionMode.Decompress);
cprs.CopyTo(msOut);
cprs.Close();
return Encoding.ASCII.GetString(msOut.ToArray());//转换为普通的字符串
}
public static void Main (string[] args)
{
string wsuri = "wss://npush.bibox360.com";
using (var ws = new WebSocket (wsuri)) {
ws.OnMessage += (sender, e) => {
Console.WriteLine ("recv: " + e.Data);
if (e.IsText) {
Console.WriteLine ("data[0]: {");
} else if (e.IsBinary) {
if (e.RawData[0] == 1) {
Console.WriteLine ("RawData[0]: 1");
string strres = Decompress(e.RawData);
Console.WriteLine (strres);
} else if (e.RawData[0] == 0) {
Console.WriteLine ("RawData[0]: 0");
string strres = Encoding.ASCII.GetString(e.RawData);
Console.WriteLine (strres);
}
}
};
ws.Connect ();
var myobj = new {
sub = "BTC_USDT_depth",
};
string payload = JsonConvert.SerializeObject(myobj, new JsonSerializerSettings { ContractResolver = new SortContractResolver() });
ws.Send (payload);
ConsoleKey key;
do
{
key=Console.ReadKey().Key;
} while (key != ConsoleKey.Q);
}
}
}
}
- 1.订阅路径
wss://npush.bibox360.com
- 2.请求参数
参数名称 | 是否必须 | 类型 | 描述 | 默认值 | 取值范围 |
---|---|---|---|---|---|
pair | true | string | 交易对 | BIX_BTC, BIX_ETH, BTC_USDT, ETH_USDT...... | |
sub | true | string | ${pair} + '_depth' |
Response
{
"topic":"BIX_USDT_depth",
"t":1,
"d":{
"pair":"BIX_USDT",
"ut":1646708795071,
"seq":2794,
"add":{
"asks":[
[
"3957.61",
"0.040961"
]
],
"bids":[
[
"7468.53",
"0.040438"
],
[
"10605.08",
"0.040273"
]
]
},
"del":{
"asks":[
[
"9326.05",
"0.041173"
]
],
"bids":[
[
"1309.51",
"0.040411"
]
]
}
}
}
- 3.返回字段
名称 | 描述 |
---|---|
state | 0代表成功,否则代表失败 |
t | 0代表全量,1代表增量 |
pair | 交易对 |
update_time | 时间戳 |
asks | 卖方深度 |
bids | 买方深度 |
price | 委托价格 |
volume | 委托数量 |
其它字段 | 忽略 |
订阅 Deals 数据
完整例子
const WebSocket = require('ws');
const zlib = require('zlib');
const biboxws = 'wss://npush.bibox360.com';
let wsClass = function () {
};
wsClass.prototype._decodeMsg = function (data) {
let data1 = data.slice(1, data.length);
zlib.unzip(data1, (err, buffer) => {
if (err) {
console.log(err);
} else {
try {
let res = JSON.parse(buffer.toString());
console.log(3, new Date(), buffer.toString());
} catch (e) {
console.log(e);
}
}
});
};
wsClass.prototype._initWs = async function () {
let that = this;
console.log(biboxws)
let ws = new WebSocket(biboxws);
that.ws = ws;
ws.on('open', function open() {
console.log(new Date(), 'open')
{// kline
ws.send(JSON.stringify({
event: 'addChannel',
sub: 'BTC_USDT_deals',
}));
}
});
ws.on('close', err => {
console.log('close, ', err);
});
ws.on('error', err => {
console.log('error', err);
});
ws.on('ping', err => {
console.log('ping ', err.toString('utf8'));
});
ws.on('pong', err => {
console.log('pong ', err.toString('utf8'));
});
ws.on('message', data => {
if (data[0] == '1') {
that._decodeMsg(data);
} else if (data[0] == '0') {
console.log(1, new Date(), JSON.parse(data.slice(1)));
} else {
console.log(2, new Date(), data);
}
});
};
let instance = new wsClass();
instance._initWs().catch(err => {
console.log(err);
});
# /usr/bin/env python
# -*- coding: UTF-8 -*-
import websocket # websocket-client
import json
import zlib
ws_url = 'wss://npush.bibox360.com'
def stringify(obj):
return json.dumps(obj, sort_keys=True).replace("\'", "\"").replace(" ", "")
def get_sub_str():
subdata = {
'sub': 'BTC_USDT_deals',
}
# print(stringify(subdata))
return stringify(subdata)
def get_unsub_str():
subdata = {
'unsub': 'BTC_USDT_deals',
}
return stringify(subdata)
def decode_data(message):
if message[0] == '\x01' or message[0] == 1:
message = message[1:]
data = zlib.decompress(message, zlib.MAX_WBITS | 32)
jmsgs = json.loads(data)
print(jmsgs)
print(type(jmsgs))
elif message[0] == '\x00' or message[0] == 0:
message = message[1:]
jmsgs = json.loads(message)
print(jmsgs)
print(type(jmsgs))
else:
jmsgs = json.loads(message)
print(jmsgs)
print(type(jmsgs))
def on_message(ws, message):
# print(message)
decode_data(message)
def on_error(ws, error):
print(error)
def on_close(ws):
print("### closed ###")
def on_open(ws):
ws.send(get_sub_str())
def connect():
websocket.enableTrace(True)
ws = websocket.WebSocketApp(ws_url,
on_message=on_message,
on_error=on_error,
on_close=on_close)
ws.on_open = on_open
ws.run_forever(ping_interval=30, ping_timeout=5)
if __name__ == "__main__":
connect()
using System;
using WebSocketSharp;
using System.Net.Http;
using System.Text;
using System.IO.Compression;
using System.Security.Cryptography;
using Newtonsoft.Json;
using Newtonsoft.Json.Serialization;
namespace Example
{
public class SortContractResolver : DefaultContractResolver
{
protected override IList<JsonProperty> CreateProperties(Type type, MemberSerialization memberSerialization)
{
IList<JsonProperty> properties = base.CreateProperties(type, memberSerialization);
return properties.OrderBy(x=>x.PropertyName).ToList();
}
}
public class Program
{
public static string Decompress(byte[] bytes)
{
MemoryStream msIn = new MemoryStream(bytes, 1, bytes.Length - 1);
MemoryStream msOut = new MemoryStream();
GZipStream cprs = new GZipStream(msIn, CompressionMode.Decompress);
cprs.CopyTo(msOut);
cprs.Close();
return Encoding.ASCII.GetString(msOut.ToArray());//转换为普通的字符串
}
public static void Main (string[] args)
{
string wsuri = "wss://npush.bibox360.com";
using (var ws = new WebSocket (wsuri)) {
ws.OnMessage += (sender, e) => {
Console.WriteLine ("recv: " + e.Data);
if (e.IsText) {
Console.WriteLine ("data[0]: {");
} else if (e.IsBinary) {
if (e.RawData[0] == 1) {
Console.WriteLine ("RawData[0]: 1");
string strres = Decompress(e.RawData);
Console.WriteLine (strres);
} else if (e.RawData[0] == 0) {
Console.WriteLine ("RawData[0]: 0");
string strres = Encoding.ASCII.GetString(e.RawData);
Console.WriteLine (strres);
}
}
};
ws.Connect ();
var myobj = new {
sub = "BTC_USDT_deals",
};
string payload = JsonConvert.SerializeObject(myobj, new JsonSerializerSettings { ContractResolver = new SortContractResolver() });
ws.Send (payload);
ConsoleKey key;
do
{
key=Console.ReadKey().Key;
} while (key != ConsoleKey.Q);
}
}
}
}
第一次会返回全量数据,接下来会返回增量数据。注意t=0和t=1时数据结构的区别。
- 1.订阅路径
wss://npush.bibox360.com
- 2.请求参数
参数名称 | 是否必须 | 类型 | 描述 | 默认值 | 取值范围 |
---|---|---|---|---|---|
pair | true | string | 交易对 | BIX_BTC, BIX_ETH, BTC_USDT, ETH_USDT...... | |
sub | true | string | ${pair} + '_deals' |
Response
{
topic: 'BTC_USDT_deals',
t: 1,
d: [
'BTC_USDT',
'38640.9',
'0.005175',
'2',
'1646709274432',
'36292624'
]
}
- 3.返回字段
名称 | 描述 |
---|---|
t | 0代表全量数据,1代表增量数据 |
d | 数组定义:交易对,成交价格,成交价值,taker成交方向(1-买,2-卖),成交时间戳 |
订阅 Ticker 数据
完整例子
'use strict'
const WebSocket = require('ws');
const zlib = require('zlib');
const biboxws = 'wss://npush.bibox360.com';
let wsClass = function () {
};
wsClass.prototype._decodeMsg = function (data) {
let data1 = data.slice(1, data.length);
zlib.unzip(data1, (err, buffer) => {
if (err) {
console.log(err);
} else {
try {
let res = JSON.parse(buffer.toString());
console.log(new Date(), buffer.toString());
} catch (e) {
console.log(e);
}
}
});
};
wsClass.prototype._initWs = async function () {
let that = this;
console.log(biboxws)
let ws = new WebSocket(biboxws);
that.ws = ws;
ws.on('open', function open() {
console.log(new Date(), 'open')
ws.send(JSON.stringify({
sub: 'BTC_USDT_ticker',
}));
});
ws.on('close', err => {
console.log('close, ', err);
});
ws.on('error', err => {
console.log('error', err);
});
ws.on('ping', err => {
console.log('ping ', err.toString('utf8'));
});
ws.on('pong', err => {
console.log('pong ', err.toString('utf8'));
});
ws.on('message', data => {
if (data[0] == '1') {
that._decodeMsg(data);
} else if (data[0] == '0') {
console.log(1, new Date(), JSON.parse(data.slice(1)));
} else {
console.log(2, new Date(), data);
}
});
};
let instance = new wsClass();
instance._initWs().catch(err => {
console.log(err);
});
# /usr/bin/env python
# -*- coding: UTF-8 -*-
import websocket # websocket-client
import json
import zlib
ws_url = 'wss://npush.bibox360.com'
def stringify(obj):
return json.dumps(obj, sort_keys=True).replace("\'", "\"").replace(" ", "")
def get_sub_str():
subdata = {
'sub': 'BTC_USDT_ticker',
}
# print(stringify(subdata))
return stringify(subdata)
def get_unsub_str():
subdata = {
'unsub': 'BTC_USDT_ticker',
}
return stringify(subdata)
def decode_data(message):
if message[0] == '\x01' or message[0] == 1:
message = message[1:]
data = zlib.decompress(message, zlib.MAX_WBITS | 32)
jmsgs = json.loads(data)
print(jmsgs)
print(type(jmsgs))
elif message[0] == '\x00' or message[0] == 0:
message = message[1:]
jmsgs = json.loads(message)
print(jmsgs)
print(type(jmsgs))
else:
jmsgs = json.loads(message)
print(jmsgs)
print(type(jmsgs))
def on_message(ws, message):
# print(message)
decode_data(message)
def on_error(ws, error):
print(error)
def on_close(ws):
print("### closed ###")
def on_open(ws):
ws.send(get_sub_str())
def connect():
websocket.enableTrace(True)
ws = websocket.WebSocketApp(ws_url,
on_message=on_message,
on_error=on_error,
on_close=on_close)
ws.on_open = on_open
ws.run_forever(ping_interval=30, ping_timeout=5)
if __name__ == "__main__":
connect()
using System;
using WebSocketSharp;
using System.Net.Http;
using System.Text;
using System.IO.Compression;
using System.Security.Cryptography;
using Newtonsoft.Json;
using Newtonsoft.Json.Serialization;
namespace Example
{
public class SortContractResolver : DefaultContractResolver
{
protected override IList<JsonProperty> CreateProperties(Type type, MemberSerialization memberSerialization)
{
IList<JsonProperty> properties = base.CreateProperties(type, memberSerialization);
return properties.OrderBy(x=>x.PropertyName).ToList();
}
}
public class Program
{
public static string Decompress(byte[] bytes)
{
MemoryStream msIn = new MemoryStream(bytes, 1, bytes.Length - 1);
MemoryStream msOut = new MemoryStream();
GZipStream cprs = new GZipStream(msIn, CompressionMode.Decompress);
cprs.CopyTo(msOut);
cprs.Close();
return Encoding.ASCII.GetString(msOut.ToArray());//转换为普通的字符串
}
public static void Main (string[] args)
{
string wsuri = "wss://npush.bibox360.com";
using (var ws = new WebSocket (wsuri)) {
ws.OnMessage += (sender, e) => {
Console.WriteLine ("recv: " + e.Data);
if (e.IsText) {
Console.WriteLine ("data[0]: {");
} else if (e.IsBinary) {
if (e.RawData[0] == 1) {
Console.WriteLine ("RawData[0]: 1");
string strres = Decompress(e.RawData);
Console.WriteLine (strres);
} else if (e.RawData[0] == 0) {
Console.WriteLine ("RawData[0]: 0");
string strres = Encoding.ASCII.GetString(e.RawData);
Console.WriteLine (strres);
}
}
};
ws.Connect ();
var myobj = new {
sub = "BTC_USDT_ticker",
};
string payload = JsonConvert.SerializeObject(myobj, new JsonSerializerSettings { ContractResolver = new SortContractResolver() });
ws.Send (payload);
ConsoleKey key;
do
{
key=Console.ReadKey().Key;
} while (key != ConsoleKey.Q);
}
}
}
}
- 1.订阅路径
wss://npush.bibox360.com
- 2.请求参数
参数名称 | 是否必须 | 类型 | 描述 | 默认值 | 取值范围 |
---|---|---|---|---|---|
pair | true | string | 交易对 | BIX_BTC, BIX_ETH, BTC_USDT, ETH_USDT...... | |
sub | true | string | ${pair} + '_ticker' |
Response
{
"topic":"BTC_USDT_ticker",
"t":1,
"d":[
"BTC_USDT",
"38635.8",
"38635.80",
"246109.80",
"39526.4000",
"37152.6000",
"38635.7",
"0.053551",
"38635.8",
"0.012292",
"4388.91754000",
"+2.66%",
"1646709436031",
"246109.80000000"
]
}
- 3.返回字段
[ 交易对, 最新成交价, 最新成交价(usd计价), 最新成交价(cny计价), 24h最高价, 24h最低价, 最新买一价, 买一价值, 最新卖一价, 卖一价值, 24h成交价值, 24h涨跌幅, 时间戳, 最新成交价(cny计价) ]
订阅用户数据方法
实际例子
'use strict'
const WebSocket = require('ws');
const zlib = require('zlib');
let CryptoJS = require("crypto-js");
const biboxws = 'wss://npush.bibox360.com'; // 1.请求路径
let ws;
let apikey = '900625568558820892a8c833c33ebc8fd2701efe'; // 你的apikey
let secret = 'c708ac3e70d115ec29efbee197330627d7edf842'; // apikey的密码
let subparam = JSON.stringify({ // 格式化参数对象,得到subparam
apikey,
sub: 'ALL_ALL_login'
});
let sign = CryptoJS.HmacMD5(subparam, String(secret)).toString(); // 用apikey的密码secret对得到subparam进行HmacMD5签名,得到签名结果sign
let form = { // 得到最终的订阅参数
apikey,
sign,
sub: 'ALL_ALL_login',
};
console.log('form', form)
let reiniting = false;
let resend = function (user_id) {
if (ws.readyState != WebSocket.OPEN) {
return setTimeout(function () {
resend(user_id);
}, 1000 * 10);
}
ws.send(JSON.stringify(form));
};
setInterval(function () {
if (ws && ws.readyState == WebSocket.OPEN) {
ws.ping(new Date().getTime());
}
}, 1000 * 10);
let reinit = function () {
if (reiniting) {
return;
}
reiniting = true;
try {
if (ws && ws.readyState == WebSocket.OPEN) {
console.log('manu close ')
ws.close();
}
} catch (err) {
}
setTimeout(function () {
init();
}, 1000 * 30);
};
let init = function (user_id) {
console.log('init', user_id);
reiniting = false;
ws = new WebSocket(biboxws);
setTimeout(function () {
if (!ws || ws.readyState != WebSocket.OPEN) {
reinit(user_id);
}
}, 1000 * 60);
ws.on('open', function open() {
resend(user_id);
});
ws.on('close', err => {
console.log('close, ', err);
reinit(user_id);
});
ws.on('error', err => {
console.log('error', err);
reinit(user_id);
});
ws.on('ping', err => {
console.log('ping on', err.toString('utf8'));
});
ws.on('pong', err => {
// console.log('pong ', err.toString('utf8'));
});
ws.on('message', function incoming(data) {
if (data[0] == '1') {
decodeMsg(data);
} else {
console.log(1, JSON.parse(data));
}
});
};
let login = function () {
if (reiniting) {
return;
}
reiniting = false;
init();
};
let decodeMsg = function (data) {
let data1 = data.slice(1, data.length);
zlib.unzip(data1, (err, buffer) => {
if (err) {
console.log('2', err);
} else {
try {
let res = JSON.parse(buffer.toString());
console.log('3', buffer.toString());
} catch (e) {
console.log('4', e);
}
}
});
};
module.exports = {};
login();
# /usr/bin/env python
# -*- coding: UTF-8 -*-
import websocket # websocket-client
import json
import zlib
import hmac
import hashlib
ws_url = 'wss://npush.bibox360.com'
apikey = '900625568558820892a8c833c33ebc8fd2701efe' # your apikey
secret = 'c708ac3e70d115ec29efbee197330627d7edf842' # your apikey secret
def stringify(obj):
return json.dumps(obj, sort_keys=True).replace("\'", "\"").replace(" ", "")
def get_sign(data, secret):
return hmac.new(secret.encode("utf-8"), data.encode("utf-8"), hashlib.md5).hexdigest()
def get_sub_str():
subdata = {
'apikey': apikey,
'sub': 'ALL_ALL_login',
}
# print(stringify(subdata))
sign = get_sign(stringify(subdata), secret)
subdata = {
'apikey': apikey,
'sign': sign,
'sub': 'ALL_ALL_login',
}
# print(stringify(subdata))
return stringify(subdata)
def get_unsub_str():
subdata = {
'unsub': 'ALL_ALL_login',
}
return stringify(subdata)
def decode_data(message):
if message[0] == '\x01' or message[0] == 1:
message = message[1:]
data = zlib.decompress(message, zlib.MAX_WBITS | 32)
jmsgs = json.loads(data)
print(jmsgs)
print(type(jmsgs))
else:
jmsgs = json.loads(message)
print(jmsgs)
print(type(jmsgs))
def on_message(ws, message):
# print(message)
decode_data(message)
def on_error(ws, error):
print(error)
def on_close(ws):
print("### closed ###")
def on_open(ws):
ws.send(get_sub_str())
def connect():
websocket.enableTrace(True)
ws = websocket.WebSocketApp(ws_url,
on_message=on_message,
on_error=on_error,
on_close=on_close)
ws.on_open = on_open
ws.run_forever(ping_interval=30, ping_timeout=5)
if __name__ == "__main__":
connect()
using System;
using WebSocketSharp;
using System.Net.Http;
using System.Text;
using System.IO.Compression;
using System.Security.Cryptography;
using Newtonsoft.Json;
using Newtonsoft.Json.Serialization;
namespace Example
{
public class SortContractResolver : DefaultContractResolver
{
protected override IList<JsonProperty> CreateProperties(Type type, MemberSerialization memberSerialization)
{
IList<JsonProperty> properties = base.CreateProperties(type, memberSerialization);
return properties.OrderBy(x=>x.PropertyName).ToList();
}
}
public class Program
{
public static string Decompress(byte[] bytes)
{
MemoryStream msIn = new MemoryStream(bytes, 1, bytes.Length - 1);
MemoryStream msOut = new MemoryStream();
GZipStream cprs = new GZipStream(msIn, CompressionMode.Decompress);
cprs.CopyTo(msOut);
cprs.Close();
return Encoding.ASCII.GetString(msOut.ToArray());//转换为普通的字符串
}
static string HmacMD5(string source, string key)
{
HMACMD5 hmacmd = new HMACMD5(Encoding.Default.GetBytes(key));
byte[] inArray = hmacmd.ComputeHash(Encoding.Default.GetBytes(source));
StringBuilder sb = new StringBuilder();
for (int i = 0; i < inArray.Length; i++)
{
sb.Append(inArray[i].ToString("X2"));
}
hmacmd.Clear();
return sb.ToString().ToLower();
}
public static void Main (string[] args)
{
string wsuri = "wss://npush.bibox360.com";
string apikey = "900625568558820892a8c833c33ebc8fd2701efe";
string secret = "c708ac3e70d115ec29efbee197330627d7edf842";
using (var ws = new WebSocket (wsuri)) {
ws.OnMessage += (sender, e) => {
Console.WriteLine ("recv: " + e.Data);
if (e.IsText) {
Console.WriteLine ("data[0]: {");
} else if (e.IsBinary) {
if (e.RawData[0] == 1) {
Console.WriteLine ("RawData[0]: 1");
string strres = Decompress(e.RawData);
Console.WriteLine (strres);
} else if (e.RawData[0] == 0) {
Console.WriteLine ("RawData[0]: 0");
string strres = Encoding.ASCII.GetString(e.RawData);
Console.WriteLine (strres);
}
}
};
ws.Connect ();
var myparam = new {
apikey = apikey,
sub = "ALL_ALL_login",
};
string myparamstr = JsonConvert.SerializeObject(myparam, new JsonSerializerSettings { ContractResolver = new SortContractResolver() });
string sign = HmacMD5(myparamstr, secret);
var myobj = new {
apikey = apikey,
sign = sign,
sub = "ALL_ALL_login",
};
string payload = JsonConvert.SerializeObject(myobj, new JsonSerializerSettings { ContractResolver = new SortContractResolver() });
ws.Send (payload);
ConsoleKey key;
do
{
key=Console.ReadKey().Key;
} while (key != ConsoleKey.Q);
}
}
}
}
- 1.请求路径
wss://npush.bibox360.com
- 2.请求参数
参数名称 | 是否必须 | 类型 | 描述 | 默认值 | 取值范围 |
---|---|---|---|---|---|
apikey | true | string | 您在Bibox交易所申请的apikey | ||
sign | true | string | 使用您在Bibox交易所申请的apisecret对整个请求数据进行签名 | ||
sub | true | string | 'ALL_ALL_login' |
- 3.签名方法
1.定义参数对象param,需要用到apikey
let apikey = 'thisisyourapikey';
let param = { "apikey": apikey, "sub": "ALL_ALL_login" };
2.格式化参数对象param,得到strParam
let strParam = JSON.stringify(param);
3.用apikey的密码secret对strParam进行HmacMD5签名,得到签名结果sign
let CryptoJS = require("crypto-js");
let secret = 'c708ac3e70d115ec29efbee197330627d7edf842';
let sign = CryptoJS.HmacMD5(strParam, secret).toString();
4.生成订阅参数 wsparam
let wsparam = { "apikey": apikey, "sign": sign, "sub": "ALL_ALL_login" };
Response
{
"topic":"ALL_ALL_login",
"uid":"100000",
"t":0,
"d":{
"result":"订阅成功"
}
}
- 4.返回字段
名称 | 描述 |
---|---|
result | "订阅成功" 代表订阅成功 |
其它字段 | 忽略 |
订阅用户数据解析币币资产
- 1.关键字段
assets
Response
{
"topic":"ALL_ALL_login",
"uid":"100000",
"t":1,
"d":{
"assets":{
"normal":{
"BIX":{
"balance":"497.59601765",
"freeze":"0.00000000"
},
"USDT":{
"balance":"20.52027574",
"freeze":"22.12000000"
}
}
}
}
}
- 2.返回字段
名称 | 描述 |
---|---|
normal | 币币账户资产 |
balance | 可用资产 |
freeze | 冻结资产 |
其它字段 | 忽略 |
订阅用户数据解析币币委托单
- 1.关键字段
orderpending
Response
{
"topic":"ALL_ALL_login",
"uid":"100000",
"t":1,
"d":{
"orderpending":{
"id":"12875281286404369",
"client_oid":"0",
"account_type":0,
"coin_symbol":"BIX",
"currency_symbol":"USDT",
"price":"0.053000",
"deal_price":"0.000000",
"amount":"100.0000",
"vamount":"100.0000",
"deal_amount":"0.0000",
"money":"5.30000000",
"deal_money":"0.00000000",
"deal_count":0,
"deal_percent":"0.00%",
"order_from":1,
"order_side":2,
"order_type":2,
"status":1,
"unexecuted":"100.0000",
"createdAt":1604325924719
}
}
}
- 2.返回字段
名称 | 描述 |
---|---|
state | 0代表成功,否则代表失败 |
count | 当前页记录数,若存在下页,count=当前页记录数+1 |
page | 第几页,从1开始 |
items | 记录列表 |
id | 订单id |
client_oid | 自定义id |
createdAt | 创建时间 |
account_type | 账户类型 0-币币账户 |
coin_symbol | 交易币种 |
currency_symbol | 定价币种 |
order_side | 交易方向,1-买,2-卖 |
order_type | 订单类型,1-市价单,2-限价单 |
price | 委托价格 |
amount | 委托数量 |
money | 委托金额 |
deal_amount | 成交数量 |
deal_percent | 成交百分比 |
unexecuted | 未成交数量 |
status | 状态,-1 失败,0或1-待成交,2-部分成交,3-完全成交,4-部分撤销,5-完全撤销 |
其它字段 | 忽略 |
订阅用户数据解析币币成交详情
- 1.关键字段
history
Response
{
"topic":"ALL_ALL_login",
"uid":"100000",
"t":1,
"d":{
"history":{
"id":"2251799825471069694",
"account_type":0,
"coin_symbol":"BIX",
"currency_symbol":"USDT",
"price":"0.050921",
"amount":"64.2237",
"money":"3.27033502",
"fee":"0.00000000",
"order_from":0,
"order_side":1,
"order_type":2,
"is_maker":0,
"relay_id":"12939052839213054",
"createdAt":1604387364308
}
}
}
- 2.返回字段
名称 | 描述 |
---|---|
state | 0代表成功,否则代表失败 |
id | 成交记录id |
createdAt | 成交时间 |
account_type | 账户类型 0-币币账户 |
coin_symbol | 交易币种 |
currency_symbol | 定价币种 |
order_side | 交易方向,1-买,2-卖 |
order_type | 订单类型,1-市价单,2-限价单 |
price | 成交价格 |
amount | 成交数量 |
money | 成交金额 |
fee | 手续费 |
is_maker | 是否maker |
relay_id | 关联订单id |
其它字段 | 忽略 |
Errors
错误码
Code | 描述 | Msg |
---|---|---|
2003 | Cookie 失效 | Cookie expired |
2033 | 操作失败!订单已完成或已撤销 | Operation failed! Order completed or canceled |
2034 | 操作失败!请检查参数是否正确 | Operation failed! Please check parameter |
2040 | 操作失败!没有该订单 | Operation failed! No record |
2064 | 订单撤销中,不能再次撤销 | Canceling. Unable to cancel again |
2065 | 委托价格设置过高,请重新设置价格 | Precatory price is exorbitant, please reset |
2066 | 委托价格设置过低,请重新设置价格 | Precatory price is low , please reset |
2067 | 暂不支持市价单 | Limit Order Only |
2068 | 下单数量不能低于0.0001 | Min Amount:0.0001 |
2069 | 市价单无法撤销 | Market order can not be canceled |
2078 | 下单价格非法 | unvalid order price |
2085 | 币种最小下单数量限制 | the trade amount is low |
2086 | 账户资产异常,限制下单 | Abnormal account assets, trade is forbiden |
2091 | 请求过于频繁,请稍后再试 | request is too frequency, please try again later |
2092 | 币种最小下单金额限制 | Minimum amount not met |
3000 | 请求参数错误 | Requested parameter incorrect |
3002 | 参数不能为空 | Parameter cannot be null |
3009 | 推送订阅channel不合法 | Illegal subscription channel |
3010 | websocket连接异常 | websocket connection error |
3011 | 接口不支持apikey请求方式 | Illegal subscribe event |
3012 | apikey无效 | Interface does not support apikey request method |
3016 | 交易对错误 | Invalid apikey |
3017 | 推送订阅event不合法 | Trading pair error |
3024 | apikey权限不足 | apikey authorization insufficient |
3025 | apikey签名验证失败 | apikey signature verification failed |
3026 | apikey ip受限制 | apikey ip is restricted |
3027 | 账户没有apikey | No apikey in your account |
3028 | 账户apikey数量超过了限制数量 | Account apikey has exceeded the limit amount |
3029 | apikey允许ip数量超过了限制数量 | apikey ip has exceeded the limit amount |
3033 | 查询类请求限制一个cmd | query allow only one cmd |
3034 | 最大cmd个数限制 | maxinum cmds |
3035 | cmd请求个数限制 | too many cmds |
4000 | 当前网络连接不稳定,请稍候重试 | the network is unstable now, please try again later |
4003 | 服务器繁忙,请稍后再试 | The server is busy, please try again later |