基础信息
请求方式
| 请求方式 | 数据格式 |
|---|---|
| POST | multipart/form-data |
加密规则
API 请求在通过 Internet 发送的过程中极有可能被篡改。为了确保请求未被更改,我们会要求用户在每个请求中带上签名,来校验参数或参数值在传输途中是否发生了更改。
以获取委托单接口为例:
如何对请求参数进行签名,用户提交的参数除sign外,都要参与签名。
首先,将待签名字符串要求按照参数名进行升序排序(首先比较所有参数名的第一个字母,按abcd顺序排列,若遇到相同首字母,则看第二个字母,以此类推)。
例如:对于如下的参数进行签名
api_key=376892265asdad5d12726d8bbfbd8912b3&nonce=309127×tamp=1510235730 再拼接上申请的api_secret(只写值,不需要写变量名,不需要写&)
例如:
bash
api_secret=aQmE8U7bxj16KdJcSd3yX8F8Sakd8aO6LopnHXh27d4kWyb28PxcaTvGrajLDvAw
拼接后的签名串:
api_key=376892265asdad5d12726d8bbfbd8912b3&nonce=309127×tamp=1510235730aQmE8U7bxj16KdJcSd3yX8F8Sakd8aO6LopnHXh27d4kWyb28PxcaTvGrajLDvAw注意,
sign为签名必传参数,调用md5前不要url编码,且勿将api_secret通过接口发送,以防泄漏
最后,是利用32位md5算法,对最终待签名字符串进行签名运算,从而得到签名结果字符串(该字符串赋值于参数sign)。
接口请求基础参数
| 参数 | 是否必传 | 类型 | 说明 |
|---|---|---|---|
| api_key | 是 | string | 用户申请的api_key |
| nonce | 是 | int | 接口随机数,仅限六位随机数 |
| timestamp | 是 | int | 请求接口秒级时间戳,仅接收十秒内的请求(以香港时间为准) |
| sign | 是 | string | 签名 |
行情信息
交易对列表
请求地址
POST/V1/Market/symbolList
接口请求参数
| 参数 | 是否必传 | 类型 | 说明 |
|---|---|---|---|
| symbol_id | 否 | int | 交易对ID |
请求方式
re 'uri'
require 'net/http'
url = URI("https://demo.testpress.in/api/v2.5/auth-token/")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
request = Net::HTTP::Post.new(url)
request["content-type"] = 'application/json'
request["cache-control"] = 'no-cache'
request.body = "{\n \"username\": \"testpress\",\n \"password\": \"demo\"\n}"
response = http.request(request)
puts response.read_body
OkHttpClient client = new OkHttpClient();
MediaType mediaType = MediaType.parse("multipart/form-data; boundary=---011000010111000001101001");
RequestBody body = RequestBody.create(mediaType, "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"username\"\r\n\r\nadmin\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"password\"\r\n\r\ndemo\r\n-----011000010111000001101001--");
Request request = new Request.Builder()
.url("http://demo.testpress.in/api/v2.2/auth-token/")
.post(body)
.addHeader("content-type", "multipart/form-data; boundary=---011000010111000001101001")
.addHeader("authorization", "JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6MTM5NTYsInVzZXJfaWQiOjEzOTU2LCJlbWFpbCI6ImRlcy5wcm8ubWFkaGFuQGhvdG1haWwuY29tIiwiZXhwIjoxNDY0MzQwMzg1fQ.TElNLpQE8KERVe7Q-vjNk9aU-9prOfzBb43srB9WmC0")
.addHeader("cache-control", "no-cache")
.addHeader("postman-token", "987488b1-1b5f-dd8b-95fc-fea8d276b2ae")
.build();
Response response = client.newCall(request).execute();
import requests
url = "https://demo.testpress.in/api/v2.5/auth-token/"
payload = "{\n \"username\": \"testpress\",\n \"password\": \"demo\"\n}"
headers = {
'content-type': "application/json",
'cache-control': "no-cache",
}
response = requests.request("POST", url, data=payload, headers=headers)
print(response.text)
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://demo.testpress.in/api/v2.3/auth-token/',
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS =>'{
"username": "<type_your_username_here>",
"password": "<type_your_password_here>"
}',
CURLOPT_HTTPHEADER => array(
'Content-Type: application/json'
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
请求响应
{
"status": 200,
"source": "API",
"msg": "OK",
"data": {
"22": {
"symbol_id": 22, //交易对ID
"symbol_type": 1, //交易对类型 1币币交易
"name": "btc_usdt", //交易对名称
"coin_from": 10005, //交易对象
"coin_to": 10007, //定价对象
"coin_from_name": "比特币",//交易对象名称
"coin_to_name": "泰达币", //定价对象名称
"status": 1, //状态 1开启 2关闭
"min_trade": "0.00100000", //单笔最小交易量
"max_trade": "20.00000000" //单笔最大交易量
}
},
"seconds": 1638877957,
"microtime": 1638877957247
}
币种列表
请求地址
POST/V1/Market/getCoinList
接口请求参数
| 参数 | 是否必传 | 类型 | 说明 |
|---|---|---|---|
| symbol_id | 否 | int | 交易对ID |
请求方式
re 'uri'
require 'net/http'
url = URI("https://demo.testpress.in/api/v2.5/auth-token/")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
request = Net::HTTP::Post.new(url)
request["content-type"] = 'application/json'
request["cache-control"] = 'no-cache'
request.body = "{\n \"username\": \"testpress\",\n \"password\": \"demo\"\n}"
response = http.request(request)
puts response.read_body
OkHttpClient client = new OkHttpClient();
MediaType mediaType = MediaType.parse("multipart/form-data; boundary=---011000010111000001101001");
RequestBody body = RequestBody.create(mediaType, "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"username\"\r\n\r\nadmin\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"password\"\r\n\r\ndemo\r\n-----011000010111000001101001--");
Request request = new Request.Builder()
.url("http://demo.testpress.in/api/v2.2/auth-token/")
.post(body)
.addHeader("content-type", "multipart/form-data; boundary=---011000010111000001101001")
.addHeader("authorization", "JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6MTM5NTYsInVzZXJfaWQiOjEzOTU2LCJlbWFpbCI6ImRlcy5wcm8ubWFkaGFuQGhvdG1haWwuY29tIiwiZXhwIjoxNDY0MzQwMzg1fQ.TElNLpQE8KERVe7Q-vjNk9aU-9prOfzBb43srB9WmC0")
.addHeader("cache-control", "no-cache")
.addHeader("postman-token", "987488b1-1b5f-dd8b-95fc-fea8d276b2ae")
.build();
Response response = client.newCall(request).execute();
import requests
url = "https://demo.testpress.in/api/v2.5/auth-token/"
payload = "{\n \"username\": \"testpress\",\n \"password\": \"demo\"\n}"
headers = {
'content-type': "application/json",
'cache-control': "no-cache",
}
response = requests.request("POST", url, data=payload, headers=headers)
print(response.text)
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://demo.testpress.in/api/v2.3/auth-token/',
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS =>'{
"username": "<type_your_username_here>",
"password": "<type_your_password_here>"
}',
CURLOPT_HTTPHEADER => array(
'Content-Type: application/json'
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
请求响应
{
"status": 200,
"source": "API",
"msg": "OK",
"data": [
{
"item_id": 100010, //币种ID
"item_name": "aed", //币种名称
"type": 2, //币种类型 1数字货币 2 法币
"status": 1, //状态 1正常 0禁用
"in_status": 1, //转入状态 1正常 0禁止
"out_status": 1 //转出状态 1正常 0禁止
"num_precision": 1 //数量精度
},
{
"item_id": 10046, //币种ID
"item_name": "sushi", //币种名称
"type": 1, //币种类型 1数字货币 2 法币
"status": 1, //状态 1正常 0禁用
"in_status": 1, //转入状态 1正常 0禁止
"out_status": 1, //转出状态 1正常 0禁止
"num_precision": 1 //数量精度
"chain_list": [ //链列表
{
"chain_tag": "erc20", //链名称
"status": 1, //状态 1正常 3 禁用
"minout": "0.0000", //单笔最小提币额
"maxout": 100000 //单笔最大提币额
}
]
}
],
"seconds": 1634059122,
"microtime": 1634059122592
}
深度
请求地址
POST/V1/Market/depth
re 'uri'
require 'net/http'
url = URI("https://demo.testpress.in/api/v2.5/auth-token/")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
request = Net::HTTP::Post.new(url)
request["content-type"] = 'application/json'
request["cache-control"] = 'no-cache'
request.body = "{\n \"username\": \"testpress\",\n \"password\": \"demo\"\n}"
response = http.request(request)
puts response.read_body
OkHttpClient client = new OkHttpClient();
MediaType mediaType = MediaType.parse("multipart/form-data; boundary=---011000010111000001101001");
RequestBody body = RequestBody.create(mediaType, "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"username\"\r\n\r\nadmin\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"password\"\r\n\r\ndemo\r\n-----011000010111000001101001--");
Request request = new Request.Builder()
.url("http://demo.testpress.in/api/v2.2/auth-token/")
.post(body)
.addHeader("content-type", "multipart/form-data; boundary=---011000010111000001101001")
.addHeader("authorization", "JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6MTM5NTYsInVzZXJfaWQiOjEzOTU2LCJlbWFpbCI6ImRlcy5wcm8ubWFkaGFuQGhvdG1haWwuY29tIiwiZXhwIjoxNDY0MzQwMzg1fQ.TElNLpQE8KERVe7Q-vjNk9aU-9prOfzBb43srB9WmC0")
.addHeader("cache-control", "no-cache")
.addHeader("postman-token", "987488b1-1b5f-dd8b-95fc-fea8d276b2ae")
.build();
Response response = client.newCall(request).execute();
import requests
url = "https://demo.testpress.in/api/v2.5/auth-token/"
payload = "{\n \"username\": \"testpress\",\n \"password\": \"demo\"\n}"
headers = {
'content-type': "application/json",
'cache-control': "no-cache",
}
response = requests.request("POST", url, data=payload, headers=headers)
print(response.text)
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://demo.testpress.in/api/v2.3/auth-token/',
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS =>'{
"username": "<type_your_username_here>",
"password": "<type_your_password_here>"
}',
CURLOPT_HTTPHEADER => array(
'Content-Type: application/json'
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
请求响应
{
"status": 200,
"source": "API",
"msg": "OK",
"data": {
"depth": {
"b": [ //买
["51252.00", "0.000200"],
["51251.93", "0.050000"],
...
],
"a": [ //卖
["51275.05", "3.608140"],
["51275.08", "0.000000"],
...
]
},
"symbol_id": 22,
"status": 200
},
"seconds": 1638873814,
"microtime": 1638873814679
}
用户信息
获取资产
请求地址
POST/Assets/getUserAssets
接口请求参数
| 参数 | 是否必传 | 类型 | 说明 |
|---|---|---|---|
| UID | 否 | int | 用户UID |
请求方式
re 'uri'
require 'net/http'
url = URI("https://demo.testpress.in/api/v2.5/auth-token/")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
request = Net::HTTP::Post.new(url)
request["content-type"] = 'application/json'
request["cache-control"] = 'no-cache'
request.body = "{\n \"username\": \"testpress\",\n \"password\": \"demo\"\n}"
response = http.request(request)
puts response.read_body
OkHttpClient client = new OkHttpClient();
MediaType mediaType = MediaType.parse("multipart/form-data; boundary=---011000010111000001101001");
RequestBody body = RequestBody.create(mediaType, "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"username\"\r\n\r\nadmin\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"password\"\r\n\r\ndemo\r\n-----011000010111000001101001--");
Request request = new Request.Builder()
.url("http://demo.testpress.in/api/v2.2/auth-token/")
.post(body)
.addHeader("content-type", "multipart/form-data; boundary=---011000010111000001101001")
.addHeader("authorization", "JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6MTM5NTYsInVzZXJfaWQiOjEzOTU2LCJlbWFpbCI6ImRlcy5wcm8ubWFkaGFuQGhvdG1haWwuY29tIiwiZXhwIjoxNDY0MzQwMzg1fQ.TElNLpQE8KERVe7Q-vjNk9aU-9prOfzBb43srB9WmC0")
.addHeader("cache-control", "no-cache")
.addHeader("postman-token", "987488b1-1b5f-dd8b-95fc-fea8d276b2ae")
.build();
Response response = client.newCall(request).execute();
import requests
url = "https://demo.testpress.in/api/v2.5/auth-token/"
payload = "{\n \"username\": \"testpress\",\n \"password\": \"demo\"\n}"
headers = {
'content-type': "application/json",
'cache-control': "no-cache",
}
response = requests.request("POST", url, data=payload, headers=headers)
print(response.text)
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://demo.testpress.in/api/v2.3/auth-token/',
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS =>'{
"username": "<type_your_username_here>",
"password": "<type_your_password_here>"
}',
CURLOPT_HTTPHEADER => array(
'Content-Type: application/json'
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
请求响应
{
"status":200,
"source":"API",
"msg":"OK",
"data":[
{
"name":"eth", //币种名称
"user_id":100000665, //用户ID
"num":"10000", //可用数量
"lock_num":"0" //冻结数量
"type":1 //1数字货币 2 法币
},
{
"name":"btc",
"user_id":100000665,
"num":"200.2379112",
"lock_num":"0.",
"type":1
},
...
],
"seconds":1625057641,
"microtime":1625057641638
}
获取充提记录
请求地址
POST/Assets/depositWithdrawList
接口请求参数
接口请求参数
| 参数 | 是否必传 | 类型 | 说明 |
|---|---|---|---|
| item_id | 否 | int | 币种ID 例如:10007 |
| from_address | 否 | sting | 来源地址 |
| to_address | 否 | sting | 目标地址 |
| type | 否 | sting | 1 充2 提 |
| start_time | 否 | sting | 开始时间戳 |
| end_time | 否 | sting | 截止时间戳 |
请求方式
re 'uri'
require 'net/http'
url = URI("https://demo.testpress.in/api/v2.5/auth-token/")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
request = Net::HTTP::Post.new(url)
request["content-type"] = 'application/json'
request["cache-control"] = 'no-cache'
request.body = "{\n \"username\": \"testpress\",\n \"password\": \"demo\"\n}"
response = http.request(request)
puts response.read_body
OkHttpClient client = new OkHttpClient();
MediaType mediaType = MediaType.parse("multipart/form-data; boundary=---011000010111000001101001");
RequestBody body = RequestBody.create(mediaType, "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"username\"\r\n\r\nadmin\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"password\"\r\n\r\ndemo\r\n-----011000010111000001101001--");
Request request = new Request.Builder()
.url("http://demo.testpress.in/api/v2.2/auth-token/")
.post(body)
.addHeader("content-type", "multipart/form-data; boundary=---011000010111000001101001")
.addHeader("authorization", "JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6MTM5NTYsInVzZXJfaWQiOjEzOTU2LCJlbWFpbCI6ImRlcy5wcm8ubWFkaGFuQGhvdG1haWwuY29tIiwiZXhwIjoxNDY0MzQwMzg1fQ.TElNLpQE8KERVe7Q-vjNk9aU-9prOfzBb43srB9WmC0")
.addHeader("cache-control", "no-cache")
.addHeader("postman-token", "987488b1-1b5f-dd8b-95fc-fea8d276b2ae")
.build();
Response response = client.newCall(request).execute();
import requests
url = "https://demo.testpress.in/api/v2.5/auth-token/"
payload = "{\n \"username\": \"testpress\",\n \"password\": \"demo\"\n}"
headers = {
'content-type': "application/json",
'cache-control': "no-cache",
}
response = requests.request("POST", url, data=payload, headers=headers)
print(response.text)
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://demo.testpress.in/api/v2.3/auth-token/',
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS =>'{
"username": "<type_your_username_here>",
"password": "<type_your_password_here>"
}',
CURLOPT_HTTPHEADER => array(
'Content-Type: application/json'
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
请求响应
{
"status": 200,
"source": "API",
"msg": "OK",
"data": [{
"ua_id": 569, //地址标识ID
"user_id": 10000007707, //平台用户ID
"client_user_id": "123456", //客户端用户ID
"item_id": 10007, //币种ID
"address": "0x1071fdff6aa32e2cfe9fbb3ce68ff4013abc9bc3",//地址
"qrcode_url": "",//不再进行维护
"chain_tag": "erc20", //链名称
"remark": "三方用户提币地址" //地址备注
},
{
"ua_id": 568,
"user_id": 10000007707,
"client_user_id": "123456",
"item_id": 10007,
"address": "0x1071fdff6aa32e2cfe9fbb3ce68ff4013abc9bc3",
"qrcode_url": "",//不再进行维护
"chain_tag": "erc20",
"remark": "三方用户提币地址"
}
],
"seconds": 1634061549,
"microtime": 1634061549422
}
获取充提详情
请求地址
DELETE/Assets/depositWithdrawInfo
接口请求参数
| 参数 | 是否必传 | 类型 | 说明 |
|---|---|---|---|
| exchange_id | 否 | int | 平台提币订单ID 与remark参数必须选传一个 |
| remark | 否 | sting | 提币备注 与exchange_id参数必须选传一个 |
请求方式
re 'uri'
require 'net/http'
url = URI("https://demo.testpress.in/api/v2.5/auth-token/")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
request = Net::HTTP::Post.new(url)
request["content-type"] = 'application/json'
request["cache-control"] = 'no-cache'
request.body = "{\n \"username\": \"testpress\",\n \"password\": \"demo\"\n}"
response = http.request(request)
puts response.read_body
OkHttpClient client = new OkHttpClient();
MediaType mediaType = MediaType.parse("multipart/form-data; boundary=---011000010111000001101001");
RequestBody body = RequestBody.create(mediaType, "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"username\"\r\n\r\nadmin\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"password\"\r\n\r\ndemo\r\n-----011000010111000001101001--");
Request request = new Request.Builder()
.url("http://demo.testpress.in/api/v2.2/auth-token/")
.post(body)
.addHeader("content-type", "multipart/form-data; boundary=---011000010111000001101001")
.addHeader("authorization", "JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6MTM5NTYsInVzZXJfaWQiOjEzOTU2LCJlbWFpbCI6ImRlcy5wcm8ubWFkaGFuQGhvdG1haWwuY29tIiwiZXhwIjoxNDY0MzQwMzg1fQ.TElNLpQE8KERVe7Q-vjNk9aU-9prOfzBb43srB9WmC0")
.addHeader("cache-control", "no-cache")
.addHeader("postman-token", "987488b1-1b5f-dd8b-95fc-fea8d276b2ae")
.build();
Response response = client.newCall(request).execute();
import requests
url = "https://demo.testpress.in/api/v2.5/auth-token/"
payload = "{\n \"username\": \"testpress\",\n \"password\": \"demo\"\n}"
headers = {
'content-type': "application/json",
'cache-control': "no-cache",
}
response = requests.request("POST", url, data=payload, headers=headers)
print(response.text)
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://demo.testpress.in/api/v2.3/auth-token/',
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS =>'{
"username": "<type_your_username_here>",
"password": "<type_your_password_here>"
}',
CURLOPT_HTTPHEADER => array(
'Content-Type: application/json'
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
请求响应
{
"status": 200,
"source": "API",
"msg": "OK",
"data": {
"chain_tag": "",//链名称
"from_address": "0xe2de2ae4aa64bcc85ef159356ead8aad87f8c28b", //来源地址
"to_address": "0x044eefb0d6d97a87a381b60800e084c712c6ea11", //转出地址
"confirm": 0, //确认数
"coin_out_status": 0, //审核状态 0 未审核 1已审核
"num": "55.0000000000", //数量
"txid": "", //交易hash
"status": "success", //状态 waiting打包中 pending发送中 confirming确认中 cantrade可交易 success已完成 faild失败
"item_id": 10007, //币种ID
"type": 1, // 1充值 2提币
"user_id": 10000007707, //平台用户ID
"create_time": 1575130609, //创建时间
"exchange_type": 1, //类型1内部地址2外部地址
"remark": "", //备注
"network_fee": "0.0000000000" //网络费用
},
"seconds": 1634068932,
"microtime": 1634068932808
}