Perbarui Log
waktu mulai berlaku | Interface | Ringkasan |
---|---|---|
2022-03-28 | rest cancelAllOrdersAfter/getSpotBills | 新增接口:rest cancelAllOrdersAfter/getSpotBills 定时取消委托/获取现货账单 |
2022-03-17 | rest cancelOrder | 修改接口:Rest cancelOrder 接口新添加下单数量、下单价格、成交总额、成交数量 |
2022-03-17 | ws kline/ws push_user_cross_asset | 新增接口:websocket k线接口和全仓杠杆推送接口 |
2022-03-01 | setExpressState/setRepayState | 新增接口:setExpressState/setRepayState |
2021-09-18 | kline | Websocket API push_user_incr_record Interface baru menambahkan empat bidang dari ID transaksi terbaru, harga, kuantitas, dan waktu |
2021-07-16 | kline | Bidang simbol nilai pengembalian interface diubah menjadi huruf besar |
2021-07-16 | all interface | Semua interface tidak lagi mendukung nama lama mata uang, dan menggunakan nama baru secara seragam, di mana nama lama meliputi:bchabc,bchsv,hsr,nxwcNama-nama baru sesuai dengan:bch,bsv,hc,xwc |
2021-03-16 | getFeeInfo | Hapus API untuk 'createSubUserKey |
2021-03-16 | restPasar | Ubah HTTP ke HTTPS |
2020-12-31 | push_user_incr_record, push_user_incr_asset | Push hanya mengubah pesanan mata uang dan aset |
Memulai
Pengenalan API
eg: https://api.zb.com/data/v1/ticker?market=btc_usdt
ZB menyediakan API untuk akses cepat ke pasar spot dengan fitur berikut: data pasar, buku pesanan, kedalaman tawaran dan permintaan, riwayat perdagangan, eksekusi perdagangan, informasi pesanan, riwayat pesanan, Informasi akun
Jika Anda memiliki masalah selama penggunaan, silakan scan kode QR di bawah ini dengan ZBAPP untuk bergabung dengan grup obrolan panas, kami akan membantu Anda menyelesaikan masalah teknis sesegera mungkin
Deskripsi API Interface
ZB.com menyediakan Rest API dan Websocket API, Anda dapat menggunakannya untuk menanyakan data pasar dan bertransaksi sesuai kebutuhan.
REST APIDeskripsi
Rest adalah kependekan dari Representational State Transfer, yang merupakan salah satu arsitektur perangkat lunak internet paling populer. Strukturnya jelas, mudah dipahami dan diperluas, membuatnya diadopsi oleh semakin banyak situs web. Keuntungannya adalah sebagai berikut::
Dalam arsitektur RESTful, setiap URL mewakili satu jenis sumber daya
Beberapa layer representasi dari sumber daya ini ditransfer antara klien dan server;
Klien menggunakan empat instruksi HTTP untuk mengoperasikan sumber daya server dan mewujudkan transisi status lapisan presentasi
Pengembang disarankan untuk menggunakan REST API untuk operasi seperti perdagangan atau penarikan aset
WebSocket API
WebSocket adalah protokol baru HTML5. Ini mewujudkan komunikasi dupleks penuh antara klien dan server, membuat data cepat ditransfer di kedua arah. Koneksi antara klien dan server dapat dibuat melalui jabat tangan sederhana, dan server dapat secara aktif mendorong informasi kepada klien sesuai aturan bisnis.Keuntungannya adalah sebagai berikut::
Ketika data ditransfer antara klien dan server, informasi header permintaan bisa relatif kecil yaitu sekitar 2 byte
Baik klien dan server dapat secara aktif mengirim data satu sama lain
Tidak perlu membuat permintaan TCP dan menghancurkannya beberapa kali untuk menghemat bandwidth dan sumber daya server
Sangat disarankan agar pengembang menggunakan WebSocket API untuk mendapatkan informasi seperti kondisi pasar dan kedalaman pasar jual beli.
Rest API
Pastikan untuk mengatur agen pengguna ke 'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.71 Safari/537.36'
Kode sampel
Tanda tangan: Gunakan sha untuk mengenkripsi kunci rahasia terlebih dahulu, lalu tandatangani parameter yang diminta sesuai dengan kunci rahasia yang dienkripsi, minta parameter untuk diurutkan dan dienkripsi sesuai dengan nilai ascii, dan isi enkripsi 16-bit dengan md5.
Pembatasan akses
1.Untuk Trade API dan Margin API, satu IP dibatasi hingga 10.000 akses per menit, sementara lebih dari 10.000 akses akan dikunci selama 1 jam dan dibuka secara otomatis setelah satu jam.。
2.Untuk Trade API dan Margin API, satu KUNCI API dibatasi hingga 60 akses per detik, dan permintaan yang melebihi 60 permintaan per detik dianggap tidak valid.。
3.Data K-Line hanya dapat diminta sekali per detik.。
Konfigurasi
Dapatkan konfigurasi pasar
Dapatkan informasi pasar terbuka, termasuk harga, jumlah tempat desimal
Contoh permintaan
// request demo
GET https://api.zb.com/data/v1/markets
// java demo
public void getMarkets() {
//Dapatkan hasil pengembalian
String returnJson = HttpRequest.get("https://api.zb.com/data/v1/markets").send().bodyText();
}
// python demo
def get(self, url):
while True:
try:
r = requests.get(url)
except Exception:
time.sleep(0.5)
continue
if r.status_code != 200:
time.sleep(0.5)
continue
r_info = r.json()
r.close()
return r_info
def getMarkets(self, market):
url = 'https://api.zb.com/data/v1/markets'
return self.get(url)
Contoh tanggapan
// Hasil Kembali
{
"btc_usdt": {
"amountScale": 4,
"minAmount": 0.0001,
"minSize": 50,
"priceScale": 2
}
}
Nilai Kembali | Deskripsi |
---|---|
priceScale | 价格小数位数 |
minAmount | Jumlah transaksi minimum dalam mata uang transaksi |
minSize | Kuantitas transaksi minimum dalam mata uang harga |
amountScale | Tempat Desimal dari Jumlah |
Pasar
Dapatkan semua data Ticker
Dapatkan semua kurs mata uang
Contoh permintaan
// request demo
GET https://api.zb.com/data/v1/allTicker
// java demo
public void getAllTicker() {
//Dapatkan hasil pengembalian
String returnJson = HttpRequest.get("https://api.zb.com/data/v1/allTicker").send().bodyText();
}
// python demo
def get(self, url):
while True:
try:
r = requests.get(url)
except Exception:
time.sleep(0.5)
continue
if r.status_code != 200:
time.sleep(0.5)
continue
r_info = r.json()
r.close()
return r_info
def getAllTicker(self, market):
url = 'https://api.zb.com/data/v1/allTicker'
return self.get(url)
Contoh tanggapan
// Hasil Kembali
{
"hpybtc":{
"vol":"19800.6",
"last":"0.00000237",
"sell":"0.000002366",
"buy":"0.00000236",
"high":"0.0000026552",
"low":"0.00000229"
"open": "0.31"
"riseRate": "4.81"
},
"tvqc":{
"vol":"2201510.1",
......
}
Nilai Kembali | Deskripsi |
---|---|
high | harga tertinggi |
low | harga terendah |
buy | Beli 1 |
sell | Jual 1 |
last | Harga transaksi terbaru |
open | harga pembukaan |
riseRate | Perubahan 24 jam |
vol | Volume (24 jam terakhir) |
Dapatkan data ticker
Dapatkan kurs dari satu mata uang
Contoh permintaan
// request demo
GET https://api.zb.com/data/v1/ticker?market=btc_usdt
// java demo
public void getTicker() {
//Dapatkan hasil pengembalian
String returnJson = HttpRequest.get("https://api.zb.com/data/v1/ticker?market=btc_usdt").send().bodyText();
}
// python demo
def get(self, url):
while True:
try:
r = requests.get(url)
except Exception:
time.sleep(0.5)
continue
if r.status_code != 200:
time.sleep(0.5)
continue
r_info = r.json()
r.close()
return r_info
def getTicker(self, market):
url = 'https://api.zb.com/data/v1/ticker?market=btc_usdt'
return self.get(url)
Contoh tanggapan
// Hasil Kembali
{
"ticker": {
"vol": "40.463",
"last": "0.899999",
"sell": "0.5",
"buy": "0.225",
"high": "0.899999",
"low": "0.081"
"open": "0.31"
"riseRate": "4.81"
},
"date": "1507875747359"
}
Nama parameter | Jenis | Rentang nilai |
---|---|---|
market | String | Sampel:btc_qc |
Nilai Kembali | Deskripsi |
---|---|
high | harga tertinggi |
low | harga terendah |
buy | Beli 1 |
sell | Jual 1 |
last | Harga transaksi terbaru |
open | harga pembukaan |
riseRate | Perubahan 24 jam |
vol | Volume (24 jam terakhir) |
Dapatkan kedalaman pasar
Contoh permintaan
// request demo
GET https://api.zb.com/data/v1/depth?market=btc_usdt&size=3
// java demo
public void getDepth() {
//Dapatkan hasil pengembalian
String returnJson = HttpRequest.get("https://api.zb.com/data/v1/depth?market=btc_usdt&size=3").send().bodyText();
}
// python demo
def get(self, url):
while True:
try:
r = requests.get(url)
except Exception:
time.sleep(0.5)
continue
if r.status_code != 200:
time.sleep(0.5)
continue
r_info = r.json()
r.close()
return r_info
def getDepth(self, market):
url = 'https://api.zb.com/data/v1/depth?market=btc_usdt&size=3'
return self.get(url)
Contoh tanggapan
// Hasil Kembali
{
"asks": [
[
83.28,
11.8
]...
],
"bids": [
[
81.91,
3.65
]...
],
"timestamp" : Stempel waktu
}
Nama parameter | Jenis | Rentang nilai |
---|---|---|
market | String | Sampel:btc_qc |
size | int | Rentang posisi dari 1 hingga 50, jika ada kedalaman kombinasi, itu hanya mengembalikan 5 posisi |
merge | float | depth default |
Nilai Kembali | Deskripsi |
---|---|
asks | Jual Order Depth |
bids | Beli pesanan |
timestamp | Stempel waktu yang dihasilkan oleh |
Dapatkan transaksi historis
Contoh permintaan
// request demo
GET https://api.zb.com/data/v1/trades?market=btc_usdt
// java demo
public void getTrades() {
//Dapatkan hasil pengembalian
String returnJson = HttpRequest.get("https://api.zb.com/data/v1/trades?market=btc_usdt").send().bodyText();
}
// python demo
def get(self, url):
while True:
try:
r = requests.get(url)
except Exception:
time.sleep(0.5)
continue
if r.status_code != 200:
time.sleep(0.5)
continue
r_info = r.json()
r.close()
return r_info
def getTrades(self, market):
url = 'https://api.zb.com/data/v1/trades?market=btc_usdt'
return self.get(url)
Contoh tanggapan
// Hasil Kembali
[
{
"amount": 0.541,
"date": 1472711925,
"price": 81.87,
"tid": 16497097,
"trade_type": "ask",
"type": "sell"
}...
]
Nama parameter | Jenis | Rentang nilai |
---|---|---|
market | String | Sampel:btc_qc |
since | long | 50 buah data setelah ID transaksi yang ditentukan |
Nilai Kembali | Deskripsi |
---|---|
date | Waktu transaksi(stempel waktu) |
price | Harga transaksi |
amount | Jumlah transaksi |
tid | Generate transaksiID |
trade_type | Jenis Pesanan: Tanya dan TawarID |
type | Jenis Perdagangan: beli dan jualID |
MemperolehKLine
Dapatkan data K-line hingga 1000 data terbaru
Contoh permintaan
// request demo
GET https://api.zb.com/data/v1/kline?market=btc_usdt
// java demo
public void getKline() {
//Dapatkan hasil pengembalian
String returnJson = HttpRequest.get("https://api.zb.com/data/v1/kline?market=btc_usdt").send().bodyText();
}
// python demo
def get(self, url):
while True:
try:
r = requests.get(url)
except Exception:
time.sleep(0.5)
continue
if r.status_code != 200:
time.sleep(0.5)
continue
r_info = r.json()
r.close()
return r_info
def getKline(self, market):
url = 'https://api.zb.com/data/v1/kline?market=btc_usdt'
return self.get(url)
Contoh tanggapan
// Hasil Kembali
{
"data": [
[
1472107500000,
3840.46,
3843.56,
3839.58,
3843.3,
492.456
]...
],
"moneyType": "USDT",
"symbol": "BTC"
}
Nama parameter | Jenis | Rentang nilai |
---|---|---|
market | String | Sampel:btc_qc |
type | String | 1min/3min/5min/15min/30min/1day/3day/1week/1hour/2hour/4hour/6hour/12hour |
since | long | Setelah stempel waktu ini |
size | int | Batas pengembalian data (default 1000, hanya mengembalikan 1000 data jika ada lebih dari 1000 data) |
Nilai Kembali | Deskripsi |
---|---|
data | Konten K line |
1472107500000 | Stempel waktu |
3840.46 | Buka |
3843.56 | Tinggi |
3839.58 | Rendah |
3843.3 | menerima |
492.456 | Volume |
moneyType | Beli mata uang |
symbol | Jual mata uang |
dana
Dapatkan Info Pengguna
Contoh permintaan
// request demo
GET https://trade.zb.com/api/getAccountInfo?accesskey=youraccesskey&method=getAccountInfo&sign=Minta string tanda tangan terenkripsi&reqTime=waktu saat ini dalam milidetik
// java demo
public void getAccountInfo() {
//TestapiKey:ce2a18e0-dshs-4c44-4515-9aca67dd706e
//TestsecretKey:c11a122s-dshs-shsa-4515-954a67dd706e
//Enkripsi:https://github.com/zb2017/api/blob/master/zb_netty_client_java/src/main/java/websocketx/client/EncryDigestUtil.java
//secretKeyDiperoleh dengan enkripsi sha1:86429c69799d3d6ac5da5c2c514baa874d75a4ba
String digest = EncryDigestUtil.digest("c11a122s-dshs-shsa-4515-954a67dd706e");
//Parameter diurutkan berdasarkan nilai ASCII
String paramStr = "accesskey=ce2a18e0-dshs-4c44-4515-9aca67dd706e&method=getAccountInfo";
//tanda dienkripsi oleh HmacMD5:25d7c24e7a3640d7d82f834976053bc9
String sign = EncryDigestUtil.hmacSign(paramStr, digest);
//permintaan terakhir yang dikirimurl
String finalUrl = "https://trade.zb.com/api/getAccountInfo?accesskey=ce2a18e0-dshs-4c44-4515-9aca67dd706e&method=getAccountInfo&reqTime=1539942325894&sign=25d7c24e7a3640d7d82f834976053bc9";
//Dapatkan hasil pengembalianjson
String resultJson = HttpRequest.get(finalUrl).send().bodyText();
}
// python demo
import hashlib
import struct
import time
import requests
class ZApi:
def __init__(self, access_key, secret_key):
self._access_key_ = access_key
self._secret_key_ = secret_key
self._markets_ = self.markets()
if len(self._markets_) < 1:
raise Exception("Get markets status failed")
def getAccountInfo(self, market, type, amount, price):
MyUrl = 'https://trade.zb.com/api/getAccountInfo'
#params = 'accesskey=ce2a18e0-dshs-4c44-4515-9aca67dd706e&method=getAccountInfo'
params = 'accesskey=' + self._access_key_ + '&method=getAccountInfo'
return self.call_api(url=MyUrl, params=params)
def call_api(self, url, params=''):
full_url = url
if params:
#sha_secret=86429c69799d3d6ac5da5c2c514baa874d75a4ba
sha_secret = self.digest(self._secret_key_)
#sign = 25d7c24e7a3640d7d82f834976053bc9
sign = self.hmac_sign(params, sha_secret)
req_time = int(round(time.time() * 1000))
params += '&sign=%s&reqTime=%d' % (sign, req_time)
#full_url = https://trade.zb.com/api/getAccountInfo?accesskey=ce2a18e0-dshs-4c44-4515-9aca67dd706e&method=getAccountInfo&reqTime=1540295995373&sign=25d7c24e7a3640d7d82f834976053bc9
full_url += '?' + params
result = {}
while True:
try:
r = requests.get(full_url, timeout=2)
except Exception:
time.sleep(0.5)
continue
if r.status_code != 200:
time.sleep(0.5)
r.close()
continue
else:
result = r.json()
r.close()
break
return result
@staticmethod
def fill(value, length, fill_byte):
if len(value) >= length:
return value
else:
fill_size = length - len(value)
return value + chr(fill_byte) * fill_size
@staticmethod
def xor(s, value):
slist = list(s.decode('utf-8'))
for index in range(len(slist)):
slist[index] = chr(ord(slist[index]) ^ value)
return "".join(slist)
def hmac_sign(self, arg_value, arg_key):
keyb = struct.pack("%ds" % len(arg_key), arg_key.encode('utf-8'))
value = struct.pack("%ds" % len(arg_value), arg_value.encode('utf-8'))
k_ipad = self.xor(keyb, 0x36)
k_opad = self.xor(keyb, 0x5c)
k_ipad = self.fill(k_ipad, 64, 54)
k_opad = self.fill(k_opad, 64, 92)
m = hashlib.md5()
m.update(k_ipad.encode('utf-8'))
m.update(value)
dg = m.digest()
m = hashlib.md5()
m.update(k_opad.encode('utf-8'))
subStr = dg[0:16]
m.update(subStr)
dg = m.hexdigest()
return dg
def digest(self, arg_value):
value = struct.pack("%ds" % len(arg_value), arg_value.encode('utf-8'))
h = hashlib.sha1()
h.update(value)
dg = h.hexdigest()
return dg
Contoh tanggapan
// Hasil Kembali
{
"result": {
"coins": [
{
"enName": "ZB",
"freez": "0.00000000",
"fundstype": 51,
"unitDecimal": 8,
"cnName": "ZB",
"isCanRecharge": true,
"unitTag": "ZB",
"isCanWithdraw": true,
"available": "0.00361064",
"canLoan": false,
"key": "zb"
},
...
],
"base": {
"username": "lianlianyi",
"trade_password_enabled": true,
"auth_google_enabled": true,
"auth_mobile_enabled": true
}
},
"assetPerm": true,
"leverPerm": true,
"entrustPerm": true,
"moneyPerm": true
}
Nama parameter | Jenis | Rentang nilai |
---|---|---|
method | String | penugasan langsunggetAccountInfo |
accesskey | String | accesskey |
sign | String | Minta string tanda tangan terenkripsi |
reqTime | long | waktu saat ini dalam milidetik |
Nilai Kembali | Deskripsi |
---|---|
auth_google_enabled | Apakah akan mengaktifkan verifikasi google |
auth_mobile_enabled | Apakah akan mengaktifkan verifikasi ponsel |
trade_password_enabled | Apakah atau tidak mengaktifkan kata sandi transaksi |
username | Nama pengguna |
key | Bunga yang telah jatuh tempo |
ename | Bahasa inggris koin |
cnName | Nama koin Cina |
showName | Gunakan nama baru jika diganti namanya,jika tidak samaename |
unitTag | Simbol koin |
isCanRecharge | Apakah tersedia untuk deposit? |
isCanWithdraw | Apakah tersedia untuk ditarik? |
canLoan | Apakah layak secara finansial? |
izin | |
leverPerm | manajemen margin:Manajemen investasi、Manajemen Pinjaman |
assetPerm | Aset query:query informasi dan aset akun |
entrustPerm | Entrust Trade:委托、Cancel、Permintaan pesanan transaksi |
moneyPerm | Deposit dan Penarikan:Dapatkan deposit、Alamat penarikan dan catatan,Memulai bisnis penarikan |
获取现货账单
Contoh permintaan
// request demo
GET https://trade.zb.com/api/getSpotBills?accesskey=youraccesskey¤cy=zb&method=getSpotBills&startDate=2022-01-28 00:00:00&endDate=2022-03-28 00:00:00&sign=Minta string tanda tangan terenkripsi&reqTime=waktu saat ini dalam milidetik
Contoh tanggapan
// Hasil Kembali
{
"code": 1000,
"message": "success",
"result": [{,
"balance": "1000 USDT",
"changeAmount": "+10 USDT",
"currencyName": "USDT",
"date": 1641784657000,
"id": 102300,
"remark": "",
"showDate": "2022-01-10 11:00:00",
"total": "10 USDT",
"typeDesc": "",
"},...]"
}
Nama parameter | Jenis | Apakah perlu? | Rentang nilai |
---|---|---|---|
method | String | yes | penugasan langsung getSpotBills |
accesskey | String | yes | accesskey |
currency | String | no | Nama koin |
startDate | String | no | Waktu mulai |
endDate | String | no | Akhir waktu |
dataType | String | no | 0: <= 48h; 1: > 48h |
pageIndex | String | no | Standarnya adalah 1 |
pageSize | String | no | Standarnya adalah 10,(10 ~ 50) |
Nilai Kembali | Deskripsi |
---|---|
code | Kode Pengembalian |
message | Petunjuk |
balance | Saldo |
changeAmount | perubahan iniCOINJumlah |
currencyName | Nama koin |
date | 日期 |
id | ID |
remark | Remark |
showDate | waktu |
total | Saldo |
typeDesc | Jenis tagihan |
Dapatkan alamat setoran
Anda harus membuka aplikasi atau web untuk mendapatkan alamatnya terlebih dahulu
Contoh permintaan
// request demo
GET https://trade.zb.com/api/getUserAddress?accesskey=youraccesskey¤cy=btc&method=getUserAddress&sign=Minta string tanda tangan terenkripsi&reqTime=waktu saat ini dalam milidetik
// java demo
public void getUserAddress() {
//TestapiKey:ce2a18e0-dshs-4c44-4515-9aca67dd706e
//TestsecretKey:c11a122s-dshs-shsa-4515-954a67dd706e
//Enkripsi:https://github.com/zb2017/api/blob/master/zb_netty_client_java/src/main/java/websocketx/client/EncryDigestUtil.java
//secretKeyDiperoleh dengan enkripsi sha1:86429c69799d3d6ac5da5c2c514baa874d75a4ba
String digest = EncryDigestUtil.digest("c11a122s-dshs-shsa-4515-954a67dd706e");
//Parameter diurutkan berdasarkan nilai ASCII
String paramStr = "accesskey=ce2a18e0-dshs-4c44-4515-9aca67dd706e¤cy=btc&method=getUserAddress";
//tanda dienkripsi oleh HmacMD5:0eea9a3d1d1665d6727ca9b1286bef98
String sign = EncryDigestUtil.hmacSign(paramStr, digest);
//permintaan terakhir yang dikirimurl
String finalUrl = "https://trade.zb.com/api/getUserAddress?accesskey=ce2a18e0-dshs-4c44-4515-9aca67dd706e¤cy=btc&method=getUserAddress&reqTime=1539942326056&sign=0eea9a3d1d1665d6727ca9b1286bef98";
//Dapatkan hasil pengembalianjson
String resultJson = HttpRequest.get(finalUrl).send().bodyText();
}
// python demo
import hashlib
import struct
import time
import requests
class ZApi:
def __init__(self, access_key, secret_key):
self._access_key_ = access_key
self._secret_key_ = secret_key
self._markets_ = self.markets()
if len(self._markets_) < 1:
raise Exception("Get markets status failed")
def getUserAddress(self, market, type, amount, price):
MyUrl = 'https://trade.zb.com/api/getUserAddress'
#params = 'accesskey=ce2a18e0-dshs-4c44-4515-9aca67dd706e¤cy=bch&method=getUserAddress'
params = 'accesskey=' + self._access_key_ + '¤cy=bch&method=getUserAddress'
return self.call_api(url=MyUrl, params=params)
def call_api(self, url, params=''):
full_url = url
if params:
#sha_secret=86429c69799d3d6ac5da5c2c514baa874d75a4ba
sha_secret = self.digest(self._secret_key_)
#sign = 0eea9a3d1d1665d6727ca9b1286bef98
sign = self.hmac_sign(params, sha_secret)
req_time = int(round(time.time() * 1000))
params += '&sign=%s&reqTime=%d' % (sign, req_time)
#full_url = https://trade.zb.com/api/getUserAddress?accesskey=ce2a18e0-dshs-4c44-4515-9aca67dd706e¤cy=btc&method=getUserAddress&reqTime=1540295995534&sign=0eea9a3d1d1665d6727ca9b1286bef98
full_url += '?' + params
result = {}
while True:
try:
r = requests.get(full_url, timeout=2)
except Exception:
time.sleep(0.5)
continue
if r.status_code != 200:
time.sleep(0.5)
r.close()
continue
else:
result = r.json()
r.close()
break
return result
@staticmethod
def fill(value, length, fill_byte):
if len(value) >= length:
return value
else:
fill_size = length - len(value)
return value + chr(fill_byte) * fill_size
@staticmethod
def xor(s, value):
slist = list(s.decode('utf-8'))
for index in range(len(slist)):
slist[index] = chr(ord(slist[index]) ^ value)
return "".join(slist)
def hmac_sign(self, arg_value, arg_key):
keyb = struct.pack("%ds" % len(arg_key), arg_key.encode('utf-8'))
value = struct.pack("%ds" % len(arg_value), arg_value.encode('utf-8'))
k_ipad = self.xor(keyb, 0x36)
k_opad = self.xor(keyb, 0x5c)
k_ipad = self.fill(k_ipad, 64, 54)
k_opad = self.fill(k_opad, 64, 92)
m = hashlib.md5()
m.update(k_ipad.encode('utf-8'))
m.update(value)
dg = m.digest()
m = hashlib.md5()
m.update(k_opad.encode('utf-8'))
subStr = dg[0:16]
m.update(subStr)
dg = m.hexdigest()
return dg
def digest(self, arg_value):
value = struct.pack("%ds" % len(arg_value), arg_value.encode('utf-8'))
h = hashlib.sha1()
h.update(value)
dg = h.hexdigest()
return dg
Contoh tanggapan
// Hasil Kembali
{
"code": 1000,
"message": {
"des": "success",
"isSuc": true,
"datas": {
"key": "0x0af7f36b8f09410f3df62c81e5846da673d4d9a9"
}
}
}
Nama parameter | Jenis | Rentang nilai |
---|---|---|
method | String | penugasan langsunggetUserAddress |
accesskey | String | accesskey |
currency | String | Bunga yang telah jatuh tempo |
sign | String | Minta string tanda tangan terenkripsi |
reqTime | long | waktu saat ini dalam milidetik |
Nilai Kembali | Deskripsi |
---|---|
key | Alamat |
Dapatkan beberapa alamat setoran berantai
Contoh permintaan
// request demo
GET https://trade.zb.com/api/getPayinAddress?accesskey=youraccesskey¤cy=usdt&method=getPayinAddress&sign=Minta string tanda tangan terenkripsi&reqTime=waktu saat ini dalam milidetik
// java demo
public void getPayinAddress() {
//TestapiKey:ce2a18e0-dshs-4c44-4515-9aca67dd706e
//TestsecretKey:c11a122s-dshs-shsa-4515-954a67dd706e
//Enkripsi:https://github.com/zb2017/api/blob/master/zb_netty_client_java/src/main/java/websocketx/client/EncryDigestUtil.java
//secretKeyDiperoleh dengan enkripsi sha1:86429c69799d3d6ac5da5c2c514baa874d75a4ba
String digest = EncryDigestUtil.digest("c11a122s-dshs-shsa-4515-954a67dd706e");
//Parameter diurutkan berdasarkan nilai ASCII
String paramStr = "accesskey=ce2a18e0-dshs-4c44-4515-9aca67dd706e¤cy=usdt&method=getPayinAddress";
//tanda dienkripsi oleh HmacMD5:393e455ac4343996db43219a38253631
String sign = EncryDigestUtil.hmacSign(paramStr, digest);
//permintaan terakhir yang dikirimurl
String finalUrl = "https://trade.zb.com/api/getPayinAddress?accesskey=ce2a18e0-dshs-4c44-4515-9aca67dd706e¤cy=usdt&method=getPayinAddress&reqTime=1560956360295&sign=393e455ac4343996db43219a38253631
//Dapatkan hasil pengembalianjson
String resultJson = HttpRequest.get(finalUrl).send().bodyText();
}
// python demo
import hashlib
import struct
import time
import requests
class ZApi:
def __init__(self, access_key, secret_key):
self._access_key_ = access_key
self._secret_key_ = secret_key
self._markets_ = self.markets()
if len(self._markets_) < 1:
raise Exception("Get markets status failed")
def getPayinAddress(self, market):
MyUrl = 'https://trade.zb.com/api/getPayinAddress'
#params = 'accesskey=ce2a18e0-dshs-4c44-4515-9aca67dd706e¤cy=usdt&method=getPayinAddress'
params = 'accesskey=' + self._access_key_ + '¤cy=usdt&method=getPayinAddress'
return self.call_api(url=MyUrl, params=params)
def call_api(self, url, params=''):
full_url = url
if params:
#sha_secret=86429c69799d3d6ac5da5c2c514baa874d75a4ba
sha_secret = self.digest(self._secret_key_)
#sign = 393e455ac4343996db43219a38253631
sign = self.hmac_sign(params, sha_secret)
req_time = int(round(time.time() * 1000))
params += '&sign=%s&reqTime=%d' % (sign, req_time)
#full_url = https://trade.zb.com/api/getPayinAddress?accesskey=ce2a18e0-dshs-4c44-4515-9aca67dd706e¤cy=usdt&method=getPayinAddress&reqTime=1560956360295&sign=393e455ac4343996db43219a38253631
full_url += '?' + params
result = {}
while True:
try:
r = requests.get(full_url, timeout=2)
except Exception:
time.sleep(0.5)
continue
if r.status_code != 200:
time.sleep(0.5)
r.close()
continue
else:
result = r.json()
r.close()
break
return result
@staticmethod
def fill(value, length, fill_byte):
if len(value) >= length:
return value
else:
fill_size = length - len(value)
return value + chr(fill_byte) * fill_size
@staticmethod
def xor(s, value):
slist = list(s.decode('utf-8'))
for index in range(len(slist)):
slist[index] = chr(ord(slist[index]) ^ value)
return "".join(slist)
def hmac_sign(self, arg_value, arg_key):
keyb = struct.pack("%ds" % len(arg_key), arg_key.encode('utf-8'))
value = struct.pack("%ds" % len(arg_value), arg_value.encode('utf-8'))
k_ipad = self.xor(keyb, 0x36)
k_opad = self.xor(keyb, 0x5c)
k_ipad = self.fill(k_ipad, 64, 54)
k_opad = self.fill(k_opad, 64, 92)
m = hashlib.md5()
m.update(k_ipad.encode('utf-8'))
m.update(value)
dg = m.digest()
m = hashlib.md5()
m.update(k_opad.encode('utf-8'))
subStr = dg[0:16]
m.update(subStr)
dg = m.hexdigest()
return dg
def digest(self, arg_value):
value = struct.pack("%ds" % len(arg_value), arg_value.encode('utf-8'))
h = hashlib.sha1()
h.update(value)
dg = h.hexdigest()
return dg
Contoh tanggapan
// Hasil Kembali
{
"code": 1000,
"message": {
"des": "success",
"isSuc": true,
"datas": [
{
"blockChain": "btc",
"isUseMemo": false,
"address": "1LL5ati6pXHZnTGzHSA3rWdqi4mGGXudwM",
"canWithdraw": true,
"canDeposit": true
},
{
"blockChain": "bts",
"isUseMemo": true,
"account": "btstest",
"memo": "123",
"canWithdraw": true,
"canDeposit": true
},
]
}
}
Nama parameter | Jenis | Rentang nilai |
---|---|---|
method | String | penugasan langsunggetPayinAddress |
accesskey | String | accesskey |
currency | String | Bunga yang telah jatuh tempo |
sign | String | Minta string tanda tangan terenkripsi |
reqTime | long | waktu saat ini dalam milidetik |
Nilai Kembali | Deskripsi |
---|---|
blockChain | Block |
canDeposit | Apakah akan menyetor |
canWithdraw | Dapat menarik koin |
isUseMemo | Apakah akan menggunakan memo atau tag. Jika 'benar', informasi setoran menggunakan 'akun+memo', jika tidak menggunakan alamat |
address | Alamat deposit, ketika isUseMemo=false |
account | Akun, ketika isUseMemo=true |
memo | memo atau tag, ketika isUseMemo=true |
获取提现地址
Dapatkan alamat penarikan verifikasi pengguna
Contoh permintaan
// request demo
GET https://trade.zb.com/api/getWithdrawAddress?accesskey=youraccesskey¤cy=btc&method=getWithdrawAddress&sign=Minta string tanda tangan terenkripsi&reqTime=waktu saat ini dalam milidetik
// java demo
public void getWithdrawAddress() {
//TestapiKey:ce2a18e0-dshs-4c44-4515-9aca67dd706e
//TestsecretKey:c11a122s-dshs-shsa-4515-954a67dd706e
//Enkripsi:https://github.com/zb2017/api/blob/master/zb_netty_client_java/src/main/java/websocketx/client/EncryDigestUtil.java
//secretKeyDiperoleh dengan enkripsi sha1:86429c69799d3d6ac5da5c2c514baa874d75a4ba
String digest = EncryDigestUtil.digest("c11a122s-dshs-shsa-4515-954a67dd706e");
//Parameter diurutkan berdasarkan nilai ASCII
String paramStr = "accesskey=ce2a18e0-dshs-4c44-4515-9aca67dd706e¤cy=btc&method=getWithdrawAddress";
//tanda dienkripsi oleh HmacMD5:a23945f53b24c404e51d6ced99fea633
String sign = EncryDigestUtil.hmacSign(paramStr, digest);
//permintaan terakhir yang dikirimurl
String finalUrl = "https://trade.zb.com/api/getWithdrawAddress?accesskey=ce2a18e0-dshs-4c44-4515-9aca67dd706e¤cy=btc&method=getWithdrawAddress&reqTime=1539942326058&sign=a23945f53b24c404e51d6ced99fea633";
//Dapatkan hasil pengembalianjson
String resultJson = HttpRequest.get(finalUrl).send().bodyText();
}
// python demo
import hashlib
import struct
import time
import requests
class ZApi:
def __init__(self, access_key, secret_key):
self._access_key_ = access_key
self._secret_key_ = secret_key
self._markets_ = self.markets()
if len(self._markets_) < 1:
raise Exception("Get markets status failed")
def getWithdrawAddress(self, market, type, amount, price):
MyUrl = 'https://trade.zb.com/api/getWithdrawAddress'
#params = 'accesskey=ce2a18e0-dshs-4c44-4515-9aca67dd706e¤cy=btc&method=getWithdrawAddress'
params = 'accesskey=' + self._access_key_ + '¤cy=btc&method=getWithdrawAddress'
return self.call_api(url=MyUrl, params=params)
def call_api(self, url, params=''):
full_url = url
if params:
#sha_secret=86429c69799d3d6ac5da5c2c514baa874d75a4ba
sha_secret = self.digest(self._secret_key_)
#sign = a23945f53b24c404e51d6ced99fea633
sign = self.hmac_sign(params, sha_secret)
req_time = int(round(time.time() * 1000))
params += '&sign=%s&reqTime=%d' % (sign, req_time)
#full_url = https://trade.zb.com/api/getWithdrawAddress?accesskey=ce2a18e0-dshs-4c44-4515-9aca67dd706e¤cy=btc&method=getWithdrawAddress&reqTime=1540295995538&sign=a23945f53b24c404e51d6ced99fea633
full_url += '?' + params
result = {}
while True:
try:
r = requests.get(full_url, timeout=2)
except Exception:
time.sleep(0.5)
continue
if r.status_code != 200:
time.sleep(0.5)
r.close()
continue
else:
result = r.json()
r.close()
break
return result
@staticmethod
def fill(value, length, fill_byte):
if len(value) >= length:
return value
else:
fill_size = length - len(value)
return value + chr(fill_byte) * fill_size
@staticmethod
def xor(s, value):
slist = list(s.decode('utf-8'))
for index in range(len(slist)):
slist[index] = chr(ord(slist[index]) ^ value)
return "".join(slist)
def hmac_sign(self, arg_value, arg_key):
keyb = struct.pack("%ds" % len(arg_key), arg_key.encode('utf-8'))
value = struct.pack("%ds" % len(arg_value), arg_value.encode('utf-8'))
k_ipad = self.xor(keyb, 0x36)
k_opad = self.xor(keyb, 0x5c)
k_ipad = self.fill(k_ipad, 64, 54)
k_opad = self.fill(k_opad, 64, 92)
m = hashlib.md5()
m.update(k_ipad.encode('utf-8'))
m.update(value)
dg = m.digest()
m = hashlib.md5()
m.update(k_opad.encode('utf-8'))
subStr = dg[0:16]
m.update(subStr)
dg = m.hexdigest()
return dg
def digest(self, arg_value):
value = struct.pack("%ds" % len(arg_value), arg_value.encode('utf-8'))
h = hashlib.sha1()
h.update(value)
dg = h.hexdigest()
return dg
Contoh tanggapan
// Hasil Kembali
{
"code": 1000,
"message": {
"des": "success",
"isSuc": true,
"datas": {
"key": "0x0af7f36b8f09410f3df62c81e5846da673d4d9a9"
}
}
}
Nama parameter | Jenis | Rentang nilai |
---|---|---|
method | String | penugasan langsunggetWithdrawAddress |
accesskey | String | accesskey |
currency | String | Bunga yang telah jatuh tempo |
sign | String | Minta string tanda tangan terenkripsi |
reqTime | long | waktu saat ini dalam milidetik |
Nilai Kembali | Deskripsi |
---|---|
key | Alamat |
Dapatkan alamat penarikan
Contoh permintaan
// request demo
GET https://trade.zb.com/api/getWithdrawRecord?accesskey=youraccesskey¤cy=eth&method=getWithdrawRecord&pageIndex=1&pageSize=10&sign=Minta string tanda tangan terenkripsi&reqTime=waktu saat ini dalam milidetik
// java demo
public void getWithdrawRecord() {
//TestapiKey:ce2a18e0-dshs-4c44-4515-9aca67dd706e
//TestsecretKey:c11a122s-dshs-shsa-4515-954a67dd706e
//Enkripsi:https://github.com/zb2017/api/blob/master/zb_netty_client_java/src/main/java/websocketx/client/EncryDigestUtil.java
//secretKeyDiperoleh dengan enkripsi sha1:86429c69799d3d6ac5da5c2c514baa874d75a4ba
String digest = EncryDigestUtil.digest("c11a122s-dshs-shsa-4515-954a67dd706e");
//Parameter diurutkan berdasarkan nilai ASCII
String paramStr = "accesskey=ce2a18e0-dshs-4c44-4515-9aca67dd706e¤cy=bch&method=getWithdrawRecord&pageIndex=1&pageSize=10";
//tanda dienkripsi oleh HmacMD5:f5eb60290d3a0ce6e2e546e562f59aff
String sign = EncryDigestUtil.hmacSign(paramStr, digest);
//permintaan terakhir yang dikirimurl
String finalUrl = "https://trade.zb.com/api/getWithdrawRecord?accesskey=ce2a18e0-dshs-4c44-4515-9aca67dd706e¤cy=bch&method=getWithdrawRecord&pageIndex=1&pageSize=10&reqTime=1539942326065&sign=f5eb60290d3a0ce6e2e546e562f59aff";
//Dapatkan hasil pengembalianjson
String resultJson = HttpRequest.get(finalUrl).send().bodyText();
}
// python demo
import hashlib
import struct
import time
import requests
class ZApi:
def __init__(self, access_key, secret_key):
self._access_key_ = access_key
self._secret_key_ = secret_key
self._markets_ = self.markets()
if len(self._markets_) < 1:
raise Exception("Get markets status failed")
def getWithdrawRecord(self, market, type, amount, price):
MyUrl = 'https://trade.zb.com/api/getWithdrawRecord'
#params = 'accesskey=ce2a18e0-dshs-4c44-4515-9aca67dd706e¤cy=bch&method=getWithdrawRecord&pageIndex=1&pageSize=10'
params = 'accesskey=' + self._access_key_ + '¤cy=bch&method=getWithdrawRecord&pageIndex=1&pageSize=10'
return self.call_api(url=MyUrl, params=params)
def call_api(self, url, params=''):
full_url = url
if params:
#sha_secret=86429c69799d3d6ac5da5c2c514baa874d75a4ba
sha_secret = self.digest(self._secret_key_)
#sign = f5eb60290d3a0ce6e2e546e562f59aff
sign = self.hmac_sign(params, sha_secret)
req_time = int(round(time.time() * 1000))
params += '&sign=%s&reqTime=%d' % (sign, req_time)
#full_url = https://trade.zb.com/api/getWithdrawRecord?accesskey=ce2a18e0-dshs-4c44-4515-9aca67dd706e¤cy=bch&method=getWithdrawRecord&pageIndex=1&pageSize=10&reqTime=1540295995549&sign=f5eb60290d3a0ce6e2e546e562f59aff
full_url += '?' + params
result = {}
while True:
try:
r = requests.get(full_url, timeout=2)
except Exception:
time.sleep(0.5)
continue
if r.status_code != 200:
time.sleep(0.5)
r.close()
continue
else:
result = r.json()
r.close()
break
return result
@staticmethod
def fill(value, length, fill_byte):
if len(value) >= length:
return value
else:
fill_size = length - len(value)
return value + chr(fill_byte) * fill_size
@staticmethod
def xor(s, value):
slist = list(s.decode('utf-8'))
for index in range(len(slist)):
slist[index] = chr(ord(slist[index]) ^ value)
return "".join(slist)
def hmac_sign(self, arg_value, arg_key):
keyb = struct.pack("%ds" % len(arg_key), arg_key.encode('utf-8'))
value = struct.pack("%ds" % len(arg_value), arg_value.encode('utf-8'))
k_ipad = self.xor(keyb, 0x36)
k_opad = self.xor(keyb, 0x5c)
k_ipad = self.fill(k_ipad, 64, 54)
k_opad = self.fill(k_opad, 64, 92)
m = hashlib.md5()
m.update(k_ipad.encode('utf-8'))
m.update(value)
dg = m.digest()
m = hashlib.md5()
m.update(k_opad.encode('utf-8'))
subStr = dg[0:16]
m.update(subStr)
dg = m.hexdigest()
return dg
def digest(self, arg_value):
value = struct.pack("%ds" % len(arg_value), arg_value.encode('utf-8'))
h = hashlib.sha1()
h.update(value)
dg = h.hexdigest()
return dg
Contoh tanggapan
// Hasil Kembali
{
"code": 1000,
"message": {
"des": "success",
"isSuc": true,
"datas": {
"list": [
{
"amount": 0.01,
"fees": 0.001,
"id": 2016042556231,
"manageTime": 1461579340000,
"status": 3,
"submitTime": 1461579288000,
"toAddress": "14fxEPirL9fyfw1i9EF439Pq6gQ5xijUmp"
"merchantOrderNo": "2021051912283100022694489"
"hash": "eb40b5787eb32e7d685555c16ecbc85d1c476736e07daa6468715d737d1fc5bd"
}...
],
"pageIndex": 1,
"pageSize": 10,
"totalCount": 4,
"totalPage": 1
}
}
}
Nama parameter | Jenis | Rentang nilai |
---|---|---|
method | String | penugasan langsunggetWithdrawRecord |
accesskey | String | accesskey |
currency | String | Bunga yang telah jatuh tempo |
pageIndex | int | nomor halaman saat ini(Seperti: 1, halaman 1) |
pageSize | int | Kuantitas per halaman |
sign | String | Minta string tanda tangan terenkripsi |
reqTime | long | waktu saat ini dalam milidetik |
Nilai Kembali | Deskripsi |
---|---|
code | Kode Pengembalian |
message | Petunjuk |
amount | Jumlah penarikan |
fees | Biaya jaringan |
id | Catatan penarikanid |
manageTime | Stempel waktu untuk waktu pemrosesan penarikan |
status | Status penarikan(0Kirimkan,1Gagal,2Berhasil,3Cancel,5dikonfirmasi) |
submitTime | Stempel waktu untuk waktu pengiriman penarikan |
toAddress | Alamat penerima penarikan |
merchantOrderNo | Nomor pesanan merchant |
hash | Nomor transaksi penarikan |
Dapatkan catatan deposit
Contoh permintaan
// request demo
GET https://trade.zb.com/api/getChargeRecord?accesskey=youraccesskey¤cy=btc&method=getChargeRecord&pageIndex=1&pageSize=10&sign=Minta string tanda tangan terenkripsi&reqTime=waktu saat ini dalam milidetik
// java demo
public void getChargeRecord() {
//TestapiKey:ce2a18e0-dshs-4c44-4515-9aca67dd706e
//TestsecretKey:c11a122s-dshs-shsa-4515-954a67dd706e
//Enkripsi:https://github.com/zb2017/api/blob/master/zb_netty_client_java/src/main/java/websocketx/client/EncryDigestUtil.java
//secretKeyDiperoleh dengan enkripsi sha1:86429c69799d3d6ac5da5c2c514baa874d75a4ba
String digest = EncryDigestUtil.digest("c11a122s-dshs-shsa-4515-954a67dd706e");
//Parameter diurutkan berdasarkan nilai ASCII
String paramStr = "accesskey=ce2a18e0-dshs-4c44-4515-9aca67dd706e¤cy=bch&method=getChargeRecord&pageIndex=1&pageSize=10";
//tanda dienkripsi oleh HmacMD5:e871dcce5138334704165ee53efe5545
String sign = EncryDigestUtil.hmacSign(paramStr, digest);
//permintaan terakhir yang dikirimurl
String finalUrl = "https://trade.zb.com/api/getChargeRecord?accesskey=ce2a18e0-dshs-4c44-4515-9aca67dd706e¤cy=bch&method=getChargeRecord&pageIndex=1&pageSize=10&reqTime=1539942326084&sign=e871dcce5138334704165ee53efe5545";
//Dapatkan hasil pengembalianjson
String resultJson = HttpRequest.get(finalUrl).send().bodyText();
}
// python demo
import hashlib
import struct
import time
import requests
class ZApi:
def __init__(self, access_key, secret_key):
self._access_key_ = access_key
self._secret_key_ = secret_key
self._markets_ = self.markets()
if len(self._markets_) < 1:
raise Exception("Get markets status failed")
def getChargeRecord(self, market, type, amount, price):
MyUrl = 'https://trade.zb.com/api/getChargeRecord'
#params = 'accesskey=ce2a18e0-dshs-4c44-4515-9aca67dd706e¤cy=bch&method=getChargeRecord&pageIndex=1&pageSize=10'
params = 'accesskey=' + self._access_key_ + '¤cy=bch&method=getChargeRecord&pageIndex=1&pageSize=10'
return self.call_api(url=MyUrl, params=params)
def call_api(self, url, params=''):
full_url = url
if params:
#sha_secret=86429c69799d3d6ac5da5c2c514baa874d75a4ba
sha_secret = self.digest(self._secret_key_)
#sign = e871dcce5138334704165ee53efe5545
sign = self.hmac_sign(params, sha_secret)
req_time = int(round(time.time() * 1000))
params += '&sign=%s&reqTime=%d' % (sign, req_time)
#full_url = https://trade.zb.com/api/getChargeRecord?accesskey=ce2a18e0-dshs-4c44-4515-9aca67dd706e¤cy=bch&method=getChargeRecord&pageIndex=1&pageSize=10&reqTime=1540295995596&sign=e871dcce5138334704165ee53efe5545
full_url += '?' + params
result = {}
while True:
try:
r = requests.get(full_url, timeout=2)
except Exception:
time.sleep(0.5)
continue
if r.status_code != 200:
time.sleep(0.5)
r.close()
continue
else:
result = r.json()
r.close()
break
return result
@staticmethod
def fill(value, length, fill_byte):
if len(value) >= length:
return value
else:
fill_size = length - len(value)
return value + chr(fill_byte) * fill_size
@staticmethod
def xor(s, value):
slist = list(s.decode('utf-8'))
for index in range(len(slist)):
slist[index] = chr(ord(slist[index]) ^ value)
return "".join(slist)
def hmac_sign(self, arg_value, arg_key):
keyb = struct.pack("%ds" % len(arg_key), arg_key.encode('utf-8'))
value = struct.pack("%ds" % len(arg_value), arg_value.encode('utf-8'))
k_ipad = self.xor(keyb, 0x36)
k_opad = self.xor(keyb, 0x5c)
k_ipad = self.fill(k_ipad, 64, 54)
k_opad = self.fill(k_opad, 64, 92)
m = hashlib.md5()
m.update(k_ipad.encode('utf-8'))
m.update(value)
dg = m.digest()
m = hashlib.md5()
m.update(k_opad.encode('utf-8'))
subStr = dg[0:16]
m.update(subStr)
dg = m.hexdigest()
return dg
def digest(self, arg_value):
value = struct.pack("%ds" % len(arg_value), arg_value.encode('utf-8'))
h = hashlib.sha1()
h.update(value)
dg = h.hexdigest()
return dg
Contoh tanggapan
// Hasil Kembali
{
"code": 1000,
"message": {
"des": "success",
"isSuc": true,
"datas": {
"list": [
{
"address": "1FKN1DZqCm8HaTujDioRL2Aezdh7Qj7xxx",
"amount": "1.00000000",
"confirmTimes": 1,
"currency": "BTC",
"description": "Berhasil Konfirmasi",
"hash": "7ce842de187c379abafadd64a5fe66c5c61c8a21fb04edff9532234a1dae6xxx",
"id": 558,
"itransfer": 1,
"status": 2,
"submit_time": "2016-12-07 18:51:57"
}...
],
"pageIndex": 1,
"pageSize": 10,
"total": 8
}
}
}
Nama parameter | Jenis | Rentang nilai |
---|---|---|
method | String | penugasan langsunggetChargeRecord |
accesskey | String | accesskey |
currency | String | Bunga yang telah jatuh tempo |
pageIndex | int | nomor halaman saat ini(Seperti: 1, halaman 1) |
pageSize | int | Kuantitas per halaman |
sign | String | Minta string tanda tangan terenkripsi |
reqTime | long | waktu saat ini dalam milidetik |
Nilai Kembali | Deskripsi |
---|---|
code | Kode Pengembalian |
message | Petunjuk |
amount | Jumlah deposit |
confirmTimes | Konfirmasi Deposit |
currency | Jenis koin setoran(modal) |
description | Deskripsi status catatan setoran |
hash | Deposit ID |
id | Catatan depositid |
itransfer | Apakah transfer internal,1iya0tidak |
status | Status(0Menunggu kepastian,1Deposit gagal,2Deposit sukses) |
submit_time | Waktu Deposit |
address | Alamat Deposit |
Dapatkan biaya penarikan
Contoh permintaan
// request demo
GET https://trade.zb.com/api/getFeeInfo?currency=btc
Contoh tanggapan
// Hasil Kembali
{
"code": 1000,
"message": success
"result": {
"USDT": [
{
"chainName": "BTC"
"fee": 0.001
"mainChainName": "BTC"
"canDeposit": true
"canWithdraw": true
}
...
]
}
}
Nama parameter | Jenis | Rentang nilai |
---|---|---|
method | String | penugasan langsunggetFeeInfo |
currency | String | Bunga yang telah jatuh tempo |
Nilai Kembali | Deskripsi |
---|---|
chainName | Blockchain |
fee | Dapatkan biaya penarikan |
mainChainName | mainChainName |
canDeposit | Bisa di isi ulang? |
canWithdraw | Apakah mungkin untuk menarik? |
Penarikan
Contoh permintaan
// request demo
GET https://trade.zb.com/api/withdraw?accesskey=youraccesskey&amount=0.0004¤cy=etc&fees=0.0003ransfer=0&method=withdraw&receiveAddr=14fxEPirL9fyfw1i9EF439Pq6gQ5xijUmp&safePwd=Kata Sandi Transaksi&sign=Minta string tanda tangan terenkripsi&reqTime=waktu saat ini dalam milidetik
// java demo
public void withdraw() {
//TestapiKey:ce2a18e0-dshs-4c44-4515-9aca67dd706e
//TestsecretKey:c11a122s-dshs-shsa-4515-954a67dd706e
//Enkripsi:https://github.com/zb2017/api/blob/master/zb_netty_client_java/src/main/java/websocketx/client/EncryDigestUtil.java
//secretKeyDiperoleh dengan enkripsi sha1:86429c69799d3d6ac5da5c2c514baa874d75a4ba
String digest = EncryDigestUtil.digest("c11a122s-dshs-shsa-4515-954a67dd706e");
//Parameter diurutkan berdasarkan nilai ASCII
String paramStr = "accesskey=ce2a18e0-dshs-4c44-4515-9aca67dd706e&amount=1.5¤cy=ada&fees=0.05ransfer=0&method=withdraw&receiveAddr=Alamatstring&safePwd=123456bb";
//tanda dienkripsi oleh HmacMD5:a2d96def2e570e2f0567fe2c0ee73d78
String sign = EncryDigestUtil.hmacSign(paramStr, digest);
//permintaan terakhir yang dikirimurl
String finalUrl = "https://trade.zb.com/api/withdraw?accesskey=ce2a18e0-dshs-4c44-4515-9aca67dd706e&amount=1.5¤cy=ada&fees=0.05ransfer=0&method=withdraw&receiveAddr=%E5%9C%B0%E5%9D%80string&reqTime=1539942326067&safePwd=123456bb&sign=a2d96def2e570e2f0567fe2c0ee73d78";
//Dapatkan hasil pengembalianjson
String resultJson = HttpRequest.get(finalUrl).send().bodyText();
}
// python demo
import hashlib
import struct
import time
import requests
class ZApi:
def __init__(self, access_key, secret_key):
self._access_key_ = access_key
self._secret_key_ = secret_key
self._markets_ = self.markets()
if len(self._markets_) < 1:
raise Exception("Get markets status failed")
def withdraw(self, market, type, amount, price):
MyUrl = 'https://trade.zb.com/api/withdraw'
#params = 'accesskey=ce2a18e0-dshs-4c44-4515-9aca67dd706e&amount=1.5¤cy=ada&fees=0.05ransfer=0&method=withdraw&receiveAddr=Alamatstring&safePwd=123456bb'
params = 'accesskey=' + self._access_key_ + '&amount=1.5¤cy=ada&fees=0.05ransfer=0&method=withdraw&receiveAddr=Alamatstring&safePwd=123456bb'
return self.call_api(url=MyUrl, params=params)
def call_api(self, url, params=''):
full_url = url
if params:
#sha_secret=86429c69799d3d6ac5da5c2c514baa874d75a4ba
sha_secret = self.digest(self._secret_key_)
#sign = a2d96def2e570e2f0567fe2c0ee73d78
sign = self.hmac_sign(params, sha_secret)
req_time = int(round(time.time() * 1000))
params += '&sign=%s&reqTime=%d' % (sign, req_time)
#full_url = https://trade.zb.com/api/withdraw?accesskey=ce2a18e0-dshs-4c44-4515-9aca67dd706e&amount=1.5¤cy=ada&fees=0.05ransfer=0&method=withdraw&receiveAddr=%E5%9C%B0%E5%9D%80string&reqTime=1540295995554&safePwd=123456bb&sign=a2d96def2e570e2f0567fe2c0ee73d78
full_url += '?' + params
result = {}
while True:
try:
r = requests.get(full_url, timeout=2)
except Exception:
time.sleep(0.5)
continue
if r.status_code != 200:
time.sleep(0.5)
r.close()
continue
else:
result = r.json()
r.close()
break
return result
@staticmethod
def fill(value, length, fill_byte):
if len(value) >= length:
return value
else:
fill_size = length - len(value)
return value + chr(fill_byte) * fill_size
@staticmethod
def xor(s, value):
slist = list(s.decode('utf-8'))
for index in range(len(slist)):
slist[index] = chr(ord(slist[index]) ^ value)
return "".join(slist)
def hmac_sign(self, arg_value, arg_key):
keyb = struct.pack("%ds" % len(arg_key), arg_key.encode('utf-8'))
value = struct.pack("%ds" % len(arg_value), arg_value.encode('utf-8'))
k_ipad = self.xor(keyb, 0x36)
k_opad = self.xor(keyb, 0x5c)
k_ipad = self.fill(k_ipad, 64, 54)
k_opad = self.fill(k_opad, 64, 92)
m = hashlib.md5()
m.update(k_ipad.encode('utf-8'))
m.update(value)
dg = m.digest()
m = hashlib.md5()
m.update(k_opad.encode('utf-8'))
subStr = dg[0:16]
m.update(subStr)
dg = m.hexdigest()
return dg
def digest(self, arg_value):
value = struct.pack("%ds" % len(arg_value), arg_value.encode('utf-8'))
h = hashlib.sha1()
h.update(value)
dg = h.hexdigest()
return dg
Contoh tanggapan
// Hasil Kembali
{
"code": 1000,
"message": "success",
"id": "Catatan penarikanid"
}
Nama parameter | Jenis | Rentang nilai |
---|---|---|
accesskey | String | accesskey |
amount | float | Jumlah penarikan |
currency | String | Bunga yang telah jatuh tempo |
fees | float | Biaya Penarikan Penambang |
itransfer | int | Setuju atau tidakbitbanktransfer internal(0Tidak setuju,1Setuju,Tidak setuju secara default) |
method | String | penugasan langsungwithdraw |
receiveAddr | String | Alamat penerima(Itu harus alamat yang diverifikasi,btsjika,menggunakan"Akun_Remark"format seperti itu) |
safePwd | String | Kata Sandi Transaksi |
sign | String | Minta string tanda tangan terenkripsi |
reqTime | long | waktu saat ini dalam milidetik |
Nilai Kembali | Deskripsi |
---|---|
code | Kode Pengembalian |
message | Petunjuk |
id | Catatan penarikanid |
Transaksi
Mempercayakan
Spot trade and margin trade berbagi interface ini, yang dibedakan oleh parameter acctType
Contoh permintaan
// request demo
GET https://trade.zb.com/api/order?accesskey=youraccesskey&acctType=0&amount=1.502¤cy=qtum_usdt&method=order&price=1.9001&tradeType=1&sign=Minta string tanda tangan terenkripsi&reqTime=waktu saat ini dalam milidetik
// java demo
public void order() {
//TestapiKey:ce2a18e0-dshs-4c44-4515-9aca67dd706e
//TestsecretKey:c11a122s-dshs-shsa-4515-954a67dd706e
//Enkripsi:https://github.com/zb2017/api/blob/master/zb_netty_client_java/src/main/java/websocketx/client/EncryDigestUtil.java
//secretKeyDiperoleh dengan enkripsi sha1:86429c69799d3d6ac5da5c2c514baa874d75a4ba
String digest = EncryDigestUtil.digest("c11a122s-dshs-shsa-4515-954a67dd706e");
//Parameter diurutkan berdasarkan nilai ASCII
String paramStr = "accesskey=ce2a18e0-dshs-4c44-4515-9aca67dd706e&acctType=0&amount=0.001¤cy=zb_qc&method=order&price=1.0&tradeType=1";
//signDiperoleh dengan enkripsi HmacMD5:a0f18f0f1007433d905272c4c40560b2
String sign = EncryDigestUtil.hmacSign(paramStr, digest);
//permintaan terakhir yang dikirimurl
String finalUrl = "https://trade.zb.com/api/order?accesskey=ce2a18e0-dshs-4c44-4515-9aca67dd706e&acctType=0&amount=0.001¤cy=zb_qc&method=order&price=1.0&reqTime=1539942326046&sign=a0f18f0f1007433d905272c4c40560b2&tradeType=1";
//Dapatkan hasil pengembalianjson
String resultJson = HttpRequest.get(finalUrl).send().bodyText();
}
// python demo
import hashlib
import struct
import time
import requests
class ZApi:
def __init__(self, access_key, secret_key):
self._access_key_ = access_key
self._secret_key_ = secret_key
self._markets_ = self.markets()
if len(self._markets_) < 1:
raise Exception("Get markets status failed")
def order(self, market, type, amount, price):
MyUrl = 'https://trade.zb.com/api/order'
#params = 'accesskey=ce2a18e0-dshs-4c44-4515-9aca67dd706e&acctType=0&amount=0.001¤cy=zb_qc&method=order&price=1.0&tradeType=1'
params = 'accesskey=' + self._access_key_ + '&acctType=0&amount=0.001¤cy=zb_qc&method=order&price=1.0&tradeType=1'
return self.call_api(url=MyUrl, params=params)
def call_api(self, url, params=''):
full_url = url
if params:
#sha_secret=86429c69799d3d6ac5da5c2c514baa874d75a4ba
sha_secret = self.digest(self._secret_key_)
#sign = a0f18f0f1007433d905272c4c40560b2
sign = self.hmac_sign(params, sha_secret)
req_time = int(round(time.time() * 1000))
params += '&sign=%s&reqTime=%d' % (sign, req_time)
#full_url = https://trade.zb.com/api/order?accesskey=ce2a18e0-dshs-4c44-4515-9aca67dd706e&acctType=0&amount=0.001¤cy=zb_qc&method=order&price=1.0&reqTime=1540295995514&sign=a0f18f0f1007433d905272c4c40560b2&tradeType=1
full_url += '?' + params
result = {}
while True:
try:
r = requests.get(full_url, timeout=2)
except Exception:
time.sleep(0.5)
continue
if r.status_code != 200:
time.sleep(0.5)
r.close()
continue
else:
result = r.json()
r.close()
break
return result
@staticmethod
def fill(value, length, fill_byte):
if len(value) >= length:
return value
else:
fill_size = length - len(value)
return value + chr(fill_byte) * fill_size
@staticmethod
def xor(s, value):
slist = list(s.decode('utf-8'))
for index in range(len(slist)):
slist[index] = chr(ord(slist[index]) ^ value)
return "".join(slist)
def hmac_sign(self, arg_value, arg_key):
keyb = struct.pack("%ds" % len(arg_key), arg_key.encode('utf-8'))
value = struct.pack("%ds" % len(arg_value), arg_value.encode('utf-8'))
k_ipad = self.xor(keyb, 0x36)
k_opad = self.xor(keyb, 0x5c)
k_ipad = self.fill(k_ipad, 64, 54)
k_opad = self.fill(k_opad, 64, 92)
m = hashlib.md5()
m.update(k_ipad.encode('utf-8'))
m.update(value)
dg = m.digest()
m = hashlib.md5()
m.update(k_opad.encode('utf-8'))
subStr = dg[0:16]
m.update(subStr)
dg = m.hexdigest()
return dg
def digest(self, arg_value):
value = struct.pack("%ds" % len(arg_value), arg_value.encode('utf-8'))
h = hashlib.sha1()
h.update(value)
dg = h.hexdigest()
return dg
Contoh tanggapan
// Hasil Kembali
{
"code": "1000",
"message": "Proses berhasil。",
"id": "20131228361867"
}
Nama parameter | Jenis | Rentang nilai |
---|---|---|
method | String | penugasan langsungorder |
accesskey | String | accesskey |
acctType | int | Margin 0/1/2[Spot/Leverage Terisolasi/Leverage posisi silang](Pilihan lain,Standarnya adalah: 0 Spot) |
enableExpress | int | 自动借币 true/false(Pilihan lain,Standarnya adalah: false) |
enableRepay | int | pembayaran otomatis true/false(Pilihan lain,Standarnya adalah: false) |
amount | float | Jumlah transaksi |
currency | String | Transaksi koin/harga koin |
customerOrderId | String | Custom ID(Pilihan lain,4-36 karakter, angka atau huruf. Pembatalan pesanan dapat menggantikan ID pesanan. Jika ada duplikat, pesanan hanya dapat dibatalkan atau data terbaru dapat ditemukan saat membatalkan pesanan dan menanyakan pesanan. |
orderType | int | jenis pesanan1/2[PostOnly/IOC]Opsional, kosong, atau pesanan batas lainnya |
price | float | Harga |
tradeType | int | Tipe transaksi1/0[buy/sell] |
sign | String | Minta string tanda tangan terenkripsi |
reqTime | long | waktu saat ini dalam milidetik |
Nilai Kembali | Deskripsi |
---|---|
code | Kode Pengembalian |
message | Petunjuk |
id | Nomor pesanan yang dipercayakan |
Pesan dalam jumlah besar
Spot trade and margin trade berbagi interface ini, yang dibedakan oleh parameter acctType
Contoh permintaan
// request demo
GET https://trade.zb.com/api/orderMoreV2?accesskey=youraccesskey&acctType=0&tradeParams=[[2,1],[2.2,1]]&market=zb_qc&method=orderMoreV2&tradeType=1&sign=Minta string tanda tangan terenkripsi&reqTime=waktu saat ini dalam milidetik
// java demo
public void orderMoreV2() {
//TestapiKey:ce2a18e0-dshs-4c44-4515-9aca67dd706e
//TestsecretKey:c11a122s-dshs-shsa-4515-954a67dd706e
//Enkripsi:https://github.com/zb2017/api/blob/master/zb_netty_client_java/src/main/java/websocketx/client/EncryDigestUtil.java
//secretKeyDiperoleh dengan enkripsi sha1:86429c69799d3d6ac5da5c2c514baa874d75a4ba
String digest = EncryDigestUtil.digest("c11a122s-dshs-shsa-4515-954a67dd706e");
//Parameter diurutkan berdasarkan nilai ASCII
String paramStr = "accesskey=ce2a18e0-dshs-4c44-4515-9aca67dd706e&acctType=1&market=eth_usdt&method=orderMoreV2&tradeParams=[[2,1],[2.2,1]]&tradeType=1";
//signDiperoleh dengan enkripsi HmacMD5:6dde6176052204af2b2ea3df495c21b0
String sign = EncryDigestUtil.hmacSign(paramStr, digest);
//permintaan terakhir yang dikirimurl
String finalUrl = "https://trade.zb.com/api/orderMoreV2&accesskey=ce2a18e0-dshs-4c44-4515-9aca67dd706e&acctType=1&market=eth_usdt&method=orderMoreV2&reqTime=1560950545558&sign=6dde6176052204af2b2ea3df495c21b0&tradeParams=[[2,1],[2.2,1]]&tradeType=1";
//Dapatkan hasil pengembalianjson
String resultJson = HttpRequest.get(finalUrl).send().bodyText();
}
// python demo
import hashlib
import struct
import time
import requests
class ZApi:
def __init__(self, access_key, secret_key):
self._access_key_ = access_key
self._secret_key_ = secret_key
self._markets_ = self.markets()
if len(self._markets_) < 1:
raise Exception("Get markets status failed")
def orderMoreV2(self, market, type, tradeParams):
MyUrl = 'https://trade.zb.com/api/orderMoreV2'
#params = 'accesskey=ce2a18e0-dshs-4c44-4515-9aca67dd706e&acctType=1&market=eth_usdt&method=orderMoreV2&tradeParams=[[2,1],[2.2,1]]&tradeType=1'
params = 'accesskey=' + self._access_key_ + '&acctType=1&market=eth_usdt&method=orderMoreV2&tradeParams=[[2,1],[2.2,1]]&tradeType=1'
return self.call_api(url=MyUrl, params=params)
def call_api(self, url, params=''):
full_url = url
if params:
#sha_secret=86429c69799d3d6ac5da5c2c514baa874d75a4ba
sha_secret = self.digest(self._secret_key_)
#sign = 6dde6176052204af2b2ea3df495c21b0
sign = self.hmac_sign(params, sha_secret)
req_time = int(round(time.time() * 1000))
params += '&sign=%s&reqTime=%d' % (sign, req_time)
#full_url = https://trade.zb.com/api/orderMoreV2&accesskey=ce2a18e0-dshs-4c44-4515-9aca67dd706e&acctType=1&market=eth_usdt&method=orderMoreV2&reqTime=1560950545558&sign=6dde6176052204af2b2ea3df495c21b0&tradeParams=[[2,1],[2.2,1]]&tradeType=1
full_url += '?' + params
result = {}
while True:
try:
r = requests.get(full_url, timeout=2)
except Exception:
time.sleep(0.5)
continue
if r.status_code != 200:
time.sleep(0.5)
r.close()
continue
else:
result = r.json()
r.close()
break
return result
@staticmethod
def fill(value, length, fill_byte):
if len(value) >= length:
return value
else:
fill_size = length - len(value)
return value + chr(fill_byte) * fill_size
@staticmethod
def xor(s, value):
slist = list(s.decode('utf-8'))
for index in range(len(slist)):
slist[index] = chr(ord(slist[index]) ^ value)
return "".join(slist)
def hmac_sign(self, arg_value, arg_key):
keyb = struct.pack("%ds" % len(arg_key), arg_key.encode('utf-8'))
value = struct.pack("%ds" % len(arg_value), arg_value.encode('utf-8'))
k_ipad = self.xor(keyb, 0x36)
k_opad = self.xor(keyb, 0x5c)
k_ipad = self.fill(k_ipad, 64, 54)
k_opad = self.fill(k_opad, 64, 92)
m = hashlib.md5()
m.update(k_ipad.encode('utf-8'))
m.update(value)
dg = m.digest()
m = hashlib.md5()
m.update(k_opad.encode('utf-8'))
subStr = dg[0:16]
m.update(subStr)
dg = m.hexdigest()
return dg
def digest(self, arg_value):
value = struct.pack("%ds" % len(arg_value), arg_value.encode('utf-8'))
h = hashlib.sha1()
h.update(value)
dg = h.hexdigest()
return dg
Contoh tanggapan
// Hasil Kembali
{
"code": "1000",
"message": "Proses berhasil。",
"data": [201902281619801,201902281619802]
}
Nama parameter | Jenis | Rentang nilai |
---|---|---|
method | String | penugasan langsungorderMoreV2 |
accesskey | String | accesskey |
market | String | Transaksi koin/harga koin |
tradeParams | String | Parameter perdagangan, format array [[harga, Jumlah],[harga, Jumlah]], hingga 20 |
tradeType | int | Tipe transaksi1/0[buy/sell] |
sign | String | Minta string tanda tangan terenkripsi |
reqTime | long | waktu saat ini dalam milidetik |
acctType | int | Margin 0/1/2[Spot/Leverage Terisolasi/Leverage posisi silang](Pilihan lain,Standarnya adalah: 0 Spot) |
Nilai Kembali | Deskripsi |
---|---|
code | Kode Pengembalian |
message | Petunjuk |
data | nomor urut id array |
Cancel Order
Contoh permintaan
// request demo
GET https://trade.zb.com/api/cancelOrder?accesskey=youraccesskey¤cy=zb_qc&id=201710111625&method=cancelOrder&sign=Minta string tanda tangan terenkripsi&reqTime=waktu saat ini dalam milidetik
// java demo
public void cancelOrder() {
//TestapiKey:ce2a18e0-dshs-4c44-4515-9aca67dd706e
//TestsecretKey:c11a122s-dshs-shsa-4515-954a67dd706e
//Enkripsi:https://github.com/zb2017/api/blob/master/zb_netty_client_java/src/main/java/websocketx/client/EncryDigestUtil.java
//secretKeyDiperoleh dengan enkripsi sha1:86429c69799d3d6ac5da5c2c514baa874d75a4ba
String digest = EncryDigestUtil.digest("c11a122s-dshs-shsa-4515-954a67dd706e");
//Parameter diurutkan berdasarkan nilai ASCII
String paramStr = "accesskey=ce2a18e0-dshs-4c44-4515-9aca67dd706e¤cy=zb_qc&id=20180522105585216&method=cancelOrder";
//tanda dienkripsi oleh HmacMD5:a435f4bddfedb50877587ae1acff1c35
String sign = EncryDigestUtil.hmacSign(paramStr, digest);
//permintaan terakhir yang dikirimurl
String finalUrl = "https://trade.zb.com/api/cancelOrder?accesskey=ce2a18e0-dshs-4c44-4515-9aca67dd706e¤cy=zb_qc&id=20180522105585216&method=cancelOrder&reqTime=1539942326052&sign=a435f4bddfedb50877587ae1acff1c35";
//Dapatkan hasil pengembalianjson
String resultJson = HttpRequest.get(finalUrl).send().bodyText();
}
// python demo
import hashlib
import struct
import time
import requests
class ZApi:
def __init__(self, access_key, secret_key):
self._access_key_ = access_key
self._secret_key_ = secret_key
self._markets_ = self.markets()
if len(self._markets_) < 1:
raise Exception("Get markets status failed")
def cancelOrder(self, market, type, amount, price):
MyUrl = 'https://trade.zb.com/api/cancelOrder'
#params = 'accesskey=ce2a18e0-dshs-4c44-4515-9aca67dd706e¤cy=zb_qc&id=20180522105585216&method=cancelOrder'
params = 'accesskey=' + self._access_key_ + '¤cy=zb_qc&id=20180522105585216&method=cancelOrder'
return self.call_api(url=MyUrl, params=params)
def call_api(self, url, params=''):
full_url = url
if params:
#sha_secret=86429c69799d3d6ac5da5c2c514baa874d75a4ba
sha_secret = self.digest(self._secret_key_)
#sign = a435f4bddfedb50877587ae1acff1c35
sign = self.hmac_sign(params, sha_secret)
req_time = int(round(time.time() * 1000))
params += '&sign=%s&reqTime=%d' % (sign, req_time)
#full_url = https://trade.zb.com/api/cancelOrder?accesskey=ce2a18e0-dshs-4c44-4515-9aca67dd706e¤cy=zb_qc&id=20180522105585216&method=cancelOrder&reqTime=1540295995526&sign=a435f4bddfedb50877587ae1acff1c35
full_url += '?' + params
result = {}
while True:
try:
r = requests.get(full_url, timeout=2)
except Exception:
time.sleep(0.5)
continue
if r.status_code != 200:
time.sleep(0.5)
r.close()
continue
else:
result = r.json()
r.close()
break
return result
@staticmethod
def fill(value, length, fill_byte):
if len(value) >= length:
return value
else:
fill_size = length - len(value)
return value + chr(fill_byte) * fill_size
@staticmethod
def xor(s, value):
slist = list(s.decode('utf-8'))
for index in range(len(slist)):
slist[index] = chr(ord(slist[index]) ^ value)
return "".join(slist)
def hmac_sign(self, arg_value, arg_key):
keyb = struct.pack("%ds" % len(arg_key), arg_key.encode('utf-8'))
value = struct.pack("%ds" % len(arg_value), arg_value.encode('utf-8'))
k_ipad = self.xor(keyb, 0x36)
k_opad = self.xor(keyb, 0x5c)
k_ipad = self.fill(k_ipad, 64, 54)
k_opad = self.fill(k_opad, 64, 92)
m = hashlib.md5()
m.update(k_ipad.encode('utf-8'))
m.update(value)
dg = m.digest()
m = hashlib.md5()
m.update(k_opad.encode('utf-8'))
subStr = dg[0:16]
m.update(subStr)
dg = m.hexdigest()
return dg
def digest(self, arg_value):
value = struct.pack("%ds" % len(arg_value), arg_value.encode('utf-8'))
h = hashlib.sha1()
h.update(value)
dg = h.hexdigest()
return dg
Contoh tanggapan
// Hasil Kembali
{
"code": 1000,
"message": "{"
"des": "Proses berhasil",
"isSuc": true,
"datas": "{"
"amount": 10.00,
"price": 12.00,
"completeMonty": 24.00,
"completeAmount": 2.00,
"}"
"}"
}
Nama parameter | Jenis | Rentang nilai |
---|---|---|
method | String | penugasan langsungcancelOrder |
accesskey | String | accesskey |
currency | String | Transaksi koin/harga koin |
id | long | Nomor pesanan yang dipercayakan |
sign | String | Minta string tanda tangan terenkripsi |
reqTime | long | waktu saat ini dalam milidetik |
customerOrderId | String | Custom ID(4-36 karakter, angka atau huruf, hanya satu ID Pesanan dan ID pelanggan yang dapat diisi) |
Nilai Kembali | Deskripsi |
---|---|
code | Kode Pengembalian |
message | Petunjuk |
amount | Jumlah pesanan |
price | Harga |
completeMonty | Jumlah transaksi yang di setujui |
completeAmount | Jumlah volume yang di setujui |
定时取消委托
定时一分钟后取消委托,再次访问刷新时间
Contoh permintaan
// request demo
GET https://trade.zb.com/api/cancelAllOrdersAfter?accesskey=youraccesskey¤cy=zb_qc&method=cancelAllOrdersAfter&sign=Minta string tanda tangan terenkripsi&reqTime=waktu saat ini dalam milidetik
Contoh tanggapan
// Hasil Kembali
{
"code": 1000,
"message": "Proses berhasil"
}
Nama parameter | Jenis | Rentang nilai |
---|---|---|
method | String | penugasan langsung cancelAllOrdersAfter |
accesskey | String | accesskey |
currency | String | Transaksi koin/harga koin |
Nilai Kembali | Deskripsi |
---|---|
code | Kode Pengembalian |
message | Petunjuk |
dapatkan pesanan
Dapatkan satu pesanan beli atau jual pesanan
Contoh permintaan
// request demo
GET https://trade.zb.com/api/getOrder?accesskey=youraccesskey¤cy=zb_qc&id=201710122805&method=getOrder&sign=Minta string tanda tangan terenkripsi&reqTime=waktu saat ini dalam milidetik
// java demo
public void getOrder() {
//TestapiKey:ce2a18e0-dshs-4c44-4515-9aca67dd706e
//TestsecretKey:c11a122s-dshs-shsa-4515-954a67dd706e
//Enkripsi:https://github.com/zb2017/api/blob/master/zb_netty_client_java/src/main/java/websocketx/client/EncryDigestUtil.java
//secretKeyDiperoleh dengan enkripsi sha1:86429c69799d3d6ac5da5c2c514baa874d75a4ba
String digest = EncryDigestUtil.digest("c11a122s-dshs-shsa-4515-954a67dd706e");
//Parameter diurutkan berdasarkan nilai ASCII
String paramStr = "accesskey=ce2a18e0-dshs-4c44-4515-9aca67dd706e¤cy=zb_qc&id=20180522105585216&method=getOrder";
//tanda dienkripsi oleh HmacMD5:c25289ab4f1f7027b6aaf83b7bd5c50b
String sign = EncryDigestUtil.hmacSign(paramStr, digest);
//permintaan terakhir yang dikirimurl
String finalUrl = "https://trade.zb.com/api/getOrder?accesskey=ce2a18e0-dshs-4c44-4515-9aca67dd706e¤cy=zb_qc&id=20180522105585216&method=getOrder&reqTime=1539942326049&sign=c25289ab4f1f7027b6aaf83b7bd5c50b";
//Dapatkan hasil pengembalianjson
String resultJson = HttpRequest.get(finalUrl).send().bodyText();
}
// python demo
import hashlib
import struct
import time
import requests
class ZApi:
def __init__(self, access_key, secret_key):
self._access_key_ = access_key
self._secret_key_ = secret_key
self._markets_ = self.markets()
if len(self._markets_) < 1:
raise Exception("Get markets status failed")
def getOrder(self, market, type, amount, price):
MyUrl = 'https://trade.zb.com/api/getOrder'
#params = 'accesskey=ce2a18e0-dshs-4c44-4515-9aca67dd706e¤cy=zb_qc&id=20180522105585216&method=getOrder'
params = 'accesskey=' + self._access_key_ + '¤cy=zb_qc&id=20180522105585216&method=getOrder'
return self.call_api(url=MyUrl, params=params)
def call_api(self, url, params=''):
full_url = url
if params:
#sha_secret=86429c69799d3d6ac5da5c2c514baa874d75a4ba
sha_secret = self.digest(self._secret_key_)
#sign = c25289ab4f1f7027b6aaf83b7bd5c50b
sign = self.hmac_sign(params, sha_secret)
req_time = int(round(time.time() * 1000))
params += '&sign=%s&reqTime=%d' % (sign, req_time)
#full_url = https://trade.zb.com/api/getOrder?accesskey=ce2a18e0-dshs-4c44-4515-9aca67dd706e¤cy=zb_qc&id=20180522105585216&method=getOrder&reqTime=1540295995519&sign=c25289ab4f1f7027b6aaf83b7bd5c50b
full_url += '?' + params
result = {}
while True:
try:
r = requests.get(full_url, timeout=2)
except Exception:
time.sleep(0.5)
continue
if r.status_code != 200:
time.sleep(0.5)
r.close()
continue
else:
result = r.json()
r.close()
break
return result
@staticmethod
def fill(value, length, fill_byte):
if len(value) >= length:
return value
else:
fill_size = length - len(value)
return value + chr(fill_byte) * fill_size
@staticmethod
def xor(s, value):
slist = list(s.decode('utf-8'))
for index in range(len(slist)):
slist[index] = chr(ord(slist[index]) ^ value)
return "".join(slist)
def hmac_sign(self, arg_value, arg_key):
keyb = struct.pack("%ds" % len(arg_key), arg_key.encode('utf-8'))
value = struct.pack("%ds" % len(arg_value), arg_value.encode('utf-8'))
k_ipad = self.xor(keyb, 0x36)
k_opad = self.xor(keyb, 0x5c)
k_ipad = self.fill(k_ipad, 64, 54)
k_opad = self.fill(k_opad, 64, 92)
m = hashlib.md5()
m.update(k_ipad.encode('utf-8'))
m.update(value)
dg = m.digest()
m = hashlib.md5()
m.update(k_opad.encode('utf-8'))
subStr = dg[0:16]
m.update(subStr)
dg = m.hexdigest()
return dg
def digest(self, arg_value):
value = struct.pack("%ds" % len(arg_value), arg_value.encode('utf-8'))
h = hashlib.sha1()
h.update(value)
dg = h.hexdigest()
return dg
Contoh tanggapan
// Hasil Kembali
{
"currency": "btc_usdt",
"id": "20150928158614292",
"price": 1560,
"status": 3,
"total_amount": 0.1,
"trade_amount": 0,
"trade_date": 1443410396717,
"trade_money": 0,
"type": 0,
"fees": "0.03",
"useZbFee": true
}
Nama parameter | Jenis | Rentang nilai |
---|---|---|
method | String | penugasan langsunggetOrder |
accesskey | String | accesskey |
id | long | Nomor pesanan yang dipercayakan |
currency | String | Transaksi koin/harga koin |
sign | String | Minta string tanda tangan terenkripsi |
reqTime | long | waktu saat ini dalam milidetik |
customerOrderId | String | Custom ID(4-36 karakter, angka atau huruf, hanya satu ID Pesanan dan ID pelanggan yang dapat diisi) |
Nilai Kembali | Deskripsi |
---|---|
currency | Tipe transaksi |
id | Nomor pesanan yang dipercayakan |
price | Harga |
status | Status pesanan:(1. Batal, 2. Selesai/Batalkan pesanan setelah sebagian selesai, 3. Pesanan tertunda/Tidak ) |
total_amount | Jumlah pesanan |
trade_amount | Jumlah volume yang di setujui |
trade_date | mempercayakan waktu |
trade_money | Jumlah transaksi yang di setujui |
type | Jenis pesanan tertunda0-limit sell,1-limit buy,2-PostOnly sell,3-PostOnly buy,4-IOC sell,5-IOC buy |
fees | Biaya transaksi |
useZbFee | Apakah itu biaya pengurangan ZB |
Dapatkan banyak pesanan
Dapatkan beberapa pesanan beli atau jual yang dipercayakan, setiap permintaan returns 10 catatan
Contoh permintaan
// request demo
GET https://trade.zb.com/api/getOrders?accesskey=youraccesskey¤cy=zb_qc&method=getOrders&pageIndex=1&tradeType=1&sign=Minta string tanda tangan terenkripsi&reqTime=waktu saat ini dalam milidetik
// java demo
public void getOrders() {
//TestapiKey:ce2a18e0-dshs-4c44-4515-9aca67dd706e
//TestsecretKey:c11a122s-dshs-shsa-4515-954a67dd706e
//Enkripsi:https://github.com/zb2017/api/blob/master/zb_netty_client_java/src/main/java/websocketx/client/EncryDigestUtil.java
//secretKeyDiperoleh dengan enkripsi sha1:86429c69799d3d6ac5da5c2c514baa874d75a4ba
String digest = EncryDigestUtil.digest("c11a122s-dshs-shsa-4515-954a67dd706e");
//Parameter diurutkan berdasarkan nilai ASCII
String paramStr = "accesskey=ce2a18e0-dshs-4c44-4515-9aca67dd706e¤cy=zb_qc&method=getOrders&pageIndex=1&tradeType=1";
//tanda dienkripsi oleh HmacMD5:083d58360afd1da87c85ac2037aa0f4f
String sign = EncryDigestUtil.hmacSign(paramStr, digest);
//permintaan terakhir yang dikirimurl
String finalUrl = "https://trade.zb.com/api/getOrders?accesskey=ce2a18e0-dshs-4c44-4515-9aca67dd706e¤cy=zb_qc&method=getOrders&pageIndex=1&reqTime=1539942326060&sign=083d58360afd1da87c85ac2037aa0f4f&tradeType=1";
//Dapatkan hasil pengembalianjson
String resultJson = HttpRequest.get(finalUrl).send().bodyText();
}
// python demo
import hashlib
import struct
import time
import requests
class ZApi:
def __init__(self, access_key, secret_key):
self._access_key_ = access_key
self._secret_key_ = secret_key
self._markets_ = self.markets()
if len(self._markets_) < 1:
raise Exception("Get markets status failed")
def getOrders(self, market, type, amount, price):
MyUrl = 'https://trade.zb.com/api/getOrders'
#params = 'accesskey=ce2a18e0-dshs-4c44-4515-9aca67dd706e¤cy=zb_qc&method=getOrders&pageIndex=1&tradeType=1'
params = 'accesskey=' + self._access_key_ + '¤cy=zb_qc&method=getOrders&pageIndex=1&tradeType=1'
return self.call_api(url=MyUrl, params=params)
def call_api(self, url, params=''):
full_url = url
if params:
#sha_secret=86429c69799d3d6ac5da5c2c514baa874d75a4ba
sha_secret = self.digest(self._secret_key_)
#sign = 083d58360afd1da87c85ac2037aa0f4f
sign = self.hmac_sign(params, sha_secret)
req_time = int(round(time.time() * 1000))
params += '&sign=%s&reqTime=%d' % (sign, req_time)
#full_url = https://trade.zb.com/api/getOrders?accesskey=ce2a18e0-dshs-4c44-4515-9aca67dd706e¤cy=zb_qc&method=getOrders&pageIndex=1&reqTime=1540295995542&sign=083d58360afd1da87c85ac2037aa0f4f&tradeType=1
full_url += '?' + params
result = {}
while True:
try:
r = requests.get(full_url, timeout=2)
except Exception:
time.sleep(0.5)
continue
if r.status_code != 200:
time.sleep(0.5)
r.close()
continue
else:
result = r.json()
r.close()
break
return result
@staticmethod
def fill(value, length, fill_byte):
if len(value) >= length:
return value
else:
fill_size = length - len(value)
return value + chr(fill_byte) * fill_size
@staticmethod
def xor(s, value):
slist = list(s.decode('utf-8'))
for index in range(len(slist)):
slist[index] = chr(ord(slist[index]) ^ value)
return "".join(slist)
def hmac_sign(self, arg_value, arg_key):
keyb = struct.pack("%ds" % len(arg_key), arg_key.encode('utf-8'))
value = struct.pack("%ds" % len(arg_value), arg_value.encode('utf-8'))
k_ipad = self.xor(keyb, 0x36)
k_opad = self.xor(keyb, 0x5c)
k_ipad = self.fill(k_ipad, 64, 54)
k_opad = self.fill(k_opad, 64, 92)
m = hashlib.md5()
m.update(k_ipad.encode('utf-8'))
m.update(value)
dg = m.digest()
m = hashlib.md5()
m.update(k_opad.encode('utf-8'))
subStr = dg[0:16]
m.update(subStr)
dg = m.hexdigest()
return dg
def digest(self, arg_value):
value = struct.pack("%ds" % len(arg_value), arg_value.encode('utf-8'))
h = hashlib.sha1()
h.update(value)
dg = h.hexdigest()
return dg
Contoh tanggapan
// Hasil Kembali
[
{
"currency": "btc_usdt",
"id": "20150928158614292",
"price": 1560,
"status": 3,
"total_amount": 0.1,
"trade_amount": 0,
"trade_date": 1443410396717,
"trade_money": 0,
"type": 0,
"fees": "0.03",
"useZbFee": true
}...
]
Nama parameter | Jenis | Rentang nilai |
---|---|---|
method | String | penugasan langsunggetOrders |
accesskey | String | accesskey |
tradeType | int | Tipe transaksi1/0[buy/sell] |
currency | String | Transaksi koin/harga koin |
pageIndex | int | nomor halaman saat ini(Seperti: 1, halaman 1) |
sign | String | Minta string tanda tangan terenkripsi |
reqTime | long | waktu saat ini dalam milidetik |
Nilai Kembali | Deskripsi |
---|---|
currency | Tipe transaksi |
id | Nomor pesanan yang dipercayakan |
price | Harga |
status | Status pesanan:(1. Batal, 2. Selesai/Batalkan pesanan setelah sebagian selesai, 3. Pesanan tertunda/Tidak ) |
total_amount | Jumlah pesanan |
trade_amount | Jumlah volume yang di setujui |
trade_date | mempercayakan waktu |
trade_money | Jumlah transaksi yang di setujui |
type | Jenis pesanan tertunda0-limit sell,1-limit buy,2-PostOnly sell,3-PostOnly buy,4-IOC sell,5-IOC buy |
fees | Biaya transaksi |
useZbFee | Apakah itu biaya pengurangan ZB |
Dapatkan pesanan abaikan jenis
Batalkan filter bidang tradeType untuk mendapatkan pesanan beli dan pesanan jual, mengembalikan 10 catatan Ukuran halaman per permintaan
Contoh permintaan
// request demo
GET https://trade.zb.com/api/getOrdersIgnoreTradeType?accesskey=youraccesskey¤cy=zb_qc&method=getOrdersIgnoreTradeType&pageIndex=1&pageSize=1&sign=Minta string tanda tangan terenkripsi&reqTime=waktu saat ini dalam milidetik
// java demo
public void getOrdersIgnoreTradeType() {
//TestapiKey:ce2a18e0-dshs-4c44-4515-9aca67dd706e
//TestsecretKey:c11a122s-dshs-shsa-4515-954a67dd706e
//Enkripsi:https://github.com/zb2017/api/blob/master/zb_netty_client_java/src/main/java/websocketx/client/EncryDigestUtil.java
//secretKeyDiperoleh dengan enkripsi sha1:86429c69799d3d6ac5da5c2c514baa874d75a4ba
String digest = EncryDigestUtil.digest("c11a122s-dshs-shsa-4515-954a67dd706e");
//Parameter diurutkan berdasarkan nilai ASCII
String paramStr = "accesskey=ce2a18e0-dshs-4c44-4515-9aca67dd706e¤cy=zb_qc&method=getOrdersIgnoreTradeType&pageIndex=1&pageSize=10";
//tanda dienkripsi oleh HmacMD5:035c3a682574790044dc7aa4cffa0259
String sign = EncryDigestUtil.hmacSign(paramStr, digest);
//permintaan terakhir yang dikirimurl
String finalUrl = "https://trade.zb.com/api/getOrdersIgnoreTradeType?method=getOrdersIgnoreTradeType&accesskey=ce2a18e0-dshs-4c44-4515-9aca67dd706e¤cy=zb_qc&pageIndex=1&pageSize=10&sign=035c3a682574790044dc7aa4cffa0259&reqTime=1539942326054";
//Dapatkan hasil pengembalianjson
String resultJson = HttpRequest.get(finalUrl).send().bodyText();
}
// python demo
import hashlib
import struct
import time
import requests
class ZApi:
def __init__(self, access_key, secret_key):
self._access_key_ = access_key
self._secret_key_ = secret_key
self._markets_ = self.markets()
if len(self._markets_) < 1:
raise Exception("Get markets status failed")
def getOrdersIgnoreTradeType(self, market, type, amount, price):
MyUrl = 'https://trade.zb.com/api/getOrdersIgnoreTradeType'
#params = 'accesskey=ce2a18e0-dshs-4c44-4515-9aca67dd706e¤cy=bch_qc&method=getOrdersIgnoreTradeType&pageIndex=1&pageSize=10'
params = 'accesskey=' + self._access_key_ + '¤cy=bch_qc&method=getOrdersIgnoreTradeType&pageIndex=1&pageSize=10'
return self.call_api(url=MyUrl, params=params)
def call_api(self, url, params=''):
full_url = url
if params:
#sha_secret=86429c69799d3d6ac5da5c2c514baa874d75a4ba
sha_secret = self.digest(self._secret_key_)
#sign = 035c3a682574790044dc7aa4cffa0259
sign = self.hmac_sign(params, sha_secret)
req_time = int(round(time.time() * 1000))
params += '&sign=%s&reqTime=%d' % (sign, req_time)
#full_url = https://trade.zb.com/api/getOrdersIgnoreTradeType?method=getOrdersIgnoreTradeType&accesskey=ce2a18e0-dshs-4c44-4515-9aca67dd706e¤cy=zb_qc&pageIndex=1&pageSize=10&sign=035c3a682574790044dc7aa4cffa0259&reqTime=1540295995530
full_url += '?' + params
result = {}
while True:
try:
r = requests.get(full_url, timeout=2)
except Exception:
time.sleep(0.5)
continue
if r.status_code != 200:
time.sleep(0.5)
r.close()
continue
else:
result = r.json()
r.close()
break
return result
@staticmethod
def fill(value, length, fill_byte):
if len(value) >= length:
return value
else:
fill_size = length - len(value)
return value + chr(fill_byte) * fill_size
@staticmethod
def xor(s, value):
slist = list(s.decode('utf-8'))
for index in range(len(slist)):
slist[index] = chr(ord(slist[index]) ^ value)
return "".join(slist)
def hmac_sign(self, arg_value, arg_key):
keyb = struct.pack("%ds" % len(arg_key), arg_key.encode('utf-8'))
value = struct.pack("%ds" % len(arg_value), arg_value.encode('utf-8'))
k_ipad = self.xor(keyb, 0x36)
k_opad = self.xor(keyb, 0x5c)
k_ipad = self.fill(k_ipad, 64, 54)
k_opad = self.fill(k_opad, 64, 92)
m = hashlib.md5()
m.update(k_ipad.encode('utf-8'))
m.update(value)
dg = m.digest()
m = hashlib.md5()
m.update(k_opad.encode('utf-8'))
subStr = dg[0:16]
m.update(subStr)
dg = m.hexdigest()
return dg
def digest(self, arg_value):
value = struct.pack("%ds" % len(arg_value), arg_value.encode('utf-8'))
h = hashlib.sha1()
h.update(value)
dg = h.hexdigest()
return dg
Contoh tanggapan
// Hasil Kembali
[
{
"currency": "btc_usdt",
"id": "20150928158614292",
"price": 1560,
"status": 3,
"total_amount": 0.1,
"trade_amount": 0,
"trade_date": 1443410396717,
"trade_money": 0,
"type": 0,
"fees": "0.03",
"useZbFee": true
}...
]
Nama parameter | Jenis | Rentang nilai |
---|---|---|
method | String | penugasan langsunggetOrdersIgnoreTradeType |
accesskey | String | accesskey |
currency | String | Transaksi koin/harga koin |
pageIndex | int | nomor halaman saat ini(Seperti: 1, halaman 1) |
pageSize | int | Kuantitas per halaman |
sign | String | Minta string tanda tangan terenkripsi |
reqTime | long | waktu saat ini dalam milidetik |
Nilai Kembali | Deskripsi |
---|---|
currency | Tipe transaksi |
id | Nomor pesanan yang dipercayakan |
price | Harga |
status | Status pesanan:(1. Batal, 2. Selesai/Batalkan pesanan setelah sebagian selesai, 3. Pesanan tertunda/Tidak ) |
total_amount | Jumlah pesanan |
trade_amount | Jumlah volume yang di setujui |
trade_date | mempercayakan waktu |
trade_money | Jumlah transaksi yang di setujui |
type | Jenis pesanan tertunda0-limit sell,1-limit buy,2-PostOnly sell,3-PostOnly buy,4-IOC sell,5-IOC buy |
fees | Biaya transaksi |
useZbFee | Apakah itu biaya pengurangan ZB |
Pesanan yang dibatalkan atau sebagian selesai
Selesaikan sebagian pesanan beli dan pesanan jual, kembalikan kurang dari 10 halaman Catatan ukuran per permintaan
Contoh permintaan
// request demo
GET https://trade.zb.com/api/getUnfinishedOrdersIgnoreTradeType?accesskey=youraccesskey¤cy=zb_qc&method=getUnfinishedOrdersIgnoreTradeType&pageIndex=1&pageSize=10&sign=Minta string tanda tangan terenkripsi&reqTime=waktu saat ini dalam milidetik
// java demo
public void getUnfinishedOrdersIgnoreTradeType() {
//TestapiKey:ce2a18e0-dshs-4c44-4515-9aca67dd706e
//TestsecretKey:c11a122s-dshs-shsa-4515-954a67dd706e
//Enkripsi:https://github.com/zb2017/api/blob/master/zb_netty_client_java/src/main/java/websocketx/client/EncryDigestUtil.java
//secretKeyDiperoleh dengan enkripsi sha1:86429c69799d3d6ac5da5c2c514baa874d75a4ba
String digest = EncryDigestUtil.digest("c11a122s-dshs-shsa-4515-954a67dd706e");
//Parameter diurutkan berdasarkan nilai ASCII
String paramStr = "accesskey=ce2a18e0-dshs-4c44-4515-9aca67dd706e¤cy=zb_qc&method=getUnfinishedOrdersIgnoreTradeType&pageIndex=1&pageSize=10";
//tanda dienkripsi oleh HmacMD5:8007befda9d8903ea5e17601ea78bd94
String sign = EncryDigestUtil.hmacSign(paramStr, digest);
//permintaan terakhir yang dikirimurl
String finalUrl = "https://trade.zb.com/api/getUnfinishedOrdersIgnoreTradeType?accesskey=ce2a18e0-dshs-4c44-4515-9aca67dd706e¤cy=zb_qc&method=getUnfinishedOrdersIgnoreTradeType&pageIndex=1&pageSize=10&reqTime=1539942326063&sign=8007befda9d8903ea5e17601ea78bd94";
//Dapatkan hasil pengembalianjson
String resultJson = HttpRequest.get(finalUrl).send().bodyText();
}
// python demo
import hashlib
import struct
import time
import requests
class ZApi:
def __init__(self, access_key, secret_key):
self._access_key_ = access_key
self._secret_key_ = secret_key
self._markets_ = self.markets()
if len(self._markets_) < 1:
raise Exception("Get markets status failed")
def getUnfinishedOrdersIgnoreTradeType(self, market, type, amount, price):
MyUrl = 'https://trade.zb.com/api/getUnfinishedOrdersIgnoreTradeType'
#params = 'accesskey=ce2a18e0-dshs-4c44-4515-9aca67dd706e¤cy=zb_qc&method=getUnfinishedOrdersIgnoreTradeType&pageIndex=1&pageSize=10'
params = 'accesskey=' + self._access_key_ + '¤cy=zb_qc&method=getUnfinishedOrdersIgnoreTradeType&pageIndex=1&pageSize=10'
return self.call_api(url=MyUrl, params=params)
def call_api(self, url, params=''):
full_url = url
if params:
#sha_secret=86429c69799d3d6ac5da5c2c514baa874d75a4ba
sha_secret = self.digest(self._secret_key_)
#sign = 8007befda9d8903ea5e17601ea78bd94
sign = self.hmac_sign(params, sha_secret)
req_time = int(round(time.time() * 1000))
params += '&sign=%s&reqTime=%d' % (sign, req_time)
#full_url = https://trade.zb.com/api/getUnfinishedOrdersIgnoreTradeType?accesskey=ce2a18e0-dshs-4c44-4515-9aca67dd706e¤cy=zb_qc&method=getUnfinishedOrdersIgnoreTradeType&pageIndex=1&pageSize=10&reqTime=1540295995546&sign=8007befda9d8903ea5e17601ea78bd94
full_url += '?' + params
result = {}
while True:
try:
r = requests.get(full_url, timeout=2)
except Exception:
time.sleep(0.5)
continue
if r.status_code != 200:
time.sleep(0.5)
r.close()
continue
else:
result = r.json()
r.close()
break
return result
@staticmethod
def fill(value, length, fill_byte):
if len(value) >= length:
return value
else:
fill_size = length - len(value)
return value + chr(fill_byte) * fill_size
@staticmethod
def xor(s, value):
slist = list(s.decode('utf-8'))
for index in range(len(slist)):
slist[index] = chr(ord(slist[index]) ^ value)
return "".join(slist)
def hmac_sign(self, arg_value, arg_key):
keyb = struct.pack("%ds" % len(arg_key), arg_key.encode('utf-8'))
value = struct.pack("%ds" % len(arg_value), arg_value.encode('utf-8'))
k_ipad = self.xor(keyb, 0x36)
k_opad = self.xor(keyb, 0x5c)
k_ipad = self.fill(k_ipad, 64, 54)
k_opad = self.fill(k_opad, 64, 92)
m = hashlib.md5()
m.update(k_ipad.encode('utf-8'))
m.update(value)
dg = m.digest()
m = hashlib.md5()
m.update(k_opad.encode('utf-8'))
subStr = dg[0:16]
m.update(subStr)
dg = m.hexdigest()
return dg
def digest(self, arg_value):
value = struct.pack("%ds" % len(arg_value), arg_value.encode('utf-8'))
h = hashlib.sha1()
h.update(value)
dg = h.hexdigest()
return dg
Contoh tanggapan
// Hasil Kembali
[
{
"currency": "btc_usdt",
"id": "20150928158614292",
"price": 1560,
"status": 3,
"total_amount": 0.1,
"trade_amount": 0,
"trade_date": 1443410396717,
"trade_money": 0,
"type": 0,
"fees": "0.03",
"useZbFee": true
}...
]
Nama parameter | Jenis | Rentang nilai |
---|---|---|
method | String | penugasan langsunggetUnfinishedOrdersIgnoreTradeType |
accesskey | String | accesskey |
currency | String | Transaksi koin/harga koin |
pageIndex | int | nomor halaman saat ini(Seperti: 1, halaman 1) |
pageSize | int | Kuantitas per halaman |
sign | String | Minta string tanda tangan terenkripsi |
reqTime | long | waktu saat ini dalam milidetik |
Nilai Kembali | Deskripsi |
---|---|
currency | Tipe transaksi |
id | Nomor pesanan yang dipercayakan |
price | Harga |
status | Status pesanan:(1. Batal, 2. Selesai/Batalkan pesanan setelah sebagian selesai, 3. Pesanan tertunda/Tidak )) |
total_amount | Jumlah pesanan |
trade_amount | Jumlah volume yang di setujui |
trade_date | mempercayakan waktu |
trade_money | Jumlah transaksi yang di setujui |
type | Jenis pesanan tertunda0-limit sell,1-limit buy,2-PostOnly sell,3-PostOnly buy,4-IOC sell,5-IOC buy |
fees | Biaya transaksi |
useZbFee | Apakah itu biaya pengurangan ZB |
Dapatkan pesanan yang terisi atau terisi sebagian
Contoh permintaan
// request demo
GET https://trade.zb.com/api/getFinishedAndPartialOrders?accesskey=youraccesskey¤cy=btc_usdt&method=getFinishedAndPartialOrders&pageIndex=1&pageSize=10&sign=Minta string tanda tangan terenkripsi&reqTime=waktu saat ini dalam milidetik
Contoh tanggapan
// Hasil Kembali
[
{
"currency": "btc_usdt",
"id": "20150928158614292",
"price": 1560,
"status": 3,
"total_amount": 0.1,
"trade_amount": 0,
"trade_date": 1443410396717,
"trade_money": 0,
"type": 0,
"fees": "0.03",
"useZbFee": true
}...
]
Nama parameter | Jenis | Rentang nilai |
---|---|---|
method | String | penugasan langsunggetFinishedAndPartialOrders |
accesskey | String | accesskey |
currency | String | Transaksi koin/harga koin |
pageIndex | int | nomor halaman saat ini(Seperti: 1, halaman 1) |
pageSize | int | Kuantitas per halaman |
sign | String | Minta string tanda tangan terenkripsi |
reqTime | long | waktu saat ini dalam milidetik |
Nilai Kembali | Deskripsi |
---|---|
currency | Tipe transaksi |
id | Nomor pesanan yang dipercayakan |
price | Harga |
status | Status pesanan:(1. Batal, 2. Selesai/Batalkan pesanan setelah sebagian selesai, 3. Pesanan tertunda/Tidak )) |
total_amount | Jumlah pesanan |
trade_amount | Jumlah volume yang di setujui |
trade_date | mempercayakan waktu |
trade_money | Jumlah transaksi yang di setujui |
type | Jenis pesanan tertunda0-limit sell,1-limit buy,2-PostOnly sell,3-PostOnly buy,4-IOC sell,5-IOC buy |
fees | Biaya transaksi |
useZbFee | Apakah itu biaya pengurangan ZB |
Sub-akun
Buat Sub-akun
Contoh permintaan
// request demo
GET https://trade.zb.com/api/addSubUser?accesskey=youraccesskey&memo=xxx&password=xxxx&method=addSubUser⊂UserName=xxxxx&sign=Minta string tanda tangan terenkripsi&reqTime=waktu saat ini dalam milidetik
// java demo
public void addSubUser() {
//TestapiKey:ce2a18e0-dshs-4c44-4515-9aca67dd706e
//TestsecretKey:c11a122s-dshs-shsa-4515-954a67dd706e
//Enkripsi:https://github.com/zb2017/api/blob/master/zb_netty_client_java/src/main/java/websocketx/client/EncryDigestUtil.java
//secretKeyDiperoleh dengan enkripsi sha1:86429c69799d3d6ac5da5c2c514baa874d75a4ba
String digest = EncryDigestUtil.digest("c11a122s-dshs-shsa-4515-954a67dd706e");
//Parameter diurutkan berdasarkan nilai ASCII
String paramStr = "accesskey=ce2a18e0-dshs-4c44-4515-9aca67dd706e&memo=hah&method=addSubUser&password=pass123457⊂UserName=test33";
//tanda dienkripsi oleh HmacMD5:9f8018b8ca1dd4fba833a1fc51b81768
String sign = EncryDigestUtil.hmacSign(paramStr, digest);
//permintaan terakhir yang dikirimurl
String finalUrl = "https://trade.zb.com/api/addSubUser?accesskey=ce2a18e0-dshs-4c44-4515-9aca67dd706e&memo=hah&method=addSubUser&password=pass123457&reqTime=1539942326088&sign=9f8018b8ca1dd4fba833a1fc51b81768⊂UserName=test33";
//Dapatkan hasil pengembalianjson
String resultJson = HttpRequest.get(finalUrl).send().bodyText();
}
// python demo
import hashlib
import struct
import time
import requests
class ZApi:
def __init__(self, access_key, secret_key):
self._access_key_ = access_key
self._secret_key_ = secret_key
self._markets_ = self.markets()
if len(self._markets_) < 1:
raise Exception("Get markets status failed")
def addSubUser(self, market, type, amount, price):
MyUrl = 'https://trade.zb.com/api/addSubUser'
#params = 'accesskey=ce2a18e0-dshs-4c44-4515-9aca67dd706e&memo=hah&method=addSubUser&password=pass123457⊂UserName=test33'
params = 'accesskey=' + self._access_key_ + '&memo=hah&method=addSubUser&password=pass123457⊂UserName=test33'
return self.call_api(url=MyUrl, params=params)
def call_api(self, url, params=''):
full_url = url
if params:
#sha_secret=86429c69799d3d6ac5da5c2c514baa874d75a4ba
sha_secret = self.digest(self._secret_key_)
#sign = 9f8018b8ca1dd4fba833a1fc51b81768
sign = self.hmac_sign(params, sha_secret)
req_time = int(round(time.time() * 1000))
params += '&sign=%s&reqTime=%d' % (sign, req_time)
#full_url = https://trade.zb.com/api/addSubUser?accesskey=ce2a18e0-dshs-4c44-4515-9aca67dd706e&memo=hah&method=addSubUser&password=pass123457&reqTime=1540295995605&sign=9f8018b8ca1dd4fba833a1fc51b81768⊂UserName=test33
full_url += '?' + params
result = {}
while True:
try:
r = requests.get(full_url, timeout=2)
except Exception:
time.sleep(0.5)
continue
if r.status_code != 200:
time.sleep(0.5)
r.close()
continue
else:
result = r.json()
r.close()
break
return result
@staticmethod
def fill(value, length, fill_byte):
if len(value) >= length:
return value
else:
fill_size = length - len(value)
return value + chr(fill_byte) * fill_size
@staticmethod
def xor(s, value):
slist = list(s.decode('utf-8'))
for index in range(len(slist)):
slist[index] = chr(ord(slist[index]) ^ value)
return "".join(slist)
def hmac_sign(self, arg_value, arg_key):
keyb = struct.pack("%ds" % len(arg_key), arg_key.encode('utf-8'))
value = struct.pack("%ds" % len(arg_value), arg_value.encode('utf-8'))
k_ipad = self.xor(keyb, 0x36)
k_opad = self.xor(keyb, 0x5c)
k_ipad = self.fill(k_ipad, 64, 54)
k_opad = self.fill(k_opad, 64, 92)
m = hashlib.md5()
m.update(k_ipad.encode('utf-8'))
m.update(value)
dg = m.digest()
m = hashlib.md5()
m.update(k_opad.encode('utf-8'))
subStr = dg[0:16]
m.update(subStr)
dg = m.hexdigest()
return dg
def digest(self, arg_value):
value = struct.pack("%ds" % len(arg_value), arg_value.encode('utf-8'))
h = hashlib.sha1()
h.update(value)
dg = h.hexdigest()
return dg
Contoh tanggapan
// Hasil Kembali
{
"code": 1000,
"message": {
"des": "success",
"isSuc": true,
"datas": {}
}
}
Nama parameter | Jenis | Rentang nilai |
---|---|---|
memo | String | Remark |
password | String | Kata sandi |
subUserName | String | Nama pengguna sub akun(tidak lebih dari6angka atau huruf) |
accesskey | String | accesskey |
reqTime | Long | waktu saat ini dalam milidetik |
sign | String | Tanda tangan |
Nilai Kembali | Deskripsi |
---|---|
code | Kode Pengembalian |
des | Petunjuk |
isSuc | Apakah berhasil |
Dapatkan daftar sub-akun
Contoh permintaan
// request demo
GET https://trade.zb.com/api/getSubUserList?accesskey=youraccesskey&method=getSubUserList&sign=Minta string tanda tangan terenkripsi&reqTime=waktu saat ini dalam milidetik
// java demo
public void getSubUserList() {
//TestapiKey:ce2a18e0-dshs-4c44-4515-9aca67dd706e
//TestsecretKey:c11a122s-dshs-shsa-4515-954a67dd706e
//Enkripsi:https://github.com/zb2017/api/blob/master/zb_netty_client_java/src/main/java/websocketx/client/EncryDigestUtil.java
//secretKeyDiperoleh dengan enkripsi sha1:86429c69799d3d6ac5da5c2c514baa874d75a4ba
String digest = EncryDigestUtil.digest("c11a122s-dshs-shsa-4515-954a67dd706e");
//Parameter diurutkan berdasarkan nilai ASCII
String paramStr = "accesskey=ce2a18e0-dshs-4c44-4515-9aca67dd706e&method=getSubUserList";
//tanda dienkripsi oleh HmacMD5:2abacfab6ecb27144b798f36e1d8443c
String sign = EncryDigestUtil.hmacSign(paramStr, digest);
//permintaan terakhir yang dikirimurl
String finalUrl = "https://trade.zb.com/api/getSubUserList?accesskey=ce2a18e0-dshs-4c44-4515-9aca67dd706e&method=getSubUserList&reqTime=1539942326091&sign=2abacfab6ecb27144b798f36e1d8443c";
//Dapatkan hasil pengembalianjson
String resultJson = HttpRequest.get(finalUrl).send().bodyText();
}
// python demo
import hashlib
import struct
import time
import requests
class ZApi:
def __init__(self, access_key, secret_key):
self._access_key_ = access_key
self._secret_key_ = secret_key
self._markets_ = self.markets()
if len(self._markets_) < 1:
raise Exception("Get markets status failed")
def getSubUserList(self, market, type, amount, price):
MyUrl = 'https://trade.zb.com/api/getSubUserList'
#params = 'accesskey=ce2a18e0-dshs-4c44-4515-9aca67dd706e&method=getSubUserList'
params = 'accesskey=' + self._access_key_ + '&method=getSubUserList'
return self.call_api(url=MyUrl, params=params)
def call_api(self, url, params=''):
full_url = url
if params:
#sha_secret=86429c69799d3d6ac5da5c2c514baa874d75a4ba
sha_secret = self.digest(self._secret_key_)
#sign = 2abacfab6ecb27144b798f36e1d8443c
sign = self.hmac_sign(params, sha_secret)
req_time = int(round(time.time() * 1000))
params += '&sign=%s&reqTime=%d' % (sign, req_time)
#full_url = https://trade.zb.com/api/getSubUserList?accesskey=ce2a18e0-dshs-4c44-4515-9aca67dd706e&method=getSubUserList&reqTime=1540295995611&sign=2abacfab6ecb27144b798f36e1d8443c
full_url += '?' + params
result = {}
while True:
try:
r = requests.get(full_url, timeout=2)
except Exception:
time.sleep(0.5)
continue
if r.status_code != 200:
time.sleep(0.5)
r.close()
continue
else:
result = r.json()
r.close()
break
return result
@staticmethod
def fill(value, length, fill_byte):
if len(value) >= length:
return value
else:
fill_size = length - len(value)
return value + chr(fill_byte) * fill_size
@staticmethod
def xor(s, value):
slist = list(s.decode('utf-8'))
for index in range(len(slist)):
slist[index] = chr(ord(slist[index]) ^ value)
return "".join(slist)
def hmac_sign(self, arg_value, arg_key):
keyb = struct.pack("%ds" % len(arg_key), arg_key.encode('utf-8'))
value = struct.pack("%ds" % len(arg_value), arg_value.encode('utf-8'))
k_ipad = self.xor(keyb, 0x36)
k_opad = self.xor(keyb, 0x5c)
k_ipad = self.fill(k_ipad, 64, 54)
k_opad = self.fill(k_opad, 64, 92)
m = hashlib.md5()
m.update(k_ipad.encode('utf-8'))
m.update(value)
dg = m.digest()
m = hashlib.md5()
m.update(k_opad.encode('utf-8'))
subStr = dg[0:16]
m.update(subStr)
dg = m.hexdigest()
return dg
def digest(self, arg_value):
value = struct.pack("%ds" % len(arg_value), arg_value.encode('utf-8'))
h = hashlib.sha1()
h.update(value)
dg = h.hexdigest()
return dg
Contoh tanggapan
// Hasil Kembali
{
"code": 1000,
"message": "Proses berhasil",
"result": [
{
"isOpenApi": false,
"memo": "1",
"userName": "xxxx@1",
"userId": 123456,
"isFreez": false
},
{
"isOpenApi": false,
"memo": "2",
"userName": "xxxx@2",
"userId": 132456,
"isFreez": false
}
]
}
Nama parameter | Jenis | Rentang nilai |
---|---|---|
accesskey | String | accesskey |
reqTime | Long | waktu saat ini dalam milidetik |
sign | String | Tanda tangan |
Nilai Kembali | Deskripsi |
---|---|
code | Kode Pengembalian |
des | Petunjuk |
isSuc | Apakah berhasil |
isOpenApi | Apakah akan membukaAPI |
userName | Nama pengguna |
isFreez | Apa di bekukan |
memo | Remark |
Internal transfer antara akun utama dan sub-akun
Contoh permintaan
// request demo
https://trade.zb.com/api/doTransferFunds?accesskey=youraccesskey&method=doTransferFunds&amount=1¤cy=xx&fromUserName=xx&toUserName=xxxx&sign=Minta string tanda tangan terenkripsi&reqTime=waktu saat ini dalam milidetik
// java demo
public void doTransferFunds() {
//TestapiKey:ce2a18e0-dshs-4c44-4515-9aca67dd706e
//TestsecretKey:c11a122s-dshs-shsa-4515-954a67dd706e
//Enkripsi:https://github.com/zb2017/api/blob/master/zb_netty_client_java/src/main/java/websocketx/client/EncryDigestUtil.java
//secretKeyDiperoleh dengan enkripsi sha1:86429c69799d3d6ac5da5c2c514baa874d75a4ba
String digest = EncryDigestUtil.digest("c11a122s-dshs-shsa-4515-954a67dd706e");
//Parameter diurutkan berdasarkan nilai ASCII
String paramStr = "accesskey=ce2a18e0-dshs-4c44-4515-9aca67dd706e&amount=1¤cy=doge&[email protected]&method=doTransferFunds&toUserName=lianlianyi@test12";
//tanda dienkripsi oleh HmacMD5:0d109b7d008c924041d10cf5706b2fce
String sign = EncryDigestUtil.hmacSign(paramStr, digest);
//permintaan terakhir yang dikirimurl
String finalUrl = "https://trade.zb.com/api/doTransferFunds?accesskey=ce2a18e0-dshs-4c44-4515-9aca67dd706e&amount=1¤cy=doge&fromUserName=lianlianyi%40vip.qq.com&method=doTransferFunds&reqTime=1539942326092&sign=0d109b7d008c924041d10cf5706b2fce&toUserName=lianlianyi%40test12";
//Dapatkan hasil pengembalianjson
String resultJson = HttpRequest.get(finalUrl).send().bodyText();
}
// python demo
import hashlib
import struct
import time
import requests
class ZApi:
def __init__(self, access_key, secret_key):
self._access_key_ = access_key
self._secret_key_ = secret_key
self._markets_ = self.markets()
if len(self._markets_) < 1:
raise Exception("Get markets status failed")
def doTransferFunds(self, market, type, amount, price):
MyUrl = 'https://trade.zb.com/api/doTransferFunds'
#params = 'accesskey=ce2a18e0-dshs-4c44-4515-9aca67dd706e&amount=1¤cy=doge&[email protected]&method=doTransferFunds&toUserName=lianlianyi@test12'
params = 'accesskey=' + self._access_key_ + '&amount=1¤cy=doge&[email protected]&method=doTransferFunds&toUserName=lianlianyi@test12'
return self.call_api(url=MyUrl, params=params)
def call_api(self, url, params=''):
full_url = url
if params:
#sha_secret=86429c69799d3d6ac5da5c2c514baa874d75a4ba
sha_secret = self.digest(self._secret_key_)
#sign = 0d109b7d008c924041d10cf5706b2fce
sign = self.hmac_sign(params, sha_secret)
req_time = int(round(time.time() * 1000))
params += '&sign=%s&reqTime=%d' % (sign, req_time)
#full_url = https://trade.zb.com/api/doTransferFunds?accesskey=ce2a18e0-dshs-4c44-4515-9aca67dd706e&amount=1¤cy=doge&fromUserName=lianlianyi%40vip.qq.com&method=doTransferFunds&reqTime=1540295995614&sign=0d109b7d008c924041d10cf5706b2fce&toUserName=lianlianyi%40test12
full_url += '?' + params
result = {}
while True:
try:
r = requests.get(full_url, timeout=2)
except Exception:
time.sleep(0.5)
continue
if r.status_code != 200:
time.sleep(0.5)
r.close()
continue
else:
result = r.json()
r.close()
break
return result
@staticmethod
def fill(value, length, fill_byte):
if len(value) >= length:
return value
else:
fill_size = length - len(value)
return value + chr(fill_byte) * fill_size
@staticmethod
def xor(s, value):
slist = list(s.decode('utf-8'))
for index in range(len(slist)):
slist[index] = chr(ord(slist[index]) ^ value)
return "".join(slist)
def hmac_sign(self, arg_value, arg_key):
keyb = struct.pack("%ds" % len(arg_key), arg_key.encode('utf-8'))
value = struct.pack("%ds" % len(arg_value), arg_value.encode('utf-8'))
k_ipad = self.xor(keyb, 0x36)
k_opad = self.xor(keyb, 0x5c)
k_ipad = self.fill(k_ipad, 64, 54)
k_opad = self.fill(k_opad, 64, 92)
m = hashlib.md5()
m.update(k_ipad.encode('utf-8'))
m.update(value)
dg = m.digest()
m = hashlib.md5()
m.update(k_opad.encode('utf-8'))
subStr = dg[0:16]
m.update(subStr)
dg = m.hexdigest()
return dg
def digest(self, arg_value):
value = struct.pack("%ds" % len(arg_value), arg_value.encode('utf-8'))
h = hashlib.sha1()
h.update(value)
dg = h.hexdigest()
return dg
Contoh tanggapan
// Hasil Kembali
{
"code": 1000,
"message": "Proses berhasil",
"result": []
}
Nama parameter | Jenis | Rentang nilai |
---|---|---|
amount | Double | Jumlah |
currency | String | Bunga yang telah jatuh tempo |
fromUserName | String | Nama Pengguna Pengalih |
toUserName | String | Nama Pengguna Penerima |
accesskey | String | accesskey |
reqTime | Long | waktu saat ini dalam milidetik |
sign | String | Tanda tangan |
Nilai Kembali | Deskripsi |
---|---|
code | Kode Pengembalian |
des | Petunjuk |
isSuc | Apakah berhasil |
Leverage Terisolasi
Dapatkan informasi yang terisolasi
Contoh permintaan
// request demo
GET https://trade.zb.com/api/getLeverAssetsInfo?accesskey=youraccesskey&method=getLeverAssetsInfo&sign=Minta string tanda tangan terenkripsi&reqTime=waktu saat ini dalam milidetik
// java demo
public void getLeverAssetsInfo() {
//TestapiKey:ce2a18e0-dshs-4c44-4515-9aca67dd706e
//TestsecretKey:c11a122s-dshs-shsa-4515-954a67dd706e
//Enkripsi:https://github.com/zb2017/api/blob/master/zb_netty_client_java/src/main/java/websocketx/client/EncryDigestUtil.java
//secretKeyDiperoleh dengan enkripsi sha1:86429c69799d3d6ac5da5c2c514baa874d75a4ba
String digest = EncryDigestUtil.digest("c11a122s-dshs-shsa-4515-954a67dd706e");
//Parameter diurutkan berdasarkan nilai ASCII
String paramStr = "accesskey=ce2a18e0-dshs-4c44-4515-9aca67dd706e&method=getLeverAssetsInfo";
//tanda dienkripsi oleh HmacMD5:0cc8a3b79dabfac0c28229dd3871862d
String sign = EncryDigestUtil.hmacSign(paramStr, digest);
//permintaan terakhir yang dikirimurl
String finalUrl = "https://trade.zb.com/api/getLeverAssetsInfo?accesskey=ce2a18e0-dshs-4c44-4515-9aca67dd706e&method=getLeverAssetsInfo&reqTime=1539942326068&sign=0cc8a3b79dabfac0c28229dd3871862d";
//Dapatkan hasil pengembalianjson
String resultJson = HttpRequest.get(finalUrl).send().bodyText();
}
// python demo
import hashlib
import struct
import time
import requests
class ZApi:
def __init__(self, access_key, secret_key):
self._access_key_ = access_key
self._secret_key_ = secret_key
self._markets_ = self.markets()
if len(self._markets_) < 1:
raise Exception("Get markets status failed")
def getLeverAssetsInfo(self, market, type, amount, price):
MyUrl = 'https://trade.zb.com/api/getLeverAssetsInfo'
#params = 'accesskey=ce2a18e0-dshs-4c44-4515-9aca67dd706e&method=getLeverAssetsInfo'
params = 'accesskey=' + self._access_key_ + '&method=getLeverAssetsInfo'
return self.call_api(url=MyUrl, params=params)
def call_api(self, url, params=''):
full_url = url
if params:
#sha_secret=86429c69799d3d6ac5da5c2c514baa874d75a4ba
sha_secret = self.digest(self._secret_key_)
#sign = 0cc8a3b79dabfac0c28229dd3871862d
sign = self.hmac_sign(params, sha_secret)
req_time = int(round(time.time() * 1000))
params += '&sign=%s&reqTime=%d' % (sign, req_time)
#full_url = https://trade.zb.com/api/getLeverAssetsInfo?accesskey=ce2a18e0-dshs-4c44-4515-9aca67dd706e&method=getLeverAssetsInfo&reqTime=1540295995557&sign=0cc8a3b79dabfac0c28229dd3871862d
full_url += '?' + params
result = {}
while True:
try:
r = requests.get(full_url, timeout=2)
except Exception:
time.sleep(0.5)
continue
if r.status_code != 200:
time.sleep(0.5)
r.close()
continue
else:
result = r.json()
r.close()
break
return result
@staticmethod
def fill(value, length, fill_byte):
if len(value) >= length:
return value
else:
fill_size = length - len(value)
return value + chr(fill_byte) * fill_size
@staticmethod
def xor(s, value):
slist = list(s.decode('utf-8'))
for index in range(len(slist)):
slist[index] = chr(ord(slist[index]) ^ value)
return "".join(slist)
def hmac_sign(self, arg_value, arg_key):
keyb = struct.pack("%ds" % len(arg_key), arg_key.encode('utf-8'))
value = struct.pack("%ds" % len(arg_value), arg_value.encode('utf-8'))
k_ipad = self.xor(keyb, 0x36)
k_opad = self.xor(keyb, 0x5c)
k_ipad = self.fill(k_ipad, 64, 54)
k_opad = self.fill(k_opad, 64, 92)
m = hashlib.md5()
m.update(k_ipad.encode('utf-8'))
m.update(value)
dg = m.digest()
m = hashlib.md5()
m.update(k_opad.encode('utf-8'))
subStr = dg[0:16]
m.update(subStr)
dg = m.hexdigest()
return dg
def digest(self, arg_value):
value = struct.pack("%ds" % len(arg_value), arg_value.encode('utf-8'))
h = hashlib.sha1()
h.update(value)
dg = h.hexdigest()
return dg
Contoh tanggapan
// Hasil Kembali
{
"code": 1000,
"message": {
"des": "success",
"isSuc": true,
"datas": {
"levers": [
{
"fLoanIn": 0,
"repayLevel": 0,
"cUnitTag": "XRP",
"unwindPrice": 0,
"fUnitDecimal": 8,
"repayLock": false,
"cLoanIn": 0,
"cEnName": "XRP",
"cAvailable": 0,
"fAvailable": 0,
"cLoanOut": 0,
"cCanLoanIn": 0,
"fLoanOut": 0,
"level": 0,
"fFreeze": 0,
"fEnName": "BTC",
"cFreeze": 0,
"fCanLoanIn": 0,
"cUnitDecimal": 8,
"cOverdraft": 0,
"key": "xrpbtc",
"repayLeverShow": "-"
}
]
}
}
}
Nama parameter | Jenis | Rentang nilai |
---|---|---|
method | String | penugasan langsung getLeverAssetsInfo |
accesskey | String | accesskey |
sign | String | Minta string tanda tangan terenkripsi |
reqTime | long | waktu saat ini dalam milidetik |
Nilai Kembali | Deskripsi |
---|---|
code | Kode Pengembalian |
des | Petunjuk |
isSuc | Apakah berhasil |
key | Nama pasar |
fshowName | Gunakan nama baru jika diganti namanya,jika tidak samafname |
cshowName | Gunakan nama baru jika diganti namanya,jika tidak samacname |
showName | Jika ada perubahan nama, itu akan menjadi nama perdagangan baru,jika tidak samakey |
fLoanIn | Jumlah pinjaman mata uang Prancis |
repayLevel | Tingkat likuidasi |
unwindPrice | Harga likuidasi |
fUnitDecimal | Titik desimal |
repayLock | Apakah pembayaran dikunci |
cLoanIn | Jumlah pinjaman |
cAvailable | Koin yang tersedia |
fAvailable | Mata uang fiat tersedia |
cLoanOut | Jumlah koin yang di pinjamkan keluar |
cCanLoanIn | Tersedia untuk dipinjam |
fLoanOut | Mata uang fiat dapat dipinjamkan |
level | Tingkat margin |
fFreeze | Fiat di bekukan |
cFreeze | Pembekuan koin |
fCanLoanIn | Mata uang fiat dapat dipinjam |
cUnitDecimal | Titik desimal koin |
cOverdraft | 币欠息 |
repayLeverShow | Resiko likuidasi |
Dapatkan Tagihan Margin Terisolasi
Contoh permintaan
// request demo
GET https://trade.zb.com/api/getLeverBills?accesskey=youraccesskey&coin=qc&method=getLeverBills&pageIndex=1&pageSize=10&sign=Minta string tanda tangan terenkripsi&reqTime=waktu saat ini dalam milidetik
// java demo
public void getLeverBills() {
//TestapiKey:ce2a18e0-dshs-4c44-4515-9aca67dd706e
//TestsecretKey:c11a122s-dshs-shsa-4515-954a67dd706e
//Enkripsi:https://github.com/zb2017/api/blob/master/zb_netty_client_java/src/main/java/websocketx/client/EncryDigestUtil.java
//secretKeyDiperoleh dengan enkripsi sha1:86429c69799d3d6ac5da5c2c514baa874d75a4ba
String digest = EncryDigestUtil.digest("c11a122s-dshs-shsa-4515-954a67dd706e");
//Parameter diurutkan berdasarkan nilai ASCII
String paramStr = "accesskey=ce2a18e0-dshs-4c44-4515-9aca67dd706e&coin=qc&dataType=0&method=getLeverBills&pageIndex=1&pageSize=10";
//tanda dienkripsi oleh HmacMD5:2473a00d93feed72583365e3cb90f391
String sign = EncryDigestUtil.hmacSign(paramStr, digest);
//permintaan terakhir yang dikirimurl
String finalUrl = "https://trade.zb.com/api/getLeverBills?accesskey=ce2a18e0-dshs-4c44-4515-9aca67dd706e&coin=qc&dataType=0&method=getLeverBills&pageIndex=1&pageSize=10&reqTime=1539942326070&sign=2473a00d93feed72583365e3cb90f391";
//Dapatkan hasil pengembalianjson
String resultJson = HttpRequest.get(finalUrl).send().bodyText();
}
// python demo
import hashlib
import struct
import time
import requests
class ZApi:
def __init__(self, access_key, secret_key):
self._access_key_ = access_key
self._secret_key_ = secret_key
self._markets_ = self.markets()
if len(self._markets_) < 1:
raise Exception("Get markets status failed")
def getLeverBills(self, market, type, amount, price):
MyUrl = 'https://trade.zb.com/api/getLeverBills'
#params = 'accesskey=ce2a18e0-dshs-4c44-4515-9aca67dd706e&coin=qc&dataType=0&method=getLeverBills&pageIndex=1&pageSize=10'
params = 'accesskey=' + self._access_key_ + '&coin=qc&dataType=0&method=getLeverBills&pageIndex=1&pageSize=10'
return self.call_api(url=MyUrl, params=params)
def call_api(self, url, params=''):
full_url = url
if params:
#sha_secret=86429c69799d3d6ac5da5c2c514baa874d75a4ba
sha_secret = self.digest(self._secret_key_)
#sign = 2473a00d93feed72583365e3cb90f391
sign = self.hmac_sign(params, sha_secret)
req_time = int(round(time.time() * 1000))
params += '&sign=%s&reqTime=%d' % (sign, req_time)
#full_url = https://trade.zb.com/api/getLeverBills?accesskey=ce2a18e0-dshs-4c44-4515-9aca67dd706e&coin=qc&dataType=0&method=getLeverBills&pageIndex=1&pageSize=10&reqTime=1540295995560&sign=2473a00d93feed72583365e3cb90f391
full_url += '?' + params
result = {}
while True:
try:
r = requests.get(full_url, timeout=2)
except Exception:
time.sleep(0.5)
continue
if r.status_code != 200:
time.sleep(0.5)
r.close()
continue
else:
result = r.json()
r.close()
break
return result
@staticmethod
def fill(value, length, fill_byte):
if len(value) >= length:
return value
else:
fill_size = length - len(value)
return value + chr(fill_byte) * fill_size
@staticmethod
def xor(s, value):
slist = list(s.decode('utf-8'))
for index in range(len(slist)):
slist[index] = chr(ord(slist[index]) ^ value)
return "".join(slist)
def hmac_sign(self, arg_value, arg_key):
keyb = struct.pack("%ds" % len(arg_key), arg_key.encode('utf-8'))
value = struct.pack("%ds" % len(arg_value), arg_value.encode('utf-8'))
k_ipad = self.xor(keyb, 0x36)
k_opad = self.xor(keyb, 0x5c)
k_ipad = self.fill(k_ipad, 64, 54)
k_opad = self.fill(k_opad, 64, 92)
m = hashlib.md5()
m.update(k_ipad.encode('utf-8'))
m.update(value)
dg = m.digest()
m = hashlib.md5()
m.update(k_opad.encode('utf-8'))
subStr = dg[0:16]
m.update(subStr)
dg = m.hexdigest()
return dg
def digest(self, arg_value):
value = struct.pack("%ds" % len(arg_value), arg_value.encode('utf-8'))
h = hashlib.sha1()
h.update(value)
dg = h.hexdigest()
return dg
Contoh tanggapan
// Hasil Kembali
{
"code" : 1000,
"message" : "Proses berhasil。",
"result" : [
{
"changeCoin" : 500.00000000,
"showCoin" : "+500.000=500.000LTC",
"type" : 1,
"date" : 1522668146000,
"database" : "default",
"dataName" : "baseBean",
"fundsType" : 3,
"billTypeValue" : "LTCDeposit",
"id" : 609,
"downTableDate" : 1520092800000,
"marketName" : "ltcusdt",
"avgPrice" : 0,
"userId" : 110803,
"coinBalance" : 500.00000000,
"entrustId" : 0
}
]
}
Nama parameter | Jenis | Rentang nilai |
---|---|---|
method | String | penugasan langsung getLeverBills |
accesskey | String | accesskey |
coin | String | Bunga yang telah jatuh tempo |
dataType | int | Jenis data[0/1](Data dalam 30 hari/Data 30 hari yang lalu) |
pageIndex | int | nomor halaman saat ini(Seperti: 1, halaman 1) |
pageSize | int | Kuantitas per halaman |
sign | String | Minta string tanda tangan terenkripsi |
reqTime | long | waktu saat ini dalam milidetik |
Nilai Kembali | Deskripsi |
---|---|
code | Kode Pengembalian |
message | Petunjuk |
id | tagihanID |
userId | UserID |
date | Waktu pembuatan tagihan |
type | Jenis tagihan |
billTypeValue | Jenis tagihan sesuai dengan bahasa Cina |
changeCoin | perubahan iniCOINJumlah |
coinBalance | berubahCOINSaldo |
changeFiat | Jumlah mata uang fiat berubah kali ini |
fiatBalance | Saldo mata uang fiat |
fundsType | COINJenis |
marketName | Nama pasar |
showCoin | menunjukkanCOINvariasi |
showFiat | Tampilkan perubahan mata uang fiat |
Aset ditransfer ke leverage margin yang terisolasi
Contoh permintaan
// request demo
GET https://trade.zb.com/api/transferInLever?accesskey=youraccesskey&amount=100&coin=qc&marketName=btsqc&method=transferInLever&sign=Minta string tanda tangan terenkripsi&reqTime=waktu saat ini dalam milidetik
// java demo
public void transferInLever() {
//TestapiKey:ce2a18e0-dshs-4c44-4515-9aca67dd706e
//TestsecretKey:c11a122s-dshs-shsa-4515-954a67dd706e
//Enkripsi:https://github.com/zb2017/api/blob/master/zb_netty_client_java/src/main/java/websocketx/client/EncryDigestUtil.java
//secretKeyDiperoleh dengan enkripsi sha1:86429c69799d3d6ac5da5c2c514baa874d75a4ba
String digest = EncryDigestUtil.digest("c11a122s-dshs-shsa-4515-954a67dd706e");
//Parameter diurutkan berdasarkan nilai ASCII
String paramStr = "accesskey=ce2a18e0-dshs-4c44-4515-9aca67dd706e&amount=1&coin=qc&marketName=btsqc&method=transferInLever";
//tanda dienkripsi oleh HmacMD5:a8fe8d3e01143e83491e5df69f288fd4
String sign = EncryDigestUtil.hmacSign(paramStr, digest);
//permintaan terakhir yang dikirimurl
String finalUrl = "https://trade.zb.com/api/transferInLever?accesskey=ce2a18e0-dshs-4c44-4515-9aca67dd706e&amount=1&coin=qc&marketName=btsqc&method=transferInLever&reqTime=1539942326071&sign=a8fe8d3e01143e83491e5df69f288fd4";
//Dapatkan hasil pengembalianjson
String resultJson = HttpRequest.get(finalUrl).send().bodyText();
}
// python demo
import hashlib
import struct
import time
import requests
class ZApi:
def __init__(self, access_key, secret_key):
self._access_key_ = access_key
self._secret_key_ = secret_key
self._markets_ = self.markets()
if len(self._markets_) < 1:
raise Exception("Get markets status failed")
def transferInLever(self, market, type, amount, price):
MyUrl = 'https://trade.zb.com/api/transferInLever'
#params = 'accesskey=ce2a18e0-dshs-4c44-4515-9aca67dd706e&amount=1&coin=qc&marketName=btsqc&method=transferInLever'
params = 'accesskey=' + self._access_key_ + '&amount=1&coin=qc&marketName=btsqc&method=transferInLever'
return self.call_api(url=MyUrl, params=params)
def call_api(self, url, params=''):
full_url = url
if params:
#sha_secret=86429c69799d3d6ac5da5c2c514baa874d75a4ba
sha_secret = self.digest(self._secret_key_)
#sign = a8fe8d3e01143e83491e5df69f288fd4
sign = self.hmac_sign(params, sha_secret)
req_time = int(round(time.time() * 1000))
params += '&sign=%s&reqTime=%d' % (sign, req_time)
#full_url = https://trade.zb.com/api/transferInLever?accesskey=ce2a18e0-dshs-4c44-4515-9aca67dd706e&amount=1&coin=qc&marketName=btsqc&method=transferInLever&reqTime=1540295995563&sign=a8fe8d3e01143e83491e5df69f288fd4
full_url += '?' + params
result = {}
while True:
try:
r = requests.get(full_url, timeout=2)
except Exception:
time.sleep(0.5)
continue
if r.status_code != 200:
time.sleep(0.5)
r.close()
continue
else:
result = r.json()
r.close()
break
return result
@staticmethod
def fill(value, length, fill_byte):
if len(value) >= length:
return value
else:
fill_size = length - len(value)
return value + chr(fill_byte) * fill_size
@staticmethod
def xor(s, value):
slist = list(s.decode('utf-8'))
for index in range(len(slist)):
slist[index] = chr(ord(slist[index]) ^ value)
return "".join(slist)
def hmac_sign(self, arg_value, arg_key):
keyb = struct.pack("%ds" % len(arg_key), arg_key.encode('utf-8'))
value = struct.pack("%ds" % len(arg_value), arg_value.encode('utf-8'))
k_ipad = self.xor(keyb, 0x36)
k_opad = self.xor(keyb, 0x5c)
k_ipad = self.fill(k_ipad, 64, 54)
k_opad = self.fill(k_opad, 64, 92)
m = hashlib.md5()
m.update(k_ipad.encode('utf-8'))
m.update(value)
dg = m.digest()
m = hashlib.md5()
m.update(k_opad.encode('utf-8'))
subStr = dg[0:16]
m.update(subStr)
dg = m.hexdigest()
return dg
def digest(self, arg_value):
value = struct.pack("%ds" % len(arg_value), arg_value.encode('utf-8'))
h = hashlib.sha1()
h.update(value)
dg = h.hexdigest()
return dg
Contoh tanggapan
// Hasil Kembali
{
"code": "1000",
"message": "Proses berhasil。"
}
Nama parameter | Jenis | Rentang nilai |
---|---|---|
method | String | penugasan langsung transferInLever |
accesskey | String | accesskey |
coin | String | Bunga yang telah jatuh tempo |
marketName | String | Nama pasar |
amount | double | Jumlah Transfer,Tempat desimal tidak boleh melebihi4,Melebihi sistem secara otomatis di potong4Bit |
sign | String | Minta string tanda tangan terenkripsi |
reqTime | long | waktu saat ini dalam milidetik |
Nilai Kembali | Deskripsi |
---|---|
code | Kode Pengembalian |
message | Petunjuk |
Aset ditransfer keluar dari terisolasi
Contoh permintaan
// request demo
GET https://trade.zb.com/api/transferOutLever?accesskey=youraccesskey&amount=100&coin=qc&marketName=btsqc&method=transferOutLever&sign=Minta string tanda tangan terenkripsi&reqTime=waktu saat ini dalam milidetik
// java demo
public void transferOutLever() {
//TestapiKey:ce2a18e0-dshs-4c44-4515-9aca67dd706e
//TestsecretKey:c11a122s-dshs-shsa-4515-954a67dd706e
//Enkripsi:https://github.com/zb2017/api/blob/master/zb_netty_client_java/src/main/java/websocketx/client/EncryDigestUtil.java
//secretKeyDiperoleh dengan enkripsi sha1:86429c69799d3d6ac5da5c2c514baa874d75a4ba
String digest = EncryDigestUtil.digest("c11a122s-dshs-shsa-4515-954a67dd706e");
//Parameter diurutkan berdasarkan nilai ASCII
String paramStr = "accesskey=ce2a18e0-dshs-4c44-4515-9aca67dd706e&amount=1&coin=qc&marketName=btsqc&method=transferOutLever";
//tanda dienkripsi oleh HmacMD5:d7dcb17e6271232862812c339611d17e
String sign = EncryDigestUtil.hmacSign(paramStr, digest);
//permintaan terakhir yang dikirimurl
String finalUrl = "https://trade.zb.com/api/transferOutLever?accesskey=ce2a18e0-dshs-4c44-4515-9aca67dd706e&amount=1&coin=qc&marketName=btsqc&method=transferOutLever&reqTime=1539942326073&sign=d7dcb17e6271232862812c339611d17e";
//Dapatkan hasil pengembalianjson
String resultJson = HttpRequest.get(finalUrl).send().bodyText();
}
// python demo
import hashlib
import struct
import time
import requests
class ZApi:
def __init__(self, access_key, secret_key):
self._access_key_ = access_key
self._secret_key_ = secret_key
self._markets_ = self.markets()
if len(self._markets_) < 1:
raise Exception("Get markets status failed")
def transferOutLever(self, market, type, amount, price):
MyUrl = 'https://trade.zb.com/api/transferOutLever'
#params = 'accesskey=ce2a18e0-dshs-4c44-4515-9aca67dd706e&amount=1&coin=qc&marketName=btsqc&method=transferOutLever'
params = 'accesskey=' + self._access_key_ + '&amount=1&coin=qc&marketName=btsqc&method=transferOutLever'
return self.call_api(url=MyUrl, params=params)
def call_api(self, url, params=''):
full_url = url
if params:
#sha_secret=86429c69799d3d6ac5da5c2c514baa874d75a4ba
sha_secret = self.digest(self._secret_key_)
#sign = d7dcb17e6271232862812c339611d17e
sign = self.hmac_sign(params, sha_secret)
req_time = int(round(time.time() * 1000))
params += '&sign=%s&reqTime=%d' % (sign, req_time)
#full_url = https://trade.zb.com/api/transferOutLever?accesskey=ce2a18e0-dshs-4c44-4515-9aca67dd706e&amount=1&coin=qc&marketName=btsqc&method=transferOutLever&reqTime=1540295995566&sign=d7dcb17e6271232862812c339611d17e
full_url += '?' + params
result = {}
while True:
try:
r = requests.get(full_url, timeout=2)
except Exception:
time.sleep(0.5)
continue
if r.status_code != 200:
time.sleep(0.5)
r.close()
continue
else:
result = r.json()
r.close()
break
return result
@staticmethod
def fill(value, length, fill_byte):
if len(value) >= length:
return value
else:
fill_size = length - len(value)
return value + chr(fill_byte) * fill_size
@staticmethod
def xor(s, value):
slist = list(s.decode('utf-8'))
for index in range(len(slist)):
slist[index] = chr(ord(slist[index]) ^ value)
return "".join(slist)
def hmac_sign(self, arg_value, arg_key):
keyb = struct.pack("%ds" % len(arg_key), arg_key.encode('utf-8'))
value = struct.pack("%ds" % len(arg_value), arg_value.encode('utf-8'))
k_ipad = self.xor(keyb, 0x36)
k_opad = self.xor(keyb, 0x5c)
k_ipad = self.fill(k_ipad, 64, 54)
k_opad = self.fill(k_opad, 64, 92)
m = hashlib.md5()
m.update(k_ipad.encode('utf-8'))
m.update(value)
dg = m.digest()
m = hashlib.md5()
m.update(k_opad.encode('utf-8'))
subStr = dg[0:16]
m.update(subStr)
dg = m.hexdigest()
return dg
def digest(self, arg_value):
value = struct.pack("%ds" % len(arg_value), arg_value.encode('utf-8'))
h = hashlib.sha1()
h.update(value)
dg = h.hexdigest()
return dg
Contoh tanggapan
// Hasil Kembali
{
"code": "1000",
"message": "Proses berhasil。"
}
Nama parameter | Jenis | Rentang nilai |
---|---|---|
method | String | penugasan langsung transferOutLever |
accesskey | String | accesskey |
coin | String | Bunga yang telah jatuh tempo |
marketName | String | Nama pasar |
amount | double | Jumlah transfer keluar,Tempat desimal tidak boleh melebihi8,Melebihi sistem secara otomatis di potong8Bit |
sign | String | Minta string tanda tangan terenkripsi |
reqTime | long | waktu saat ini dalam milidetik |
Nilai Kembali | Deskripsi |
---|---|
code | Kode Pengembalian |
message | Petunjuk |
Pasca manajemen keuangan
Contoh permintaan
// request demo
GET https://trade.zb.com/api/loan?accesskey=youraccesskey&amount=100&coin=qc&interestRateOfDay=0.1&isLoop=1&method=loan&repaymentDay=20&safePwd=Kata Sandi Transaksi&sign=Minta string tanda tangan terenkripsi&reqTime=waktu saat ini dalam milidetik
// java demo
public void loan() {
//TestapiKey:ce2a18e0-dshs-4c44-4515-9aca67dd706e
//TestsecretKey:c11a122s-dshs-shsa-4515-954a67dd706e
//Enkripsi:https://github.com/zb2017/api/blob/master/zb_netty_client_java/src/main/java/websocketx/client/EncryDigestUtil.java
//secretKeyDiperoleh dengan enkripsi sha1:86429c69799d3d6ac5da5c2c514baa874d75a4ba
String digest = EncryDigestUtil.digest("c11a122s-dshs-shsa-4515-954a67dd706e");
//Parameter diurutkan berdasarkan nilai ASCII
String paramStr = "accesskey=ce2a18e0-dshs-4c44-4515-9aca67dd706e&amount=1&coin=qc&interestRateOfDay=0.05&isLoop=0&method=loan&repaymentDay=10";
//tanda dienkripsi oleh HmacMD5:0237aa2fd02b155142a1915c8589b2b1
String sign = EncryDigestUtil.hmacSign(paramStr, digest);
//permintaan terakhir yang dikirimurl
String finalUrl = "https://trade.zb.com/api/loan?accesskey=ce2a18e0-dshs-4c44-4515-9aca67dd706e&amount=1&coin=qc&interestRateOfDay=0.05&isLoop=0&method=loan&repaymentDay=10&reqTime=1539942326074&sign=0237aa2fd02b155142a1915c8589b2b1";
//Dapatkan hasil pengembalianjson
String resultJson = HttpRequest.get(finalUrl).send().bodyText();
}
// python demo
import hashlib
import struct
import time
import requests
class ZApi:
def __init__(self, access_key, secret_key):
self._access_key_ = access_key
self._secret_key_ = secret_key
self._markets_ = self.markets()
if len(self._markets_) < 1:
raise Exception("Get markets status failed")
def loan(self, market, type, amount, price):
MyUrl = 'https://trade.zb.com/api/loan'
#params = 'accesskey=ce2a18e0-dshs-4c44-4515-9aca67dd706e&amount=1&coin=qc&interestRateOfDay=0.05&isLoop=0&method=loan&repaymentDay=10'
params = 'accesskey=' + self._access_key_ + '&amount=1&coin=qc&interestRateOfDay=0.05&isLoop=0&method=loan&repaymentDay=10'
return self.call_api(url=MyUrl, params=params)
def call_api(self, url, params=''):
full_url = url
if params:
#sha_secret=86429c69799d3d6ac5da5c2c514baa874d75a4ba
sha_secret = self.digest(self._secret_key_)
#sign = 0237aa2fd02b155142a1915c8589b2b1
sign = self.hmac_sign(params, sha_secret)
req_time = int(round(time.time() * 1000))
params += '&sign=%s&reqTime=%d' % (sign, req_time)
#full_url = https://trade.zb.com/api/loan?accesskey=ce2a18e0-dshs-4c44-4515-9aca67dd706e&amount=1&coin=qc&interestRateOfDay=0.05&isLoop=0&method=loan&repaymentDay=10&reqTime=1540295995569&sign=0237aa2fd02b155142a1915c8589b2b1
full_url += '?' + params
result = {}
while True:
try:
r = requests.get(full_url, timeout=2)
except Exception:
time.sleep(0.5)
continue
if r.status_code != 200:
time.sleep(0.5)
r.close()
continue
else:
result = r.json()
r.close()
break
return result
@staticmethod
def fill(value, length, fill_byte):
if len(value) >= length:
return value
else:
fill_size = length - len(value)
return value + chr(fill_byte) * fill_size
@staticmethod
def xor(s, value):
slist = list(s.decode('utf-8'))
for index in range(len(slist)):
slist[index] = chr(ord(slist[index]) ^ value)
return "".join(slist)
def hmac_sign(self, arg_value, arg_key):
keyb = struct.pack("%ds" % len(arg_key), arg_key.encode('utf-8'))
value = struct.pack("%ds" % len(arg_value), arg_value.encode('utf-8'))
k_ipad = self.xor(keyb, 0x36)
k_opad = self.xor(keyb, 0x5c)
k_ipad = self.fill(k_ipad, 64, 54)
k_opad = self.fill(k_opad, 64, 92)
m = hashlib.md5()
m.update(k_ipad.encode('utf-8'))
m.update(value)
dg = m.digest()
m = hashlib.md5()
m.update(k_opad.encode('utf-8'))
subStr = dg[0:16]
m.update(subStr)
dg = m.hexdigest()
return dg
def digest(self, arg_value):
value = struct.pack("%ds" % len(arg_value), arg_value.encode('utf-8'))
h = hashlib.sha1()
h.update(value)
dg = h.hexdigest()
return dg
Contoh tanggapan
// Hasil Kembali
{
"code": "1000",
"message": "Proses berhasil。",
"id": "97"
}
Nama parameter | Jenis | Rentang nilai |
---|---|---|
method | String | penugasan langsung loan |
accesskey | String | accesskey |
coin | String | Bunga yang telah jatuh tempo |
amount | double | Jumlah investasi,Tempat desimal tidak boleh melebihi4,Melebihi sistem secara otomatis di potong4Bit |
interestRateOfDay | double | Suku bunga harian [0.05-0.2] Persen,Tempat desimal tidak boleh melebihi3,Melebihi sistem secara otomatis di potong3Bit |
repaymentDay | int | Hari pinjaman [10/20/30] |
isLoop | boolean | Apakah akan secara otomatis meminjamkan [1/0] |
sign | String | Minta string tanda tangan terenkripsi |
reqTime | long | waktu saat ini dalam milidetik |
Nilai Kembali | Deskripsi |
---|---|
code | Kode Pengembalian |
message | Petunjuk |
id | InvestasiID |
Cancel investasi
Contoh permintaan
// request demo
GET https://trade.zb.com/api/cancelLoan?accesskey=youraccesskey&loanId=100&method=cancelLoan&sign=Minta string tanda tangan terenkripsi&reqTime=waktu saat ini dalam milidetik
// java demo
public void cancelLoan() {
//TestapiKey:ce2a18e0-dshs-4c44-4515-9aca67dd706e
//TestsecretKey:c11a122s-dshs-shsa-4515-954a67dd706e
//Enkripsi:https://github.com/zb2017/api/blob/master/zb_netty_client_java/src/main/java/websocketx/client/EncryDigestUtil.java
//secretKeyDiperoleh dengan enkripsi sha1:86429c69799d3d6ac5da5c2c514baa874d75a4ba
String digest = EncryDigestUtil.digest("c11a122s-dshs-shsa-4515-954a67dd706e");
//Parameter diurutkan berdasarkan nilai ASCII
String paramStr = "accesskey=ce2a18e0-dshs-4c44-4515-9aca67dd706e&loanId=1454545445&method=cancelLoan";
//tanda dienkripsi oleh HmacMD5:0def7152ff2f6d4a8cab5f684d825a4a
String sign = EncryDigestUtil.hmacSign(paramStr, digest);
//permintaan terakhir yang dikirimurl
String finalUrl = "https://trade.zb.com/api/cancelLoan?accesskey=ce2a18e0-dshs-4c44-4515-9aca67dd706e&loanId=1454545445&method=cancelLoan&reqTime=1539942326076&sign=0def7152ff2f6d4a8cab5f684d825a4a";
//Dapatkan hasil pengembalianjson
String resultJson = HttpRequest.get(finalUrl).send().bodyText();
}
// python demo
import hashlib
import struct
import time
import requests
class ZApi:
def __init__(self, access_key, secret_key):
self._access_key_ = access_key
self._secret_key_ = secret_key
self._markets_ = self.markets()
if len(self._markets_) < 1:
raise Exception("Get markets status failed")
def cancelLoan(self, market, type, amount, price):
MyUrl = 'https://trade.zb.com/api/cancelLoan'
#params = 'accesskey=ce2a18e0-dshs-4c44-4515-9aca67dd706e&loanId=1454545445&method=cancelLoan'
params = 'accesskey=' + self._access_key_ + '&loanId=1454545445&method=cancelLoan'
return self.call_api(url=MyUrl, params=params)
def call_api(self, url, params=''):
full_url = url
if params:
#sha_secret=86429c69799d3d6ac5da5c2c514baa874d75a4ba
sha_secret = self.digest(self._secret_key_)
#sign = 0def7152ff2f6d4a8cab5f684d825a4a
sign = self.hmac_sign(params, sha_secret)
req_time = int(round(time.time() * 1000))
params += '&sign=%s&reqTime=%d' % (sign, req_time)
#full_url = https://trade.zb.com/api/cancelLoan?accesskey=ce2a18e0-dshs-4c44-4515-9aca67dd706e&loanId=1454545445&method=cancelLoan&reqTime=1540295995572&sign=0def7152ff2f6d4a8cab5f684d825a4a
full_url += '?' + params
result = {}
while True:
try:
r = requests.get(full_url, timeout=2)
except Exception:
time.sleep(0.5)
continue
if r.status_code != 200:
time.sleep(0.5)
r.close()
continue
else:
result = r.json()
r.close()
break
return result
@staticmethod
def fill(value, length, fill_byte):
if len(value) >= length:
return value
else:
fill_size = length - len(value)
return value + chr(fill_byte) * fill_size
@staticmethod
def xor(s, value):
slist = list(s.decode('utf-8'))
for index in range(len(slist)):
slist[index] = chr(ord(slist[index]) ^ value)
return "".join(slist)
def hmac_sign(self, arg_value, arg_key):
keyb = struct.pack("%ds" % len(arg_key), arg_key.encode('utf-8'))
value = struct.pack("%ds" % len(arg_value), arg_value.encode('utf-8'))
k_ipad = self.xor(keyb, 0x36)
k_opad = self.xor(keyb, 0x5c)
k_ipad = self.fill(k_ipad, 64, 54)
k_opad = self.fill(k_opad, 64, 92)
m = hashlib.md5()
m.update(k_ipad.encode('utf-8'))
m.update(value)
dg = m.digest()
m = hashlib.md5()
m.update(k_opad.encode('utf-8'))
subStr = dg[0:16]
m.update(subStr)
dg = m.hexdigest()
return dg
def digest(self, arg_value):
value = struct.pack("%ds" % len(arg_value), arg_value.encode('utf-8'))
h = hashlib.sha1()
h.update(value)
dg = h.hexdigest()
return dg
Contoh tanggapan
// Hasil Kembali
{
"code": "1000",
"message": "Proses berhasil。"
}
Nama parameter | Jenis | Rentang nilai |
---|---|---|
method | String | penugasan langsung cancelLoan |
accesskey | String | accesskey |
loanId | String | InvestasiID |
sign | String | Minta string tanda tangan terenkripsi |
reqTime | long | waktu saat ini dalam milidetik |
Nilai Kembali | Deskripsi |
---|---|
code | Kode Pengembalian |
message | Petunjuk |
Dapatkan daftar pinjaman yang tersedia
Contoh permintaan
// request demo
GET https://trade.zb.com/api/getLoans?accesskey=youraccesskey&coin=qc&method=getLoans&pageIndex=1&pageSize=10&sign=Minta string tanda tangan terenkripsi&reqTime=waktu saat ini dalam milidetik
// java demo
public void getLoans() {
//TestapiKey:ce2a18e0-dshs-4c44-4515-9aca67dd706e
//TestsecretKey:c11a122s-dshs-shsa-4515-954a67dd706e
//Enkripsi:https://github.com/zb2017/api/blob/master/zb_netty_client_java/src/main/java/websocketx/client/EncryDigestUtil.java
//secretKeyDiperoleh dengan enkripsi sha1:86429c69799d3d6ac5da5c2c514baa874d75a4ba
String digest = EncryDigestUtil.digest("c11a122s-dshs-shsa-4515-954a67dd706e");
//Parameter diurutkan berdasarkan nilai ASCII
String paramStr = "accesskey=ce2a18e0-dshs-4c44-4515-9aca67dd706e&coin=qc&method=getLoans&pageIndex=1&pageSize=10";
//tanda dienkripsi oleh HmacMD5:9ed81061104f5b87703861ba77806eba
String sign = EncryDigestUtil.hmacSign(paramStr, digest);
//permintaan terakhir yang dikirimurl
String finalUrl = "https://trade.zb.com/api/getLoans?method=getLoans&cesskey=ce2a18e0-dshs-4c44-4515-9aca67dd706e&coin=qc&pageIndex=1&pageSize=10&sign=9ed81061104f5b87703861ba77806eba&reqTime=1539942326077";
//Dapatkan hasil pengembalianjson
String resultJson = HttpRequest.get(finalUrl).send().bodyText();
}
// python demo
import hashlib
import struct
import time
import requests
class ZApi:
def __init__(self, access_key, secret_key):
self._access_key_ = access_key
self._secret_key_ = secret_key
self._markets_ = self.markets()
if len(self._markets_) < 1:
raise Exception("Get markets status failed")
def getLoans(self, market, type, amount, price):
MyUrl = 'https://trade.zb.com/api/getLoans'
#params = 'accesskey=ce2a18e0-dshs-4c44-4515-9aca67dd706e&coin=qc&method=getLoans&pageIndex=1&pageSize=10'
params = 'accesskey=' + self._access_key_ + '&coin=qc&method=getLoans&pageIndex=1&pageSize=10'
return self.call_api(url=MyUrl, params=params)
def call_api(self, url, params=''):
full_url = url
if params:
#sha_secret=86429c69799d3d6ac5da5c2c514baa874d75a4ba
sha_secret = self.digest(self._secret_key_)
#sign = 9ed81061104f5b87703861ba77806eba
sign = self.hmac_sign(params, sha_secret)
req_time = int(round(time.time() * 1000))
params += '&sign=%s&reqTime=%d' % (sign, req_time)
#full_url = https://trade.zb.com/api/getLoans?method=getLoans&cesskey=ce2a18e0-dshs-4c44-4515-9aca67dd706e&coin=qc&pageIndex=1&pageSize=10&sign=9ed81061104f5b87703861ba77806eba&reqTime=1540295995575
full_url += '?' + params
result = {}
while True:
try:
r = requests.get(full_url, timeout=2)
except Exception:
time.sleep(0.5)
continue
if r.status_code != 200:
time.sleep(0.5)
r.close()
continue
else:
result = r.json()
r.close()
break
return result
@staticmethod
def fill(value, length, fill_byte):
if len(value) >= length:
return value
else:
fill_size = length - len(value)
return value + chr(fill_byte) * fill_size
@staticmethod
def xor(s, value):
slist = list(s.decode('utf-8'))
for index in range(len(slist)):
slist[index] = chr(ord(slist[index]) ^ value)
return "".join(slist)
def hmac_sign(self, arg_value, arg_key):
keyb = struct.pack("%ds" % len(arg_key), arg_key.encode('utf-8'))
value = struct.pack("%ds" % len(arg_value), arg_value.encode('utf-8'))
k_ipad = self.xor(keyb, 0x36)
k_opad = self.xor(keyb, 0x5c)
k_ipad = self.fill(k_ipad, 64, 54)
k_opad = self.fill(k_opad, 64, 92)
m = hashlib.md5()
m.update(k_ipad.encode('utf-8'))
m.update(value)
dg = m.digest()
m = hashlib.md5()
m.update(k_opad.encode('utf-8'))
subStr = dg[0:16]
m.update(subStr)
dg = m.hexdigest()
return dg
def digest(self, arg_value):
value = struct.pack("%ds" % len(arg_value), arg_value.encode('utf-8'))
h = hashlib.sha1()
h.update(value)
dg = h.hexdigest()
return dg
Contoh tanggapan
// Hasil Kembali
{
"code" : 1000,
"message" : "Proses berhasil。",
"result" : [
{
"amount" : "0.1",
"balance" : "0.00008001",
"coinName" : "qc",
"repaymentDay" : 10,
"interestRateOfDay" : "0.0005"
}
]
}
Nama parameter | Jenis | Rentang nilai |
---|---|---|
method | String | penugasan langsung getLoans |
accesskey | String | accesskey |
coin | String | Bunga yang telah jatuh tempo |
pageIndex | int | nomor halaman saat ini(Seperti: 1, halaman 1) |
pageSize | int | Kuantitas per halaman |
sign | String | Minta string tanda tangan terenkripsi |
reqTime | long | waktu saat ini dalam milidetik |
Nilai Kembali | Deskripsi |
---|---|
code | Kode Pengembalian |
message | Petunjuk |
amount | Jumlah |
balance | Jumlah pinjaman yang tersedia |
coinName | Bunga yang telah jatuh tempo |
repaymentDay | jangka waktu pinjaman |
interestRateOfDay | Suku bunga harian |
Dapatkan riwayat pinjaman
Contoh permintaan
// request demo
GET https://trade.zb.com/api/getLoanRecords?accesskey=youraccesskey&marketName=btsqc&method=getLoanRecords&pageIndex=1&pageSize=10&status=2&sign=Minta string tanda tangan terenkripsi&reqTime=waktu saat ini dalam milidetik
// java demo
public void getLoanRecords() {
//TestapiKey:ce2a18e0-dshs-4c44-4515-9aca67dd706e
//TestsecretKey:c11a122s-dshs-shsa-4515-954a67dd706e
//Enkripsi:https://github.com/zb2017/api/blob/master/zb_netty_client_java/src/main/java/websocketx/client/EncryDigestUtil.java
//secretKeyDiperoleh dengan enkripsi sha1:86429c69799d3d6ac5da5c2c514baa874d75a4ba
String digest = EncryDigestUtil.digest("c11a122s-dshs-shsa-4515-954a67dd706e");
//Parameter diurutkan berdasarkan nilai ASCII
String paramStr = "accesskey=ce2a18e0-dshs-4c44-4515-9aca67dd706e&loanId=1545454415&marketName=btsqc&method=getLoanRecords&pageIndex=1&pageSize=10&status=1";
//tanda dienkripsi oleh HmacMD5:08891e23a060aa0f979332939e7e845d
String sign = EncryDigestUtil.hmacSign(paramStr, digest);
//permintaan terakhir yang dikirimurl
String finalUrl = "https://trade.zb.com/api/getLoanRecords?accesskey=ce2a18e0-dshs-4c44-4515-9aca67dd706e&loanId=1545454415&marketName=btsqc&method=getLoanRecords&pageIndex=1&pageSize=10&reqTime=1539942326078&sign=08891e23a060aa0f979332939e7e845d&status=1";
//Dapatkan hasil pengembalianjson
String resultJson = HttpRequest.get(finalUrl).send().bodyText();
}
// python demo
import hashlib
import struct
import time
import requests
class ZApi:
def __init__(self, access_key, secret_key):
self._access_key_ = access_key
self._secret_key_ = secret_key
self._markets_ = self.markets()
if len(self._markets_) < 1:
raise Exception("Get markets status failed")
def getLoanRecords(self, market, type, amount, price):
MyUrl = 'https://trade.zb.com/api/getLoanRecords'
#params = 'accesskey=ce2a18e0-dshs-4c44-4515-9aca67dd706e&loanId=1545454415&marketName=btsqc&method=getLoanRecords&pageIndex=1&pageSize=10&status=1'
params = 'accesskey=' + self._access_key_ + '&loanId=1545454415&marketName=btsqc&method=getLoanRecords&pageIndex=1&pageSize=10&status=1'
return self.call_api(url=MyUrl, params=params)
def call_api(self, url, params=''):
full_url = url
if params:
#sha_secret=86429c69799d3d6ac5da5c2c514baa874d75a4ba
sha_secret = self.digest(self._secret_key_)
#sign = 08891e23a060aa0f979332939e7e845d
sign = self.hmac_sign(params, sha_secret)
req_time = int(round(time.time() * 1000))
params += '&sign=%s&reqTime=%d' % (sign, req_time)
#full_url = https://trade.zb.com/api/getLoanRecords?accesskey=ce2a18e0-dshs-4c44-4515-9aca67dd706e&loanId=1545454415&marketName=btsqc&method=getLoanRecords&pageIndex=1&pageSize=10&reqTime=1540295995578&sign=08891e23a060aa0f979332939e7e845d&status=1
full_url += '?' + params
result = {}
while True:
try:
r = requests.get(full_url, timeout=2)
except Exception:
time.sleep(0.5)
continue
if r.status_code != 200:
time.sleep(0.5)
r.close()
continue
else:
result = r.json()
r.close()
break
return result
@staticmethod
def fill(value, length, fill_byte):
if len(value) >= length:
return value
else:
fill_size = length - len(value)
return value + chr(fill_byte) * fill_size
@staticmethod
def xor(s, value):
slist = list(s.decode('utf-8'))
for index in range(len(slist)):
slist[index] = chr(ord(slist[index]) ^ value)
return "".join(slist)
def hmac_sign(self, arg_value, arg_key):
keyb = struct.pack("%ds" % len(arg_key), arg_key.encode('utf-8'))
value = struct.pack("%ds" % len(arg_value), arg_value.encode('utf-8'))
k_ipad = self.xor(keyb, 0x36)
k_opad = self.xor(keyb, 0x5c)
k_ipad = self.fill(k_ipad, 64, 54)
k_opad = self.fill(k_opad, 64, 92)
m = hashlib.md5()
m.update(k_ipad.encode('utf-8'))
m.update(value)
dg = m.digest()
m = hashlib.md5()
m.update(k_opad.encode('utf-8'))
subStr = dg[0:16]
m.update(subStr)
dg = m.hexdigest()
return dg
def digest(self, arg_value):
value = struct.pack("%ds" % len(arg_value), arg_value.encode('utf-8'))
h = hashlib.sha1()
h.update(value)
dg = h.hexdigest()
return dg
Contoh tanggapan
// Hasil Kembali
{
"code" : 1000,
"message" : "Proses berhasil",
"result" : [
{
"createTime" : 1522473159000,
"statusShow" : "pembayaran kembali",
"freezId" : "0",
"tstatus" : 0,
"withoutLxAmount" : "0",
"investMark" : false,
"withoutLxDays" : 0,
"hasRepay" : "0",
"amount" : "0.10008001",
"id" : 290,
"fwfScale" : "0.2",
"rate" : "0.0005",
"marketName" : "btsqc",
"hasLx" : "0",
"isIn" : false,
"balanceAmount" : "0",
"fundType" : 15,
"outUserId" : 110797,
"inUserId" : 110797,
"repayDate" : 1523337159000,
"zheLx" : "0",
"outUserFees" : "",
"dikouLx" : "0",
"sourceType" : 8,
"coinName" : "QC",
"reward" : "0",
"status" : 1,
"arrearsLx" : "0.00005004",
"balanceWithoutLxDays" : 0,
"riskManage" : 1,
"rateAddVal" : "0",
"outUserName" : "18022121179",
"inUserName" : "18022121179",
"inUserLock" : false,
"rateForm" : 1,
"loanId" : 94,
"nextRepayDate" : 1522559559000
}
...
]
}
Nama parameter | Jenis | Rentang nilai |
---|---|---|
method | String | penugasan langsung getLoanRecords |
accesskey | String | accesskey |
loanId | String | Investasiid(Jumlah Pinjaman Jangan transfer jika meminjam) |
marketName | String | Pasar |
status | int | Status(1pembayaran kembali 2Dilunasi 3 Perlu Dilikuidasi 4 Pembayaran likuidasi 5Pembayaran otomatis sedang berlangsung 6pembayaran otomatis) |
pageIndex | int | nomor halaman saat ini(Seperti: 1, halaman 1) |
pageSize | int | Kuantitas per halaman |
sign | String | Minta string tanda tangan terenkripsi |
reqTime | long | waktu saat ini dalam milidetik |
Nilai Kembali | Deskripsi |
---|---|
code | Kode Pengembalian |
message | Petunjuk |
id | Catatan PeminjamanID |
loanId | InvestasiID |
inUserId | PeminjamID |
inUserName | Nama Pengguna Peminjam |
outUserId | 借出者ID |
outUserName | Pemberi pinjaman |
fundType | Jenis koin |
amount | 借入金额 |
status | Status 1pembayaran kembali 2Dilunasi 3Perlu Dilikuidasi 4 Pembayaran likuidasi 5pembayaran otomatis |
createTime | waktu sukses pinjaman |
reward | Jumlah Hadiah |
balanceAmount | Jumlah yang tersedia |
rate | Rate bunga |
hasRepay | Jumlah Pokok yang Dibayarkan |
hasLx | Bunga yang dibayarkan |
dikouLx | Bunga telah di potong |
zheLx | Harga yang dikonversi |
arrearsLx | Bunga yang telah jatuh tempo |
nextRepayDate | waktu pembayaran berikutnya |
riskManage | pengendalian risiko |
inUserLock | Apakah peminjam terkunci |
withoutLxAmount | Jumlah bebas bunga |
withoutLxDays | Hari tanpa bunga |
balanceWithoutLxDays | Sisa hari bebas bunga |
rateForm | Jenis bunga |
rateAddVal | Tingkatkan Jangkauan |
repayDate | Waktu Pembayaran |
marketName | Pasar |
fwfScale | tarif biaya layanan |
investMark | Perbaharui Otomatis |
sourceType | jenis sumber: 8”Web”,5”handphoneAPP”,6”InterfaceAPI” |
meminjamkan
Contoh permintaan
// request demo
GET https://trade.zb.com/api/borrow?accesskey=youraccesskey&amount=100&coin=qc&interestRateOfDay=0.1&isLoop=1&marketName=btcqc&method=borrow&repaymentDay=20&safePwd=Kata Sandi Transaksi&sign=Minta string tanda tangan terenkripsi&reqTime=waktu saat ini dalam milidetik
// java demo
public void borrow() {
//TestapiKey:ce2a18e0-dshs-4c44-4515-9aca67dd706e
//TestsecretKey:c11a122s-dshs-shsa-4515-954a67dd706e
//Enkripsi:https://github.com/zb2017/api/blob/master/zb_netty_client_java/src/main/java/websocketx/client/EncryDigestUtil.java
//secretKeyDiperoleh dengan enkripsi sha1:86429c69799d3d6ac5da5c2c514baa874d75a4ba
String digest = EncryDigestUtil.digest("c11a122s-dshs-shsa-4515-954a67dd706e");
//Parameter diurutkan berdasarkan nilai ASCII
String paramStr = "accesskey=ce2a18e0-dshs-4c44-4515-9aca67dd706e&amount=0.5&coin=qc&interestRateOfDay=0.05&isLoop=0&marketName=aeqc&method=borrow&repaymentDay=10&safePwd=152433";
//tanda dienkripsi oleh HmacMD5:0018e23184496b1fd5b7eadfaab2cc99
String sign = EncryDigestUtil.hmacSign(paramStr, digest);
//permintaan terakhir yang dikirimurl
String finalUrl = "https://trade.zb.com/api/borrow?method=borrow&accesskey=ce2a18e0-dshs-4c44-4515-9aca67dd706e&marketName=aeqc&coin=qc&amount=0.5&interestRateOfDay=0.05&repaymentDay=10&isLoop=0&safePwd=152433&sign=0018e23184496b1fd5b7eadfaab2cc99&reqTime=1539942326079";
//Dapatkan hasil pengembalianjson
String resultJson = HttpRequest.get(finalUrl).send().bodyText();
}
// python demo
import hashlib
import struct
import time
import requests
class ZApi:
def __init__(self, access_key, secret_key):
self._access_key_ = access_key
self._secret_key_ = secret_key
self._markets_ = self.markets()
if len(self._markets_) < 1:
raise Exception("Get markets status failed")
def borrow(self, market, type, amount, price):
MyUrl = 'https://trade.zb.com/api/borrow'
#params = 'accesskey=ce2a18e0-dshs-4c44-4515-9aca67dd706e&amount=0.5&coin=qc&interestRateOfDay=0.05&isLoop=0&marketName=aeqc&method=borrow&repaymentDay=10&safePwd=152433'
params = 'accesskey=' + self._access_key_ + '&amount=0.5&coin=qc&interestRateOfDay=0.05&isLoop=0&marketName=aeqc&method=borrow&repaymentDay=10&safePwd=152433'
return self.call_api(url=MyUrl, params=params)
def call_api(self, url, params=''):
full_url = url
if params:
#sha_secret=86429c69799d3d6ac5da5c2c514baa874d75a4ba
sha_secret = self.digest(self._secret_key_)
#sign = 0018e23184496b1fd5b7eadfaab2cc99
sign = self.hmac_sign(params, sha_secret)
req_time = int(round(time.time() * 1000))
params += '&sign=%s&reqTime=%d' % (sign, req_time)
#full_url = https://trade.zb.com/api/borrow?method=borrow&accesskey=ce2a18e0-dshs-4c44-4515-9aca67dd706e&marketName=aeqc&coin=qc&amount=0.5&interestRateOfDay=0.05&repaymentDay=10&isLoop=0&safePwd=152433&sign=0018e23184496b1fd5b7eadfaab2cc99&reqTime=1540295995582
full_url += '?' + params
result = {}
while True:
try:
r = requests.get(full_url, timeout=2)
except Exception:
time.sleep(0.5)
continue
if r.status_code != 200:
time.sleep(0.5)
r.close()
continue
else:
result = r.json()
r.close()
break
return result
@staticmethod
def fill(value, length, fill_byte):
if len(value) >= length:
return value
else:
fill_size = length - len(value)
return value + chr(fill_byte) * fill_size
@staticmethod
def xor(s, value):
slist = list(s.decode('utf-8'))
for index in range(len(slist)):
slist[index] = chr(ord(slist[index]) ^ value)
return "".join(slist)
def hmac_sign(self, arg_value, arg_key):
keyb = struct.pack("%ds" % len(arg_key), arg_key.encode('utf-8'))
value = struct.pack("%ds" % len(arg_value), arg_value.encode('utf-8'))
k_ipad = self.xor(keyb, 0x36)
k_opad = self.xor(keyb, 0x5c)
k_ipad = self.fill(k_ipad, 64, 54)
k_opad = self.fill(k_opad, 64, 92)
m = hashlib.md5()
m.update(k_ipad.encode('utf-8'))
m.update(value)
dg = m.digest()
m = hashlib.md5()
m.update(k_opad.encode('utf-8'))
subStr = dg[0:16]
m.update(subStr)
dg = m.hexdigest()
return dg
def digest(self, arg_value):
value = struct.pack("%ds" % len(arg_value), arg_value.encode('utf-8'))
h = hashlib.sha1()
h.update(value)
dg = h.hexdigest()
return dg
Contoh tanggapan
// Hasil Kembali
{
"code": "1000",
"message": "Proses berhasil。"
}
Nama parameter | Jenis | Rentang nilai |
---|---|---|
method | String | penugasan langsung borrow |
accesskey | String | accesskey |
marketName | String | 杠杆市场 |
coin | String | Bunga yang telah jatuh tempo |
amount | double | 借入金额,Tempat desimal tidak boleh melebihi4,Melebihi sistem secara otomatis di potong4Bit |
interestRateOfDay | double | Suku bunga harian [0.05-0.2] Persen,Tempat desimal tidak boleh melebihi3,Melebihi sistem secara otomatis di potong3Bit |
repaymentDay | int | jangka waktu pinjaman [10/20/30]Hari |
isLoop | int | Apakah akan memperbarui secara otomatis [1/0](Perpanjangan otomatis setelah kedaluwarsa/Pembayaran otomatis saat jatuh tempo) |
sign | String | Minta string tanda tangan terenkripsi |
reqTime | long | waktu saat ini dalam milidetik |
Nilai Kembali | Deskripsi |
---|---|
code | Kode Pengembalian |
message | Petunjuk |
Pinjaman sekali klik
Prioritas peminjaman dana dimulai dari yang bunganya paling rendah
Contoh permintaan
// request demo
GET https://trade.zb.com/api/autoBorrow?accesskey=youraccesskey&amount=100&coin=qc&interestRateOfDay=0.1&marketName=btsqc&method=autoBorrow&repaymentDay=20&safePwd=Kata Sandi Transaksi&sign=Minta string tanda tangan terenkripsi&reqTime=waktu saat ini dalam milidetik
// java demo
public void borrow() {
//TestapiKey:ce2a18e0-dshs-4c44-4515-9aca67dd706e
//TestsecretKey:c11a122s-dshs-shsa-4515-954a67dd706e
//Enkripsi:https://github.com/zb2017/api/blob/master/zb_netty_client_java/src/main/java/websocketx/client/EncryDigestUtil.java
//secretKeyDiperoleh dengan enkripsi sha1:86429c69799d3d6ac5da5c2c514baa874d75a4ba
String digest = EncryDigestUtil.digest("c11a122s-dshs-shsa-4515-954a67dd706e");
//Parameter diurutkan berdasarkan nilai ASCII
String paramStr = "accesskey=ce2a18e0-dshs-4c44-4515-9aca67dd706e&amount=100&coin=qc&interestRateOfDay=0.2&marketName=btsqc&method=autoBorrow&repaymentDay=20&safePwd=152433";
//tanda dienkripsi oleh HmacMD5:09c5fe77bfd19ce4c636cb9ef0543d44
String sign = EncryDigestUtil.hmacSign(paramStr, digest);
//permintaan terakhir yang dikirimurl
String finalUrl = "https://trade.zb.com/api/autoBorrow?accesskey=ce2a18e0-dshs-4c44-4515-9aca67dd706e&amount=100&coin=qc&interestRateOfDay=0.2&marketName=btsqc&method=autoBorrow&repaymentDay=20&reqTime=1566290460905&safePwd=152433&sign=09c5fe77bfd19ce4c636cb9ef0543d44";
//Dapatkan hasil pengembalianjson
String resultJson = HttpRequest.get(finalUrl).send().bodyText();
}
// python demo
import hashlib
import struct
import time
import requests
class ZApi:
def __init__(self, access_key, secret_key):
self._access_key_ = access_key
self._secret_key_ = secret_key
self._markets_ = self.markets()
if len(self._markets_) < 1:
raise Exception("Get markets status failed")
def autoBorrow(self):
MyUrl = 'https://trade.zb.com/api/autoBorrow'
#params = 'accesskey=ce2a18e0-dshs-4c44-4515-9aca67dd706e&amount=100&coin=qc&interestRateOfDay=0.2&marketName=btsqc&method=autoBorrow&repaymentDay=20&safePwd=152433'
params = 'accesskey=' + self._access_key_ + '&amount=100&coin=qc&interestRateOfDay=0.2&marketName=btsqc&method=autoBorrow&repaymentDay=20&safePwd=152433'
return self.call_api(url=MyUrl, params=params)
def call_api(self, url, params=''):
full_url = url
if params:
#sha_secret=86429c69799d3d6ac5da5c2c514baa874d75a4ba
sha_secret = self.digest(self._secret_key_)
#sign = 09c5fe77bfd19ce4c636cb9ef0543d44
sign = self.hmac_sign(params, sha_secret)
req_time = int(round(time.time() * 1000))
params += '&sign=%s&reqTime=%d' % (sign, req_time)
#full_url = https://trade.zb.com/api/autoBorrow?accesskey=ce2a18e0-dshs-4c44-4515-9aca67dd706e&amount=100&coin=qc&interestRateOfDay=0.2&marketName=btsqc&method=autoBorrow&repaymentDay=20&reqTime=1566290460905&safePwd=152433&sign=09c5fe77bfd19ce4c636cb9ef0543d44
full_url += '?' + params
result = {}
while True:
try:
r = requests.get(full_url, timeout=2)
except Exception:
time.sleep(0.5)
continue
if r.status_code != 200:
time.sleep(0.5)
r.close()
continue
else:
result = r.json()
r.close()
break
return result
@staticmethod
def fill(value, length, fill_byte):
if len(value) >= length:
return value
else:
fill_size = length - len(value)
return value + chr(fill_byte) * fill_size
@staticmethod
def xor(s, value):
slist = list(s.decode('utf-8'))
for index in range(len(slist)):
slist[index] = chr(ord(slist[index]) ^ value)
return "".join(slist)
def hmac_sign(self, arg_value, arg_key):
keyb = struct.pack("%ds" % len(arg_key), arg_key.encode('utf-8'))
value = struct.pack("%ds" % len(arg_value), arg_value.encode('utf-8'))
k_ipad = self.xor(keyb, 0x36)
k_opad = self.xor(keyb, 0x5c)
k_ipad = self.fill(k_ipad, 64, 54)
k_opad = self.fill(k_opad, 64, 92)
m = hashlib.md5()
m.update(k_ipad.encode('utf-8'))
m.update(value)
dg = m.digest()
m = hashlib.md5()
m.update(k_opad.encode('utf-8'))
subStr = dg[0:16]
m.update(subStr)
dg = m.hexdigest()
return dg
def digest(self, arg_value):
value = struct.pack("%ds" % len(arg_value), arg_value.encode('utf-8'))
h = hashlib.sha1()
h.update(value)
dg = h.hexdigest()
return dg
Contoh tanggapan
// Hasil Kembali
{
"code": "1000",
"message": "Proses berhasil。"
}
Nama parameter | Jenis | Rentang nilai |
---|---|---|
method | String | penugasan langsung autoBorrow |
accesskey | String | accesskey |
marketName | String | 杠杆市场 |
coin | String | Bunga yang telah jatuh tempo |
amount | double | 借入金额,Tempat desimal tidak boleh melebihi4,Melebihi sistem secara otomatis di potong4Bit |
interestRateOfDay | double | Suku bunga harian [0.05-0.2] Persen,Tempat desimal tidak boleh melebihi3,Melebihi sistem secara otomatis di potong3Bit |
repaymentDay | int | jangka waktu pinjaman [10/20/30]Hari |
safePwd | String | Kata Sandi Transaksi |
sign | String | Minta string tanda tangan terenkripsi |
reqTime | long | waktu saat ini dalam milidetik |
Nilai Kembali | Deskripsi |
---|---|
code | Kode Pengembalian |
message | Petunjuk |
pembayaran
Contoh permintaan
// request demo
GET https://trade.zb.com/api/repay?accesskey=youraccesskey&loanRecordId=289&method=repay&repayAmount=100&repayType=0&sign=Minta string tanda tangan terenkripsi&reqTime=waktu saat ini dalam milidetik
// java demo
public void repay() {
//TestapiKey:ce2a18e0-dshs-4c44-4515-9aca67dd706e
//TestsecretKey:c11a122s-dshs-shsa-4515-954a67dd706e
//Enkripsi:https://github.com/zb2017/api/blob/master/zb_netty_client_java/src/main/java/websocketx/client/EncryDigestUtil.java
//secretKeyDiperoleh dengan enkripsi sha1:86429c69799d3d6ac5da5c2c514baa874d75a4ba
String digest = EncryDigestUtil.digest("c11a122s-dshs-shsa-4515-954a67dd706e");
//Parameter diurutkan berdasarkan nilai ASCII
String paramStr = "accesskey=ce2a18e0-dshs-4c44-4515-9aca67dd706e&loanRecordId=1454545415&method=repay&repayAmount=1.5&repayType=1";
//tanda dienkripsi oleh HmacMD5:90fb3aacda467ffb95ce36c054173fff
String sign = EncryDigestUtil.hmacSign(paramStr, digest);
//permintaan terakhir yang dikirimurl
String finalUrl = "https://trade.zb.com/api/repay?accesskey=ce2a18e0-dshs-4c44-4515-9aca67dd706e&loanRecordId=1454545415&method=repay&repayAmount=1.5&repayType=1&reqTime=1539942326080&sign=90fb3aacda467ffb95ce36c054173fff";
//Dapatkan hasil pengembalianjson
String resultJson = HttpRequest.get(finalUrl).send().bodyText();
}
// python demo
import hashlib
import struct
import time
import requests
class ZApi:
def __init__(self, access_key, secret_key):
self._access_key_ = access_key
self._secret_key_ = secret_key
self._markets_ = self.markets()
if len(self._markets_) < 1:
raise Exception("Get markets status failed")
def repay(self, market, type, amount, price):
MyUrl = 'https://trade.zb.com/api/repay'
#params = 'accesskey=ce2a18e0-dshs-4c44-4515-9aca67dd706e&loanRecordId=1454545415&method=repay&repayAmount=1.5&repayType=1'
params = 'accesskey=' + self._access_key_ + '&loanRecordId=1454545415&method=repay&repayAmount=1.5&repayType=1'
return self.call_api(url=MyUrl, params=params)
def call_api(self, url, params=''):
full_url = url
if params:
#sha_secret=86429c69799d3d6ac5da5c2c514baa874d75a4ba
sha_secret = self.digest(self._secret_key_)
#sign = 90fb3aacda467ffb95ce36c054173fff
sign = self.hmac_sign(params, sha_secret)
req_time = int(round(time.time() * 1000))
params += '&sign=%s&reqTime=%d' % (sign, req_time)
#full_url = https://trade.zb.com/api/repay?accesskey=ce2a18e0-dshs-4c44-4515-9aca67dd706e&loanRecordId=1454545415&method=repay&repayAmount=1.5&repayType=1&reqTime=1540295995586&sign=90fb3aacda467ffb95ce36c054173fff
full_url += '?' + params
result = {}
while True:
try:
r = requests.get(full_url, timeout=2)
except Exception:
time.sleep(0.5)
continue
if r.status_code != 200:
time.sleep(0.5)
r.close()
continue
else:
result = r.json()
r.close()
break
return result
@staticmethod
def fill(value, length, fill_byte):
if len(value) >= length:
return value
else:
fill_size = length - len(value)
return value + chr(fill_byte) * fill_size
@staticmethod
def xor(s, value):
slist = list(s.decode('utf-8'))
for index in range(len(slist)):
slist[index] = chr(ord(slist[index]) ^ value)
return "".join(slist)
def hmac_sign(self, arg_value, arg_key):
keyb = struct.pack("%ds" % len(arg_key), arg_key.encode('utf-8'))
value = struct.pack("%ds" % len(arg_value), arg_value.encode('utf-8'))
k_ipad = self.xor(keyb, 0x36)
k_opad = self.xor(keyb, 0x5c)
k_ipad = self.fill(k_ipad, 64, 54)
k_opad = self.fill(k_opad, 64, 92)
m = hashlib.md5()
m.update(k_ipad.encode('utf-8'))
m.update(value)
dg = m.digest()
m = hashlib.md5()
m.update(k_opad.encode('utf-8'))
subStr = dg[0:16]
m.update(subStr)
dg = m.hexdigest()
return dg
def digest(self, arg_value):
value = struct.pack("%ds" % len(arg_value), arg_value.encode('utf-8'))
h = hashlib.sha1()
h.update(value)
dg = h.hexdigest()
return dg
Contoh tanggapan
// Hasil Kembali
{
"code": "1000",
"message": "Proses berhasil。"
}
Nama parameter | Jenis | Rentang nilai |
---|---|---|
method | String | penugasan langsung repay |
accesskey | String | accesskey |
loanRecordId | String | Catatan Peminjamanid |
repayAmount | double | Jumlah pembayaran |
repayType | int | Meteode pembayaran [0/1](Semua/Bagian) |
sign | String | Minta string tanda tangan terenkripsi |
reqTime | long | waktu saat ini dalam milidetik |
Nilai Kembali | Deskripsi |
---|---|
code | Kode Pengembalian |
message | Petunjuk |
Pembayaran Cepat
Bayar semua pinjaman yang belum dibayar
Contoh permintaan
// request demo
GET https://trade.zb.com/api/doAllRepay?accesskey=ce2a18e0-dshs-4c44-4515-9aca67dd706e&marketName=btsqc&method=doAllRepay&sign=Minta string tanda tangan terenkripsi&reqTime=waktu saat ini dalam milidetik
// java demo
public void doAllRepay() {
//TestapiKey:ce2a18e0-dshs-4c44-4515-9aca67dd706e
//TestsecretKey:c11a122s-dshs-shsa-4515-954a67dd706e
//Enkripsi:https://github.com/zb2017/api/blob/master/zb_netty_client_java/src/main/java/websocketx/client/EncryDigestUtil.java
//secretKeyDiperoleh dengan enkripsi sha1:86429c69799d3d6ac5da5c2c514baa874d75a4ba
String digest = EncryDigestUtil.digest("c11a122s-dshs-shsa-4515-954a67dd706e");
//Parameter diurutkan berdasarkan nilai ASCII
String paramStr = "accesskey=ce2a18e0-dshs-4c44-4515-9aca67dd706e&marketName=btsqc&method=doAllRepay";
//tanda dienkripsi oleh HmacMD5:ce749e942171b8123a98c0eb0e097543
String sign = EncryDigestUtil.hmacSign(paramStr, digest);
//permintaan terakhir yang dikirimurl
String finalUrl = "https://trade.zb.com/api/doAllRepay?accesskey=ce2a18e0-dshs-4c44-4515-9aca67dd706e&marketName=btsqc&method=doAllRepay&reqTime=1566315002580&sign=ce749e942171b8123a98c0eb0e097543";
//Dapatkan hasil pengembalianjson
String resultJson = HttpRequest.get(finalUrl).send().bodyText();
}
// python demo
import hashlib
import struct
import time
import requests
class ZApi:
def __init__(self, access_key, secret_key):
self._access_key_ = access_key
self._secret_key_ = secret_key
self._markets_ = self.markets()
if len(self._markets_) < 1:
raise Exception("Get markets status failed")
def doAllRepay(self):
MyUrl = 'https://trade.zb.com/api/doAllRepay'
#params = 'accesskey=ce2a18e0-dshs-4c44-4515-9aca67dd706e&marketName=btsqc&method=doAllRepay'
params = 'accesskey=' + self._access_key_ + '&marketName=btsqc&method=doAllRepay'
return self.call_api(url=MyUrl, params=params)
def call_api(self, url, params=''):
full_url = url
if params:
#sha_secret=86429c69799d3d6ac5da5c2c514baa874d75a4ba
sha_secret = self.digest(self._secret_key_)
#sign = ce749e942171b8123a98c0eb0e097543
sign = self.hmac_sign(params, sha_secret)
req_time = int(round(time.time() * 1000))
params += '&sign=%s&reqTime=%d' % (sign, req_time)
#full_url = https://trade.zb.com/api/doAllRepay?accesskey=ce2a18e0-dshs-4c44-4515-9aca67dd706e&marketName=btsqc&method=doAllRepay&reqTime=1566315002580&sign=ce749e942171b8123a98c0eb0e097543
full_url += '?' + params
result = {}
while True:
try:
r = requests.get(full_url, timeout=2)
except Exception:
time.sleep(0.5)
continue
if r.status_code != 200:
time.sleep(0.5)
r.close()
continue
else:
result = r.json()
r.close()
break
return result
@staticmethod
def fill(value, length, fill_byte):
if len(value) >= length:
return value
else:
fill_size = length - len(value)
return value + chr(fill_byte) * fill_size
@staticmethod
def xor(s, value):
slist = list(s.decode('utf-8'))
for index in range(len(slist)):
slist[index] = chr(ord(slist[index]) ^ value)
return "".join(slist)
def hmac_sign(self, arg_value, arg_key):
keyb = struct.pack("%ds" % len(arg_key), arg_key.encode('utf-8'))
value = struct.pack("%ds" % len(arg_value), arg_value.encode('utf-8'))
k_ipad = self.xor(keyb, 0x36)
k_opad = self.xor(keyb, 0x5c)
k_ipad = self.fill(k_ipad, 64, 54)
k_opad = self.fill(k_opad, 64, 92)
m = hashlib.md5()
m.update(k_ipad.encode('utf-8'))
m.update(value)
dg = m.digest()
m = hashlib.md5()
m.update(k_opad.encode('utf-8'))
subStr = dg[0:16]
m.update(subStr)
dg = m.hexdigest()
return dg
def digest(self, arg_value):
value = struct.pack("%ds" % len(arg_value), arg_value.encode('utf-8'))
h = hashlib.sha1()
h.update(value)
dg = h.hexdigest()
return dg
Contoh tanggapan
// Hasil Kembali
{
"code": "1000",
"message": "Proses berhasil。"
}
Nama parameter | Jenis | Rentang nilai |
---|---|---|
method | String | penugasan langsung doAllRepay |
accesskey | String | accesskey |
marketName | String | pasar leveragebtcqc |
coin | String | Mata uang (opsional jika jumlah pembayaran tidak diisi) |
repayAmount | String | Jumlah pembayaran (opsional, pembayaran penuh default) |
sign | String | Minta string tanda tangan terenkripsi |
reqTime | long | waktu saat ini dalam milidetik |
Nilai Kembali | Deskripsi |
---|---|
code | Kode Pengembalian |
message | Petunjuk |
Dapatkan catatan pembayaran
Contoh permintaan
// request demo
GET https://trade.zb.com/api/getRepayments?accesskey=youraccesskey&loanRecordId=50&method=getRepayments&pageIndex=1&pageSize=10&sign=Minta string tanda tangan terenkripsi&reqTime=waktu saat ini dalam milidetik
// java demo
public void getRepayments() {
//TestapiKey:ce2a18e0-dshs-4c44-4515-9aca67dd706e
//TestsecretKey:c11a122s-dshs-shsa-4515-954a67dd706e
//Enkripsi:https://github.com/zb2017/api/blob/master/zb_netty_client_java/src/main/java/websocketx/client/EncryDigestUtil.java
//secretKeyDiperoleh dengan enkripsi sha1:86429c69799d3d6ac5da5c2c514baa874d75a4ba
String digest = EncryDigestUtil.digest("c11a122s-dshs-shsa-4515-954a67dd706e");
//Parameter diurutkan berdasarkan nilai ASCII
String paramStr = "accesskey=ce2a18e0-dshs-4c44-4515-9aca67dd706e&loanRecordId=1454545415&method=getRepayments&pageIndex=1&pageSize=10";
//tanda dienkripsi oleh HmacMD5:3a8808fa43fac898bb7e6bb32713f7bb
String sign = EncryDigestUtil.hmacSign(paramStr, digest);
//permintaan terakhir yang dikirimurl
String finalUrl = "https://trade.zb.com/api/getRepayments?accesskey=ce2a18e0-dshs-4c44-4515-9aca67dd706e&loanRecordId=1454545415&method=getRepayments&pageIndex=1&pageSize=10&reqTime=1539942326082&sign=3a8808fa43fac898bb7e6bb32713f7bb";
//Dapatkan hasil pengembalianjson
String resultJson = HttpRequest.get(finalUrl).send().bodyText();
}
// python demo
import hashlib
import struct
import time
import requests
class ZApi:
def __init__(self, access_key, secret_key):
self._access_key_ = access_key
self._secret_key_ = secret_key
self._markets_ = self.markets()
if len(self._markets_) < 1:
raise Exception("Get markets status failed")
def getRepayments(self, market, type, amount, price):
MyUrl = 'https://trade.zb.com/api/getRepayments'
#params = 'accesskey=ce2a18e0-dshs-4c44-4515-9aca67dd706e&loanRecordId=1454545415&method=getRepayments&pageIndex=1&pageSize=10'
params = 'accesskey=' + self._access_key_ + '&loanRecordId=1454545415&method=getRepayments&pageIndex=1&pageSize=10'
return self.call_api(url=MyUrl, params=params)
def call_api(self, url, params=''):
full_url = url
if params:
#sha_secret=86429c69799d3d6ac5da5c2c514baa874d75a4ba
sha_secret = self.digest(self._secret_key_)
#sign = 3a8808fa43fac898bb7e6bb32713f7bb
sign = self.hmac_sign(params, sha_secret)
req_time = int(round(time.time() * 1000))
params += '&sign=%s&reqTime=%d' % (sign, req_time)
#full_url = https://trade.zb.com/api/getRepayments?accesskey=ce2a18e0-dshs-4c44-4515-9aca67dd706e&loanRecordId=1454545415&method=getRepayments&pageIndex=1&pageSize=10&reqTime=1540295995590&sign=3a8808fa43fac898bb7e6bb32713f7bb
full_url += '?' + params
result = {}
while True:
try:
r = requests.get(full_url, timeout=2)
except Exception:
time.sleep(0.5)
continue
if r.status_code != 200:
time.sleep(0.5)
r.close()
continue
else:
result = r.json()
r.close()
break
return result
@staticmethod
def fill(value, length, fill_byte):
if len(value) >= length:
return value
else:
fill_size = length - len(value)
return value + chr(fill_byte) * fill_size
@staticmethod
def xor(s, value):
slist = list(s.decode('utf-8'))
for index in range(len(slist)):
slist[index] = chr(ord(slist[index]) ^ value)
return "".join(slist)
def hmac_sign(self, arg_value, arg_key):
keyb = struct.pack("%ds" % len(arg_key), arg_key.encode('utf-8'))
value = struct.pack("%ds" % len(arg_value), arg_value.encode('utf-8'))
k_ipad = self.xor(keyb, 0x36)
k_opad = self.xor(keyb, 0x5c)
k_ipad = self.fill(k_ipad, 64, 54)
k_opad = self.fill(k_opad, 64, 92)
m = hashlib.md5()
m.update(k_ipad.encode('utf-8'))
m.update(value)
dg = m.digest()
m = hashlib.md5()
m.update(k_opad.encode('utf-8'))
subStr = dg[0:16]
m.update(subStr)
dg = m.hexdigest()
return dg
def digest(self, arg_value):
value = struct.pack("%ds" % len(arg_value), arg_value.encode('utf-8'))
h = hashlib.sha1()
h.update(value)
dg = h.hexdigest()
return dg
Contoh tanggapan
// Hasil Kembali
{
"code" : 1000,
"message" : "Proses berhasil",
"result" : [
{
"benJin" : "29",
"id" : 42,
"statusShow" : "Di kembalikan",
"status" : 1,
"liXi" : "0.0145",
"actureDate" : 1522031604000
}
]
}
Nama parameter | Jenis | Rentang nilai |
---|---|---|
method | String | penugasan langsung getRepayments |
accesskey | String | accesskey |
loanRecordId | String | Catatan Peminjamanid |
pageIndex | int | nomor halaman saat ini(Seperti: 1, halaman 1) |
pageSize | int | Kuantitas per halaman |
sign | String | Minta string tanda tangan terenkripsi |
reqTime | long | waktu saat ini dalam milidetik |
Nilai Kembali | Deskripsi |
---|---|
code | Kode Pengembalian |
message | Petunjuk |
id | Catatan PembayaranID |
benJin | Modal |
liXi | Bunga |
status | Status |
statusShow | Nilai status dalam bahasa chinese |
actureDate | Tanggal Pelunasan Sebenarnya |
Dapatkan Catatan Investasi
Contoh permintaan
// request demo
GET https://trade.zb.com/api/getFinanceRecords?accesskey=youraccesskey&coin=qc&method=getFinanceRecords&pageIndex=1&pageSize=10&sign=Minta string tanda tangan terenkripsi&reqTime=waktu saat ini dalam milidetik
// java demo
public void getFinanceRecords() {
//TestapiKey:ce2a18e0-dshs-4c44-4515-9aca67dd706e
//TestsecretKey:c11a122s-dshs-shsa-4515-954a67dd706e
//Enkripsi:https://github.com/zb2017/api/blob/master/zb_netty_client_java/src/main/java/websocketx/client/EncryDigestUtil.java
//secretKeyDiperoleh dengan enkripsi sha1:86429c69799d3d6ac5da5c2c514baa874d75a4ba
String digest = EncryDigestUtil.digest("c11a122s-dshs-shsa-4515-954a67dd706e");
//Parameter diurutkan berdasarkan nilai ASCII
String paramStr = "accesskey=ce2a18e0-dshs-4c44-4515-9aca67dd706e&coin=qc&method=getFinanceRecords&pageIndex=1&pageSize=10";
//tanda dienkripsi oleh HmacMD5:c448737856caa08575d83f26e33cdde0
String sign = EncryDigestUtil.hmacSign(paramStr, digest);
//permintaan terakhir yang dikirimurl
String finalUrl = "https://trade.zb.com/api/getFinanceRecords?accesskey=ce2a18e0-dshs-4c44-4515-9aca67dd706e&coin=qc&method=getFinanceRecords&pageIndex=1&pageSize=10&reqTime=1539943777351&sign=c448737856caa08575d83f26e33cdde0";
//Dapatkan hasil pengembalianjson
String resultJson = HttpRequest.get(finalUrl).send().bodyText();
}
// python demo
import hashlib
import struct
import time
import requests
class ZApi:
def __init__(self, access_key, secret_key):
self._access_key_ = access_key
self._secret_key_ = secret_key
self._markets_ = self.markets()
if len(self._markets_) < 1:
raise Exception("Get markets status failed")
def getFinanceRecords(self, market, type, amount, price):
MyUrl = 'https://trade.zb.com/api/getFinanceRecords'
#params = 'accesskey=ce2a18e0-dshs-4c44-4515-9aca67dd706e&coin=qc&method=getFinanceRecords&pageIndex=1&pageSize=10'
params = 'accesskey=' + self._access_key_ + '&coin=qc&method=getFinanceRecords&pageIndex=1&pageSize=10'
return self.call_api(url=MyUrl, params=params)
def call_api(self, url, params=''):
full_url = url
if params:
#sha_secret=86429c69799d3d6ac5da5c2c514baa874d75a4ba
sha_secret = self.digest(self._secret_key_)
#sign = c448737856caa08575d83f26e33cdde0
sign = self.hmac_sign(params, sha_secret)
req_time = int(round(time.time() * 1000))
params += '&sign=%s&reqTime=%d' % (sign, req_time)
#full_url = https://trade.zb.com/api/getFinanceRecords?accesskey=ce2a18e0-dshs-4c44-4515-9aca67dd706e&coin=qc&method=getFinanceRecords&pageIndex=1&pageSize=10&reqTime=1540295995593&sign=c448737856caa08575d83f26e33cdde0
full_url += '?' + params
result = {}
while True:
try:
r = requests.get(full_url, timeout=2)
except Exception:
time.sleep(0.5)
continue
if r.status_code != 200:
time.sleep(0.5)
r.close()
continue
else:
result = r.json()
r.close()
break
return result
@staticmethod
def fill(value, length, fill_byte):
if len(value) >= length:
return value
else:
fill_size = length - len(value)
return value + chr(fill_byte) * fill_size
@staticmethod
def xor(s, value):
slist = list(s.decode('utf-8'))
for index in range(len(slist)):
slist[index] = chr(ord(slist[index]) ^ value)
return "".join(slist)
def hmac_sign(self, arg_value, arg_key):
keyb = struct.pack("%ds" % len(arg_key), arg_key.encode('utf-8'))
value = struct.pack("%ds" % len(arg_value), arg_value.encode('utf-8'))
k_ipad = self.xor(keyb, 0x36)
k_opad = self.xor(keyb, 0x5c)
k_ipad = self.fill(k_ipad, 64, 54)
k_opad = self.fill(k_opad, 64, 92)
m = hashlib.md5()
m.update(k_ipad.encode('utf-8'))
m.update(value)
dg = m.digest()
m = hashlib.md5()
m.update(k_opad.encode('utf-8'))
subStr = dg[0:16]
m.update(subStr)
dg = m.hexdigest()
return dg
def digest(self, arg_value):
value = struct.pack("%ds" % len(arg_value), arg_value.encode('utf-8'))
h = hashlib.sha1()
h.update(value)
dg = h.hexdigest()
return dg
Contoh tanggapan
// Hasil Kembali
{
"code" : 1000,
"message" : "Proses berhasil。",
"result" : [
{
"id" : 156,
"userId" : 110803,
"userName" : "13427002684",
"fundType" : 15,
"coinName" : "QC",
"amount" : "10",
"hasAmount" : "0",
"status" : 0,
"statusShow" : "tidak dipinjam",
"createTime" : 1524541195000,
"interestRateOfDay" : "0.0012",
"repaymentDay" : 10,
"isLoop" : true,
"inTimes" : 0,
"sourceType" : 6
},
...
]
}
Nama parameter | Jenis | Rentang nilai |
---|---|---|
method | String | penugasan langsung getFinanceRecords |
accesskey | String | accesskey |
coin | String | Bunga yang telah jatuh tempo |
pageIndex | int | nomor halaman saat ini(Seperti: 1, halaman 1) |
pageSize | int | Kuantitas per halaman |
sign | String | Minta string tanda tangan terenkripsi |
reqTime | long | waktu saat ini dalam milidetik |
Nilai Kembali | Deskripsi |
---|---|
code | Kode Pengembalian |
message | Petunjuk |
id | InvestasiID |
userId | UserID |
userName | Nama pengguna |
fundType | Jenis koin |
coinName | Nama koin |
amount | Jumlah investasi |
hasAmount | Jumlah yang dipinjamkan |
status | Nilai status |
statusShow | Nilai status dalam bahasa chinese |
createTime | Waktu Rilis |
interestRateOfDay | Suku bunga harian |
repaymentDay | hari peminjaman |
isLoop | Apakah akan secara otomatis meminjamkan |
inTimes | Investasi yang dipinjam |
sourceType | jenis sumber: 8”Web”,5”handphoneAPP”,6”InterfaceAPI” |
Ubah ke pinjaman otomatis atau tidak
Contoh permintaan
// request demo
GET https://trade.zb.com/api/changeInvestMark?accesskey=youraccesskey&investMark=1&loanRecordId=meminjamkanid&method=changeInvestMark&sign=Minta string tanda tangan terenkripsi&reqTime=waktu saat ini dalam milidetik
// java demo
public void changeInvestMark() {
//TestapiKey:ce2a18e0-dshs-4c44-4515-9aca67dd706e
//TestsecretKey:c11a122s-dshs-shsa-4515-954a67dd706e
//Enkripsi:https://github.com/zb2017/api/blob/master/zb_netty_client_java/src/main/java/websocketx/client/EncryDigestUtil.java
//secretKeyDiperoleh dengan enkripsi sha1:86429c69799d3d6ac5da5c2c514baa874d75a4ba
String digest = EncryDigestUtil.digest("c11a122s-dshs-shsa-4515-954a67dd706e");
//Parameter diurutkan berdasarkan nilai ASCII
String paramStr = "accesskey=ce2a18e0-dshs-4c44-4515-9aca67dd706&investMark=1&loanRecordId=154545,457457574&method=changeInvestMark";
//tanda dienkripsi oleh HmacMD5:904182d4286992037130fbcbdabbe5cb
String sign = EncryDigestUtil.hmacSign(paramStr, digest);
//permintaan terakhir yang dikirimurl
String finalUrl = "https://trade.zb.com/api/changeInvestMark?accesskey=ce2a18e0-dshs-4c44-4515-9aca67dd706&investMark=1&loanRecordId=154545%2C457457574&method=changeInvestMark&reqTime=1539942326086&sign=904182d4286992037130fbcbdabbe5cb";
//Dapatkan hasil pengembalianjson
String resultJson = HttpRequest.get(finalUrl).send().bodyText();
}
// python demo
import hashlib
import struct
import time
import requests
class ZApi:
def __init__(self, access_key, secret_key):
self._access_key_ = access_key
self._secret_key_ = secret_key
self._markets_ = self.markets()
if len(self._markets_) < 1:
raise Exception("Get markets status failed")
def changeInvestMark(self, market, type, amount, price):
MyUrl = 'https://trade.zb.com/api/changeInvestMark'
params = 'accesskey=ce2a18e0-dshs-4c44-4515-9aca67dd706&investMark=1&loanRecordId=154545,457457574&method=changeInvestMark'
return self.call_api(url=MyUrl, params=params)
def call_api(self, url, params=''):
full_url = url
if params:
#sha_secret=86429c69799d3d6ac5da5c2c514baa874d75a4ba
sha_secret = self.digest(self._secret_key_)
#sign = 904182d4286992037130fbcbdabbe5cb
sign = self.hmac_sign(params, sha_secret)
req_time = int(round(time.time() * 1000))
params += '&sign=%s&reqTime=%d' % (sign, req_time)
#full_url = https://trade.zb.com/api/changeInvestMark?accesskey=ce2a18e0-dshs-4c44-4515-9aca67dd706&investMark=1;loanRecordId=154545%2C457457574&method=changeInvestMark&ime=1540295995599&sign=904182d4286992037130fbcbdabbe5cb
full_url += '?' + params
result = {}
while True:
try:
r = requests.get(full_url, timeout=2)
except Exception:
time.sleep(0.5)
continue
if r.status_code != 200:
time.sleep(0.5)
r.close()
continue
else:
result = r.json()
r.close()
break
return result
@staticmethod
def fill(value, length, fill_byte):
if len(value) >= length:
return value
else:
fill_size = length - len(value)
return value + chr(fill_byte) * fill_size
@staticmethod
def xor(s, value):
slist = list(s.decode('utf-8'))
for index in range(len(slist)):
slist[index] = chr(ord(slist[index]) ^ value)
return "".join(slist)
def hmac_sign(self, arg_value, arg_key):
keyb = struct.pack("%ds" % len(arg_key), arg_key.encode('utf-8'))
value = struct.pack("%ds" % len(arg_value), arg_value.encode('utf-8'))
k_ipad = self.xor(keyb, 0x36)
k_opad = self.xor(keyb, 0x5c)
k_ipad = self.fill(k_ipad, 64, 54)
k_opad = self.fill(k_opad, 64, 92)
m = hashlib.md5()
m.update(k_ipad.encode('utf-8'))
m.update(value)
dg = m.digest()
m = hashlib.md5()
m.update(k_opad.encode('utf-8'))
subStr = dg[0:16]
m.update(subStr)
dg = m.hexdigest()
return dg
def digest(self, arg_value):
value = struct.pack("%ds" % len(arg_value), arg_value.encode('utf-8'))
h = hashlib.sha1()
h.update(value)
dg = h.hexdigest()
return dg
Contoh tanggapan
// Hasil Kembali
{
"code" : 1000,
"message" : "Proses berhasil。",
}
Nama parameter | Jenis | Rentang nilai |
---|---|---|
method | String | penugasan langsung changeInvestMark |
accesskey | String | accesskey |
investMark | int | Jenis Pembaruan[0/1](Tidak otomatis/Perbaharui Otomatis) |
loanRecordId | String | meminjamkanId,banyak dalam bahasa inggris‘,’Terbagi |
sign | String | Minta string tanda tangan terenkripsi |
reqTime | long | waktu saat ini dalam milidetik |
Nilai Kembali | Deskripsi |
---|---|
code | Kode Pengembalian |
message | Petunjuk |
变更是否自动放贷
Contoh permintaan
// request demo
GET https://trade.zb.com/api/changeLoop?accesskey=youraccesskey&isLoop=1&loanId=Pinjamanid&method=changeLoop&sign=Minta string tanda tangan terenkripsi&reqTime=waktu saat ini dalam milidetik
// java demo
public void changeLoop() {
//TestapiKey:ce2a18e0-dshs-4c44-4515-9aca67dd706e
//TestsecretKey:c11a122s-dshs-shsa-4515-954a67dd706e
//Enkripsi:https://github.com/zb2017/api/blob/master/zb_netty_client_java/src/main/java/websocketx/client/EncryDigestUtil.java
//secretKeyDiperoleh dengan enkripsi sha1:86429c69799d3d6ac5da5c2c514baa874d75a4ba
String digest = EncryDigestUtil.digest("c11a122s-dshs-shsa-4515-954a67dd706e");
//Parameter diurutkan berdasarkan nilai ASCII
String paramStr = "accesskey=ce2a18e0-dshs-4c44-4515-9aca67dd706e&isLoop=0&loanId=1154545&method=changeLoop";
//tanda dienkripsi oleh HmacMD5:cfa39cb7fc939b2f4fd4dd3d788bf842
String sign = EncryDigestUtil.hmacSign(paramStr, digest);
//permintaan terakhir yang dikirimurl
String finalUrl = "https://trade.zb.com/api/changeLoop?accesskey=ce2a18e0-dshs-4c44-4515-9aca67dd706e&isLoop=0&loanId=1154545&method=changeLoop&reqTime=1539942326087&sign=cfa39cb7fc939b2f4fd4dd3d788bf842";
//Dapatkan hasil pengembalianjson
String resultJson = HttpRequest.get(finalUrl).send().bodyText();
}
// python demo
import hashlib
import struct
import time
import requests
class ZApi:
def __init__(self, access_key, secret_key):
self._access_key_ = access_key
self._secret_key_ = secret_key
self._markets_ = self.markets()
if len(self._markets_) < 1:
raise Exception("Get markets status failed")
def changeLoop(self, market, type, amount, price):
MyUrl = 'https://trade.zb.com/api/changeLoop'
#params = 'accesskey=ce2a18e0-dshs-4c44-4515-9aca67dd706e&isLoop=0&loanId=1154545&method=changeLoop'
params = 'accesskey=' + self._access_key_ + '&isLoop=0&loanId=1154545&method=changeLoop'
return self.call_api(url=MyUrl, params=params)
def call_api(self, url, params=''):
full_url = url
if params:
#sha_secret=86429c69799d3d6ac5da5c2c514baa874d75a4ba
sha_secret = self.digest(self._secret_key_)
#sign = cfa39cb7fc939b2f4fd4dd3d788bf842
sign = self.hmac_sign(params, sha_secret)
req_time = int(round(time.time() * 1000))
params += '&sign=%s&reqTime=%d' % (sign, req_time)
#full_url = https://trade.zb.com/api/changeLoop?accesskey=ce2a18e0-dshs-4c44-4515-9aca67dd706e&isLoop=0&loanId=1154545&method=changeLoop&reqTime=1540295995602&sign=cfa39cb7fc939b2f4fd4dd3d788bf842
full_url += '?' + params
result = {}
while True:
try:
r = requests.get(full_url, timeout=2)
except Exception:
time.sleep(0.5)
continue
if r.status_code != 200:
time.sleep(0.5)
r.close()
continue
else:
result = r.json()
r.close()
break
return result
@staticmethod
def fill(value, length, fill_byte):
if len(value) >= length:
return value
else:
fill_size = length - len(value)
return value + chr(fill_byte) * fill_size
@staticmethod
def xor(s, value):
slist = list(s.decode('utf-8'))
for index in range(len(slist)):
slist[index] = chr(ord(slist[index]) ^ value)
return "".join(slist)
def hmac_sign(self, arg_value, arg_key):
keyb = struct.pack("%ds" % len(arg_key), arg_key.encode('utf-8'))
value = struct.pack("%ds" % len(arg_value), arg_value.encode('utf-8'))
k_ipad = self.xor(keyb, 0x36)
k_opad = self.xor(keyb, 0x5c)
k_ipad = self.fill(k_ipad, 64, 54)
k_opad = self.fill(k_opad, 64, 92)
m = hashlib.md5()
m.update(k_ipad.encode('utf-8'))
m.update(value)
dg = m.digest()
m = hashlib.md5()
m.update(k_opad.encode('utf-8'))
subStr = dg[0:16]
m.update(subStr)
dg = m.hexdigest()
return dg
def digest(self, arg_value):
value = struct.pack("%ds" % len(arg_value), arg_value.encode('utf-8'))
h = hashlib.sha1()
h.update(value)
dg = h.hexdigest()
return dg
Contoh tanggapan
// Hasil Kembali
{
"code": 1000,
"message": "success",
}
Nama parameter | Jenis | Rentang nilai |
---|---|---|
method | String | penugasan langsung changeLoop |
accesskey | String | accesskey |
isLoop | int | Jenis pinjaman[0/1](Tidak otomatis/pinjaman otomatis) |
loanId | String | Pinjamanid |
sign | String | Minta string tanda tangan terenkripsi |
reqTime | long | waktu saat ini dalam milidetik |
Nilai Kembali | Deskripsi |
---|---|
code | Kode Pengembalian |
message | Petunjuk |
Leverage posisi silang
Dapatkan informasi leverage lintas margin
Contoh permintaan
// request demo
GET https://trade.zb.com/api/getCrossAssets?accesskey=youraccesskey&method=getCrossAssets&sign=Minta string tanda tangan terenkripsi&reqTime=waktu saat ini dalam milidetik
// java demo
public void getCrossAssets() {
//TestapiKey:ce2a18e0-dshs-4c44-4515-9aca67dd706e
//TestsecretKey:c11a122s-dshs-shsa-4515-954a67dd706e
//Enkripsi:https://github.com/zb2017/api/blob/master/zb_netty_client_java/src/main/java/websocketx/client/EncryDigestUtil.java
//secretKeyDiperoleh dengan enkripsi sha1:86429c69799d3d6ac5da5c2c514baa874d75a4ba
String digest = EncryDigestUtil.digest("c11a122s-dshs-shsa-4515-954a67dd706e");
//Parameter diurutkan berdasarkan nilai ASCII
String paramStr = "accesskey=ce2a18e0-dshs-4c44-4515-9aca67dd706e&method=getCrossAssets";
//tanda dienkripsi oleh HmacMD5:0cc8a3b79dabfac0c28229dd3871862d
String sign = EncryDigestUtil.hmacSign(paramStr, digest);
//permintaan terakhir yang dikirimurl
String finalUrl = "https://trade.zb.com/api/getCrossAssets?accesskey=ce2a18e0-dshs-4c44-4515-9aca67dd706e&method=getCrossAssets&reqTime=1539942326068&sign=0cc8a3b79dabfac0c28229dd3871862d";
//Dapatkan hasil pengembalianjson
String resultJson = HttpRequest.get(finalUrl).send().bodyText();
}
// python demo
import hashlib
import struct
import time
import requests
class ZApi:
def __init__(self, access_key, secret_key):
self._access_key_ = access_key
self._secret_key_ = secret_key
self._markets_ = self.markets()
if len(self._markets_) < 1:
raise Exception("Get markets status failed")
def getCrossAssets(self):
MyUrl = 'https://trade.zb.com/api/getCrossAssets'
#params = 'accesskey=ce2a18e0-dshs-4c44-4515-9aca67dd706e&method=getLeverAssetsInfo'
params = 'accesskey=' + self._access_key_ + '&method=getCrossAssets'
return self.call_api(url=MyUrl, params=params)
def call_api(self, url, params=''):
full_url = url
if params:
#sha_secret=86429c69799d3d6ac5da5c2c514baa874d75a4ba
sha_secret = self.digest(self._secret_key_)
#sign = 0cc8a3b79dabfac0c28229dd3871862d
sign = self.hmac_sign(params, sha_secret)
req_time = int(round(time.time() * 1000))
params += '&sign=%s&reqTime=%d' % (sign, req_time)
#full_url = https://trade.zb.com/api/getCrossAssets?accesskey=ce2a18e0-dshs-4c44-4515-9aca67dd706e&method=getCrossAssets&reqTime=1540295995557&sign=0cc8a3b79dabfac0c28229dd3871862d
full_url += '?' + params
result = {}
while True:
try:
r = requests.get(full_url, timeout=2)
except Exception:
time.sleep(0.5)
continue
if r.status_code != 200:
time.sleep(0.5)
r.close()
continue
else:
result = r.json()
r.close()
break
return result
@staticmethod
def fill(value, length, fill_byte):
if len(value) >= length:
return value
else:
fill_size = length - len(value)
return value + chr(fill_byte) * fill_size
@staticmethod
def xor(s, value):
slist = list(s.decode('utf-8'))
for index in range(len(slist)):
slist[index] = chr(ord(slist[index]) ^ value)
return "".join(slist)
def hmac_sign(self, arg_value, arg_key):
keyb = struct.pack("%ds" % len(arg_key), arg_key.encode('utf-8'))
value = struct.pack("%ds" % len(arg_value), arg_value.encode('utf-8'))
k_ipad = self.xor(keyb, 0x36)
k_opad = self.xor(keyb, 0x5c)
k_ipad = self.fill(k_ipad, 64, 54)
k_opad = self.fill(k_opad, 64, 92)
m = hashlib.md5()
m.update(k_ipad.encode('utf-8'))
m.update(value)
dg = m.digest()
m = hashlib.md5()
m.update(k_opad.encode('utf-8'))
subStr = dg[0:16]
m.update(subStr)
dg = m.hexdigest()
return dg
def digest(self, arg_value):
value = struct.pack("%ds" % len(arg_value), arg_value.encode('utf-8'))
h = hashlib.sha1()
h.update(value)
dg = h.hexdigest()
return dg
Contoh tanggapan
// Hasil Kembali
{
"code": 1000,
"message": Proses berhasil,
"result": {
"loanIn": 100,
"total": 1000,
"list": [
{
"fundType": 15,
"loanIn": 33,
"amount": 44,
"freeze": 0,
"overdraft": 13,
"key": "QC",
"canTransferOut": 0
},
...
],
"net": 1000
}
}
}
Nama parameter | Jenis | Rentang nilai |
---|---|---|
method | String | penugasan langsung getCrossAssets |
accesskey | String | accesskey |
sign | String | Minta string tanda tangan terenkripsi |
reqTime | long | waktu saat ini dalam milidetik |
Nilai Kembali | Deskripsi |
---|---|
code | Kode Pengembalian |
loanIn | meminjam |
total | Total aset |
riskRate | Tingkat risiko |
fundType | Bunga yang telah jatuh tempo ID |
amount | Koin yang tersedia |
freeze | Pembekuan koin |
overdraft | Bunga |
key | Nama koin |
canTransferOut | Jumlah yang dapat ditransfer keluar |
Dapatkan pernyataan leverage lintas margin
Contoh permintaan
// request demo
GET https://trade.zb.com/api/getCrossBills?accesskey=youraccesskey&coin=qc&dataType=0&method=getCrossBills&pageIndex=1&pageSize=10&sign=Minta string tanda tangan terenkripsi&reqTime=waktu saat ini dalam milidetik
// java demo
public void getCrossBills() {
//TestapiKey:ce2a18e0-dshs-4c44-4515-9aca67dd706e
//TestsecretKey:c11a122s-dshs-shsa-4515-954a67dd706e
//Enkripsi:https://github.com/zb2017/api/blob/master/zb_netty_client_java/src/main/java/websocketx/client/EncryDigestUtil.java
//secretKeyDiperoleh dengan enkripsi sha1:86429c69799d3d6ac5da5c2c514baa874d75a4ba
String digest = EncryDigestUtil.digest("c11a122s-dshs-shsa-4515-954a67dd706e");
//Parameter diurutkan berdasarkan nilai ASCII
String paramStr = "accesskey=ce2a18e0-dshs-4c44-4515-9aca67dd706e&coin=qc&dataType=0&method=getLeverBills&pageIndex=1&pageSize=10";
//tanda dienkripsi oleh HmacMD5:2473a00d93feed72583365e3cb90f391
String sign = EncryDigestUtil.hmacSign(paramStr, digest);
//permintaan terakhir yang dikirimurl
String finalUrl = "https://trade.zb.com/api/getCrossBills?accesskey=ce2a18e0-dshs-4c44-4515-9aca67dd706e&coin=qc&dataType=0&method=getCrossBills&pageIndex=1&pageSize=10&reqTime=1539942326070&sign=2473a00d93feed72583365e3cb90f391";
//Dapatkan hasil pengembalianjson
String resultJson = HttpRequest.get(finalUrl).send().bodyText();
}
// python demo
import hashlib
import struct
import time
import requests
class ZApi:
def __init__(self, access_key, secret_key):
self._access_key_ = access_key
self._secret_key_ = secret_key
self._markets_ = self.markets()
if len(self._markets_) < 1:
raise Exception("Get markets status failed")
def getCrossBills(self, amount, coin, dataType):
MyUrl = 'https://trade.zb.com/api/getCrossBills'
#params = 'accesskey=ce2a18e0-dshs-4c44-4515-9aca67dd706e&coin=qc&dataType=0&method=getCrossBills&pageIndex=1&pageSize=10'
params = 'accesskey=' + self._access_key_ + '&coin=qc&dataType=0&method=getCrossBills&pageIndex=1&pageSize=10'
return self.call_api(url=MyUrl, params=params)
def call_api(self, url, params=''):
full_url = url
if params:
#sha_secret=86429c69799d3d6ac5da5c2c514baa874d75a4ba
sha_secret = self.digest(self._secret_key_)
#sign = 2473a00d93feed72583365e3cb90f391
sign = self.hmac_sign(params, sha_secret)
req_time = int(round(time.time() * 1000))
params += '&sign=%s&reqTime=%d' % (sign, req_time)
#full_url = https://trade.zb.com/api/getCrossBills?accesskey=ce2a18e0-dshs-4c44-4515-9aca67dd706e&coin=qc&dataType=0&method=getCrossBills&pageIndex=1&pageSize=10&reqTime=1540295995560&sign=2473a00d93feed72583365e3cb90f391
full_url += '?' + params
result = {}
while True:
try:
r = requests.get(full_url, timeout=2)
except Exception:
time.sleep(0.5)
continue
if r.status_code != 200:
time.sleep(0.5)
r.close()
continue
else:
result = r.json()
r.close()
break
return result
@staticmethod
def fill(value, length, fill_byte):
if len(value) >= length:
return value
else:
fill_size = length - len(value)
return value + chr(fill_byte) * fill_size
@staticmethod
def xor(s, value):
slist = list(s.decode('utf-8'))
for index in range(len(slist)):
slist[index] = chr(ord(slist[index]) ^ value)
return "".join(slist)
def hmac_sign(self, arg_value, arg_key):
keyb = struct.pack("%ds" % len(arg_key), arg_key.encode('utf-8'))
value = struct.pack("%ds" % len(arg_value), arg_value.encode('utf-8'))
k_ipad = self.xor(keyb, 0x36)
k_opad = self.xor(keyb, 0x5c)
k_ipad = self.fill(k_ipad, 64, 54)
k_opad = self.fill(k_opad, 64, 92)
m = hashlib.md5()
m.update(k_ipad.encode('utf-8'))
m.update(value)
dg = m.digest()
m = hashlib.md5()
m.update(k_opad.encode('utf-8'))
subStr = dg[0:16]
m.update(subStr)
dg = m.hexdigest()
return dg
def digest(self, arg_value):
value = struct.pack("%ds" % len(arg_value), arg_value.encode('utf-8'))
h = hashlib.sha1()
h.update(value)
dg = h.hexdigest()
return dg
Contoh tanggapan
// Hasil Kembali
{
"code" : 1000,
"message" : "Proses berhasil",
"result" : [
{
"balance" : +1.000=1.000QC,
"showFiat" : "...",
"createTime" : 1605784831000,
"typeName" : "QC转入",
"showCoin" : "+1.000=1.000QC",
"id" : 609,
"type" : 1,
"changed" : 1
}
],
}
Nama parameter | Jenis | Rentang nilai |
---|---|---|
method | String | penugasan langsung getCrossBills |
accesskey | String | accesskey |
coin | String | Bunga yang telah jatuh tempo |
dataType | int | Jenis data[0/1](Data dalam 30 hari/Data 30 hari yang lalu) |
pageIndex | int | nomor halaman saat ini(Seperti: 1, halaman 1) |
pageSize | int | Kuantitas per halaman |
sign | String | Minta string tanda tangan terenkripsi |
reqTime | long | waktu saat ini dalam milidetik |
Nilai Kembali | Deskripsi |
---|---|
code | Kode Pengembalian |
message | Petunjuk |
balance | Saldo |
showFiat | ... |
createTime | Waktu pembuatan tagihan |
typeName | Jenis tagihan sesuai dengan bahasa Cina |
showCoin | menunjukkanCOINvariasi |
id | tagihanID |
type | Jenis tagihan |
changed | perubahan iniCOINJumlah |
Aset ditransfer ke leverage lintas margin
Contoh permintaan
// request demo
GET https://trade.zb.com/api/transferInCross?accesskey=youraccesskey&amount=100&coin=qc&method=transferInCross&sign=Minta string tanda tangan terenkripsi&reqTime=waktu saat ini dalam milidetik
// java demo
public void transferInCross() {
//TestapiKey:ce2a18e0-dshs-4c44-4515-9aca67dd706e
//TestsecretKey:c11a122s-dshs-shsa-4515-954a67dd706e
//Enkripsi:https://github.com/zb2017/api/blob/master/zb_netty_client_java/src/main/java/websocketx/client/EncryDigestUtil.java
//secretKeyDiperoleh dengan enkripsi sha1:86429c69799d3d6ac5da5c2c514baa874d75a4ba
String digest = EncryDigestUtil.digest("c11a122s-dshs-shsa-4515-954a67dd706e");
//Parameter diurutkan berdasarkan nilai ASCII
String paramStr = "accesskey=ce2a18e0-dshs-4c44-4515-9aca67dd706e&amount=1&coin=qc&method=transferInCross";
//tanda dienkripsi oleh HmacMD5:a8fe8d3e01143e83491e5df69f288fd4
String sign = EncryDigestUtil.hmacSign(paramStr, digest);
//permintaan terakhir yang dikirimurl
String finalUrl = "https://trade.zb.com/api/transferInCross?accesskey=ce2a18e0-dshs-4c44-4515-9aca67dd706e&amount=1&coin=qc&method=transferInCross&reqTime=1539942326071&sign=a8fe8d3e01143e83491e5df69f288fd4";
//Dapatkan hasil pengembalianjson
String resultJson = HttpRequest.get(finalUrl).send().bodyText();
}
// python demo
import hashlib
import struct
import time
import requests
class ZApi:
def __init__(self, access_key, secret_key):
self._access_key_ = access_key
self._secret_key_ = secret_key
self._markets_ = self.markets()
if len(self._markets_) < 1:
raise Exception("Get markets status failed")
def transferInLever(self, coin, amount):
MyUrl = 'https://trade.zb.com/api/transferInCross'
#params = 'accesskey=ce2a18e0-dshs-4c44-4515-9aca67dd706e&amount=1&coin=qc&method=transferInCross'
params = 'accesskey=' + self._access_key_ + '&amount=1&coin=qc&marketName=btsqc&method=transferInLever'
return self.call_api(url=MyUrl, params=params)
def call_api(self, url, params=''):
full_url = url
if params:
#sha_secret=86429c69799d3d6ac5da5c2c514baa874d75a4ba
sha_secret = self.digest(self._secret_key_)
#sign = a8fe8d3e01143e83491e5df69f288fd4
sign = self.hmac_sign(params, sha_secret)
req_time = int(round(time.time() * 1000))
params += '&sign=%s&reqTime=%d' % (sign, req_time)
#full_url = https://trade.zb.com/api/transferInCross?accesskey=ce2a18e0-dshs-4c44-4515-9aca67dd706e&amount=1&coin=qc&method=transferInCross&reqTime=1540295995563&sign=a8fe8d3e01143e83491e5df69f288fd4
full_url += '?' + params
result = {}
while True:
try:
r = requests.get(full_url, timeout=2)
except Exception:
time.sleep(0.5)
continue
if r.status_code != 200:
time.sleep(0.5)
r.close()
continue
else:
result = r.json()
r.close()
break
return result
@staticmethod
def fill(value, length, fill_byte):
if len(value) >= length:
return value
else:
fill_size = length - len(value)
return value + chr(fill_byte) * fill_size
@staticmethod
def xor(s, value):
slist = list(s.decode('utf-8'))
for index in range(len(slist)):
slist[index] = chr(ord(slist[index]) ^ value)
return "".join(slist)
def hmac_sign(self, arg_value, arg_key):
keyb = struct.pack("%ds" % len(arg_key), arg_key.encode('utf-8'))
value = struct.pack("%ds" % len(arg_value), arg_value.encode('utf-8'))
k_ipad = self.xor(keyb, 0x36)
k_opad = self.xor(keyb, 0x5c)
k_ipad = self.fill(k_ipad, 64, 54)
k_opad = self.fill(k_opad, 64, 92)
m = hashlib.md5()
m.update(k_ipad.encode('utf-8'))
m.update(value)
dg = m.digest()
m = hashlib.md5()
m.update(k_opad.encode('utf-8'))
subStr = dg[0:16]
m.update(subStr)
dg = m.hexdigest()
return dg
def digest(self, arg_value):
value = struct.pack("%ds" % len(arg_value), arg_value.encode('utf-8'))
h = hashlib.sha1()
h.update(value)
dg = h.hexdigest()
return dg
Contoh tanggapan
// Hasil Kembali
{
"code": "1000",
"message": "Proses berhasil。"
}
Nama parameter | Jenis | Rentang nilai |
---|---|---|
method | String | penugasan langsung transferInCross |
accesskey | String | accesskey |
coin | String | Bunga yang telah jatuh tempo |
amount | double | Jumlah Transfer,Tempat desimal tidak boleh melebihi4,Melebihi sistem secara otomatis di potong4Bit |
sign | String | Minta string tanda tangan terenkripsi |
reqTime | long | waktu saat ini dalam milidetik |
Nilai Kembali | Deskripsi |
---|---|
code | Kode Pengembalian |
message | Petunjuk |
Transfer aset dari leverage lintas margin
Contoh permintaan
// request demo
GET https://trade.zb.com/api/transferOutCross?accesskey=youraccesskey&amount=100&coin=qc&method=transferOutCross&sign=Minta string tanda tangan terenkripsi&reqTime=waktu saat ini dalam milidetik
// java demo
public void transferOutCross() {
//TestapiKey:ce2a18e0-dshs-4c44-4515-9aca67dd706e
//TestsecretKey:c11a122s-dshs-shsa-4515-954a67dd706e
//Enkripsi:https://github.com/zb2017/api/blob/master/zb_netty_client_java/src/main/java/websocketx/client/EncryDigestUtil.java
//secretKeyDiperoleh dengan enkripsi sha1:86429c69799d3d6ac5da5c2c514baa874d75a4ba
String digest = EncryDigestUtil.digest("c11a122s-dshs-shsa-4515-954a67dd706e");
//Parameter diurutkan berdasarkan nilai ASCII
String paramStr = "accesskey=ce2a18e0-dshs-4c44-4515-9aca67dd706e&amount=1&coin=qc&method=transferOutCross";
//tanda dienkripsi oleh HmacMD5:d7dcb17e6271232862812c339611d17e
String sign = EncryDigestUtil.hmacSign(paramStr, digest);
//permintaan terakhir yang dikirimurl
String finalUrl = "https://trade.zb.com/api/transferOutCross?accesskey=ce2a18e0-dshs-4c44-4515-9aca67dd706e&amount=1&coin=qc&method=transferOutLever&reqTime=1539942326073&sign=d7dcb17e6271232862812c339611d17e";
//Dapatkan hasil pengembalianjson
String resultJson = HttpRequest.get(finalUrl).send().bodyText();
}
// python demo
import hashlib
import struct
import time
import requests
class ZApi:
def __init__(self, access_key, secret_key):
self._access_key_ = access_key
self._secret_key_ = secret_key
self._markets_ = self.markets()
if len(self._markets_) < 1:
raise Exception("Get markets status failed")
def transferOutLever(self, amount, coin):
MyUrl = 'https://trade.zb.com/api/transferOutCross'
#params = 'accesskey=ce2a18e0-dshs-4c44-4515-9aca67dd706e&amount=1&coin=qc&method=transferOutCross'
params = 'accesskey=' + self._access_key_ + '&amount=1&coin=qc&method=transferOutCross'
return self.call_api(url=MyUrl, params=params)
def call_api(self, url, params=''):
full_url = url
if params:
#sha_secret=86429c69799d3d6ac5da5c2c514baa874d75a4ba
sha_secret = self.digest(self._secret_key_)
#sign = d7dcb17e6271232862812c339611d17e
sign = self.hmac_sign(params, sha_secret)
req_time = int(round(time.time() * 1000))
params += '&sign=%s&reqTime=%d' % (sign, req_time)
#full_url = https://trade.zb.com/api/transferOutCross?accesskey=ce2a18e0-dshs-4c44-4515-9aca67dd706e&amount=1&coin=qc&&method=transferOutLever&reqTime=1540295995566&sign=d7dcb17e6271232862812c339611d17e
full_url += '?' + params
result = {}
while True:
try:
r = requests.get(full_url, timeout=2)
except Exception:
time.sleep(0.5)
continue
if r.status_code != 200:
time.sleep(0.5)
r.close()
continue
else:
result = r.json()
r.close()
break
return result
@staticmethod
def fill(value, length, fill_byte):
if len(value) >= length:
return value
else:
fill_size = length - len(value)
return value + chr(fill_byte) * fill_size
@staticmethod
def xor(s, value):
slist = list(s.decode('utf-8'))
for index in range(len(slist)):
slist[index] = chr(ord(slist[index]) ^ value)
return "".join(slist)
def hmac_sign(self, arg_value, arg_key):
keyb = struct.pack("%ds" % len(arg_key), arg_key.encode('utf-8'))
value = struct.pack("%ds" % len(arg_value), arg_value.encode('utf-8'))
k_ipad = self.xor(keyb, 0x36)
k_opad = self.xor(keyb, 0x5c)
k_ipad = self.fill(k_ipad, 64, 54)
k_opad = self.fill(k_opad, 64, 92)
m = hashlib.md5()
m.update(k_ipad.encode('utf-8'))
m.update(value)
dg = m.digest()
m = hashlib.md5()
m.update(k_opad.encode('utf-8'))
subStr = dg[0:16]
m.update(subStr)
dg = m.hexdigest()
return dg
def digest(self, arg_value):
value = struct.pack("%ds" % len(arg_value), arg_value.encode('utf-8'))
h = hashlib.sha1()
h.update(value)
dg = h.hexdigest()
return dg
Contoh tanggapan
// Hasil Kembali
{
"code": "1000",
"message": "Proses berhasil。"
}
Nama parameter | Jenis | Rentang nilai |
---|---|---|
method | String | penugasan langsung transferOutCross |
accesskey | String | accesskey |
coin | String | Bunga yang telah jatuh tempo |
amount | double | Jumlah transfer keluar,Tempat desimal tidak boleh melebihi8,Melebihi sistem secara otomatis di potong8Bit |
sign | String | Minta string tanda tangan terenkripsi |
reqTime | long | waktu saat ini dalam milidetik |
Nilai Kembali | Deskripsi |
---|---|
code | Kode Pengembalian |
message | Petunjuk |
meminjamkan
Contoh permintaan
// request demo
GET https://trade.zb.com/api/doCrossLoan?accesskey=youraccesskey&amount=100&coin=qc&method=doCrossLoan&safePwd=Kata Sandi Transaksi&sign=Minta string tanda tangan terenkripsi&reqTime=waktu saat ini dalam milidetik
// java demo
public void doCrossLoan() {
//TestapiKey:ce2a18e0-dshs-4c44-4515-9aca67dd706e
//TestsecretKey:c11a122s-dshs-shsa-4515-954a67dd706e
//Enkripsi:https://github.com/zb2017/api/blob/master/zb_netty_client_java/src/main/java/websocketx/client/EncryDigestUtil.java
//secretKeyDiperoleh dengan enkripsi sha1:86429c69799d3d6ac5da5c2c514baa874d75a4ba
String digest = EncryDigestUtil.digest("c11a122s-dshs-shsa-4515-954a67dd706e");
//Parameter diurutkan berdasarkan nilai ASCII
String paramStr = "accesskey=ce2a18e0-dshs-4c44-4515-9aca67dd706e&amount=0.5&coin=qc&method=doCrossLoan&safePwd=152433";
//tanda dienkripsi oleh HmacMD5:0018e23184496b1fd5b7eadfaab2cc99
String sign = EncryDigestUtil.hmacSign(paramStr, digest);
//permintaan terakhir yang dikirimurl
String finalUrl = "https://trade.zb.com/api/doCrossLoan?accesskey=ce2a18e0-dshs-4c44-4515-9aca67dd706ecoin=qc&amount=0.5&method=doCrossLoan&safePwd=152433&sign=0018e23184496b1fd5b7eadfaab2cc99&reqTime=1539942326079";
//Dapatkan hasil pengembalianjson
String resultJson = HttpRequest.get(finalUrl).send().bodyText();
}
// python demo
import hashlib
import struct
import time
import requests
class ZApi:
def __init__(self, access_key, secret_key):
self._access_key_ = access_key
self._secret_key_ = secret_key
self._markets_ = self.markets()
if len(self._markets_) < 1:
raise Exception("Get markets status failed")
def borrow(self, amount, coin, safePwd):
MyUrl = 'https://trade.zb.com/api/doCrossLoan'
#params = 'accesskey=ce2a18e0-dshs-4c44-4515-9aca67dd706e&coin=qc&method=doCrossLoan&safePwd=152433'
params = 'accesskey=' + self._access_key_ + '&amount=0.5&coin=qc&method=doCrossLoan&safePwd=152433'
return self.call_api(url=MyUrl, params=params)
def call_api(self, url, params=''):
full_url = url
if params:
#sha_secret=86429c69799d3d6ac5da5c2c514baa874d75a4ba
sha_secret = self.digest(self._secret_key_)
#sign = 0018e23184496b1fd5b7eadfaab2cc99
sign = self.hmac_sign(params, sha_secret)
req_time = int(round(time.time() * 1000))
params += '&sign=%s&reqTime=%d' % (sign, req_time)
#full_url = https://trade.zb.com/api/doCrossLoan?accesskey=ce2a18e0-dshs-4c44-4515-9aca67dd706e&coin=qc&amount=0.5&method=doCrossLoan&safePwd=152433&sign=0018e23184496b1fd5b7eadfaab2cc99&reqTime=1540295995582
full_url += '?' + params
result = {}
while True:
try:
r = requests.get(full_url, timeout=2)
except Exception:
time.sleep(0.5)
continue
if r.status_code != 200:
time.sleep(0.5)
r.close()
continue
else:
result = r.json()
r.close()
break
return result
@staticmethod
def fill(value, length, fill_byte):
if len(value) >= length:
return value
else:
fill_size = length - len(value)
return value + chr(fill_byte) * fill_size
@staticmethod
def xor(s, value):
slist = list(s.decode('utf-8'))
for index in range(len(slist)):
slist[index] = chr(ord(slist[index]) ^ value)
return "".join(slist)
def hmac_sign(self, arg_value, arg_key):
keyb = struct.pack("%ds" % len(arg_key), arg_key.encode('utf-8'))
value = struct.pack("%ds" % len(arg_value), arg_value.encode('utf-8'))
k_ipad = self.xor(keyb, 0x36)
k_opad = self.xor(keyb, 0x5c)
k_ipad = self.fill(k_ipad, 64, 54)
k_opad = self.fill(k_opad, 64, 92)
m = hashlib.md5()
m.update(k_ipad.encode('utf-8'))
m.update(value)
dg = m.digest()
m = hashlib.md5()
m.update(k_opad.encode('utf-8'))
subStr = dg[0:16]
m.update(subStr)
dg = m.hexdigest()
return dg
def digest(self, arg_value):
value = struct.pack("%ds" % len(arg_value), arg_value.encode('utf-8'))
h = hashlib.sha1()
h.update(value)
dg = h.hexdigest()
return dg
Contoh tanggapan
// Hasil Kembali
{
"code": "1000",
"message": "Proses berhasil。"
}
Nama parameter | Jenis | Rentang nilai |
---|---|---|
method | String | penugasan langsung doCrossLoan |
accesskey | String | accesskey |
coin | String | Bunga yang telah jatuh tempo |
amount | double | 借入金额,Tempat desimal tidak boleh melebihi4,Melebihi sistem secara otomatis di potong4Bit |
safePwd | String | Kata sandi dana |
sign | String | Minta string tanda tangan terenkripsi |
reqTime | long | waktu saat ini dalam milidetik |
Nilai Kembali | Deskripsi |
---|---|
code | Kode Pengembalian |
message | Petunjuk |
pembayaran
Contoh permintaan
// request demo
GET https://trade.zb.com/api/doCrossRepay?accesskey=youraccesskey&coins=qc,usdt&method=doCrossRepay&repayAmount=100,200&&sign=Minta string tanda tangan terenkripsi&reqTime=waktu saat ini dalam milidetik
// java demo
public void doCrossRepay() {
//TestapiKey:ce2a18e0-dshs-4c44-4515-9aca67dd706e
//TestsecretKey:c11a122s-dshs-shsa-4515-954a67dd706e
//Enkripsi:https://github.com/zb2017/api/blob/master/zb_netty_client_java/src/main/java/websocketx/client/EncryDigestUtil.java
//secretKeyDiperoleh dengan enkripsi sha1:86429c69799d3d6ac5da5c2c514baa874d75a4ba
String digest = EncryDigestUtil.digest("c11a122s-dshs-shsa-4515-954a67dd706e");
//Parameter diurutkan berdasarkan nilai ASCII
String paramStr = "accesskey=ce2a18e0-dshs-4c44-4515-9aca67dd706e&method=doCrossRepay&repayAmount=1.5";
//tanda dienkripsi oleh HmacMD5:90fb3aacda467ffb95ce36c054173fff
String sign = EncryDigestUtil.hmacSign(paramStr, digest);
//permintaan terakhir yang dikirimurl
String finalUrl = "https://trade.zb.com/api/doCrossRepay?accesskey=ce2a18e0-dshs-4c44-4515-9aca67dd706e&method=doCrossRepay&reqTime=1539942326080&sign=90fb3aacda467ffb95ce36c054173fff";
//Dapatkan hasil pengembalianjson
String resultJson = HttpRequest.get(finalUrl).send().bodyText();
}
// python demo
import hashlib
import struct
import time
import requests
class ZApi:
def __init__(self, access_key, secret_key):
self._access_key_ = access_key
self._secret_key_ = secret_key
self._markets_ = self.markets()
if len(self._markets_) < 1:
raise Exception("Get markets status failed")
def repay(self, coins, amount, price):
MyUrl = 'https://trade.zb.com/api/doCrossRepay'
#params = 'accesskey=ce2a18e0-dshs-4c44-4515-9aca67dd706e&method=repay&repayAmount=1.5'
params = 'accesskey=' + self._access_key_ + '&method=repay&repayAmount=1.5'
return self.call_api(url=MyUrl, params=params)
def call_api(self, url, params=''):
full_url = url
if params:
#sha_secret=86429c69799d3d6ac5da5c2c514baa874d75a4ba
sha_secret = self.digest(self._secret_key_)
#sign = 90fb3aacda467ffb95ce36c054173fff
sign = self.hmac_sign(params, sha_secret)
req_time = int(round(time.time() * 1000))
params += '&sign=%s&reqTime=%d' % (sign, req_time)
#full_url = https://trade.zb.com/api/doCrossRepay?accesskey=ce2a18e0-dshs-4c44-4515-9aca67dd706e&method=repay&repayAmount=1.5&reqTime=1540295995586&sign=90fb3aacda467ffb95ce36c054173fff
full_url += '?' + params
result = {}
while True:
try:
r = requests.get(full_url, timeout=2)
except Exception:
time.sleep(0.5)
continue
if r.status_code != 200:
time.sleep(0.5)
r.close()
continue
else:
result = r.json()
r.close()
break
return result
@staticmethod
def fill(value, length, fill_byte):
if len(value) >= length:
return value
else:
fill_size = length - len(value)
return value + chr(fill_byte) * fill_size
@staticmethod
def xor(s, value):
slist = list(s.decode('utf-8'))
for index in range(len(slist)):
slist[index] = chr(ord(slist[index]) ^ value)
return "".join(slist)
def hmac_sign(self, arg_value, arg_key):
keyb = struct.pack("%ds" % len(arg_key), arg_key.encode('utf-8'))
value = struct.pack("%ds" % len(arg_value), arg_value.encode('utf-8'))
k_ipad = self.xor(keyb, 0x36)
k_opad = self.xor(keyb, 0x5c)
k_ipad = self.fill(k_ipad, 64, 54)
k_opad = self.fill(k_opad, 64, 92)
m = hashlib.md5()
m.update(k_ipad.encode('utf-8'))
m.update(value)
dg = m.digest()
m = hashlib.md5()
m.update(k_opad.encode('utf-8'))
subStr = dg[0:16]
m.update(subStr)
dg = m.hexdigest()
return dg
def digest(self, arg_value):
value = struct.pack("%ds" % len(arg_value), arg_value.encode('utf-8'))
h = hashlib.sha1()
h.update(value)
dg = h.hexdigest()
return dg
Contoh tanggapan
// Hasil Kembali
{
"code": "1000",
"message": "Proses berhasil。"
}
Nama parameter | Jenis | Rentang nilai |
---|---|---|
method | String | penugasan langsung doCrossRepay |
accesskey | String | accesskey |
coins | String | Mata uang (opsional jika jumlah pembayaran tidak diisi) |
repayAmount | double | Jumlah pembayaran (opsional, pembayaran penuh default) |
sign | String | Minta string tanda tangan terenkripsi |
reqTime | long | waktu saat ini dalam milidetik |
Nilai Kembali | Deskripsi |
---|---|
code | Kode Pengembalian |
message | Petunjuk |
自动借币
Contoh permintaan
// request demo
GET https://trade.zb.com/api/setExpressState?accesskey=youraccesskey&enableExpress=true&method=setExpressState&sign=Minta string tanda tangan terenkripsi&reqTime=waktu saat ini dalam milidetik
Contoh tanggapan
// Hasil Kembali
{
"code": "1000",
"message": "Proses berhasil。"
}
Nama parameter | Jenis | Rentang nilai |
---|---|---|
method | String | penugasan langsung setExpressState |
accesskey | String | accesskey |
enableExpress | String | true/false |
sign | String | Minta string tanda tangan terenkripsi |
reqTime | long | waktu saat ini dalam milidetik |
Nilai Kembali | Deskripsi |
---|---|
code | Kode Pengembalian |
message | Petunjuk |
pembayaran otomatis
Contoh permintaan
// request demo
GET https://trade.zb.com/api/setRepayState?accesskey=youraccesskey&enableRepay=true&method=setRepayState&sign=Minta string tanda tangan terenkripsi&reqTime=waktu saat ini dalam milidetik
Contoh tanggapan
// Hasil Kembali
{
"code": "1000",
"message": "Proses berhasil。"
}
Nama parameter | Jenis | Rentang nilai |
---|---|---|
method | String | penugasan langsung setRepayState |
accesskey | String | accesskey |
enableRepay | String | true/false |
sign | String | Minta string tanda tangan terenkripsi |
reqTime | long | waktu saat ini dalam milidetik |
Nilai Kembali | Deskripsi |
---|---|
code | Kode Pengembalian |
message | Petunjuk |
Dapatkan daftar pelunasan
Contoh permintaan
// request demo
GET https://trade.zb.com/api/getCrossRepayRecords?accesskey=youraccesskey&coin=qc&method=getCrossRepayRecords&pageIndex=1&pageSize=10&sign=Minta string tanda tangan terenkripsi&reqTime=waktu saat ini dalam milidetik
// java demo
public void getCrossRepayRecords() {
//TestapiKey:ce2a18e0-dshs-4c44-4515-9aca67dd706e
//TestsecretKey:c11a122s-dshs-shsa-4515-954a67dd706e
//Enkripsi:https://github.com/zb2017/api/blob/master/zb_netty_client_java/src/main/java/websocketx/client/EncryDigestUtil.java
//secretKeyDiperoleh dengan enkripsi sha1:86429c69799d3d6ac5da5c2c514baa874d75a4ba
String digest = EncryDigestUtil.digest("c11a122s-dshs-shsa-4515-954a67dd706e");
//Parameter diurutkan berdasarkan nilai ASCII
String paramStr = "accesskey=ce2a18e0-dshs-4c44-4515-9aca67dd706e&coin=qc&method=getCrossRepayRecords&pageIndex=1&pageSize=10";
//tanda dienkripsi oleh HmacMD5:9ed81061104f5b87703861ba77806eba
String sign = EncryDigestUtil.hmacSign(paramStr, digest);
//permintaan terakhir yang dikirimurl
String finalUrl = "https://trade.zb.com/api/getCrossRepayRecords?method=getCrossRepayRecords&cesskey=ce2a18e0-dshs-4c44-4515-9aca67dd706e&coin=qc&pageIndex=1&pageSize=10&sign=9ed81061104f5b87703861ba77806eba&reqTime=1539942326077";
//Dapatkan hasil pengembalianjson
String resultJson = HttpRequest.get(finalUrl).send().bodyText();
}
// python demo
import hashlib
import struct
import time
import requests
class ZApi:
def __init__(self, access_key, secret_key):
self._access_key_ = access_key
self._secret_key_ = secret_key
self._markets_ = self.markets()
if len(self._markets_) < 1:
raise Exception("Get markets status failed")
def getCrossRepayRecords(self, coin, pageIndex, pageSize):
MyUrl = 'https://trade.zb.com/api/getCrossRepayRecords'
#params = 'accesskey=ce2a18e0-dshs-4c44-4515-9aca67dd706e&coin=qc&method=getLoans&pageIndex=1&pageSize=10'
params = 'accesskey=' + self._access_key_ + '&coin=qc&method=getCrossRepayRecords&pageIndex=1&pageSize=10'
return self.call_api(url=MyUrl, params=params)
def call_api(self, url, params=''):
full_url = url
if params:
#sha_secret=86429c69799d3d6ac5da5c2c514baa874d75a4ba
sha_secret = self.digest(self._secret_key_)
#sign = 9ed81061104f5b87703861ba77806eba
sign = self.hmac_sign(params, sha_secret)
req_time = int(round(time.time() * 1000))
params += '&sign=%s&reqTime=%d' % (sign, req_time)
#full_url = https://trade.zb.com/api/getCrossRepayRecords?method=getCrossRepayRecords&cesskey=ce2a18e0-dshs-4c44-4515-9aca67dd706e&coin=qc&pageIndex=1&pageSize=10&sign=9ed81061104f5b87703861ba77806eba&reqTime=1540295995575
full_url += '?' + params
result = {}
while True:
try:
r = requests.get(full_url, timeout=2)
except Exception:
time.sleep(0.5)
continue
if r.status_code != 200:
time.sleep(0.5)
r.close()
continue
else:
result = r.json()
r.close()
break
return result
@staticmethod
def fill(value, length, fill_byte):
if len(value) >= length:
return value
else:
fill_size = length - len(value)
return value + chr(fill_byte) * fill_size
@staticmethod
def xor(s, value):
slist = list(s.decode('utf-8'))
for index in range(len(slist)):
slist[index] = chr(ord(slist[index]) ^ value)
return "".join(slist)
def hmac_sign(self, arg_value, arg_key):
keyb = struct.pack("%ds" % len(arg_key), arg_key.encode('utf-8'))
value = struct.pack("%ds" % len(arg_value), arg_value.encode('utf-8'))
k_ipad = self.xor(keyb, 0x36)
k_opad = self.xor(keyb, 0x5c)
k_ipad = self.fill(k_ipad, 64, 54)
k_opad = self.fill(k_opad, 64, 92)
m = hashlib.md5()
m.update(k_ipad.encode('utf-8'))
m.update(value)
dg = m.digest()
m = hashlib.md5()
m.update(k_opad.encode('utf-8'))
subStr = dg[0:16]
m.update(subStr)
dg = m.hexdigest()
return dg
def digest(self, arg_value):
value = struct.pack("%ds" % len(arg_value), arg_value.encode('utf-8'))
h = hashlib.sha1()
h.update(value)
dg = h.hexdigest()
return dg
Contoh tanggapan
// Hasil Kembali
{
"code" : 1000,
"message" : "Proses berhasil。",
"result" : [
{
"fundType" : 13,
"newStatus" : 2,
"oldStatus" : 1,
"sourceType" : 6,
"benJin" : 0.1
"crossLoanrecordId" : 1480
"repayDate" : 1605792527000
"id" : 698
"userName" : 18712342222
"liXi" : 0.1
"userId" : 32231
}
]
}
Nama parameter | Jenis | Rentang nilai |
---|---|---|
method | String | penugasan langsung getCrossRepayRecords |
accesskey | String | accesskey |
coin | String | qc |
pageIndex | int | nomor halaman saat ini(Seperti: 1, halaman 1) |
pageSize | int | Kuantitas per halaman |
accesskey | String | accesskey |
sign | String | Minta string tanda tangan terenkripsi |
reqTime | long | waktu saat ini dalam milidetik |
Nilai Kembali | Deskripsi | |
---|---|---|
code | Kode Pengembalian | |
message | Petunjuk | |
fundType | String | Bunga yang telah jatuh tempoID |
newStatus | int | Status sebelum pelunasan,1 pembayaran kembali,2 Dilunasi,3 Likuidasi paksa,4 Pembayaran likuidasi |
oldStatus | int | Status setelah pembayaran |
sourceType | jenis sumber: 8”Web”,5”handphoneAPP”,6”InterfaceAPI” | |
benJin | int | Modal |
crossLoanrecordId | String | ID Catatan Pinjaman Lintas Gudang |
repayDate | int | Waktu Pembayaran |
id | int | id |
userName | int | Nama pengguna |
liXi | int | Bunga |
userId | int | user id |
WebSocket API
ZB menyediakan API yang kuat untuk akses cepat ke pasar spot dengan fitur berikut: data pasar, buku pesanan, kedalaman tawaran dan permintaan, riwayat perdagangan, eksekusi perdagangan, informasi pesanan, riwayat pesanan, informasi akun.。
Pengaturan detak jantung, kirim ping, kembalikan pong
WebSocketalamat layanan
ZB WebSocketAlamat Koneksi Layanan:wss://api.zb.com/websocket
Kode sampel
Tanda tangan: Gunakan sha untuk mengenkripsi kunci rahasia terlebih dahulu, lalu tandatangani parameter yang diminta sesuai dengan kunci rahasia yang dienkripsi, minta parameter untuk diurutkan dan dienkripsi sesuai dengan nilai ascii, dan isi enkripsi 16-bit dengan md5.
Pembatasan akses
1.Untuk Trade API dan Margin API, satu KUNCI API dibatasi hingga 60 akses per detik, dan permintaan yang melebihi 60 permintaan per detik dianggap tidak valid.。
WSKonfigurasi
Dapatkan konfigurasi pasar
Contoh permintaan
// request demo
{
"event":"addChannel",
"channel":"markets"
}
// java demo
public void markets() {
val data = new TreeMap();
data.put("event", "addChannel");
data.put("channel", "markets");
ws.sendText(JSONObject.toJSONString(data));
}
// python demo
import hashlib
import zlib
import json
from time import sleep
from threading import Thread
import websocket
import urllib2, hashlib,struct,sha,time
zb_usd_url = "wss://api.zb.com/websocket"
class ZB_Sub_Spot_Api(object):
"""基于Websocket的API对象"""
def __init__(self):
"""Constructor"""
self.ws_sub_spot = None # websocketObjek aplikasi Objek spot
#----------------------------------------------------------------------
def reconnect(self):
"""sambungkan kembali"""
# Tutup dulu koneksi sebelumnya
self.close()
# sambungkan kembali lagi
self.ws_sub_spot = websocket.WebSocketApp(self.host,
on_message=self.onMessage,
on_error=self.onError,
on_close=self.onClose,
on_open=self.onOpen)
self.thread = Thread(target=self.ws_sub_spot.run_forever)
self.thread.start()
#----------------------------------------------------------------------
def connect_Subpot(self, apiKey , secretKey , trace = False):
self.host = zb_usd_url
self.apiKey = apiKey
self.secretKey = secretKey
websocket.enableTrace(trace)
self.ws_sub_spot = websocket.WebSocketApp(self.host,
on_message=self.onMessage,
on_error=self.onError,
on_close=self.onClose,
on_open=self.onOpen)
self.thread = Thread(target=self.ws_sub_spot.run_forever)
self.thread.start()
#----------------------------------------------------------------------
def readData(self, evt):
"""Ekstrak dan dorong data yang diterima"""
# # Ekstrak dan dorong data yang diterima
# decompress = zlib.decompressobj(-zlib.MAX_WBITS)
# # Dekompresi data asli menjadi string
# inflated = decompress.decompress(evt) + decompress.flush()
# Parse strings via json
data = json.loads(evt)
return data
#----------------------------------------------------------------------
def close(self):
"""Interface tutup"""
if self.thread and self.thread.isAlive():
self.ws_sub_spot.close()
self.thread.join()
#----------------------------------------------------------------------
def onMessage(self, ws, evt):
"""Push informasi"""
print evt
#----------------------------------------------------------------------
def onError(self, ws, evt):
"""salah push"""
print 'onError'
print evt
#----------------------------------------------------------------------
def onClose(self, ws):
"""Putuskan Sambungan Interface"""
print 'onClose'
#----------------------------------------------------------------------
def onOpen(self, ws):
"""Buka interface"""
print 'onOpen'
#----------------------------------------------------------------------
def sendJson(self):
req = "{'event':'addChannel','channel':'markets'}"
self.ws_sub_spot.send(req)
Contoh tanggapan
// Hasil Kembali
{
"code":1000,
"data":{
"btc_usdt":{
"amountScale":4,
"minAmount":0.0001,
"minSize":50,
"priceScale":2
},
...
},
"success":true,
"channel":"markets",
"message":"Proses berhasil。"
}
Nama parameter | Jenis | Rentang nilai |
---|---|---|
event | String | penugasan langsungaddChannel |
channel | String | markets |
Nilai Kembali | Deskripsi |
---|---|
priceScale | 价格小数位数 |
minAmount | Jumlah transaksi minimum dalam mata uang transaksi |
minSize | Kuantitas transaksi minimum dalam mata uang harga |
amountScale | Tempat Desimal dari Jumlah |
WSPasar
MemperolehtickerData
Contoh permintaan
// request demo
{
"event":"addChannel",
"channel":"ltcbtc_ticker",
}
// java demo
public void ticker() {
val data = new TreeMap();
data.put("event", "addChannel");
data.put("channel", "ltcbtc_ticker");
ws.sendText(JSONObject.toJSONString(data));
}
// python demo
import hashlib
import zlib
import json
from time import sleep
from threading import Thread
import websocket
import urllib2, hashlib,struct,sha,time
zb_usd_url = "wss://api.zb.com/websocket"
class ZB_Sub_Spot_Api(object):
"""基于Websocket的API对象"""
def __init__(self):
"""Constructor"""
self.ws_sub_spot = None # websocketObjek aplikasi Objek spot
#----------------------------------------------------------------------
def reconnect(self):
"""sambungkan kembali"""
# Tutup dulu koneksi sebelumnya
self.close()
# sambungkan kembali lagi
self.ws_sub_spot = websocket.WebSocketApp(self.host,
on_message=self.onMessage,
on_error=self.onError,
on_close=self.onClose,
on_open=self.onOpen)
self.thread = Thread(target=self.ws_sub_spot.run_forever)
self.thread.start()
#----------------------------------------------------------------------
def connect_Subpot(self, apiKey , secretKey , trace = False):
self.host = zb_usd_url
self.apiKey = apiKey
self.secretKey = secretKey
websocket.enableTrace(trace)
self.ws_sub_spot = websocket.WebSocketApp(self.host,
on_message=self.onMessage,
on_error=self.onError,
on_close=self.onClose,
on_open=self.onOpen)
self.thread = Thread(target=self.ws_sub_spot.run_forever)
self.thread.start()
#----------------------------------------------------------------------
def readData(self, evt):
"""Ekstrak dan dorong data yang diterima"""
# # Ekstrak dan dorong data yang diterima
# decompress = zlib.decompressobj(-zlib.MAX_WBITS)
# # Dekompresi data asli menjadi string
# inflated = decompress.decompress(evt) + decompress.flush()
# Parse strings via json
data = json.loads(evt)
return data
#----------------------------------------------------------------------
def close(self):
"""Interface tutup"""
if self.thread and self.thread.isAlive():
self.ws_sub_spot.close()
self.thread.join()
#----------------------------------------------------------------------
def onMessage(self, ws, evt):
"""Push informasi"""
print evt
#----------------------------------------------------------------------
def onError(self, ws, evt):
"""salah push"""
print 'onError'
print evt
#----------------------------------------------------------------------
def onClose(self, ws):
"""Putuskan Sambungan Interface"""
print 'onClose'
#----------------------------------------------------------------------
def onOpen(self, ws):
"""Buka interface"""
print 'onOpen'
#----------------------------------------------------------------------
def sendJson(self):
req = "{'event':'addChannel','channel':'ltcbtc_ticker'}"
self.ws_sub_spot.send(req)
Contoh tanggapan
// Hasil Kembali
{
"channel": "ltcbtc_ticker",
"date": "1472800466093",
"no": 245539,
"ticker": {
"buy": "3826.94",
"high": "3838.22",
"last": "3826.94",
"low": "3802.0",
"sell": "3828.25",
"open": "0.31"
"riseRate": "4.81"
"vol": "90151.83"
}
}
Nama parameter | Jenis | Rentang nilai |
---|---|---|
event | String | penugasan langsungaddChannel |
channel | String | zbqc_ticker |
Nilai Kembali | Deskripsi |
---|---|
date | Waktu server saat mengembalikan data |
high | harga tertinggi |
low | harga terendah |
buy | Beli 1 |
sell | Jual 1 |
last | Harga transaksi terbaru |
open | harga pembukaan |
riseRate | Perubahan 24 jam |
vol | Volume perdagangan(Terbaru24Jam) |
channel | Permintaan saat inichannel |
Dapatkan kedalaman pasar
Contoh permintaan
// request demo
{
"event":"addChannel",
"channel":"ltcbtc_depth",
}
// java demo
public void depth() {
val data = new TreeMap();
data.put("event", "addChannel");
data.put("channel", "ltcqc_depth");
ws.sendText(JSONObject.toJSONString(data));
}
// python demo
import hashlib
import zlib
import json
from time import sleep
from threading import Thread
import websocket
import urllib2, hashlib,struct,sha,time
zb_usd_url = "wss://api.zb.com/websocket"
class ZB_Sub_Spot_Api(object):
"""基于Websocket的API对象"""
def __init__(self):
"""Constructor"""
self.ws_sub_spot = None # websocketObjek aplikasi Objek spot
#----------------------------------------------------------------------
def reconnect(self):
"""sambungkan kembali"""
# Tutup dulu koneksi sebelumnya
self.close()
# sambungkan kembali lagi
self.ws_sub_spot = websocket.WebSocketApp(self.host,
on_message=self.onMessage,
on_error=self.onError,
on_close=self.onClose,
on_open=self.onOpen)
self.thread = Thread(target=self.ws_sub_spot.run_forever)
self.thread.start()
#----------------------------------------------------------------------
def connect_Subpot(self, apiKey , secretKey , trace = False):
self.host = zb_usd_url
self.apiKey = apiKey
self.secretKey = secretKey
websocket.enableTrace(trace)
self.ws_sub_spot = websocket.WebSocketApp(self.host,
on_message=self.onMessage,
on_error=self.onError,
on_close=self.onClose,
on_open=self.onOpen)
self.thread = Thread(target=self.ws_sub_spot.run_forever)
self.thread.start()
#----------------------------------------------------------------------
def readData(self, evt):
"""Ekstrak dan dorong data yang diterima"""
# # Ekstrak dan dorong data yang diterima
# decompress = zlib.decompressobj(-zlib.MAX_WBITS)
# # Dekompresi data asli menjadi string
# inflated = decompress.decompress(evt) + decompress.flush()
# Parse strings via json
data = json.loads(evt)
return data
#----------------------------------------------------------------------
def close(self):
"""Interface tutup"""
if self.thread and self.thread.isAlive():
self.ws_sub_spot.close()
self.thread.join()
#----------------------------------------------------------------------
def onMessage(self, ws, evt):
"""Push informasi"""
print evt
#----------------------------------------------------------------------
def onError(self, ws, evt):
"""salah push"""
print 'onError'
print evt
#----------------------------------------------------------------------
def onClose(self, ws):
"""Putuskan Sambungan Interface"""
print 'onClose'
#----------------------------------------------------------------------
def onOpen(self, ws):
"""Buka interface"""
print 'onOpen'
#----------------------------------------------------------------------
def sendJson(self):
req = "{'event':'addChannel','channel':'ltcbtc_depth'}"
self.ws_sub_spot.send(req)
Contoh tanggapan
// Hasil Kembali
{
"asks": [
[
3846.94,
0.659
]...
],
"bids": [
[
3826.94,
4.843
]...
],
"channel": "ltcbtc_depth",
"no": 245539
}
Nama parameter | Jenis | Rentang nilai |
---|---|---|
event | String | penugasan langsungaddChannel |
channel | String | ltcbtc_depth |
Nilai Kembali | Deskripsi |
---|---|
asks | Jual Order Depth |
bids | Beli pesanan |
channel | Permintaan saat inichannel |
Dapatkan transaksi historis
Contoh permintaan
// request demo
{
"event":"addChannel",
"channel":"ltcbtc_trades",
}
// java demo
public void trades() {
val data = new TreeMap();
data.put("event", "addChannel");
data.put("channel", "ltcbtc_trades");
ws.sendText(JSONObject.toJSONString(data));
}
// python demo
import hashlib
import zlib
import json
from time import sleep
from threading import Thread
import websocket
import urllib2, hashlib,struct,sha,time
zb_usd_url = "wss://api.zb.com/websocket"
class ZB_Sub_Spot_Api(object):
"""基于Websocket的API对象"""
def __init__(self):
"""Constructor"""
self.ws_sub_spot = None # websocketObjek aplikasi Objek spot
#----------------------------------------------------------------------
def reconnect(self):
"""sambungkan kembali"""
# Tutup dulu koneksi sebelumnya
self.close()
# sambungkan kembali lagi
self.ws_sub_spot = websocket.WebSocketApp(self.host,
on_message=self.onMessage,
on_error=self.onError,
on_close=self.onClose,
on_open=self.onOpen)
self.thread = Thread(target=self.ws_sub_spot.run_forever)
self.thread.start()
#----------------------------------------------------------------------
def connect_Subpot(self, apiKey , secretKey , trace = False):
self.host = zb_usd_url
self.apiKey = apiKey
self.secretKey = secretKey
websocket.enableTrace(trace)
self.ws_sub_spot = websocket.WebSocketApp(self.host,
on_message=self.onMessage,
on_error=self.onError,
on_close=self.onClose,
on_open=self.onOpen)
self.thread = Thread(target=self.ws_sub_spot.run_forever)
self.thread.start()
#----------------------------------------------------------------------
def readData(self, evt):
"""Ekstrak dan dorong data yang diterima"""
# # Ekstrak dan dorong data yang diterima
# decompress = zlib.decompressobj(-zlib.MAX_WBITS)
# # Dekompresi data asli menjadi string
# inflated = decompress.decompress(evt) + decompress.flush()
# Parse strings via json
data = json.loads(evt)
return data
#----------------------------------------------------------------------
def close(self):
"""Interface tutup"""
if self.thread and self.thread.isAlive():
self.ws_sub_spot.close()
self.thread.join()
#----------------------------------------------------------------------
def onMessage(self, ws, evt):
"""Push informasi"""
print evt
#----------------------------------------------------------------------
def onError(self, ws, evt):
"""salah push"""
print 'onError'
print evt
#----------------------------------------------------------------------
def onClose(self, ws):
"""Putuskan Sambungan Interface"""
print 'onClose'
#----------------------------------------------------------------------
def onOpen(self, ws):
"""Buka interface"""
print 'onOpen'
#----------------------------------------------------------------------
def sendJson(self):
req = "{'event':'addChannel','channel':'ltcbtc_trades'}"
self.ws_sub_spot.send(req)
Contoh tanggapan
// Hasil Kembali
{
"data": [
{
"date":"1443428902",
"price":"1565.91",
"amount":"0.553",
"tid":"37594617",
"type":"sell",
"trade_type":"ask"
}...
],
"no": 1031995,
"channel": "ltcbtc_trades"
}
Nama parameter | Jenis | Rentang nilai |
---|---|---|
event | String | penugasan langsungaddChannel |
channel | String | ltcbtc_trades |
Nilai Kembali | Deskripsi |
---|---|
date | Jam transaksi |
price | Harga transaksi |
amount | Jumlah transaksi |
tid | Generate transaksiID |
channel | Permintaan saat inichannel |
获取K线数据
Contoh permintaan
// request demo
{
"event":"addChannel",
"channel":"btcusdt_kline_15min",
}
Contoh tanggapan
// Hasil Kembali
{
"datas":
{
"date":[[1647446400000(time),40605.46(open),41435.92(high),39339.33(low),40796.16(collect),9248.8589( )]]",
}
"channel":"btcusdt_kline_1day",
"isSuc":true,
}
Nama parameter | Jenis | Rentang nilai |
---|---|---|
event | String | penugasan langsungaddChannel |
channel | String | btcusdt_kline_1day (1week, 3day, 1day, 12hour, 6hour, 4hour, 2hour, 1hour, 30min, 15min, 5min, 3min, 1min) |
Nilai Kembali | Deskripsi |
---|---|
channel | Permintaan saat inichannel |
WSTransaksi
Mempercayakan
Contoh permintaan
// request demo
{
"accesskey": your key,
"amount": 0.01,
"channel": "ltcbtc_order",
"event": "addChannel",
"no": "14728151154382111746154",
"price": 100,
"sign": Tanda tangan,
"tradeType": 1,
"acctType" : 1
}
// java demo
public void usdtqc_order() {
//TestapiKey:ce2a18e0-dshs-4c44-4515-9aca67dd706e
//TestsecretKey:c11a122s-dshs-shsa-4515-954a67dd706e
//Enkripsi:https://github.com/zb2017/api/blob/master/zb_netty_client_java/src/main/java/websocketx/client/EncryDigestUtil.java
//secretKeyDiperoleh dengan enkripsi sha1:86429c69799d3d6ac5da5c2c514baa874d75a4ba
String secret = EncryDigestUtil.digest("c11a122s-dshs-shsa-4515-954a67dd706e");
//Parameter diurutkan berdasarkan nilai ASCII
String params = "{"accesskey":"ce2a18e0-dshs-4c44-4515-9aca67dd706e","amount":"0.001","channel":"usdtqc_order","event":"addChannel","no":"test001","price":"1.0","tradeType":"1"}";
//tanda dienkripsi oleh HmacMD5:6b9cd4aaee79a6b74fffa49146ae8879
String sign = EncryDigestUtil.hmacSign(params, secret);
//Selanjutnya kirim ke permintaan parameter server json
String json = "{"accesskey":"ce2a18e0-dshs-4c44-4515-9aca67dd706e","amount":"0.001","channel":"usdtqc_order","event":"addChannel","no":"test001","price":"1.0","sign":"6b9cd4aaee79a6b74fffa49146ae8879","tradeType":"1"}";
ws.sendText(json);
}
// python demo
import hashlib
import zlib
import json
from time import sleep
from threading import Thread
import websocket
import urllib2, hashlib,struct,sha,time
zb_usd_url = "wss://api.zb.com/websocket"
class ZB_Sub_Spot_Api(object):
"""基于Websocket的API对象"""
def __init__(self):
"""Constructor"""
self.apiKey = 'ce2a18e0-dshs-4c44-4515-9aca67dd706e'
self.secretKey = 'c11a122s-dshs-shsa-4515-954a67dd706e'
self.ws_sub_spot = None # websocketObjek aplikasi Objek spot
#----------------------------------------------------------------------
def reconnect(self):
"""sambungkan kembali"""
# Tutup dulu koneksi sebelumnya
self.close()
# sambungkan kembali lagi
self.ws_sub_spot = websocket.WebSocketApp(self.host,
on_message=self.onMessage,
on_error=self.onError,
on_close=self.onClose,
on_open=self.onOpen)
self.thread = Thread(target=self.ws_sub_spot.run_forever)
self.thread.start()
#----------------------------------------------------------------------
def connect_Subpot(self, apiKey , secretKey , trace = False):
self.host = zb_usd_url
self.apiKey = apiKey
self.secretKey = secretKey
websocket.enableTrace(trace)
self.ws_sub_spot = websocket.WebSocketApp(self.host,
on_message=self.onMessage,
on_error=self.onError,
on_close=self.onClose,
on_open=self.onOpen)
self.thread = Thread(target=self.ws_sub_spot.run_forever)
self.thread.start()
#----------------------------------------------------------------------
def readData(self, evt):
"""Ekstrak dan dorong data yang diterima"""
# # Ekstrak dan dorong data yang diterima
# decompress = zlib.decompressobj(-zlib.MAX_WBITS)
# # Dekompresi data asli menjadi string
# inflated = decompress.decompress(evt) + decompress.flush()
# Parse strings via json
data = json.loads(evt)
return data
#----------------------------------------------------------------------
def close(self):
"""Interface tutup"""
if self.thread and self.thread.isAlive():
self.ws_sub_spot.close()
self.thread.join()
#----------------------------------------------------------------------
def onMessage(self, ws, evt):
"""Push informasi"""
print evt
#----------------------------------------------------------------------
def onError(self, ws, evt):
"""salah push"""
print 'onError'
print evt
#----------------------------------------------------------------------
def onClose(self, ws):
"""Putuskan Sambungan Interface"""
print 'onClose'
#----------------------------------------------------------------------
def onOpen(self, ws):
"""Buka interface"""
print 'onOpen'
#----------------------------------------------------------------------
def __fill(self, value, length, fillByte):
if len(value) >= length:
return value
else:
fillSize = length - len(value)
return value + chr(fillByte) * fillSize
#----------------------------------------------------------------------
def __doXOr(self, s, value):
slist = list(s)
for index in xrange(len(slist)):
slist[index] = chr(ord(slist[index]) ^ value)
return "".join(slist)
#----------------------------------------------------------------------
def __hmacSign(self, aValue, aKey):
keyb = struct.pack("%ds" % len(aKey), aKey)
value = struct.pack("%ds" % len(aValue), aValue)
k_ipad = self.__doXOr(keyb, 0x36)
k_opad = self.__doXOr(keyb, 0x5c)
k_ipad = self.__fill(k_ipad, 64, 54)
k_opad = self.__fill(k_opad, 64, 92)
m = hashlib.md5()
m.update(k_ipad)
m.update(value)
dg = m.digest()
m = hashlib.md5()
m.update(k_opad)
subStr = dg[0:16]
m.update(subStr)
dg = m.hexdigest()
return dg
#----------------------------------------------------------------------
def __digest(self, aValue):
value = struct.pack("%ds" % len(aValue), aValue)
h = sha.new()
h.update(value)
dg = h.hexdigest()
return dg
#----------------------------------------------------------------------
def generateSign(self, params):
#Parameter diurutkan berdasarkan nilai ASCII: {"accesskey":"ce2a18e0-dshs-4c44-4515-9aca67dd706e","amount":"0.001","channel":"usdtqc_order","event":"addChannel","no":"test001","price":"1.0","tradeType":"1"}
#secretKey Setelah mengenkripsi:86429c69799d3d6ac5da5c2c514baa874d75a4ba
SHA_secret = self.__digest(self.secretKey)
#Hitung tandanya: 6b9cd4aaee79a6b74fffa49146ae8879
return self.__hmacSign( paramsStr, SHA_secret)
#----------------------------------------------------------------------
def usdtqc_order(self, symbol_pair, type_, price, amount):
json = "{"accesskey":"ce2a18e0-dshs-4c44-4515-9aca67dd706e","amount":"0.001","channel":"usdtqc_order","event":"addChannel","no":"test001","price":"1.0","sign":"6b9cd4aaee79a6b74fffa49146ae8879","tradeType":"1"}";
try:
self.ws_sub_spot.send(json)
except websocket.WebSocketConnectionClosedException:
pass
Contoh tanggapan
// Hasil Kembali
{
"message":"Proses berhasil。",
"no":"0",
"data":"{
"entrustId":201711133673
}",
"code":1000,
"channel":"ltcbtc_order",
"success":true
}
Nama parameter | Jenis | Rentang nilai |
---|---|---|
accesskey | String | accesskey |
amount | float | Jumlah transaksi |
channel | String | Transaksi koin/harga koin_order(btcusdt_order) |
event | String | penugasan langsungaddChannel |
no | String | Identitas unik permintaan digunakan untuk membedakan konten saat dikembalikan |
price | float | Harga |
tradeType | int | Tipe transaksi1/0[buy/sell] |
acctType | int | Margin 0/1/2[Spot/Leverage Terisolasi/Leverage posisi silang](Pilihan lain,Standarnya adalah: 0 Spot) |
sign | String | Minta string tanda tangan terenkripsi |
Nilai Kembali | Deskripsi |
---|---|
code | Kode Pengembalian |
message | Petunjuk |
entrustId | Nomor pesanan yang dipercayakan |
channel | saluran yang diminta |
no | Identitas unik permintaan digunakan untuk membedakan konten saat dikembalikan |
Cancel Order
Contoh permintaan
// request demo
{
"accesskey": your key,
"channel": "ltcbtc_cancelorder",
"event": "addChannel",
"id": 20160902387645980,
"no": "1472814987517496849777",
"sign": Tanda tangan,
}
// java demo
public void usdtqc_cancelorder() {
//TestapiKey:ce2a18e0-dshs-4c44-4515-9aca67dd706e
//TestsecretKey:c11a122s-dshs-shsa-4515-954a67dd706e
//Enkripsi:https://github.com/zb2017/api/blob/master/zb_netty_client_java/src/main/java/websocketx/client/EncryDigestUtil.java
//secretKeyDiperoleh dengan enkripsi sha1:86429c69799d3d6ac5da5c2c514baa874d75a4ba
String secret = EncryDigestUtil.digest("c11a122s-dshs-shsa-4515-954a67dd706e");
//Parameter diurutkan berdasarkan nilai ASCII
String params = "{"accesskey":"ce2a18e0-dshs-4c44-4515-9aca67dd706e","channel":"usdtqc_cancelorder","event":"addChannel","id":"20180522105585216","no":"test001"}";
//tanda dienkripsi oleh HmacMD5:100d377228931b1147895f9d9785b2a3
String sign = EncryDigestUtil.hmacSign(params, secret);
//Selanjutnya kirim ke permintaan parameter server json
String json = "{"accesskey":"ce2a18e0-dshs-4c44-4515-9aca67dd706e","channel":"usdtqc_cancelorder","event":"addChannel","id":"20180522105585216","no":"test001","sign":"100d377228931b1147895f9d9785b2a3"}";
ws.sendText(json);
}
// python demo
import hashlib
import zlib
import json
from time import sleep
from threading import Thread
import websocket
import urllib2, hashlib,struct,sha,time
zb_usd_url = "wss://api.zb.com/websocket"
class ZB_Sub_Spot_Api(object):
"""基于Websocket的API对象"""
def __init__(self):
"""Constructor"""
self.apiKey = 'ce2a18e0-dshs-4c44-4515-9aca67dd706e'
self.secretKey = 'c11a122s-dshs-shsa-4515-954a67dd706e'
self.ws_sub_spot = None # websocketObjek aplikasi Objek spot
#----------------------------------------------------------------------
def reconnect(self):
"""sambungkan kembali"""
# Tutup dulu koneksi sebelumnya
self.close()
# sambungkan kembali lagi
self.ws_sub_spot = websocket.WebSocketApp(self.host,
on_message=self.onMessage,
on_error=self.onError,
on_close=self.onClose,
on_open=self.onOpen)
self.thread = Thread(target=self.ws_sub_spot.run_forever)
self.thread.start()
#----------------------------------------------------------------------
def connect_Subpot(self, apiKey , secretKey , trace = False):
self.host = zb_usd_url
self.apiKey = apiKey
self.secretKey = secretKey
websocket.enableTrace(trace)
self.ws_sub_spot = websocket.WebSocketApp(self.host,
on_message=self.onMessage,
on_error=self.onError,
on_close=self.onClose,
on_open=self.onOpen)
self.thread = Thread(target=self.ws_sub_spot.run_forever)
self.thread.start()
#----------------------------------------------------------------------
def readData(self, evt):
"""Ekstrak dan dorong data yang diterima"""
# # Ekstrak dan dorong data yang diterima
# decompress = zlib.decompressobj(-zlib.MAX_WBITS)
# # Dekompresi data asli menjadi string
# inflated = decompress.decompress(evt) + decompress.flush()
# Parse strings via json
data = json.loads(evt)
return data
#----------------------------------------------------------------------
def close(self):
"""Interface tutup"""
if self.thread and self.thread.isAlive():
self.ws_sub_spot.close()
self.thread.join()
#----------------------------------------------------------------------
def onMessage(self, ws, evt):
"""Push informasi"""
print evt
#----------------------------------------------------------------------
def onError(self, ws, evt):
"""salah push"""
print 'onError'
print evt
#----------------------------------------------------------------------
def onClose(self, ws):
"""Putuskan Sambungan Interface"""
print 'onClose'
#----------------------------------------------------------------------
def onOpen(self, ws):
"""Buka interface"""
print 'onOpen'
#----------------------------------------------------------------------
def __fill(self, value, length, fillByte):
if len(value) >= length:
return value
else:
fillSize = length - len(value)
return value + chr(fillByte) * fillSize
#----------------------------------------------------------------------
def __doXOr(self, s, value):
slist = list(s)
for index in xrange(len(slist)):
slist[index] = chr(ord(slist[index]) ^ value)
return "".join(slist)
#----------------------------------------------------------------------
def __hmacSign(self, aValue, aKey):
keyb = struct.pack("%ds" % len(aKey), aKey)
value = struct.pack("%ds" % len(aValue), aValue)
k_ipad = self.__doXOr(keyb, 0x36)
k_opad = self.__doXOr(keyb, 0x5c)
k_ipad = self.__fill(k_ipad, 64, 54)
k_opad = self.__fill(k_opad, 64, 92)
m = hashlib.md5()
m.update(k_ipad)
m.update(value)
dg = m.digest()
m = hashlib.md5()
m.update(k_opad)
subStr = dg[0:16]
m.update(subStr)
dg = m.hexdigest()
return dg
#----------------------------------------------------------------------
def __digest(self, aValue):
value = struct.pack("%ds" % len(aValue), aValue)
h = sha.new()
h.update(value)
dg = h.hexdigest()
return dg
#----------------------------------------------------------------------
def generateSign(self, params):
#Parameter diurutkan berdasarkan nilai ASCII: {"accesskey":"ce2a18e0-dshs-4c44-4515-9aca67dd706e","channel":"usdtqc_cancelorder","event":"addChannel","id":"20180522105585216","no":"test001"}
#secretKey Setelah mengenkripsi:86429c69799d3d6ac5da5c2c514baa874d75a4ba
SHA_secret = self.__digest(self.secretKey)
#Hitung tandanya: 100d377228931b1147895f9d9785b2a3
return self.__hmacSign( paramsStr, SHA_secret)
#----------------------------------------------------------------------
def usdtqc_cancelorder(self, symbol_pair, type_, price, amount):
json = "{"accesskey":"ce2a18e0-dshs-4c44-4515-9aca67dd706e","channel":"usdtqc_cancelorder","event":"addChannel","id":"20180522105585216","no":"test001","sign":"100d377228931b1147895f9d9785b2a3"}";
try:
self.ws_sub_spot.send(json)
except websocket.WebSocketConnectionClosedException:
pass
Contoh tanggapan
// Hasil Kembali
{
"success": true,
"code": 1000,
"channel": "ltcbtc_cancelorder",
"message": "Proses berhasil。",
"no": "1472814987517496849777"
}
Nama parameter | Jenis | Rentang nilai |
---|---|---|
accesskey | String | accesskey |
channel | String | Transaksi koin/harga koin_cancelorder(btcusdt_cancelorder) |
event | String | penugasan langsungaddChannel |
id | long | 委托单id |
no | String | Identitas unik permintaan digunakan untuk membedakan konten saat dikembalikan |
sign | String | Minta string tanda tangan terenkripsi |
Nilai Kembali | Deskripsi |
---|---|
code | Kode Pengembalian |
message | Petunjuk |
entrustId | Nomor pesanan yang dipercayakan |
channel | saluran yang diminta |
no | Identitas unik permintaan digunakan untuk membedakan konten saat dikembalikan |
dapatkan pesanan
Contoh permintaan
// request demo
{
"accesskey": your key,
"channel": "ltcbtc_getorder",
"event": "addChannel",
"id": 20160902387645980,
"no": "14728149875431230591268",
"sign": Tanda tangan,
}
// java demo
public void usdtqc_getorder() {
//TestapiKey:ce2a18e0-dshs-4c44-4515-9aca67dd706e
//TestsecretKey:c11a122s-dshs-shsa-4515-954a67dd706e
//Enkripsi:https://github.com/zb2017/api/blob/master/zb_netty_client_java/src/main/java/websocketx/client/EncryDigestUtil.java
//secretKeyDiperoleh dengan enkripsi sha1:86429c69799d3d6ac5da5c2c514baa874d75a4ba
String secret = EncryDigestUtil.digest("c11a122s-dshs-shsa-4515-954a67dd706e");
//Parameter diurutkan berdasarkan nilai ASCII
String params = "{"accesskey":"ce2a18e0-dshs-4c44-4515-9aca67dd706e","channel":"usdtqc_getorder","event":"addChannel","id":"20180522105585216","no":"test001"}";
//tanda dienkripsi oleh HmacMD5:aa67749256db23191458fea8970f1b6e
String sign = EncryDigestUtil.hmacSign(params, secret);
//Selanjutnya kirim ke permintaan parameter server json
String json = "{"accesskey":"ce2a18e0-dshs-4c44-4515-9aca67dd706e","channel":"usdtqc_getorder","event":"addChannel","id":"20180522105585216","no":"test001","sign":"aa67749256db23191458fea8970f1b6e"}";
ws.sendText(json);
}
// python demo
import hashlib
import zlib
import json
from time import sleep
from threading import Thread
import websocket
import urllib2, hashlib,struct,sha,time
zb_usd_url = "wss://api.zb.com/websocket"
class ZB_Sub_Spot_Api(object):
"""基于Websocket的API对象"""
def __init__(self):
"""Constructor"""
self.apiKey = 'ce2a18e0-dshs-4c44-4515-9aca67dd706e'
self.secretKey = 'c11a122s-dshs-shsa-4515-954a67dd706e'
self.ws_sub_spot = None # websocketObjek aplikasi Objek spot
#----------------------------------------------------------------------
def reconnect(self):
"""sambungkan kembali"""
# Tutup dulu koneksi sebelumnya
self.close()
# sambungkan kembali lagi
self.ws_sub_spot = websocket.WebSocketApp(self.host,
on_message=self.onMessage,
on_error=self.onError,
on_close=self.onClose,
on_open=self.onOpen)
self.thread = Thread(target=self.ws_sub_spot.run_forever)
self.thread.start()
#----------------------------------------------------------------------
def connect_Subpot(self, apiKey , secretKey , trace = False):
self.host = zb_usd_url
self.apiKey = apiKey
self.secretKey = secretKey
websocket.enableTrace(trace)
self.ws_sub_spot = websocket.WebSocketApp(self.host,
on_message=self.onMessage,
on_error=self.onError,
on_close=self.onClose,
on_open=self.onOpen)
self.thread = Thread(target=self.ws_sub_spot.run_forever)
self.thread.start()
#----------------------------------------------------------------------
def readData(self, evt):
"""Ekstrak dan dorong data yang diterima"""
# # Ekstrak dan dorong data yang diterima
# decompress = zlib.decompressobj(-zlib.MAX_WBITS)
# # Dekompresi data asli menjadi string
# inflated = decompress.decompress(evt) + decompress.flush()
# Parse strings via json
data = json.loads(evt)
return data
#----------------------------------------------------------------------
def close(self):
"""Interface tutup"""
if self.thread and self.thread.isAlive():
self.ws_sub_spot.close()
self.thread.join()
#----------------------------------------------------------------------
def onMessage(self, ws, evt):
"""Push informasi"""
print evt
#----------------------------------------------------------------------
def onError(self, ws, evt):
"""salah push"""
print 'onError'
print evt
#----------------------------------------------------------------------
def onClose(self, ws):
"""Putuskan Sambungan Interface"""
print 'onClose'
#----------------------------------------------------------------------
def onOpen(self, ws):
"""Buka interface"""
print 'onOpen'
#----------------------------------------------------------------------
def __fill(self, value, length, fillByte):
if len(value) >= length:
return value
else:
fillSize = length - len(value)
return value + chr(fillByte) * fillSize
#----------------------------------------------------------------------
def __doXOr(self, s, value):
slist = list(s)
for index in xrange(len(slist)):
slist[index] = chr(ord(slist[index]) ^ value)
return "".join(slist)
#----------------------------------------------------------------------
def __hmacSign(self, aValue, aKey):
keyb = struct.pack("%ds" % len(aKey), aKey)
value = struct.pack("%ds" % len(aValue), aValue)
k_ipad = self.__doXOr(keyb, 0x36)
k_opad = self.__doXOr(keyb, 0x5c)
k_ipad = self.__fill(k_ipad, 64, 54)
k_opad = self.__fill(k_opad, 64, 92)
m = hashlib.md5()
m.update(k_ipad)
m.update(value)
dg = m.digest()
m = hashlib.md5()
m.update(k_opad)
subStr = dg[0:16]
m.update(subStr)
dg = m.hexdigest()
return dg
#----------------------------------------------------------------------
def __digest(self, aValue):
value = struct.pack("%ds" % len(aValue), aValue)
h = sha.new()
h.update(value)
dg = h.hexdigest()
return dg
#----------------------------------------------------------------------
def generateSign(self, params):
#Parameter diurutkan berdasarkan nilai ASCII: {"accesskey":"ce2a18e0-dshs-4c44-4515-9aca67dd706e","channel":"usdtqc_getorder","event":"addChannel","id":"20180522105585216","no":"test001"}
#secretKey Setelah mengenkripsi:86429c69799d3d6ac5da5c2c514baa874d75a4ba
SHA_secret = self.__digest(self.secretKey)
#Hitung tandanya: aa67749256db23191458fea8970f1b6e
return self.__hmacSign( paramsStr, SHA_secret)
#----------------------------------------------------------------------
def usdtqc_getorder(self, symbol_pair, type_, price, amount):
json = "{"accesskey":"ce2a18e0-dshs-4c44-4515-9aca67dd706e","channel":"usdtqc_getorder","event":"addChannel","id":"20180522105585216","no":"test001","sign":"aa67749256db23191458fea8970f1b6e"}";
try:
self.ws_sub_spot.send(json)
except websocket.WebSocketConnectionClosedException:
pass
Contoh tanggapan
// Hasil Kembali
{
"success": true,
"code": 1000,
"data": {
"currency": "ltc_btc",
"id": "20160902387645980",
"price": 100,
"status": 0,
"total_amount": 0.01,
"trade_amount": 0,
"trade_date": 1472814905567,
"trade_money": 0,
"type": 1
},
"channel": "ltcbtc_getorder",
"message": "Proses berhasil。",
"no": "14728149875431230591268"
}
Nama parameter | Jenis | Rentang nilai |
---|---|---|
accesskey | String | accesskey |
channel | String | Transaksi koin/harga koin_getorder(btcusdt_getorder) |
event | String | penugasan langsungaddChannel |
id | long | Nomor pesanan yang dipercayakan |
no | String | Identitas unik permintaan digunakan untuk membedakan konten saat dikembalikan |
sign | String | Minta string tanda tangan terenkripsi |
Nilai Kembali | Deskripsi |
---|---|
id | Nomor pesanan yang dipercayakan |
currency | Tipe transaksi |
trade_amount | Jumlah volume yang di setujui |
trade_money | Jumlah transaksi yang di setujui |
total_amount | Jumlah pesanan |
trade_date | mempercayakan waktu |
code | Kode Pengembalian |
message | Petunjuk |
channel | saluran yang diminta |
no | Identitas unik permintaan digunakan untuk membedakan konten saat dikembalikan |
Dapatkan banyak pesanan
Contoh permintaan
// request demo
{
"accesskey": "your key",
"channel": "ltcbtc_getorders",
"event": "addChannel",
"no": "14728004752031866329548",
"pageIndex": 1,
"sign": Tanda tangan,
"tradeType": 1
}
// java demo
public void usdtqc_getorders() {
//TestapiKey:ce2a18e0-dshs-4c44-4515-9aca67dd706e
//TestsecretKey:c11a122s-dshs-shsa-4515-954a67dd706e
//Enkripsi:https://github.com/zb2017/api/blob/master/zb_netty_client_java/src/main/java/websocketx/client/EncryDigestUtil.java
//secretKeyDiperoleh dengan enkripsi sha1:86429c69799d3d6ac5da5c2c514baa874d75a4ba
String secret = EncryDigestUtil.digest("c11a122s-dshs-shsa-4515-954a67dd706e");
//Parameter diurutkan berdasarkan nilai ASCII
String params = "{"accesskey":"ce2a18e0-dshs-4c44-4515-9aca67dd706e","acctType":"0","channel":"usdtqc_getorders","event":"addChannel","no":"test001","pageIndex":"1","tradeType":"1"}";
//tanda dienkripsi oleh HmacMD5:027cf41d1f761e5ab8fc61b7e3efda54
String sign = EncryDigestUtil.hmacSign(params, secret);
//Selanjutnya kirim ke permintaan parameter server json
String json = "{"accesskey":"ce2a18e0-dshs-4c44-4515-9aca67dd706e","acctType":"0","channel":"usdtqc_getorders","event":"addChannel","no":"test001","pageIndex":"1","sign":"027cf41d1f761e5ab8fc61b7e3efda54","tradeType":"1"}";
ws.sendText(json);
}
// python demo
import hashlib
import zlib
import json
from time import sleep
from threading import Thread
import websocket
import urllib2, hashlib,struct,sha,time
zb_usd_url = "wss://api.zb.com/websocket"
class ZB_Sub_Spot_Api(object):
"""基于Websocket的API对象"""
def __init__(self):
"""Constructor"""
self.apiKey = 'ce2a18e0-dshs-4c44-4515-9aca67dd706e'
self.secretKey = 'c11a122s-dshs-shsa-4515-954a67dd706e'
self.ws_sub_spot = None # websocketObjek aplikasi Objek spot
#----------------------------------------------------------------------
def reconnect(self):
"""sambungkan kembali"""
# Tutup dulu koneksi sebelumnya
self.close()
# sambungkan kembali lagi
self.ws_sub_spot = websocket.WebSocketApp(self.host,
on_message=self.onMessage,
on_error=self.onError,
on_close=self.onClose,
on_open=self.onOpen)
self.thread = Thread(target=self.ws_sub_spot.run_forever)
self.thread.start()
#----------------------------------------------------------------------
def connect_Subpot(self, apiKey , secretKey , trace = False):
self.host = zb_usd_url
self.apiKey = apiKey
self.secretKey = secretKey
websocket.enableTrace(trace)
self.ws_sub_spot = websocket.WebSocketApp(self.host,
on_message=self.onMessage,
on_error=self.onError,
on_close=self.onClose,
on_open=self.onOpen)
self.thread = Thread(target=self.ws_sub_spot.run_forever)
self.thread.start()
#----------------------------------------------------------------------
def readData(self, evt):
"""Ekstrak dan dorong data yang diterima"""
# # Ekstrak dan dorong data yang diterima
# decompress = zlib.decompressobj(-zlib.MAX_WBITS)
# # Dekompresi data asli menjadi string
# inflated = decompress.decompress(evt) + decompress.flush()
# Parse strings via json
data = json.loads(evt)
return data
#----------------------------------------------------------------------
def close(self):
"""Interface tutup"""
if self.thread and self.thread.isAlive():
self.ws_sub_spot.close()
self.thread.join()
#----------------------------------------------------------------------
def onMessage(self, ws, evt):
"""Push informasi"""
print evt
#----------------------------------------------------------------------
def onError(self, ws, evt):
"""salah push"""
print 'onError'
print evt
#----------------------------------------------------------------------
def onClose(self, ws):
"""Putuskan Sambungan Interface"""
print 'onClose'
#----------------------------------------------------------------------
def onOpen(self, ws):
"""Buka interface"""
print 'onOpen'
#----------------------------------------------------------------------
def __fill(self, value, length, fillByte):
if len(value) >= length:
return value
else:
fillSize = length - len(value)
return value + chr(fillByte) * fillSize
#----------------------------------------------------------------------
def __doXOr(self, s, value):
slist = list(s)
for index in xrange(len(slist)):
slist[index] = chr(ord(slist[index]) ^ value)
return "".join(slist)
#----------------------------------------------------------------------
def __hmacSign(self, aValue, aKey):
keyb = struct.pack("%ds" % len(aKey), aKey)
value = struct.pack("%ds" % len(aValue), aValue)
k_ipad = self.__doXOr(keyb, 0x36)
k_opad = self.__doXOr(keyb, 0x5c)
k_ipad = self.__fill(k_ipad, 64, 54)
k_opad = self.__fill(k_opad, 64, 92)
m = hashlib.md5()
m.update(k_ipad)
m.update(value)
dg = m.digest()
m = hashlib.md5()
m.update(k_opad)
subStr = dg[0:16]
m.update(subStr)
dg = m.hexdigest()
return dg
#----------------------------------------------------------------------
def __digest(self, aValue):
value = struct.pack("%ds" % len(aValue), aValue)
h = sha.new()
h.update(value)
dg = h.hexdigest()
return dg
#----------------------------------------------------------------------
def generateSign(self, params):
#Parameter diurutkan berdasarkan nilai ASCII: {"accesskey":"ce2a18e0-dshs-4c44-4515-9aca67dd706e","acctType":"0","channel":"usdtqc_getorders","event":"addChannel","no":"test001","pageIndex":"1","tradeType":"1"}
#secretKey Setelah mengenkripsi:86429c69799d3d6ac5da5c2c514baa874d75a4ba
SHA_secret = self.__digest(self.secretKey)
#Hitung tandanya: 027cf41d1f761e5ab8fc61b7e3efda54
return self.__hmacSign( paramsStr, SHA_secret)
#----------------------------------------------------------------------
def usdtqc_getorders(self, symbol_pair, type_, price, amount):
json = "{"accesskey":"ce2a18e0-dshs-4c44-4515-9aca67dd706e","acctType":"0","channel":"usdtqc_getorders","event":"addChannel","no":"test001","pageIndex":"1","sign":"027cf41d1f761e5ab8fc61b7e3efda54","tradeType":"1"}";
try:
self.ws_sub_spot.send(json)
except websocket.WebSocketConnectionClosedException:
pass
Contoh tanggapan
// Hasil Kembali
{
"success": true,
"code": 1000,
"data": [
{
"currency": "ltc_btc",
"id": "20160901385862136",
"price": 3700,
"status": 0,
"total_amount": 1.845,
"trade_amount": 0,
"trade_date": 1472706387742,
"trade_money": 0,
"type": 1
}...
],
"channel": "ltcbtc_getorders",
"message": "Proses berhasil。",
"no": "14728004752031866329548"
}
Nama parameter | Jenis | Rentang nilai |
---|---|---|
accesskey | String | accesskey |
channel | String | Transaksi koin/harga koin_getorders(btcusdt_getorders) |
event | String | penugasan langsungaddChannel |
no | String | Identitas unik permintaan digunakan untuk membedakan konten saat dikembalikan |
pageIndex | int | nomor halaman saat ini(Seperti: 1, halaman 1) |
tradeType | int | Tipe transaksi1/0[buy/sell] |
Nilai Kembali | Deskripsi |
---|---|
currency | Tipe transaksi |
id | Nomor pesanan yang dipercayakan |
price | Harga |
status | Status pesanan:(1. Batal, 2. Selesai/Batalkan pesanan setelah sebagian selesai, 3. Pesanan tertunda/Tidak ) |
total_amount | Jumlah pesanan |
trade_amount | Jumlah volume yang di setujui |
trade_date | mempercayakan waktu |
trade_money | Jumlah transaksi yang di setujui |
type | Jenis pesanan tertunda0-limit sell,1-limit buy,2-PostOnly sell,3-PostOnly buy,4-IOC sell,5-IOC buy |
fees | Biaya transaksi |
useZbFee | Apakah itu biaya pengurangan ZB |
code | Kode Pengembalian |
message | Petunjuk |
channel | saluran yang diminta |
no | Identitas unik permintaan digunakan untuk membedakan konten saat dikembalikan |
Dapatkan pesanan abaikan jenis
Contoh permintaan
// request demo
{
"accesskey": "your key",
"channel": "ltcbtc_getordersignoretradetype",
"event": "addChannel",
"no": "1472800475206-1927246702",
"pageIndex": 1,
"pageSize": 10,
"sign": Tanda tangan,
}
// java demo
public void usdtqc_getordersignoretradetype() {
//TestapiKey:ce2a18e0-dshs-4c44-4515-9aca67dd706e
//TestsecretKey:c11a122s-dshs-shsa-4515-954a67dd706e
//Enkripsi:https://github.com/zb2017/api/blob/master/zb_netty_client_java/src/main/java/websocketx/client/EncryDigestUtil.java
//secretKeyDiperoleh dengan enkripsi sha1:86429c69799d3d6ac5da5c2c514baa874d75a4ba
String secret = EncryDigestUtil.digest("c11a122s-dshs-shsa-4515-954a67dd706e");
//Parameter diurutkan berdasarkan nilai ASCII
String params = "{"accesskey":"ce2a18e0-dshs-4c44-4515-9aca67dd706e","channel":"usdtqc_getordersignoretradetype","event":"addChannel","no":"test001","pageIndex":"1","pageSize":"10"}";
//tanda dienkripsi oleh HmacMD5:71ea0655343e47e6359de635b9ffe312
String sign = EncryDigestUtil.hmacSign(params, secret);
//Selanjutnya kirim ke permintaan parameter server json
String json = "{"accesskey":"ce2a18e0-dshs-4c44-4515-9aca67dd706e","channel":"usdtqc_getordersignoretradetype","event":"addChannel","no":"test001","pageIndex":"1","pageSize":"10","sign":"71ea0655343e47e6359de635b9ffe312"}";
ws.sendText(json);
}
// python demo
import hashlib
import zlib
import json
from time import sleep
from threading import Thread
import websocket
import urllib2, hashlib,struct,sha,time
zb_usd_url = "wss://api.zb.com/websocket"
class ZB_Sub_Spot_Api(object):
"""基于Websocket的API对象"""
def __init__(self):
"""Constructor"""
self.apiKey = 'ce2a18e0-dshs-4c44-4515-9aca67dd706e'
self.secretKey = 'c11a122s-dshs-shsa-4515-954a67dd706e'
self.ws_sub_spot = None # websocketObjek aplikasi Objek spot
#----------------------------------------------------------------------
def reconnect(self):
"""sambungkan kembali"""
# Tutup dulu koneksi sebelumnya
self.close()
# sambungkan kembali lagi
self.ws_sub_spot = websocket.WebSocketApp(self.host,
on_message=self.onMessage,
on_error=self.onError,
on_close=self.onClose,
on_open=self.onOpen)
self.thread = Thread(target=self.ws_sub_spot.run_forever)
self.thread.start()
#----------------------------------------------------------------------
def connect_Subpot(self, apiKey , secretKey , trace = False):
self.host = zb_usd_url
self.apiKey = apiKey
self.secretKey = secretKey
websocket.enableTrace(trace)
self.ws_sub_spot = websocket.WebSocketApp(self.host,
on_message=self.onMessage,
on_error=self.onError,
on_close=self.onClose,
on_open=self.onOpen)
self.thread = Thread(target=self.ws_sub_spot.run_forever)
self.thread.start()
#----------------------------------------------------------------------
def readData(self, evt):
"""Ekstrak dan dorong data yang diterima"""
# # Ekstrak dan dorong data yang diterima
# decompress = zlib.decompressobj(-zlib.MAX_WBITS)
# # Dekompresi data asli menjadi string
# inflated = decompress.decompress(evt) + decompress.flush()
# Parse strings via json
data = json.loads(evt)
return data
#----------------------------------------------------------------------
def close(self):
"""Interface tutup"""
if self.thread and self.thread.isAlive():
self.ws_sub_spot.close()
self.thread.join()
#----------------------------------------------------------------------
def onMessage(self, ws, evt):
"""Push informasi"""
print evt
#----------------------------------------------------------------------
def onError(self, ws, evt):
"""salah push"""
print 'onError'
print evt
#----------------------------------------------------------------------
def onClose(self, ws):
"""Putuskan Sambungan Interface"""
print 'onClose'
#----------------------------------------------------------------------
def onOpen(self, ws):
"""Buka interface"""
print 'onOpen'
#----------------------------------------------------------------------
def __fill(self, value, length, fillByte):
if len(value) >= length:
return value
else:
fillSize = length - len(value)
return value + chr(fillByte) * fillSize
#----------------------------------------------------------------------
def __doXOr(self, s, value):
slist = list(s)
for index in xrange(len(slist)):
slist[index] = chr(ord(slist[index]) ^ value)
return "".join(slist)
#----------------------------------------------------------------------
def __hmacSign(self, aValue, aKey):
keyb = struct.pack("%ds" % len(aKey), aKey)
value = struct.pack("%ds" % len(aValue), aValue)
k_ipad = self.__doXOr(keyb, 0x36)
k_opad = self.__doXOr(keyb, 0x5c)
k_ipad = self.__fill(k_ipad, 64, 54)
k_opad = self.__fill(k_opad, 64, 92)
m = hashlib.md5()
m.update(k_ipad)
m.update(value)
dg = m.digest()
m = hashlib.md5()
m.update(k_opad)
subStr = dg[0:16]
m.update(subStr)
dg = m.hexdigest()
return dg
#----------------------------------------------------------------------
def __digest(self, aValue):
value = struct.pack("%ds" % len(aValue), aValue)
h = sha.new()
h.update(value)
dg = h.hexdigest()
return dg
#----------------------------------------------------------------------
def generateSign(self, params):
#Parameter diurutkan berdasarkan nilai ASCII: {"accesskey":"ce2a18e0-dshs-4c44-4515-9aca67dd706e","channel":"usdtqc_getordersignoretradetype","event":"addChannel","no":"test001","pageIndex":"1","pageSize":"10"}
#secretKey Setelah mengenkripsi:86429c69799d3d6ac5da5c2c514baa874d75a4ba
SHA_secret = self.__digest(self.secretKey)
#Hitung tandanya: 71ea0655343e47e6359de635b9ffe312
return self.__hmacSign( paramsStr, SHA_secret)
#----------------------------------------------------------------------
def usdtqc_getordersignoretradetype(self, symbol_pair, type_, price, amount):
json = "{"accesskey":"ce2a18e0-dshs-4c44-4515-9aca67dd706e","channel":"usdtqc_getordersignoretradetype","event":"addChannel","no":"test001","pageIndex":"1","pageSize":"10","sign":"71ea0655343e47e6359de635b9ffe312"}";
try:
self.ws_sub_spot.send(json)
except websocket.WebSocketConnectionClosedException:
pass
Contoh tanggapan
// Hasil Kembali
{
"success": true,
"code": 1000,
"data": [
{
"currency": "ltc_btc",
"id": "20160901385862136",
"price": 3700,
"status": 0,
"total_amount": 1.845,
"trade_amount": 0,
"trade_date": 1472706387742,
"trade_money": 0,
"type": 1
}...
],
"channel": "ltcbtc_getordersignoretradetype",
"message": "Proses berhasil。",
"no": "1472800475205-217627433"
}
Nama parameter | Jenis | Rentang nilai |
---|---|---|
accesskey | String | accesskey |
channel | String | Transaksi koin/harga koin_getordersignoretradetype(btcusdt_getordersignoretradetype) |
event | String | penugasan langsungaddChannel |
no | String | Identitas unik permintaan digunakan untuk membedakan konten saat dikembalikan |
pageIndex | int | nomor halaman saat ini(Seperti: 1, halaman 1) |
pageSize | int | Kuantitas per halaman |
Nilai Kembali | Deskripsi |
---|---|
currency | Tipe transaksi |
id | Nomor pesanan yang dipercayakan |
price | Harga |
status | Status pesanan:(1. Batal, 2. Selesai/Batalkan pesanan setelah sebagian selesai, 3. Pesanan tertunda/Tidak ) |
total_amount | Jumlah pesanan |
trade_amount | Jumlah volume yang di setujui |
trade_date | mempercayakan waktu |
trade_money | Jumlah transaksi yang di setujui |
code | Kode Pengembalian |
message | Petunjuk |
channel | saluran yang diminta |
no | Identitas unik permintaan digunakan untuk membedakan konten saat dikembalikan |
Dapatkan Info Pengguna
Contoh permintaan
// request demo
{
"accesskey":"your key",
"channel":"getaccountinfo",
"event":"addChannel",
"no" : Identitas unik permintaan digunakan untuk membedakan konten saat dikembalikan,
"sign":Tanda tangan
}
// java demo
public void getaccountinfo() {
//TestapiKey:ce2a18e0-dshs-4c44-4515-9aca67dd706e
//TestsecretKey:c11a122s-dshs-shsa-4515-954a67dd706e
//Enkripsi:https://github.com/zb2017/api/blob/master/zb_netty_client_java/src/main/java/websocketx/client/EncryDigestUtil.java
//secretKeyDiperoleh dengan enkripsi sha1:86429c69799d3d6ac5da5c2c514baa874d75a4ba
String secret = EncryDigestUtil.digest("c11a122s-dshs-shsa-4515-954a67dd706e");
//Parameter diurutkan berdasarkan nilai ASCII
String params = "{"accesskey":"ce2a18e0-dshs-4c44-4515-9aca67dd706e","channel":"getaccountinfo","event":"addChannel","no":"test001"}";
//tanda dienkripsi oleh HmacMD5:c2683870eaade9be66e46747520ca95f
String sign = EncryDigestUtil.hmacSign(params, secret);
//Selanjutnya kirim ke permintaan parameter server json
String json = "{"accesskey":"ce2a18e0-dshs-4c44-4515-9aca67dd706e","channel":"getaccountinfo","event":"addChannel","no":"test001","sign":"c2683870eaade9be66e46747520ca95f"}";
ws.sendText(json);
}
// python demo
import hashlib
import zlib
import json
from time import sleep
from threading import Thread
import websocket
import urllib2, hashlib,struct,sha,time
zb_usd_url = "wss://api.zb.com/websocket"
class ZB_Sub_Spot_Api(object):
"""基于Websocket的API对象"""
def __init__(self):
"""Constructor"""
self.apiKey = 'ce2a18e0-dshs-4c44-4515-9aca67dd706e'
self.secretKey = 'c11a122s-dshs-shsa-4515-954a67dd706e'
self.ws_sub_spot = None # websocketObjek aplikasi Objek spot
#----------------------------------------------------------------------
def reconnect(self):
"""sambungkan kembali"""
# Tutup dulu koneksi sebelumnya
self.close()
# sambungkan kembali lagi
self.ws_sub_spot = websocket.WebSocketApp(self.host,
on_message=self.onMessage,
on_error=self.onError,
on_close=self.onClose,
on_open=self.onOpen)
self.thread = Thread(target=self.ws_sub_spot.run_forever)
self.thread.start()
#----------------------------------------------------------------------
def connect_Subpot(self, apiKey , secretKey , trace = False):
self.host = zb_usd_url
self.apiKey = apiKey
self.secretKey = secretKey
websocket.enableTrace(trace)
self.ws_sub_spot = websocket.WebSocketApp(self.host,
on_message=self.onMessage,
on_error=self.onError,
on_close=self.onClose,
on_open=self.onOpen)
self.thread = Thread(target=self.ws_sub_spot.run_forever)
self.thread.start()
#----------------------------------------------------------------------
def readData(self, evt):
"""Ekstrak dan dorong data yang diterima"""
# # Ekstrak dan dorong data yang diterima
# decompress = zlib.decompressobj(-zlib.MAX_WBITS)
# # Dekompresi data asli menjadi string
# inflated = decompress.decompress(evt) + decompress.flush()
# Parse strings via json
data = json.loads(evt)
return data
#----------------------------------------------------------------------
def close(self):
"""Interface tutup"""
if self.thread and self.thread.isAlive():
self.ws_sub_spot.close()
self.thread.join()
#----------------------------------------------------------------------
def onMessage(self, ws, evt):
"""Push informasi"""
print evt
#----------------------------------------------------------------------
def onError(self, ws, evt):
"""salah push"""
print 'onError'
print evt
#----------------------------------------------------------------------
def onClose(self, ws):
"""Putuskan Sambungan Interface"""
print 'onClose'
#----------------------------------------------------------------------
def onOpen(self, ws):
"""Buka interface"""
print 'onOpen'
#----------------------------------------------------------------------
def __fill(self, value, length, fillByte):
if len(value) >= length:
return value
else:
fillSize = length - len(value)
return value + chr(fillByte) * fillSize
#----------------------------------------------------------------------
def __doXOr(self, s, value):
slist = list(s)
for index in xrange(len(slist)):
slist[index] = chr(ord(slist[index]) ^ value)
return "".join(slist)
#----------------------------------------------------------------------
def __hmacSign(self, aValue, aKey):
keyb = struct.pack("%ds" % len(aKey), aKey)
value = struct.pack("%ds" % len(aValue), aValue)
k_ipad = self.__doXOr(keyb, 0x36)
k_opad = self.__doXOr(keyb, 0x5c)
k_ipad = self.__fill(k_ipad, 64, 54)
k_opad = self.__fill(k_opad, 64, 92)
m = hashlib.md5()
m.update(k_ipad)
m.update(value)
dg = m.digest()
m = hashlib.md5()
m.update(k_opad)
subStr = dg[0:16]
m.update(subStr)
dg = m.hexdigest()
return dg
#----------------------------------------------------------------------
def __digest(self, aValue):
value = struct.pack("%ds" % len(aValue), aValue)
h = sha.new()
h.update(value)
dg = h.hexdigest()
return dg
#----------------------------------------------------------------------
def generateSign(self, params):
#Parameter diurutkan berdasarkan nilai ASCII: {"accesskey":"ce2a18e0-dshs-4c44-4515-9aca67dd706e","channel":"getaccountinfo","event":"addChannel","no":"test001"}
#secretKey Setelah mengenkripsi:86429c69799d3d6ac5da5c2c514baa874d75a4ba
SHA_secret = self.__digest(self.secretKey)
#Hitung tandanya: c2683870eaade9be66e46747520ca95f
return self.__hmacSign( paramsStr, SHA_secret)
#----------------------------------------------------------------------
def getaccountinfo(self, symbol_pair, type_, price, amount):
json = "{"accesskey":"ce2a18e0-dshs-4c44-4515-9aca67dd706e","channel":"getaccountinfo","event":"addChannel","no":"test001","sign":"c2683870eaade9be66e46747520ca95f"}";
try:
self.ws_sub_spot.send(json)
except websocket.WebSocketConnectionClosedException:
pass
Contoh tanggapan
// Hasil Kembali
{
"message": "Proses berhasil",
"no": "15207605119",
"data": {
"coins": [
{
"freez": "1.35828369",
"enName": "BTC",
"unitDecimal": 8,
"cnName": "BTC",
"unitTag": "฿",
"available": "0.72771906",
"key": "btc"
},
{
"freez": "0.011",
"enName": "LTC",
"unitDecimal": 8,
"cnName": "LTC",
"unitTag": "Ł",
"available": "3.51859814",
"key": "ltc"
},
...
],
"base": {
"username": "15207605119",
"trade_password_enabled": true,
"auth_google_enabled": true,
"auth_mobile_enabled": true
}
},
"code": 1000,
"channel": "getaccountinfo",
"success": true
}
Nama parameter | Jenis | Rentang nilai |
---|---|---|
accesskey | String | accesskey |
channel | String | getaccountinfo |
event | String | penugasan langsungaddChannel |
no | String | Identitas unik permintaan digunakan untuk membedakan konten saat dikembalikan |
sign | String | Tanda tangan |
Nilai Kembali | Deskripsi |
---|---|
auth_google_enabled | Apakah akan mengaktifkan verifikasi google |
auth_mobile_enabled | Apakah akan mengaktifkan verifikasi ponsel |
trade_password_enabled | Apakah atau tidak mengaktifkan kata sandi transaksi |
username | Nama pengguna |
ename | Bahasa inggris koin |
cnName | Nama koin Cina |
unitTag | Simbol koin |
key | Bunga yang telah jatuh tempo |
code | Kode Pengembalian |
message | Petunjuk |
channel | saluran yang diminta |
no | Identitas unik permintaan digunakan untuk membedakan konten saat dikembalikan |
WSsub-akun
Buat Sub-akun
Contoh permintaan
// request demo
{
"accesskey": "ceb1569d-7c17-xxxx-b4a1-xxxxxxxxx",
"channel": "addSubUser",
"event": "addChannel",
"memo": "memo",
"password": "123456",
"subUserName": "1",
"sign":"Tanda tangan"
}
// java demo
public void addSubUser() {
//TestapiKey:ce2a18e0-dshs-4c44-4515-9aca67dd706e
//TestsecretKey:c11a122s-dshs-shsa-4515-954a67dd706e
//Enkripsi:https://github.com/zb2017/api/blob/master/zb_netty_client_java/src/main/java/websocketx/client/EncryDigestUtil.java
//secretKeyDiperoleh dengan enkripsi sha1:86429c69799d3d6ac5da5c2c514baa874d75a4ba
String secret = EncryDigestUtil.digest("c11a122s-dshs-shsa-4515-954a67dd706e");
//Parameter diurutkan berdasarkan nilai ASCII
String params = "{"accesskey":"ce2a18e0-dshs-4c44-4515-9aca67dd706e","channel":"addSubUser","event":"addChannel","memo":"memo","no":"test001","password":"123456","subUserName":"test1"}";
//tanda dienkripsi oleh HmacMD5:475fdd83600e42140d2d0336b8d57ce4
String sign = EncryDigestUtil.hmacSign(params, secret);
//Selanjutnya kirim ke permintaan parameter server json
String json = "{"accesskey":"ce2a18e0-dshs-4c44-4515-9aca67dd706e","channel":"addSubUser","event":"addChannel","memo":"memo","no":"test001","password":"123456","sign":"475fdd83600e42140d2d0336b8d57ce4","subUserName":"test1"}";
ws.sendText(json);
}
// python demo
import hashlib
import zlib
import json
from time import sleep
from threading import Thread
import websocket
import urllib2, hashlib,struct,sha,time
zb_usd_url = "wss://api.zb.com/websocket"
class ZB_Sub_Spot_Api(object):
"""基于Websocket的API对象"""
def __init__(self):
"""Constructor"""
self.apiKey = 'ce2a18e0-dshs-4c44-4515-9aca67dd706e'
self.secretKey = 'c11a122s-dshs-shsa-4515-954a67dd706e'
self.ws_sub_spot = None # websocketObjek aplikasi Objek spot
#----------------------------------------------------------------------
def reconnect(self):
"""sambungkan kembali"""
# Tutup dulu koneksi sebelumnya
self.close()
# sambungkan kembali lagi
self.ws_sub_spot = websocket.WebSocketApp(self.host,
on_message=self.onMessage,
on_error=self.onError,
on_close=self.onClose,
on_open=self.onOpen)
self.thread = Thread(target=self.ws_sub_spot.run_forever)
self.thread.start()
#----------------------------------------------------------------------
def connect_Subpot(self, apiKey , secretKey , trace = False):
self.host = zb_usd_url
self.apiKey = apiKey
self.secretKey = secretKey
websocket.enableTrace(trace)
self.ws_sub_spot = websocket.WebSocketApp(self.host,
on_message=self.onMessage,
on_error=self.onError,
on_close=self.onClose,
on_open=self.onOpen)
self.thread = Thread(target=self.ws_sub_spot.run_forever)
self.thread.start()
#----------------------------------------------------------------------
def readData(self, evt):
"""Ekstrak dan dorong data yang diterima"""
# # Ekstrak dan dorong data yang diterima
# decompress = zlib.decompressobj(-zlib.MAX_WBITS)
# # Dekompresi data asli menjadi string
# inflated = decompress.decompress(evt) + decompress.flush()
# Parse strings via json
data = json.loads(evt)
return data
#----------------------------------------------------------------------
def close(self):
"""Interface tutup"""
if self.thread and self.thread.isAlive():
self.ws_sub_spot.close()
self.thread.join()
#----------------------------------------------------------------------
def onMessage(self, ws, evt):
"""Push informasi"""
print evt
#----------------------------------------------------------------------
def onError(self, ws, evt):
"""salah push"""
print 'onError'
print evt
#----------------------------------------------------------------------
def onClose(self, ws):
"""Putuskan Sambungan Interface"""
print 'onClose'
#----------------------------------------------------------------------
def onOpen(self, ws):
"""Buka interface"""
print 'onOpen'
#----------------------------------------------------------------------
def __fill(self, value, length, fillByte):
if len(value) >= length:
return value
else:
fillSize = length - len(value)
return value + chr(fillByte) * fillSize
#----------------------------------------------------------------------
def __doXOr(self, s, value):
slist = list(s)
for index in xrange(len(slist)):
slist[index] = chr(ord(slist[index]) ^ value)
return "".join(slist)
#----------------------------------------------------------------------
def __hmacSign(self, aValue, aKey):
keyb = struct.pack("%ds" % len(aKey), aKey)
value = struct.pack("%ds" % len(aValue), aValue)
k_ipad = self.__doXOr(keyb, 0x36)
k_opad = self.__doXOr(keyb, 0x5c)
k_ipad = self.__fill(k_ipad, 64, 54)
k_opad = self.__fill(k_opad, 64, 92)
m = hashlib.md5()
m.update(k_ipad)
m.update(value)
dg = m.digest()
m = hashlib.md5()
m.update(k_opad)
subStr = dg[0:16]
m.update(subStr)
dg = m.hexdigest()
return dg
#----------------------------------------------------------------------
def __digest(self, aValue):
value = struct.pack("%ds" % len(aValue), aValue)
h = sha.new()
h.update(value)
dg = h.hexdigest()
return dg
#----------------------------------------------------------------------
def generateSign(self, params):
#Parameter diurutkan berdasarkan nilai ASCII: {"accesskey":"ce2a18e0-dshs-4c44-4515-9aca67dd706e","channel":"addSubUser","event":"addChannel","memo":"memo","no":"test001","password":"123456","subUserName":"test1"}
#secretKey Setelah mengenkripsi:86429c69799d3d6ac5da5c2c514baa874d75a4ba
SHA_secret = self.__digest(self.secretKey)
#Hitung tandanya: 475fdd83600e42140d2d0336b8d57ce4
return self.__hmacSign( paramsStr, SHA_secret)
#----------------------------------------------------------------------
def addSubUser(self, symbol_pair, type_, price, amount):
json = "{"accesskey":"ce2a18e0-dshs-4c44-4515-9aca67dd706e","channel":"addSubUser","event":"addChannel","memo":"memo","no":"test001","password":"123456","sign":"475fdd83600e42140d2d0336b8d57ce4","subUserName":"test1"}";
try:
self.ws_sub_spot.send(json)
except websocket.WebSocketConnectionClosedException:
pass
Contoh tanggapan
// Hasil Kembali
{
"success": true,
"code": 1000,
"channel": "addSubUser",
"message": "Proses berhasil",
"no": "0"
}
Nama parameter | Jenis | Rentang nilai |
---|---|---|
accesskey | String | accesskey |
channel | String | addSubUser |
event | String | penugasan langsungaddChannel |
memo | String | Remark |
password | String | Kata sandi |
subUserName | String | Nama pengguna sub akun(tidak lebih dari6angka atau huruf) |
no | String | Identitas unik permintaan digunakan untuk membedakan konten saat dikembalikan |
sign | String | Tanda tangan |
Nilai Kembali | Deskripsi |
---|---|
success | Apakah berhasil |
code | Kode Pengembalian |
message | Petunjuk |
channel | saluran yang diminta |
no | Identitas unik permintaan digunakan untuk membedakan konten saat dikembalikan |
Dapatkan daftar sub-akun
Contoh permintaan
// request demo
{
"accesskey": "ceb1569d-7c17-487a-b4a1-10bf2a8d925d",
"channel": "getSubUserList",
"event": "addChannel",
"sign":"Tanda tangan"
}
// java demo
public void getSubUserList() {
//TestapiKey:ce2a18e0-dshs-4c44-4515-9aca67dd706e
//TestsecretKey:c11a122s-dshs-shsa-4515-954a67dd706e
//Enkripsi:https://github.com/zb2017/api/blob/master/zb_netty_client_java/src/main/java/websocketx/client/EncryDigestUtil.java
//secretKeyDiperoleh dengan enkripsi sha1:86429c69799d3d6ac5da5c2c514baa874d75a4ba
String secret = EncryDigestUtil.digest("c11a122s-dshs-shsa-4515-954a67dd706e");
//Parameter diurutkan berdasarkan nilai ASCII
String params = "{"accesskey":"ce2a18e0-dshs-4c44-4515-9aca67dd706e","channel":"getSubUserList","event":"addChannel","no":"test001"}";
//tanda dienkripsi oleh HmacMD5:5fe82bf1864091af1120b184f773d1f9
String sign = EncryDigestUtil.hmacSign(params, secret);
//Selanjutnya kirim ke permintaan parameter server json
String json = "{"accesskey":"ce2a18e0-dshs-4c44-4515-9aca67dd706e","channel":"getSubUserList","event":"addChannel","no":"test001","sign":"5fe82bf1864091af1120b184f773d1f9"}";
ws.sendText(json);
}
// python demo
import hashlib
import zlib
import json
from time import sleep
from threading import Thread
import websocket
import urllib2, hashlib,struct,sha,time
zb_usd_url = "wss://api.zb.com/websocket"
class ZB_Sub_Spot_Api(object):
"""基于Websocket的API对象"""
def __init__(self):
"""Constructor"""
self.apiKey = 'ce2a18e0-dshs-4c44-4515-9aca67dd706e'
self.secretKey = 'c11a122s-dshs-shsa-4515-954a67dd706e'
self.ws_sub_spot = None # websocketObjek aplikasi Objek spot
#----------------------------------------------------------------------
def reconnect(self):
"""sambungkan kembali"""
# Tutup dulu koneksi sebelumnya
self.close()
# sambungkan kembali lagi
self.ws_sub_spot = websocket.WebSocketApp(self.host,
on_message=self.onMessage,
on_error=self.onError,
on_close=self.onClose,
on_open=self.onOpen)
self.thread = Thread(target=self.ws_sub_spot.run_forever)
self.thread.start()
#----------------------------------------------------------------------
def connect_Subpot(self, apiKey , secretKey , trace = False):
self.host = zb_usd_url
self.apiKey = apiKey
self.secretKey = secretKey
websocket.enableTrace(trace)
self.ws_sub_spot = websocket.WebSocketApp(self.host,
on_message=self.onMessage,
on_error=self.onError,
on_close=self.onClose,
on_open=self.onOpen)
self.thread = Thread(target=self.ws_sub_spot.run_forever)
self.thread.start()
#----------------------------------------------------------------------
def readData(self, evt):
"""Ekstrak dan dorong data yang diterima"""
# # Ekstrak dan dorong data yang diterima
# decompress = zlib.decompressobj(-zlib.MAX_WBITS)
# # Dekompresi data asli menjadi string
# inflated = decompress.decompress(evt) + decompress.flush()
# Parse strings via json
data = json.loads(evt)
return data
#----------------------------------------------------------------------
def close(self):
"""Interface tutup"""
if self.thread and self.thread.isAlive():
self.ws_sub_spot.close()
self.thread.join()
#----------------------------------------------------------------------
def onMessage(self, ws, evt):
"""Push informasi"""
print evt
#----------------------------------------------------------------------
def onError(self, ws, evt):
"""salah push"""
print 'onError'
print evt
#----------------------------------------------------------------------
def onClose(self, ws):
"""Putuskan Sambungan Interface"""
print 'onClose'
#----------------------------------------------------------------------
def onOpen(self, ws):
"""Buka interface"""
print 'onOpen'
#----------------------------------------------------------------------
def __fill(self, value, length, fillByte):
if len(value) >= length:
return value
else:
fillSize = length - len(value)
return value + chr(fillByte) * fillSize
#----------------------------------------------------------------------
def __doXOr(self, s, value):
slist = list(s)
for index in xrange(len(slist)):
slist[index] = chr(ord(slist[index]) ^ value)
return "".join(slist)
#----------------------------------------------------------------------
def __hmacSign(self, aValue, aKey):
keyb = struct.pack("%ds" % len(aKey), aKey)
value = struct.pack("%ds" % len(aValue), aValue)
k_ipad = self.__doXOr(keyb, 0x36)
k_opad = self.__doXOr(keyb, 0x5c)
k_ipad = self.__fill(k_ipad, 64, 54)
k_opad = self.__fill(k_opad, 64, 92)
m = hashlib.md5()
m.update(k_ipad)
m.update(value)
dg = m.digest()
m = hashlib.md5()
m.update(k_opad)
subStr = dg[0:16]
m.update(subStr)
dg = m.hexdigest()
return dg
#----------------------------------------------------------------------
def __digest(self, aValue):
value = struct.pack("%ds" % len(aValue), aValue)
h = sha.new()
h.update(value)
dg = h.hexdigest()
return dg
#----------------------------------------------------------------------
def generateSign(self, params):
#Parameter diurutkan berdasarkan nilai ASCII: {"accesskey":"ce2a18e0-dshs-4c44-4515-9aca67dd706e","channel":"getSubUserList","event":"addChannel","no":"test001"}
#secretKey Setelah mengenkripsi:86429c69799d3d6ac5da5c2c514baa874d75a4ba
SHA_secret = self.__digest(self.secretKey)
#Hitung tandanya: 5fe82bf1864091af1120b184f773d1f9
return self.__hmacSign( paramsStr, SHA_secret)
#----------------------------------------------------------------------
def getSubUserList(self, symbol_pair, type_, price, amount):
json = "{"accesskey":"ce2a18e0-dshs-4c44-4515-9aca67dd706e","channel":"getSubUserList","event":"addChannel","no":"test001","sign":"5fe82bf1864091af1120b184f773d1f9"}";
try:
self.ws_sub_spot.send(json)
except websocket.WebSocketConnectionClosedException:
pass
Contoh tanggapan
// Hasil Kembali
{
"success": true,
"code": 1000,
"channel": "getSubUserList",
"message": " [{
"isOpenApi": false,
"memo": "1",
"userName": "15914665280@1",
"userId": 110980,
"isFreez": false
}, {
"isOpenApi": false,
"memo": "2",
"userName": "15914665280@2",
"userId": 110984,
"isFreez": false
}, {
"isOpenApi": false,
"memo": "test3",
"userName": "15914665280@3",
"userId": 111014,
"isFreez": false
}]",
"no": "0"
}
Nama parameter | Jenis | Rentang nilai |
---|---|---|
accesskey | String | accesskey |
channel | String | getSubUserList |
event | String | penugasan langsungaddChannel |
no | String | Identitas unik permintaan digunakan untuk membedakan konten saat dikembalikan |
sign | String | Tanda tangan |
Nilai Kembali | Deskripsi |
---|---|
success | Apakah berhasil |
code | Kode Pengembalian |
message | Petunjuk |
channel | saluran yang diminta |
no | Identitas unik permintaan digunakan untuk membedakan konten saat dikembalikan |
isOpenApi | Apakah akan membukaAPI |
userName | Nama pengguna |
isFreez | Apa di bekukan |
memo | Remark |
Transfer internal antar sub-akun
Contoh permintaan
// request demo
{
"accesskey": "ceb1569d-7c17-487a-b4a1-10bf2a8d925d",
"amount": "1",
"channel": "doTransferFunds",
"currency": "zb",
"event": "addChannel",
"fromUserName": "xxxxxx",
"toUserName":"xxxx",
"sign":"Tanda tangan"
}
// java demo
public void doTransferFunds() {
//TestapiKey:ce2a18e0-dshs-4c44-4515-9aca67dd706e
//TestsecretKey:c11a122s-dshs-shsa-4515-954a67dd706e
//Enkripsi:https://github.com/zb2017/api/blob/master/zb_netty_client_java/src/main/java/websocketx/client/EncryDigestUtil.java
//secretKeyDiperoleh dengan enkripsi sha1:86429c69799d3d6ac5da5c2c514baa874d75a4ba
String secret = EncryDigestUtil.digest("c11a122s-dshs-shsa-4515-954a67dd706e");
//Parameter diurutkan berdasarkan nilai ASCII
String params = "{"accesskey":"ce2a18e0-dshs-4c44-4515-9aca67dd706e","amount":"1","channel":"doTransferFunds","currency":"zb","event":"addChannel","fromUserName":"xxxx","no":"test001","toUserName":"xxxx"}";
//tanda dienkripsi oleh HmacMD5:3c1ab8f0b974e022ef8a151ff620062d
String sign = EncryDigestUtil.hmacSign(params, secret);
//Selanjutnya kirim ke permintaan parameter server json
String json = "{"accesskey":"ce2a18e0-dshs-4c44-4515-9aca67dd706e","amount":"1","channel":"doTransferFunds","currency":"zb","event":"addChannel","fromUserName":"xxxx","no":"test001","sign":"3c1ab8f0b974e022ef8a151ff620062d","toUserName":"xxxx"}";
ws.sendText(json);
}
// python demo
import hashlib
import zlib
import json
from time import sleep
from threading import Thread
import websocket
import urllib2, hashlib,struct,sha,time
zb_usd_url = "wss://api.zb.com/websocket"
class ZB_Sub_Spot_Api(object):
"""基于Websocket的API对象"""
def __init__(self):
"""Constructor"""
self.apiKey = 'ce2a18e0-dshs-4c44-4515-9aca67dd706e'
self.secretKey = 'c11a122s-dshs-shsa-4515-954a67dd706e'
self.ws_sub_spot = None # websocketObjek aplikasi Objek spot
#----------------------------------------------------------------------
def reconnect(self):
"""sambungkan kembali"""
# Tutup dulu koneksi sebelumnya
self.close()
# sambungkan kembali lagi
self.ws_sub_spot = websocket.WebSocketApp(self.host,
on_message=self.onMessage,
on_error=self.onError,
on_close=self.onClose,
on_open=self.onOpen)
self.thread = Thread(target=self.ws_sub_spot.run_forever)
self.thread.start()
#----------------------------------------------------------------------
def connect_Subpot(self, apiKey , secretKey , trace = False):
self.host = zb_usd_url
self.apiKey = apiKey
self.secretKey = secretKey
websocket.enableTrace(trace)
self.ws_sub_spot = websocket.WebSocketApp(self.host,
on_message=self.onMessage,
on_error=self.onError,
on_close=self.onClose,
on_open=self.onOpen)
self.thread = Thread(target=self.ws_sub_spot.run_forever)
self.thread.start()
#----------------------------------------------------------------------
def readData(self, evt):
"""Ekstrak dan dorong data yang diterima"""
# # Ekstrak dan dorong data yang diterima
# decompress = zlib.decompressobj(-zlib.MAX_WBITS)
# # Dekompresi data asli menjadi string
# inflated = decompress.decompress(evt) + decompress.flush()
# Parse strings via json
data = json.loads(evt)
return data
#----------------------------------------------------------------------
def close(self):
"""Interface tutup"""
if self.thread and self.thread.isAlive():
self.ws_sub_spot.close()
self.thread.join()
#----------------------------------------------------------------------
def onMessage(self, ws, evt):
"""Push informasi"""
print evt
#----------------------------------------------------------------------
def onError(self, ws, evt):
"""salah push"""
print 'onError'
print evt
#----------------------------------------------------------------------
def onClose(self, ws):
"""Putuskan Sambungan Interface"""
print 'onClose'
#----------------------------------------------------------------------
def onOpen(self, ws):
"""Buka interface"""
print 'onOpen'
#----------------------------------------------------------------------
def __fill(self, value, length, fillByte):
if len(value) >= length:
return value
else:
fillSize = length - len(value)
return value + chr(fillByte) * fillSize
#----------------------------------------------------------------------
def __doXOr(self, s, value):
slist = list(s)
for index in xrange(len(slist)):
slist[index] = chr(ord(slist[index]) ^ value)
return "".join(slist)
#----------------------------------------------------------------------
def __hmacSign(self, aValue, aKey):
keyb = struct.pack("%ds" % len(aKey), aKey)
value = struct.pack("%ds" % len(aValue), aValue)
k_ipad = self.__doXOr(keyb, 0x36)
k_opad = self.__doXOr(keyb, 0x5c)
k_ipad = self.__fill(k_ipad, 64, 54)
k_opad = self.__fill(k_opad, 64, 92)
m = hashlib.md5()
m.update(k_ipad)
m.update(value)
dg = m.digest()
m = hashlib.md5()
m.update(k_opad)
subStr = dg[0:16]
m.update(subStr)
dg = m.hexdigest()
return dg
#----------------------------------------------------------------------
def __digest(self, aValue):
value = struct.pack("%ds" % len(aValue), aValue)
h = sha.new()
h.update(value)
dg = h.hexdigest()
return dg
#----------------------------------------------------------------------
def generateSign(self, params):
#Parameter diurutkan berdasarkan nilai ASCII: {"accesskey":"ce2a18e0-dshs-4c44-4515-9aca67dd706e","amount":"1","channel":"doTransferFunds","currency":"zb","event":"addChannel","fromUserName":"xxxx","no":"test001","toUserName":"xxxx"}
#secretKey Setelah mengenkripsi:86429c69799d3d6ac5da5c2c514baa874d75a4ba
SHA_secret = self.__digest(self.secretKey)
#Hitung tandanya: 3c1ab8f0b974e022ef8a151ff620062d
return self.__hmacSign( paramsStr, SHA_secret)
#----------------------------------------------------------------------
def doTransferFunds(self, symbol_pair, type_, price, amount):
json = "{"accesskey":"ce2a18e0-dshs-4c44-4515-9aca67dd706e","amount":"1","channel":"doTransferFunds","currency":"zb","event":"addChannel","fromUserName":"xxxx","no":"test001","sign":"3c1ab8f0b974e022ef8a151ff620062d","toUserName":"xxxx"}";
try:
self.ws_sub_spot.send(json)
except websocket.WebSocketConnectionClosedException:
pass
Contoh tanggapan
// Hasil Kembali
{
"success": true,
"code": 1000,
"channel": "doTransferFunds",
"message": "Proses berhasil",
"no": "0"
}
Nama parameter | Jenis | Rentang nilai |
---|---|---|
accesskey | String | accesskey |
channel | String | doTransferFunds |
event | String | penugasan langsungaddChannel |
amount | String | Jumlah |
currency | String | Bunga yang telah jatuh tempo |
fromUserName | String | Nama Pengguna Pengalih |
toUserName | String | Nama Pengguna Penerima |
no | String | Identitas unik permintaan digunakan untuk membedakan konten saat dikembalikan |
sign | String | Tanda tangan |
Nilai Kembali | Deskripsi |
---|---|
success | Apakah berhasil |
code | Kode Pengembalian |
message | Petunjuk |
channel | saluran yang diminta |
no | Identitas unik permintaan digunakan untuk membedakan konten saat dikembalikan |
WSMargin
Dapatkan Info Margin Pengguna
Contoh permintaan
// request demo
{
"accesskey":"your key",
"channel":"getuserLeverAsset",
"event":"addChannel",
"no" : Identitas unik permintaan digunakan untuk membedakan konten saat dikembalikan,
"sign":Tanda tangan
}
// java demo
public void getuserLeverAsset() {
//TestapiKey:ce2a18e0-dshs-4c44-4515-9aca67dd706e
//TestsecretKey:c11a122s-dshs-shsa-4515-954a67dd706e
//Enkripsi:https://github.com/zb2017/api/blob/master/zb_netty_client_java/src/main/java/websocketx/client/EncryDigestUtil.java
//secretKeyDiperoleh dengan enkripsi sha1:86429c69799d3d6ac5da5c2c514baa874d75a4ba
String secret = EncryDigestUtil.digest("c11a122s-dshs-shsa-4515-954a67dd706e");
//Parameter diurutkan berdasarkan nilai ASCII
String params = "{"accesskey":"ce2a18e0-dshs-4c44-4515-9aca67dd706e","channel":"getuserLeverAsset","event":"addChannel","no":"test001"}";
//tanda dienkripsi oleh HmacMD5:f060147b2f8a276291c7da4bf1f1d420
String sign = EncryDigestUtil.hmacSign(params, secret);
//Selanjutnya kirim ke permintaan parameter server json
String json = "{"accesskey":"ce2a18e0-dshs-4c44-4515-9aca67dd706e","channel":"getuserLeverAsset","event":"addChannel","no":"test001","sign":"f060147b2f8a276291c7da4bf1f1d420"}";
ws.sendText(json);
}
// python demo
import hashlib
import zlib
import json
from time import sleep
from threading import Thread
import websocket
import urllib2, hashlib,struct,sha,time
zb_usd_url = "wss://api.zb.com/websocket"
class ZB_Sub_Spot_Api(object):
"""基于Websocket的API对象"""
def __init__(self):
"""Constructor"""
self.apiKey = 'ce2a18e0-dshs-4c44-4515-9aca67dd706e'
self.secretKey = 'c11a122s-dshs-shsa-4515-954a67dd706e'
self.ws_sub_spot = None # websocketObjek aplikasi Objek spot
#----------------------------------------------------------------------
def reconnect(self):
"""sambungkan kembali"""
# Tutup dulu koneksi sebelumnya
self.close()
# sambungkan kembali lagi
self.ws_sub_spot = websocket.WebSocketApp(self.host,
on_message=self.onMessage,
on_error=self.onError,
on_close=self.onClose,
on_open=self.onOpen)
self.thread = Thread(target=self.ws_sub_spot.run_forever)
self.thread.start()
#----------------------------------------------------------------------
def connect_Subpot(self, apiKey , secretKey , trace = False):
self.host = zb_usd_url
self.apiKey = apiKey
self.secretKey = secretKey
websocket.enableTrace(trace)
self.ws_sub_spot = websocket.WebSocketApp(self.host,
on_message=self.onMessage,
on_error=self.onError,
on_close=self.onClose,
on_open=self.onOpen)
self.thread = Thread(target=self.ws_sub_spot.run_forever)
self.thread.start()
#----------------------------------------------------------------------
def readData(self, evt):
"""Ekstrak dan dorong data yang diterima"""
# # Ekstrak dan dorong data yang diterima
# decompress = zlib.decompressobj(-zlib.MAX_WBITS)
# # Dekompresi data asli menjadi string
# inflated = decompress.decompress(evt) + decompress.flush()
# Parse strings via json
data = json.loads(evt)
return data
#----------------------------------------------------------------------
def close(self):
"""Interface tutup"""
if self.thread and self.thread.isAlive():
self.ws_sub_spot.close()
self.thread.join()
#----------------------------------------------------------------------
def onMessage(self, ws, evt):
"""Push informasi"""
print evt
#----------------------------------------------------------------------
def onError(self, ws, evt):
"""salah push"""
print 'onError'
print evt
#----------------------------------------------------------------------
def onClose(self, ws):
"""Putuskan Sambungan Interface"""
print 'onClose'
#----------------------------------------------------------------------
def onOpen(self, ws):
"""Buka interface"""
print 'onOpen'
#----------------------------------------------------------------------
def __fill(self, value, length, fillByte):
if len(value) >= length:
return value
else:
fillSize = length - len(value)
return value + chr(fillByte) * fillSize
#----------------------------------------------------------------------
def __doXOr(self, s, value):
slist = list(s)
for index in xrange(len(slist)):
slist[index] = chr(ord(slist[index]) ^ value)
return "".join(slist)
#----------------------------------------------------------------------
def __hmacSign(self, aValue, aKey):
keyb = struct.pack("%ds" % len(aKey), aKey)
value = struct.pack("%ds" % len(aValue), aValue)
k_ipad = self.__doXOr(keyb, 0x36)
k_opad = self.__doXOr(keyb, 0x5c)
k_ipad = self.__fill(k_ipad, 64, 54)
k_opad = self.__fill(k_opad, 64, 92)
m = hashlib.md5()
m.update(k_ipad)
m.update(value)
dg = m.digest()
m = hashlib.md5()
m.update(k_opad)
subStr = dg[0:16]
m.update(subStr)
dg = m.hexdigest()
return dg
#----------------------------------------------------------------------
def __digest(self, aValue):
value = struct.pack("%ds" % len(aValue), aValue)
h = sha.new()
h.update(value)
dg = h.hexdigest()
return dg
#----------------------------------------------------------------------
def generateSign(self, params):
#Parameter diurutkan berdasarkan nilai ASCII: {"accesskey":"ce2a18e0-dshs-4c44-4515-9aca67dd706e","channel":"getuserLeverAsset","event":"addChannel","no":"test001"}
#secretKey Setelah mengenkripsi:86429c69799d3d6ac5da5c2c514baa874d75a4ba
SHA_secret = self.__digest(self.secretKey)
#Hitung tandanya: f060147b2f8a276291c7da4bf1f1d420
return self.__hmacSign( paramsStr, SHA_secret)
#----------------------------------------------------------------------
def getuserLeverAsset(self, symbol_pair, type_, price, amount):
json = "{"accesskey":"ce2a18e0-dshs-4c44-4515-9aca67dd706e","channel":"getuserLeverAsset","event":"addChannel","no":"test001","sign":"f060147b2f8a276291c7da4bf1f1d420"}";
try:
self.ws_sub_spot.send(json)
except websocket.WebSocketConnectionClosedException:
pass
Contoh tanggapan
// Hasil Kembali
{
"message": "Proses berhasil",
"no": "0",
"data": "
{
"levers": [
{
"fLoanIn": "0",
"repayLevel": "0",
"cUnitTag": "BTC",
"unwindPrice": "0",
"fUnitDecimal": "8",
"repayLock": "false",
"cLoanIn": "0",
"cEnName": "BTC",
"cAvailable": "0",
"fAvailable": "0",
"cLoanOut": "0",
"cCanLoanIn": "0",
"fLoanOut": "0",
"level": "0",
"fFreeze": "0",
"fEnName": "QC",
"cFreeze": "0",
"fCanLoanIn": "0",
"cUnitDecimal": "8",
"cOverdraft": "0",
"key": "btcqc",
"repayLeverShow": "-"
},
...
]
}
",
"code": 1000,
"channel": "getuserLeverAsset",
"success": true
}
Nama parameter | Jenis | Rentang nilai |
---|---|---|
accesskey | String | accesskey |
channel | String | getuserLeverAsset |
event | String | penugasan langsungaddChannel |
no | String | Identitas unik permintaan digunakan untuk membedakan konten saat dikembalikan |
sign | String | Tanda tangan |
Nilai Kembali | Deskripsi |
---|---|
code | Kode Pengembalian |
des | Petunjuk |
isSuc | Apakah berhasil |
fLoanIn | Jumlah pinjaman mata uang Prancis |
repayLevel | Tingkat likuidasi |
unwindPrice | Harga likuidasi |
fUnitDecimal | Titik desimal |
repayLock | Apakah pembayaran dikunci |
cLoanIn | Jumlah pinjaman |
cAvailable | Koin yang tersedia |
fAvailable | Mata uang fiat tersedia |
cLoanOut | Jumlah koin yang di pinjamkan keluar |
cCanLoanIn | Tersedia untuk dipinjam |
fLoanOut | Mata uang fiat dapat dipinjamkan |
level | Tingkat margin |
fFreeze | Fiat di bekukan |
cFreeze | Pembekuan koin |
fCanLoanIn | Mata uang fiat dapat dipinjam |
cUnitDecimal | Titik desimal koin |
cOverdraft | 币欠息 |
repayLeverShow | Resiko likuidasi |
Dapatkan Catatan Margin
Contoh permintaan
// request demo
{
"accesskey":"your accesskey",
"channel":"getLeverBills",
"coin":"qc",
"event":"addChannel",
"pageIndex":1,
"pageSize":10,
"sign":Tanda tangan
}
// java demo
public void getLeverBills() {
//TestapiKey:ce2a18e0-dshs-4c44-4515-9aca67dd706e
//TestsecretKey:c11a122s-dshs-shsa-4515-954a67dd706e
//Enkripsi:https://github.com/zb2017/api/blob/master/zb_netty_client_java/src/main/java/websocketx/client/EncryDigestUtil.java
//secretKeyDiperoleh dengan enkripsi sha1:86429c69799d3d6ac5da5c2c514baa874d75a4ba
String secret = EncryDigestUtil.digest("c11a122s-dshs-shsa-4515-954a67dd706e");
//Parameter diurutkan berdasarkan nilai ASCII
String params = "{"accesskey":"ce2a18e0-dshs-4c44-4515-9aca67dd706e","channel":"getLeverBills","coin":"qc","event":"addChannel","no":"test001","pageIndex":"1","pageSize":"10"}";
//tanda dienkripsi oleh HmacMD5:e92666397d9b03a47edfafd8cb4e759a
String sign = EncryDigestUtil.hmacSign(params, secret);
//Selanjutnya kirim ke permintaan parameter server json
String json = "{"accesskey":"ce2a18e0-dshs-4c44-4515-9aca67dd706e","channel":"getLeverBills","coin":"qc","event":"addChannel","no":"test001","pageIndex":"1","pageSize":"10","sign":"e92666397d9b03a47edfafd8cb4e759a"}";
ws.sendText(json);
}
// python demo
import hashlib
import zlib
import json
from time import sleep
from threading import Thread
import websocket
import urllib2, hashlib,struct,sha,time
zb_usd_url = "wss://api.zb.com/websocket"
class ZB_Sub_Spot_Api(object):
"""基于Websocket的API对象"""
def __init__(self):
"""Constructor"""
self.apiKey = 'ce2a18e0-dshs-4c44-4515-9aca67dd706e'
self.secretKey = 'c11a122s-dshs-shsa-4515-954a67dd706e'
self.ws_sub_spot = None # websocketObjek aplikasi Objek spot
#----------------------------------------------------------------------
def reconnect(self):
"""sambungkan kembali"""
# Tutup dulu koneksi sebelumnya
self.close()
# sambungkan kembali lagi
self.ws_sub_spot = websocket.WebSocketApp(self.host,
on_message=self.onMessage,
on_error=self.onError,
on_close=self.onClose,
on_open=self.onOpen)
self.thread = Thread(target=self.ws_sub_spot.run_forever)
self.thread.start()
#----------------------------------------------------------------------
def connect_Subpot(self, apiKey , secretKey , trace = False):
self.host = zb_usd_url
self.apiKey = apiKey
self.secretKey = secretKey
websocket.enableTrace(trace)
self.ws_sub_spot = websocket.WebSocketApp(self.host,
on_message=self.onMessage,
on_error=self.onError,
on_close=self.onClose,
on_open=self.onOpen)
self.thread = Thread(target=self.ws_sub_spot.run_forever)
self.thread.start()
#----------------------------------------------------------------------
def readData(self, evt):
"""Ekstrak dan dorong data yang diterima"""
# # Ekstrak dan dorong data yang diterima
# decompress = zlib.decompressobj(-zlib.MAX_WBITS)
# # Dekompresi data asli menjadi string
# inflated = decompress.decompress(evt) + decompress.flush()
# Parse strings via json
data = json.loads(evt)
return data
#----------------------------------------------------------------------
def close(self):
"""Interface tutup"""
if self.thread and self.thread.isAlive():
self.ws_sub_spot.close()
self.thread.join()
#----------------------------------------------------------------------
def onMessage(self, ws, evt):
"""Push informasi"""
print evt
#----------------------------------------------------------------------
def onError(self, ws, evt):
"""salah push"""
print 'onError'
print evt
#----------------------------------------------------------------------
def onClose(self, ws):
"""Putuskan Sambungan Interface"""
print 'onClose'
#----------------------------------------------------------------------
def onOpen(self, ws):
"""Buka interface"""
print 'onOpen'
#----------------------------------------------------------------------
def __fill(self, value, length, fillByte):
if len(value) >= length:
return value
else:
fillSize = length - len(value)
return value + chr(fillByte) * fillSize
#----------------------------------------------------------------------
def __doXOr(self, s, value):
slist = list(s)
for index in xrange(len(slist)):
slist[index] = chr(ord(slist[index]) ^ value)
return "".join(slist)
#----------------------------------------------------------------------
def __hmacSign(self, aValue, aKey):
keyb = struct.pack("%ds" % len(aKey), aKey)
value = struct.pack("%ds" % len(aValue), aValue)
k_ipad = self.__doXOr(keyb, 0x36)
k_opad = self.__doXOr(keyb, 0x5c)
k_ipad = self.__fill(k_ipad, 64, 54)
k_opad = self.__fill(k_opad, 64, 92)
m = hashlib.md5()
m.update(k_ipad)
m.update(value)
dg = m.digest()
m = hashlib.md5()
m.update(k_opad)
subStr = dg[0:16]
m.update(subStr)
dg = m.hexdigest()
return dg
#----------------------------------------------------------------------
def __digest(self, aValue):
value = struct.pack("%ds" % len(aValue), aValue)
h = sha.new()
h.update(value)
dg = h.hexdigest()
return dg
#----------------------------------------------------------------------
def generateSign(self, params):
#Parameter diurutkan berdasarkan nilai ASCII: {"accesskey":"ce2a18e0-dshs-4c44-4515-9aca67dd706e","channel":"getLeverBills","coin":"qc","event":"addChannel","no":"test001","pageIndex":"1","pageSize":"10"}
#secretKey Setelah mengenkripsi:86429c69799d3d6ac5da5c2c514baa874d75a4ba
SHA_secret = self.__digest(self.secretKey)
#Hitung tandanya: e92666397d9b03a47edfafd8cb4e759a
return self.__hmacSign( paramsStr, SHA_secret)
#----------------------------------------------------------------------
def getLeverBills(self, symbol_pair, type_, price, amount):
json = "{"accesskey":"ce2a18e0-dshs-4c44-4515-9aca67dd706e","channel":"getLeverBills","coin":"qc","event":"addChannel","no":"test001","pageIndex":"1","pageSize":"10","sign":"e92666397d9b03a47edfafd8cb4e759a"}";
try:
self.ws_sub_spot.send(json)
except websocket.WebSocketConnectionClosedException:
pass
Contoh tanggapan
// Hasil Kembali
{
"success":true,
"code":1000,
"data":[
{
"changeCoin":10,
"showFiat":"…",
"showCoin":"-10.000=2200.000QC",
"type":12,
"date":1523001559000,
"database":"default",
"dataName":"baseBean",
"fundsType":15,
"billTypeValue":"MeminjamkanQC",
"id":898,
"downTableDate":1520697600000,
"marketName":"btsqc",
"avgPrice":0,
"userId":110803,
"coinBalance":2200,
"entrustId":0
},
...
],
"channel":"getLeverBills",
"message":"Proses berhasil",
"no":"0"
}
Nama parameter | Jenis | Rentang nilai |
---|---|---|
accesskey | String | accesskey |
channel | String | getLeverBills |
event | String | penugasan langsungaddChannel |
coin | String | Bunga yang telah jatuh tempo |
pageIndex | int | nomor halaman saat ini(Seperti: 1, halaman 1) |
pageSize | int | Kuantitas per halaman |
no | String | Identitas unik permintaan digunakan untuk membedakan konten saat dikembalikan |
sign | String | Tanda tangan |
Nilai Kembali | Deskripsi |
---|---|
success | Apakah berhasil |
code | Kode Pengembalian |
message | Petunjuk |
channel | saluran yang diminta |
no | Identitas unik permintaan digunakan untuk membedakan konten saat dikembalikan |
id | tagihanID |
userId | UserID |
date | Waktu pembuatan tagihan |
type | Jenis tagihan |
billTypeValue | Jenis tagihan sesuai dengan bahasa Cina |
changeCoin | perubahan iniCOINJumlah |
coinBalance | berubahCOINSaldo |
changeFiat | Jumlah mata uang fiat berubah kali ini |
fiatBalance | Saldo mata uang fiat |
fundsType | COINJenis |
marketName | Nama pasar |
showCoin | menunjukkanCOINvariasi |
showFiat | Tampilkan perubahan mata uang fiat |
Transfer dana ke Akun Margin
Contoh permintaan
// request demo
{
"accesskey":"your accesskey",
"amount":100,
"channel":"transferInLever",
"coin":"qc",
"event":"addChannel",
"marketName":"btsqc",
"sign":Tanda tangan
}
// java demo
public void transferInLever() {
//TestapiKey:ce2a18e0-dshs-4c44-4515-9aca67dd706e
//TestsecretKey:c11a122s-dshs-shsa-4515-954a67dd706e
//Enkripsi:https://github.com/zb2017/api/blob/master/zb_netty_client_java/src/main/java/websocketx/client/EncryDigestUtil.java
//secretKeyDiperoleh dengan enkripsi sha1:86429c69799d3d6ac5da5c2c514baa874d75a4ba
String secret = EncryDigestUtil.digest("c11a122s-dshs-shsa-4515-954a67dd706e");
//Parameter diurutkan berdasarkan nilai ASCII
String params = "{"accesskey":"ce2a18e0-dshs-4c44-4515-9aca67dd706e","amount":"100","channel":"transferInLever","coin":"qc","event":"addChannel","marketName":"btsqc","no":"test001"}";
//tanda dienkripsi oleh HmacMD5:c9ef0030df66980464ccc47675900832
String sign = EncryDigestUtil.hmacSign(params, secret);
//Selanjutnya kirim ke permintaan parameter server json
String json = "{"accesskey":"ce2a18e0-dshs-4c44-4515-9aca67dd706e","amount":"100","channel":"transferInLever","coin":"qc","event":"addChannel","marketName":"btsqc","no":"test001","sign":"c9ef0030df66980464ccc47675900832"}";
ws.sendText(json);
}
// python demo
import hashlib
import zlib
import json
from time import sleep
from threading import Thread
import websocket
import urllib2, hashlib,struct,sha,time
zb_usd_url = "wss://api.zb.com/websocket"
class ZB_Sub_Spot_Api(object):
"""基于Websocket的API对象"""
def __init__(self):
"""Constructor"""
self.apiKey = 'ce2a18e0-dshs-4c44-4515-9aca67dd706e'
self.secretKey = 'c11a122s-dshs-shsa-4515-954a67dd706e'
self.ws_sub_spot = None # websocketObjek aplikasi Objek spot
#----------------------------------------------------------------------
def reconnect(self):
"""sambungkan kembali"""
# Tutup dulu koneksi sebelumnya
self.close()
# sambungkan kembali lagi
self.ws_sub_spot = websocket.WebSocketApp(self.host,
on_message=self.onMessage,
on_error=self.onError,
on_close=self.onClose,
on_open=self.onOpen)
self.thread = Thread(target=self.ws_sub_spot.run_forever)
self.thread.start()
#----------------------------------------------------------------------
def connect_Subpot(self, apiKey , secretKey , trace = False):
self.host = zb_usd_url
self.apiKey = apiKey
self.secretKey = secretKey
websocket.enableTrace(trace)
self.ws_sub_spot = websocket.WebSocketApp(self.host,
on_message=self.onMessage,
on_error=self.onError,
on_close=self.onClose,
on_open=self.onOpen)
self.thread = Thread(target=self.ws_sub_spot.run_forever)
self.thread.start()
#----------------------------------------------------------------------
def readData(self, evt):
"""Ekstrak dan dorong data yang diterima"""
# # Ekstrak dan dorong data yang diterima
# decompress = zlib.decompressobj(-zlib.MAX_WBITS)
# # Dekompresi data asli menjadi string
# inflated = decompress.decompress(evt) + decompress.flush()
# Parse strings via json
data = json.loads(evt)
return data
#----------------------------------------------------------------------
def close(self):
"""Interface tutup"""
if self.thread and self.thread.isAlive():
self.ws_sub_spot.close()
self.thread.join()
#----------------------------------------------------------------------
def onMessage(self, ws, evt):
"""Push informasi"""
print evt
#----------------------------------------------------------------------
def onError(self, ws, evt):
"""salah push"""
print 'onError'
print evt
#----------------------------------------------------------------------
def onClose(self, ws):
"""Putuskan Sambungan Interface"""
print 'onClose'
#----------------------------------------------------------------------
def onOpen(self, ws):
"""Buka interface"""
print 'onOpen'
#----------------------------------------------------------------------
def __fill(self, value, length, fillByte):
if len(value) >= length:
return value
else:
fillSize = length - len(value)
return value + chr(fillByte) * fillSize
#----------------------------------------------------------------------
def __doXOr(self, s, value):
slist = list(s)
for index in xrange(len(slist)):
slist[index] = chr(ord(slist[index]) ^ value)
return "".join(slist)
#----------------------------------------------------------------------
def __hmacSign(self, aValue, aKey):
keyb = struct.pack("%ds" % len(aKey), aKey)
value = struct.pack("%ds" % len(aValue), aValue)
k_ipad = self.__doXOr(keyb, 0x36)
k_opad = self.__doXOr(keyb, 0x5c)
k_ipad = self.__fill(k_ipad, 64, 54)
k_opad = self.__fill(k_opad, 64, 92)
m = hashlib.md5()
m.update(k_ipad)
m.update(value)
dg = m.digest()
m = hashlib.md5()
m.update(k_opad)
subStr = dg[0:16]
m.update(subStr)
dg = m.hexdigest()
return dg
#----------------------------------------------------------------------
def __digest(self, aValue):
value = struct.pack("%ds" % len(aValue), aValue)
h = sha.new()
h.update(value)
dg = h.hexdigest()
return dg
#----------------------------------------------------------------------
def generateSign(self, params):
#Parameter diurutkan berdasarkan nilai ASCII: {"accesskey":"ce2a18e0-dshs-4c44-4515-9aca67dd706e","amount":"100","channel":"transferInLever","coin":"qc","event":"addChannel","marketName":"btsqc","no":"test001"}
#secretKey Setelah mengenkripsi:86429c69799d3d6ac5da5c2c514baa874d75a4ba
SHA_secret = self.__digest(self.secretKey)
#Hitung tandanya: c9ef0030df66980464ccc47675900832
return self.__hmacSign( paramsStr, SHA_secret)
#----------------------------------------------------------------------
def transferInLever(self, symbol_pair, type_, price, amount):
json = "{"accesskey":"ce2a18e0-dshs-4c44-4515-9aca67dd706e","amount":"100","channel":"transferInLever","coin":"qc","event":"addChannel","marketName":"btsqc","no":"test001","sign":"c9ef0030df66980464ccc47675900832"}";
try:
self.ws_sub_spot.send(json)
except websocket.WebSocketConnectionClosedException:
pass
Contoh tanggapan
// Hasil Kembali
{
"success":true,
"code":1000,
"channel":"transferInLever",
"message":"Proses berhasil",
"no":"0"
}
Nama parameter | Jenis | Rentang nilai |
---|---|---|
accesskey | String | accesskey |
channel | String | transferInLever |
event | String | penugasan langsungaddChannel |
coin | String | Bunga yang telah jatuh tempo |
marketName | String | Pasar |
amount | Double | Jumlah Transfer |
no | String | Identitas unik permintaan digunakan untuk membedakan konten saat dikembalikan |
sign | String | Tanda tangan |
Nilai Kembali | Deskripsi |
---|---|
success | Apakah berhasil |
code | Kode Pengembalian |
message | Petunjuk |
channel | saluran yang diminta |
no | Identitas unik permintaan digunakan untuk membedakan konten saat dikembalikan |
Transfer dana keluar dari Akun Margin
Contoh permintaan
// request demo
{
"accesskey":"your accesskey",
"amount":100,
"channel":"transferOutLever",
"coin":"qc",
"event":"addChannel",
"marketName":"btsqc",
"sign":Tanda tangan
}
// java demo
public void transferOutLever() {
//TestapiKey:ce2a18e0-dshs-4c44-4515-9aca67dd706e
//TestsecretKey:c11a122s-dshs-shsa-4515-954a67dd706e
//Enkripsi:https://github.com/zb2017/api/blob/master/zb_netty_client_java/src/main/java/websocketx/client/EncryDigestUtil.java
//secretKeyDiperoleh dengan enkripsi sha1:86429c69799d3d6ac5da5c2c514baa874d75a4ba
String secret = EncryDigestUtil.digest("c11a122s-dshs-shsa-4515-954a67dd706e");
//Parameter diurutkan berdasarkan nilai ASCII
String params = "{"accesskey":"ce2a18e0-dshs-4c44-4515-9aca67dd706e","amount":"100","channel":"transferOutLever","coin":"qc","event":"addChannel","marketName":"btsqc","no":"test001"}";
//tanda dienkripsi oleh HmacMD5:da3b000acb6fb245a1ba2f661f2fd398
String sign = EncryDigestUtil.hmacSign(params, secret);
//Selanjutnya kirim ke permintaan parameter server json
String json = "{"accesskey":"ce2a18e0-dshs-4c44-4515-9aca67dd706e","amount":"100","channel":"transferOutLever","coin":"qc","event":"addChannel","marketName":"btsqc","no":"test001","sign":"da3b000acb6fb245a1ba2f661f2fd398"}";
ws.sendText(json);
}
// python demo
import hashlib
import zlib
import json
from time import sleep
from threading import Thread
import websocket
import urllib2, hashlib,struct,sha,time
zb_usd_url = "wss://api.zb.com/websocket"
class ZB_Sub_Spot_Api(object):
"""基于Websocket的API对象"""
def __init__(self):
"""Constructor"""
self.apiKey = 'ce2a18e0-dshs-4c44-4515-9aca67dd706e'
self.secretKey = 'c11a122s-dshs-shsa-4515-954a67dd706e'
self.ws_sub_spot = None # websocketObjek aplikasi Objek spot
#----------------------------------------------------------------------
def reconnect(self):
"""sambungkan kembali"""
# Tutup dulu koneksi sebelumnya
self.close()
# sambungkan kembali lagi
self.ws_sub_spot = websocket.WebSocketApp(self.host,
on_message=self.onMessage,
on_error=self.onError,
on_close=self.onClose,
on_open=self.onOpen)
self.thread = Thread(target=self.ws_sub_spot.run_forever)
self.thread.start()
#----------------------------------------------------------------------
def connect_Subpot(self, apiKey , secretKey , trace = False):
self.host = zb_usd_url
self.apiKey = apiKey
self.secretKey = secretKey
websocket.enableTrace(trace)
self.ws_sub_spot = websocket.WebSocketApp(self.host,
on_message=self.onMessage,
on_error=self.onError,
on_close=self.onClose,
on_open=self.onOpen)
self.thread = Thread(target=self.ws_sub_spot.run_forever)
self.thread.start()
#----------------------------------------------------------------------
def readData(self, evt):
"""Ekstrak dan dorong data yang diterima"""
# # Ekstrak dan dorong data yang diterima
# decompress = zlib.decompressobj(-zlib.MAX_WBITS)
# # Dekompresi data asli menjadi string
# inflated = decompress.decompress(evt) + decompress.flush()
# Parse strings via json
data = json.loads(evt)
return data
#----------------------------------------------------------------------
def close(self):
"""Interface tutup"""
if self.thread and self.thread.isAlive():
self.ws_sub_spot.close()
self.thread.join()
#----------------------------------------------------------------------
def onMessage(self, ws, evt):
"""Push informasi"""
print evt
#----------------------------------------------------------------------
def onError(self, ws, evt):
"""salah push"""
print 'onError'
print evt
#----------------------------------------------------------------------
def onClose(self, ws):
"""Putuskan Sambungan Interface"""
print 'onClose'
#----------------------------------------------------------------------
def onOpen(self, ws):
"""Buka interface"""
print 'onOpen'
#----------------------------------------------------------------------
def __fill(self, value, length, fillByte):
if len(value) >= length:
return value
else:
fillSize = length - len(value)
return value + chr(fillByte) * fillSize
#----------------------------------------------------------------------
def __doXOr(self, s, value):
slist = list(s)
for index in xrange(len(slist)):
slist[index] = chr(ord(slist[index]) ^ value)
return "".join(slist)
#----------------------------------------------------------------------
def __hmacSign(self, aValue, aKey):
keyb = struct.pack("%ds" % len(aKey), aKey)
value = struct.pack("%ds" % len(aValue), aValue)
k_ipad = self.__doXOr(keyb, 0x36)
k_opad = self.__doXOr(keyb, 0x5c)
k_ipad = self.__fill(k_ipad, 64, 54)
k_opad = self.__fill(k_opad, 64, 92)
m = hashlib.md5()
m.update(k_ipad)
m.update(value)
dg = m.digest()
m = hashlib.md5()
m.update(k_opad)
subStr = dg[0:16]
m.update(subStr)
dg = m.hexdigest()
return dg
#----------------------------------------------------------------------
def __digest(self, aValue):
value = struct.pack("%ds" % len(aValue), aValue)
h = sha.new()
h.update(value)
dg = h.hexdigest()
return dg
#----------------------------------------------------------------------
def generateSign(self, params):
#Parameter diurutkan berdasarkan nilai ASCII: {"accesskey":"ce2a18e0-dshs-4c44-4515-9aca67dd706e","amount":"100","channel":"transferOutLever","coin":"qc","event":"addChannel","marketName":"btsqc","no":"test001"}
#secretKey Setelah mengenkripsi:86429c69799d3d6ac5da5c2c514baa874d75a4ba
SHA_secret = self.__digest(self.secretKey)
#Hitung tandanya: da3b000acb6fb245a1ba2f661f2fd398
return self.__hmacSign( paramsStr, SHA_secret)
#----------------------------------------------------------------------
def transferOutLever(self, symbol_pair, type_, price, amount):
json = "{"accesskey":"ce2a18e0-dshs-4c44-4515-9aca67dd706e","amount":"100","channel":"transferOutLever","coin":"qc","event":"addChannel","marketName":"btsqc","no":"test001","sign":"da3b000acb6fb245a1ba2f661f2fd398"}";
try:
self.ws_sub_spot.send(json)
except websocket.WebSocketConnectionClosedException:
pass
Contoh tanggapan
// Hasil Kembali
{
"success":true,
"code":1000,
"channel":"transferOutLever",
"message":"Proses berhasil",
"no":"0"
}
Nama parameter | Jenis | Rentang nilai |
---|---|---|
accesskey | String | accesskey |
channel | String | transferOutLever |
event | String | penugasan langsungaddChannel |
coin | String | Bunga yang telah jatuh tempo |
marketName | String | Pasar |
amount | Double | Jumlah transfer keluar |
no | String | Identitas unik permintaan digunakan untuk membedakan konten saat dikembalikan |
sign | String | Tanda tangan |
Nilai Kembali | Deskripsi |
---|---|
success | Apakah berhasil |
code | Kode Pengembalian |
message | Petunjuk |
channel | saluran yang diminta |
no | Identitas unik permintaan digunakan untuk membedakan konten saat dikembalikan |
Pasca manajemen keuangan
Contoh permintaan
// request demo
{
"accesskey":"your accesskey",
"amount":100,
"channel":"loan",
"coin":"qc",
"event":"addChannel",
"interestRateOfDay":0.15
"isLoop":1
"repaymentDay":20
"safePwd":Kata Sandi Transaksi
"sign":Tanda tangan
}
// java demo
public void loan() {
//TestapiKey:ce2a18e0-dshs-4c44-4515-9aca67dd706e
//TestsecretKey:c11a122s-dshs-shsa-4515-954a67dd706e
//Enkripsi:https://github.com/zb2017/api/blob/master/zb_netty_client_java/src/main/java/websocketx/client/EncryDigestUtil.java
//secretKeyDiperoleh dengan enkripsi sha1:86429c69799d3d6ac5da5c2c514baa874d75a4ba
String secret = EncryDigestUtil.digest("c11a122s-dshs-shsa-4515-954a67dd706e");
//Parameter diurutkan berdasarkan nilai ASCII
String params = "{"accesskey":"ce2a18e0-dshs-4c44-4515-9aca67dd706e","amount":"100","channel":"loan","coin":"qc","event":"addChannel","interestRateOfDay":"0.15","isLoop":"1","no":"test001","repaymentDay":"20","safePwd":"123456"}";
//tanda dienkripsi oleh HmacMD5:4ca79117822a780511307e55eb176d6b
String sign = EncryDigestUtil.hmacSign(params, secret);
//Selanjutnya kirim ke permintaan parameter server json
String json = "{"accesskey":"ce2a18e0-dshs-4c44-4515-9aca67dd706e","amount":"100","channel":"loan","coin":"qc","event":"addChannel","interestRateOfDay":"0.15","isLoop":"1","no":"test001","repaymentDay":"20","safePwd":"123456","sign":"4ca79117822a780511307e55eb176d6b"}";
ws.sendText(json);
}
// python demo
import hashlib
import zlib
import json
from time import sleep
from threading import Thread
import websocket
import urllib2, hashlib,struct,sha,time
zb_usd_url = "wss://api.zb.com/websocket"
class ZB_Sub_Spot_Api(object):
"""基于Websocket的API对象"""
def __init__(self):
"""Constructor"""
self.apiKey = 'ce2a18e0-dshs-4c44-4515-9aca67dd706e'
self.secretKey = 'c11a122s-dshs-shsa-4515-954a67dd706e'
self.ws_sub_spot = None # websocketObjek aplikasi Objek spot
#----------------------------------------------------------------------
def reconnect(self):
"""sambungkan kembali"""
# Tutup dulu koneksi sebelumnya
self.close()
# sambungkan kembali lagi
self.ws_sub_spot = websocket.WebSocketApp(self.host,
on_message=self.onMessage,
on_error=self.onError,
on_close=self.onClose,
on_open=self.onOpen)
self.thread = Thread(target=self.ws_sub_spot.run_forever)
self.thread.start()
#----------------------------------------------------------------------
def connect_Subpot(self, apiKey , secretKey , trace = False):
self.host = zb_usd_url
self.apiKey = apiKey
self.secretKey = secretKey
websocket.enableTrace(trace)
self.ws_sub_spot = websocket.WebSocketApp(self.host,
on_message=self.onMessage,
on_error=self.onError,
on_close=self.onClose,
on_open=self.onOpen)
self.thread = Thread(target=self.ws_sub_spot.run_forever)
self.thread.start()
#----------------------------------------------------------------------
def readData(self, evt):
"""Ekstrak dan dorong data yang diterima"""
# # Ekstrak dan dorong data yang diterima
# decompress = zlib.decompressobj(-zlib.MAX_WBITS)
# # Dekompresi data asli menjadi string
# inflated = decompress.decompress(evt) + decompress.flush()
# Parse strings via json
data = json.loads(evt)
return data
#----------------------------------------------------------------------
def close(self):
"""Interface tutup"""
if self.thread and self.thread.isAlive():
self.ws_sub_spot.close()
self.thread.join()
#----------------------------------------------------------------------
def onMessage(self, ws, evt):
"""Push informasi"""
print evt
#----------------------------------------------------------------------
def onError(self, ws, evt):
"""salah push"""
print 'onError'
print evt
#----------------------------------------------------------------------
def onClose(self, ws):
"""Putuskan Sambungan Interface"""
print 'onClose'
#----------------------------------------------------------------------
def onOpen(self, ws):
"""Buka interface"""
print 'onOpen'
#----------------------------------------------------------------------
def __fill(self, value, length, fillByte):
if len(value) >= length:
return value
else:
fillSize = length - len(value)
return value + chr(fillByte) * fillSize
#----------------------------------------------------------------------
def __doXOr(self, s, value):
slist = list(s)
for index in xrange(len(slist)):
slist[index] = chr(ord(slist[index]) ^ value)
return "".join(slist)
#----------------------------------------------------------------------
def __hmacSign(self, aValue, aKey):
keyb = struct.pack("%ds" % len(aKey), aKey)
value = struct.pack("%ds" % len(aValue), aValue)
k_ipad = self.__doXOr(keyb, 0x36)
k_opad = self.__doXOr(keyb, 0x5c)
k_ipad = self.__fill(k_ipad, 64, 54)
k_opad = self.__fill(k_opad, 64, 92)
m = hashlib.md5()
m.update(k_ipad)
m.update(value)
dg = m.digest()
m = hashlib.md5()
m.update(k_opad)
subStr = dg[0:16]
m.update(subStr)
dg = m.hexdigest()
return dg
#----------------------------------------------------------------------
def __digest(self, aValue):
value = struct.pack("%ds" % len(aValue), aValue)
h = sha.new()
h.update(value)
dg = h.hexdigest()
return dg
#----------------------------------------------------------------------
def generateSign(self, params):
#Parameter diurutkan berdasarkan nilai ASCII: {"accesskey":"ce2a18e0-dshs-4c44-4515-9aca67dd706e","amount":"100","channel":"loan","coin":"qc","event":"addChannel","interestRateOfDay":"0.15","isLoop":"1","no":"test001","repaymentDay":"20","safePwd":"123456"}
#secretKey Setelah mengenkripsi:86429c69799d3d6ac5da5c2c514baa874d75a4ba
SHA_secret = self.__digest(self.secretKey)
#Hitung tandanya: 4ca79117822a780511307e55eb176d6b
return self.__hmacSign( paramsStr, SHA_secret)
#----------------------------------------------------------------------
def loan(self, symbol_pair, type_, price, amount):
json = "{"accesskey":"ce2a18e0-dshs-4c44-4515-9aca67dd706e","amount":"100","channel":"loan","coin":"qc","event":"addChannel","interestRateOfDay":"0.15","isLoop":"1","no":"test001","repaymentDay":"20","safePwd":"123456","sign":"4ca79117822a780511307e55eb176d6b"}";
try:
self.ws_sub_spot.send(json)
except websocket.WebSocketConnectionClosedException:
pass
Contoh tanggapan
// Hasil Kembali
{
"success":true,
"code":1000,
"channel":"loan",
"message":"Proses berhasil",
"no":"0",
"data":{
"loanId":121
}
}
Nama parameter | Jenis | Rentang nilai |
---|---|---|
accesskey | String | accesskey |
channel | String | loan |
event | String | penugasan langsungaddChannel |
coin | String | Bunga yang telah jatuh tempo |
amount | Double | Jumlah investasi |
interestRateOfDay | Double | Suku bunga harian [0.05-0.2]% |
repaymentDay | int | Hari pinjaman [10/20/30] |
isLoop | int | Apakah akan secara otomatis meminjamkan [1/0] |
no | String | Identitas unik permintaan digunakan untuk membedakan konten saat dikembalikan |
sign | String | Tanda tangan |
Nilai Kembali | Deskripsi |
---|---|
success | Apakah berhasil |
code | Kode Pengembalian |
message | Petunjuk |
channel | saluran yang diminta |
no | Identitas unik permintaan digunakan untuk membedakan konten saat dikembalikan |
data | |
loanId | InvestasiID |
Cancel investasi
Contoh permintaan
// request demo
{
"accesskey":"your accesskey",
"channel":"cancelLoan",
"event":"addChannel",
"loanId":121,
"sign":Tanda tangan
}
// java demo
public void cancelLoan() {
//TestapiKey:ce2a18e0-dshs-4c44-4515-9aca67dd706e
//TestsecretKey:c11a122s-dshs-shsa-4515-954a67dd706e
//Enkripsi:https://github.com/zb2017/api/blob/master/zb_netty_client_java/src/main/java/websocketx/client/EncryDigestUtil.java
//secretKeyDiperoleh dengan enkripsi sha1:86429c69799d3d6ac5da5c2c514baa874d75a4ba
String secret = EncryDigestUtil.digest("c11a122s-dshs-shsa-4515-954a67dd706e");
//Parameter diurutkan berdasarkan nilai ASCII
String params = "{"accesskey":"ce2a18e0-dshs-4c44-4515-9aca67dd706e","channel":"cancelLoan","event":"addChannel","loanId":"121","no":"test001"}";
//tanda dienkripsi oleh HmacMD5:c19662ffe48ff586d5f5fa3ba8fcf2e1
String sign = EncryDigestUtil.hmacSign(params, secret);
//Selanjutnya kirim ke permintaan parameter server json
String json = "{"accesskey":"ce2a18e0-dshs-4c44-4515-9aca67dd706e","channel":"cancelLoan","event":"addChannel","loanId":"121","no":"test001","sign":"c19662ffe48ff586d5f5fa3ba8fcf2e1"}";
ws.sendText(json);
}
// python demo
import hashlib
import zlib
import json
from time import sleep
from threading import Thread
import websocket
import urllib2, hashlib,struct,sha,time
zb_usd_url = "wss://api.zb.com/websocket"
class ZB_Sub_Spot_Api(object):
"""基于Websocket的API对象"""
def __init__(self):
"""Constructor"""
self.apiKey = 'ce2a18e0-dshs-4c44-4515-9aca67dd706e'
self.secretKey = 'c11a122s-dshs-shsa-4515-954a67dd706e'
self.ws_sub_spot = None # websocketObjek aplikasi Objek spot
#----------------------------------------------------------------------
def reconnect(self):
"""sambungkan kembali"""
# Tutup dulu koneksi sebelumnya
self.close()
# sambungkan kembali lagi
self.ws_sub_spot = websocket.WebSocketApp(self.host,
on_message=self.onMessage,
on_error=self.onError,
on_close=self.onClose,
on_open=self.onOpen)
self.thread = Thread(target=self.ws_sub_spot.run_forever)
self.thread.start()
#----------------------------------------------------------------------
def connect_Subpot(self, apiKey , secretKey , trace = False):
self.host = zb_usd_url
self.apiKey = apiKey
self.secretKey = secretKey
websocket.enableTrace(trace)
self.ws_sub_spot = websocket.WebSocketApp(self.host,
on_message=self.onMessage,
on_error=self.onError,
on_close=self.onClose,
on_open=self.onOpen)
self.thread = Thread(target=self.ws_sub_spot.run_forever)
self.thread.start()
#----------------------------------------------------------------------
def readData(self, evt):
"""Ekstrak dan dorong data yang diterima"""
# # Ekstrak dan dorong data yang diterima
# decompress = zlib.decompressobj(-zlib.MAX_WBITS)
# # Dekompresi data asli menjadi string
# inflated = decompress.decompress(evt) + decompress.flush()
# Parse strings via json
data = json.loads(evt)
return data
#----------------------------------------------------------------------
def close(self):
"""Interface tutup"""
if self.thread and self.thread.isAlive():
self.ws_sub_spot.close()
self.thread.join()
#----------------------------------------------------------------------
def onMessage(self, ws, evt):
"""Push informasi"""
print evt
#----------------------------------------------------------------------
def onError(self, ws, evt):
"""salah push"""
print 'onError'
print evt
#----------------------------------------------------------------------
def onClose(self, ws):
"""Putuskan Sambungan Interface"""
print 'onClose'
#----------------------------------------------------------------------
def onOpen(self, ws):
"""Buka interface"""
print 'onOpen'
#----------------------------------------------------------------------
def __fill(self, value, length, fillByte):
if len(value) >= length:
return value
else:
fillSize = length - len(value)
return value + chr(fillByte) * fillSize
#----------------------------------------------------------------------
def __doXOr(self, s, value):
slist = list(s)
for index in xrange(len(slist)):
slist[index] = chr(ord(slist[index]) ^ value)
return "".join(slist)
#----------------------------------------------------------------------
def __hmacSign(self, aValue, aKey):
keyb = struct.pack("%ds" % len(aKey), aKey)
value = struct.pack("%ds" % len(aValue), aValue)
k_ipad = self.__doXOr(keyb, 0x36)
k_opad = self.__doXOr(keyb, 0x5c)
k_ipad = self.__fill(k_ipad, 64, 54)
k_opad = self.__fill(k_opad, 64, 92)
m = hashlib.md5()
m.update(k_ipad)
m.update(value)
dg = m.digest()
m = hashlib.md5()
m.update(k_opad)
subStr = dg[0:16]
m.update(subStr)
dg = m.hexdigest()
return dg
#----------------------------------------------------------------------
def __digest(self, aValue):
value = struct.pack("%ds" % len(aValue), aValue)
h = sha.new()
h.update(value)
dg = h.hexdigest()
return dg
#----------------------------------------------------------------------
def generateSign(self, params):
#Parameter diurutkan berdasarkan nilai ASCII: {"accesskey":"ce2a18e0-dshs-4c44-4515-9aca67dd706e","channel":"cancelLoan","event":"addChannel","loanId":"121","no":"test001"}
#secretKey Setelah mengenkripsi:86429c69799d3d6ac5da5c2c514baa874d75a4ba
SHA_secret = self.__digest(self.secretKey)
#Hitung tandanya: c19662ffe48ff586d5f5fa3ba8fcf2e1
return self.__hmacSign( paramsStr, SHA_secret)
#----------------------------------------------------------------------
def cancelLoan(self, symbol_pair, type_, price, amount):
json = "{"accesskey":"ce2a18e0-dshs-4c44-4515-9aca67dd706e","channel":"cancelLoan","event":"addChannel","loanId":"121","no":"test001","sign":"c19662ffe48ff586d5f5fa3ba8fcf2e1"}";
try:
self.ws_sub_spot.send(json)
except websocket.WebSocketConnectionClosedException:
pass
Contoh tanggapan
// Hasil Kembali
{
"success":true,
"code":1000,
"channel":"cancelLoan",
"message":"Proses berhasil",
"no":"0"
}
Nama parameter | Jenis | Rentang nilai |
---|---|---|
accesskey | String | accesskey |
channel | String | cancelLoan |
event | String | penugasan langsungaddChannel |
loanId | Long | InvestasiID |
no | String | Identitas unik permintaan digunakan untuk membedakan konten saat dikembalikan |
sign | String | Tanda tangan |
Nilai Kembali | Deskripsi |
---|---|
success | Apakah berhasil |
code | Kode Pengembalian |
message | Petunjuk |
channel | saluran yang diminta |
no | Identitas unik permintaan digunakan untuk membedakan konten saat dikembalikan |
Dapatkan daftar pinjaman yang tersedia
Contoh permintaan
// request demo
{
"accesskey":"your accesskey",
"channel":"getLoans",
"coin":"qc",
"event":"addChannel",
"pageIndex":1,
"pageSize":10,
"sign":Tanda tangan
}
// java demo
public void getLoans() {
//TestapiKey:ce2a18e0-dshs-4c44-4515-9aca67dd706e
//TestsecretKey:c11a122s-dshs-shsa-4515-954a67dd706e
//Enkripsi:https://github.com/zb2017/api/blob/master/zb_netty_client_java/src/main/java/websocketx/client/EncryDigestUtil.java
//secretKeyDiperoleh dengan enkripsi sha1:86429c69799d3d6ac5da5c2c514baa874d75a4ba
String secret = EncryDigestUtil.digest("c11a122s-dshs-shsa-4515-954a67dd706e");
//Parameter diurutkan berdasarkan nilai ASCII
String params = "{"accesskey":"ce2a18e0-dshs-4c44-4515-9aca67dd706e","channel":"getLoans","coin":"qc","event":"addChannel","no":"test001","pageIndex":"1","pageSize":"10"}";
//tanda dienkripsi oleh HmacMD5:357e94bcc5b2544f71364c6e05914f2e
String sign = EncryDigestUtil.hmacSign(params, secret);
//Selanjutnya kirim ke permintaan parameter server json
String json = "{"accesskey":"ce2a18e0-dshs-4c44-4515-9aca67dd706e","channel":"getLoans","coin":"qc","event":"addChannel","no":"test001","pageIndex":"1","pageSize":"10","sign":"357e94bcc5b2544f71364c6e05914f2e"}";
ws.sendText(json);
}
// python demo
import hashlib
import zlib
import json
from time import sleep
from threading import Thread
import websocket
import urllib2, hashlib,struct,sha,time
zb_usd_url = "wss://api.zb.com/websocket"
class ZB_Sub_Spot_Api(object):
"""基于Websocket的API对象"""
def __init__(self):
"""Constructor"""
self.apiKey = 'ce2a18e0-dshs-4c44-4515-9aca67dd706e'
self.secretKey = 'c11a122s-dshs-shsa-4515-954a67dd706e'
self.ws_sub_spot = None # websocketObjek aplikasi Objek spot
#----------------------------------------------------------------------
def reconnect(self):
"""sambungkan kembali"""
# Tutup dulu koneksi sebelumnya
self.close()
# sambungkan kembali lagi
self.ws_sub_spot = websocket.WebSocketApp(self.host,
on_message=self.onMessage,
on_error=self.onError,
on_close=self.onClose,
on_open=self.onOpen)
self.thread = Thread(target=self.ws_sub_spot.run_forever)
self.thread.start()
#----------------------------------------------------------------------
def connect_Subpot(self, apiKey , secretKey , trace = False):
self.host = zb_usd_url
self.apiKey = apiKey
self.secretKey = secretKey
websocket.enableTrace(trace)
self.ws_sub_spot = websocket.WebSocketApp(self.host,
on_message=self.onMessage,
on_error=self.onError,
on_close=self.onClose,
on_open=self.onOpen)
self.thread = Thread(target=self.ws_sub_spot.run_forever)
self.thread.start()
#----------------------------------------------------------------------
def readData(self, evt):
"""Ekstrak dan dorong data yang diterima"""
# # Ekstrak dan dorong data yang diterima
# decompress = zlib.decompressobj(-zlib.MAX_WBITS)
# # Dekompresi data asli menjadi string
# inflated = decompress.decompress(evt) + decompress.flush()
# Parse strings via json
data = json.loads(evt)
return data
#----------------------------------------------------------------------
def close(self):
"""Interface tutup"""
if self.thread and self.thread.isAlive():
self.ws_sub_spot.close()
self.thread.join()
#----------------------------------------------------------------------
def onMessage(self, ws, evt):
"""Push informasi"""
print evt
#----------------------------------------------------------------------
def onError(self, ws, evt):
"""salah push"""
print 'onError'
print evt
#----------------------------------------------------------------------
def onClose(self, ws):
"""Putuskan Sambungan Interface"""
print 'onClose'
#----------------------------------------------------------------------
def onOpen(self, ws):
"""Buka interface"""
print 'onOpen'
#----------------------------------------------------------------------
def __fill(self, value, length, fillByte):
if len(value) >= length:
return value
else:
fillSize = length - len(value)
return value + chr(fillByte) * fillSize
#----------------------------------------------------------------------
def __doXOr(self, s, value):
slist = list(s)
for index in xrange(len(slist)):
slist[index] = chr(ord(slist[index]) ^ value)
return "".join(slist)
#----------------------------------------------------------------------
def __hmacSign(self, aValue, aKey):
keyb = struct.pack("%ds" % len(aKey), aKey)
value = struct.pack("%ds" % len(aValue), aValue)
k_ipad = self.__doXOr(keyb, 0x36)
k_opad = self.__doXOr(keyb, 0x5c)
k_ipad = self.__fill(k_ipad, 64, 54)
k_opad = self.__fill(k_opad, 64, 92)
m = hashlib.md5()
m.update(k_ipad)
m.update(value)
dg = m.digest()
m = hashlib.md5()
m.update(k_opad)
subStr = dg[0:16]
m.update(subStr)
dg = m.hexdigest()
return dg
#----------------------------------------------------------------------
def __digest(self, aValue):
value = struct.pack("%ds" % len(aValue), aValue)
h = sha.new()
h.update(value)
dg = h.hexdigest()
return dg
#----------------------------------------------------------------------
def generateSign(self, params):
#Parameter diurutkan berdasarkan nilai ASCII: {"accesskey":"ce2a18e0-dshs-4c44-4515-9aca67dd706e","channel":"getLoans","coin":"qc","event":"addChannel","no":"test001","pageIndex":"1","pageSize":"10"}
#secretKey Setelah mengenkripsi:86429c69799d3d6ac5da5c2c514baa874d75a4ba
SHA_secret = self.__digest(self.secretKey)
#Hitung tandanya: 357e94bcc5b2544f71364c6e05914f2e
return self.__hmacSign( paramsStr, SHA_secret)
#----------------------------------------------------------------------
def getLoans(self, symbol_pair, type_, price, amount):
json = "{"accesskey":"ce2a18e0-dshs-4c44-4515-9aca67dd706e","channel":"getLoans","coin":"qc","event":"addChannel","no":"test001","pageIndex":"1","pageSize":"10","sign":"357e94bcc5b2544f71364c6e05914f2e"}";
try:
self.ws_sub_spot.send(json)
except websocket.WebSocketConnectionClosedException:
pass
Contoh tanggapan
// Hasil Kembali
{
"success":true,
"code":1000,
"data":[
{
"amount":"1400",
"balance":"1300",
"coinName":"qc",
"repaymentDay":30,
"lowestAmount":0.1,
"interestRateOfDay":"0.0011"
},
{
"amount":"2551.58399997",
"balance":"901.58399997",
"coinName":"qc",
"repaymentDay":20,
"lowestAmount":0.1,
"interestRateOfDay":"0.0012"
},
...
],
"channel":"getLoans",
"message":"Proses berhasil",
"no":"0"
}
Nama parameter | Jenis | Rentang nilai |
---|---|---|
accesskey | String | accesskey |
channel | String | getLoans |
event | String | penugasan langsungaddChannel |
coin | String | Bunga yang telah jatuh tempo |
pageIndex | int | nomor halaman saat ini(Seperti: 1, halaman 1) |
pageSize | int | Kuantitas per halaman |
no | String | Identitas unik permintaan digunakan untuk membedakan konten saat dikembalikan |
sign | String | Tanda tangan |
Nilai Kembali | Deskripsi |
---|---|
success | Apakah berhasil |
code | Kode Pengembalian |
message | Petunjuk |
channel | saluran yang diminta |
no | Identitas unik permintaan digunakan untuk membedakan konten saat dikembalikan |
amount | Jumlah |
balance | Jumlah pinjaman yang tersedia |
coinName | Bunga yang telah jatuh tempo |
repaymentDay | jangka waktu pinjaman |
interestRateOfDay | Suku bunga harian |
Dapatkan riwayat pinjaman
Contoh permintaan
// request demo
{
"accesskey":"your accesskey",
"channel":"getLoanRecords",
"loanId":58,
"marketName":"btsqc",
"pageIndex":1,
"pageSize":10,
"sign":Tanda tangan,
"status":""
}
// java demo
public void getLoanRecords() {
//TestapiKey:ce2a18e0-dshs-4c44-4515-9aca67dd706e
//TestsecretKey:c11a122s-dshs-shsa-4515-954a67dd706e
//Enkripsi:https://github.com/zb2017/api/blob/master/zb_netty_client_java/src/main/java/websocketx/client/EncryDigestUtil.java
//secretKeyDiperoleh dengan enkripsi sha1:86429c69799d3d6ac5da5c2c514baa874d75a4ba
String secret = EncryDigestUtil.digest("c11a122s-dshs-shsa-4515-954a67dd706e");
//Parameter diurutkan berdasarkan nilai ASCII
String params = "{"accesskey":"ce2a18e0-dshs-4c44-4515-9aca67dd706e","channel":"getLoanRecords","event":"addChannel","loanId":"58","marketName":"btsqc","no":"test001","pageIndex":"1","pageSize":"10"}";
//tanda dienkripsi oleh HmacMD5:a728271842900000f82a046d06f5ceee
String sign = EncryDigestUtil.hmacSign(params, secret);
//Selanjutnya kirim ke permintaan parameter server json
String json = "{"accesskey":"ce2a18e0-dshs-4c44-4515-9aca67dd706e","channel":"getLoanRecords","event":"addChannel","loanId":"58","marketName":"btsqc","no":"test001","pageIndex":"1","pageSize":"10","sign":"a728271842900000f82a046d06f5ceee"}";
ws.sendText(json);
}
// python demo
import hashlib
import zlib
import json
from time import sleep
from threading import Thread
import websocket
import urllib2, hashlib,struct,sha,time
zb_usd_url = "wss://api.zb.com/websocket"
class ZB_Sub_Spot_Api(object):
"""基于Websocket的API对象"""
def __init__(self):
"""Constructor"""
self.apiKey = 'ce2a18e0-dshs-4c44-4515-9aca67dd706e'
self.secretKey = 'c11a122s-dshs-shsa-4515-954a67dd706e'
self.ws_sub_spot = None # websocketObjek aplikasi Objek spot
#----------------------------------------------------------------------
def reconnect(self):
"""sambungkan kembali"""
# Tutup dulu koneksi sebelumnya
self.close()
# sambungkan kembali lagi
self.ws_sub_spot = websocket.WebSocketApp(self.host,
on_message=self.onMessage,
on_error=self.onError,
on_close=self.onClose,
on_open=self.onOpen)
self.thread = Thread(target=self.ws_sub_spot.run_forever)
self.thread.start()
#----------------------------------------------------------------------
def connect_Subpot(self, apiKey , secretKey , trace = False):
self.host = zb_usd_url
self.apiKey = apiKey
self.secretKey = secretKey
websocket.enableTrace(trace)
self.ws_sub_spot = websocket.WebSocketApp(self.host,
on_message=self.onMessage,
on_error=self.onError,
on_close=self.onClose,
on_open=self.onOpen)
self.thread = Thread(target=self.ws_sub_spot.run_forever)
self.thread.start()
#----------------------------------------------------------------------
def readData(self, evt):
"""Ekstrak dan dorong data yang diterima"""
# # Ekstrak dan dorong data yang diterima
# decompress = zlib.decompressobj(-zlib.MAX_WBITS)
# # Dekompresi data asli menjadi string
# inflated = decompress.decompress(evt) + decompress.flush()
# Parse strings via json
data = json.loads(evt)
return data
#----------------------------------------------------------------------
def close(self):
"""Interface tutup"""
if self.thread and self.thread.isAlive():
self.ws_sub_spot.close()
self.thread.join()
#----------------------------------------------------------------------
def onMessage(self, ws, evt):
"""Push informasi"""
print evt
#----------------------------------------------------------------------
def onError(self, ws, evt):
"""salah push"""
print 'onError'
print evt
#----------------------------------------------------------------------
def onClose(self, ws):
"""Putuskan Sambungan Interface"""
print 'onClose'
#----------------------------------------------------------------------
def onOpen(self, ws):
"""Buka interface"""
print 'onOpen'
#----------------------------------------------------------------------
def __fill(self, value, length, fillByte):
if len(value) >= length:
return value
else:
fillSize = length - len(value)
return value + chr(fillByte) * fillSize
#----------------------------------------------------------------------
def __doXOr(self, s, value):
slist = list(s)
for index in xrange(len(slist)):
slist[index] = chr(ord(slist[index]) ^ value)
return "".join(slist)
#----------------------------------------------------------------------
def __hmacSign(self, aValue, aKey):
keyb = struct.pack("%ds" % len(aKey), aKey)
value = struct.pack("%ds" % len(aValue), aValue)
k_ipad = self.__doXOr(keyb, 0x36)
k_opad = self.__doXOr(keyb, 0x5c)
k_ipad = self.__fill(k_ipad, 64, 54)
k_opad = self.__fill(k_opad, 64, 92)
m = hashlib.md5()
m.update(k_ipad)
m.update(value)
dg = m.digest()
m = hashlib.md5()
m.update(k_opad)
subStr = dg[0:16]
m.update(subStr)
dg = m.hexdigest()
return dg
#----------------------------------------------------------------------
def __digest(self, aValue):
value = struct.pack("%ds" % len(aValue), aValue)
h = sha.new()
h.update(value)
dg = h.hexdigest()
return dg
#----------------------------------------------------------------------
def generateSign(self, params):
#Parameter diurutkan berdasarkan nilai ASCII: {"accesskey":"ce2a18e0-dshs-4c44-4515-9aca67dd706e","channel":"getLoanRecords","event":"addChannel","loanId":"58","marketName":"btsqc","no":"test001","pageIndex":"1","pageSize":"10"}
#secretKey Setelah mengenkripsi:86429c69799d3d6ac5da5c2c514baa874d75a4ba
SHA_secret = self.__digest(self.secretKey)
#Hitung tandanya: a728271842900000f82a046d06f5ceee
return self.__hmacSign( paramsStr, SHA_secret)
#----------------------------------------------------------------------
def getLoanRecords(self, symbol_pair, type_, price, amount):
json = "{"accesskey":"ce2a18e0-dshs-4c44-4515-9aca67dd706e","channel":"getLoanRecords","event":"addChannel","loanId":"58","marketName":"btsqc","no":"test001","pageIndex":"1","pageSize":"10","sign":"a728271842900000f82a046d06f5ceee"}";
try:
self.ws_sub_spot.send(json)
except websocket.WebSocketConnectionClosedException:
pass
Contoh tanggapan
// Hasil Kembali
{
"success":true,
"code":1000,
"data":[
{
"createTime":1521789778000,
"statusShow":"pembayaran kembali",
"freezId":"0",
"tstatus":0,
"withoutLxAmount":"0",
"investMark":false,
"withoutLxDays":0,
"hasRepay":"0",
"amount":"600",
"id":59,
"fwfScale":"0.2",
"rate":"0.0015",
"marketName":"btsqc",
"hasLx":"0",
"isIn":false,
"balanceAmount":"0",
"fundType":15,
"outUserId":110652,
"inUserId":110652,
"repayDate":1524381778000,
"zheLx":"0",
"outUserFees":"",
"dikouLx":"0",
"sourceType":8,
"coinName":"QC",
"reward":"0",
"status":1,
"arrearsLx":"0.9",
"statusColor":"orange",
"balanceWithoutLxDays":0,
"riskManage":1,
"rateAddVal":"0",
"outUserName":"13800138000",
"inUserName":"13800138000",
"inUserLock":false,
"rateForm":1,
"loanId":58,
"nextRepayDate":1521876178000
}
],
"channel":"getLoanRecords",
"message":"Proses berhasil",
"no":"0"
}
Nama parameter | Jenis | Rentang nilai |
---|---|---|
accesskey | String | accesskey |
channel | String | getLoanRecords |
event | String | penugasan langsungaddChannel |
loanId | Long | Investasiid(Jumlah Pinjaman Jangan transfer jika meminjam) |
marketName | String | Pasar |
status | int | Status(1pembayaran kembali 2Dilunasi 3 Perlu Dilikuidasi 4 Pembayaran likuidasi 5Pembayaran otomatis sedang berlangsung 6pembayaran otomatis) |
pageIndex | int | nomor halaman saat ini(Seperti: 1, halaman 1) |
pageSize | int | Kuantitas per halaman |
no | String | Identitas unik permintaan digunakan untuk membedakan konten saat dikembalikan |
sign | String | Tanda tangan |
Nilai Kembali | Deskripsi |
---|---|
success | Apakah berhasil |
code | Kode Pengembalian |
message | Petunjuk |
channel | saluran yang diminta |
no | Identitas unik permintaan digunakan untuk membedakan konten saat dikembalikan |
id | Catatan PeminjamanID |
loanId | InvestasiID |
inUserId | PeminjamID |
inUserName | Nama Pengguna Peminjam |
outUserId | 借出者ID |
outUserName | Pemberi pinjaman |
fundType | Jenis koin |
amount | 借入金额 |
status | Status 1pembayaran kembali 2Dilunasi 3Perlu Dilikuidasi 4 Pembayaran likuidasi 5pembayaran otomatis |
createTime | waktu sukses pinjaman |
reward | Jumlah Hadiah |
balanceAmount | Jumlah yang tersedia |
rate | Rate bunga |
hasRepay | Jumlah Pokok yang Dibayarkan |
hasLx | Bunga yang dibayarkan |
dikouLx | Bunga telah di potong |
zheLx | Harga yang dikonversi |
arrearsLx | Bunga yang telah jatuh tempo |
nextRepayDate | waktu pembayaran berikutnya |
riskManage | pengendalian risiko |
inUserLock | Apakah peminjam terkunci |
withoutLxAmount | Jumlah bebas bunga |
withoutLxDays | Hari tanpa bunga |
balanceWithoutLxDays | Sisa hari bebas bunga |
rateForm | Jenis bunga |
rateAddVal | Tingkatkan Jangkauan |
repayDate | Waktu Pembayaran |
marketName | Pasar |
fwfScale | tarif biaya layanan |
investMark | Perbaharui Otomatis |
sourceType | jenis sumber: 8”Web”,5”handphoneAPP”,6”InterfaceAPI” |
meminjamkan
Contoh permintaan
// request demo
{
"accesskey":"your accesskey",
"amount":100,
"channel":"borrow",
"coin":"qc",
"event":"addChannel",
"interestRateOfDay":0.15
"isLoop":1
"repaymentDay":20
"safePwd":Kata Sandi Transaksi
"sign":Tanda tangan
}
// java demo
public void borrow() {
//TestapiKey:ce2a18e0-dshs-4c44-4515-9aca67dd706e
//TestsecretKey:c11a122s-dshs-shsa-4515-954a67dd706e
//Enkripsi:https://github.com/zb2017/api/blob/master/zb_netty_client_java/src/main/java/websocketx/client/EncryDigestUtil.java
//secretKeyDiperoleh dengan enkripsi sha1:86429c69799d3d6ac5da5c2c514baa874d75a4ba
String secret = EncryDigestUtil.digest("c11a122s-dshs-shsa-4515-954a67dd706e");
//Parameter diurutkan berdasarkan nilai ASCII
String params = "{"accesskey":"ce2a18e0-dshs-4c44-4515-9aca67dd706e","amount":"100","channel":"borrow","coin":"qc","event":"addChannel","interestRateOfDay":"0.15","isLoop":"1","no":"test001","repaymentDay":"20","safePwd":"123456"}";
//tanda dienkripsi oleh HmacMD5:378348551685d6d5ddbdf02a4df71f43
String sign = EncryDigestUtil.hmacSign(params, secret);
//Selanjutnya kirim ke permintaan parameter server json
String json = "{"accesskey":"ce2a18e0-dshs-4c44-4515-9aca67dd706e","amount":"100","channel":"borrow","coin":"qc","event":"addChannel","interestRateOfDay":"0.15","isLoop":"1","no":"test001","repaymentDay":"20","safePwd":"123456","sign":"378348551685d6d5ddbdf02a4df71f43"}";
ws.sendText(json);
}
// python demo
import hashlib
import zlib
import json
from time import sleep
from threading import Thread
import websocket
import urllib2, hashlib,struct,sha,time
zb_usd_url = "wss://api.zb.com/websocket"
class ZB_Sub_Spot_Api(object):
"""基于Websocket的API对象"""
def __init__(self):
"""Constructor"""
self.apiKey = 'ce2a18e0-dshs-4c44-4515-9aca67dd706e'
self.secretKey = 'c11a122s-dshs-shsa-4515-954a67dd706e'
self.ws_sub_spot = None # websocketObjek aplikasi Objek spot
#----------------------------------------------------------------------
def reconnect(self):
"""sambungkan kembali"""
# Tutup dulu koneksi sebelumnya
self.close()
# sambungkan kembali lagi
self.ws_sub_spot = websocket.WebSocketApp(self.host,
on_message=self.onMessage,
on_error=self.onError,
on_close=self.onClose,
on_open=self.onOpen)
self.thread = Thread(target=self.ws_sub_spot.run_forever)
self.thread.start()
#----------------------------------------------------------------------
def connect_Subpot(self, apiKey , secretKey , trace = False):
self.host = zb_usd_url
self.apiKey = apiKey
self.secretKey = secretKey
websocket.enableTrace(trace)
self.ws_sub_spot = websocket.WebSocketApp(self.host,
on_message=self.onMessage,
on_error=self.onError,
on_close=self.onClose,
on_open=self.onOpen)
self.thread = Thread(target=self.ws_sub_spot.run_forever)
self.thread.start()
#----------------------------------------------------------------------
def readData(self, evt):
"""Ekstrak dan dorong data yang diterima"""
# # Ekstrak dan dorong data yang diterima
# decompress = zlib.decompressobj(-zlib.MAX_WBITS)
# # Dekompresi data asli menjadi string
# inflated = decompress.decompress(evt) + decompress.flush()
# Parse strings via json
data = json.loads(evt)
return data
#----------------------------------------------------------------------
def close(self):
"""Interface tutup"""
if self.thread and self.thread.isAlive():
self.ws_sub_spot.close()
self.thread.join()
#----------------------------------------------------------------------
def onMessage(self, ws, evt):
"""Push informasi"""
print evt
#----------------------------------------------------------------------
def onError(self, ws, evt):
"""salah push"""
print 'onError'
print evt
#----------------------------------------------------------------------
def onClose(self, ws):
"""Putuskan Sambungan Interface"""
print 'onClose'
#----------------------------------------------------------------------
def onOpen(self, ws):
"""Buka interface"""
print 'onOpen'
#----------------------------------------------------------------------
def __fill(self, value, length, fillByte):
if len(value) >= length:
return value
else:
fillSize = length - len(value)
return value + chr(fillByte) * fillSize
#----------------------------------------------------------------------
def __doXOr(self, s, value):
slist = list(s)
for index in xrange(len(slist)):
slist[index] = chr(ord(slist[index]) ^ value)
return "".join(slist)
#----------------------------------------------------------------------
def __hmacSign(self, aValue, aKey):
keyb = struct.pack("%ds" % len(aKey), aKey)
value = struct.pack("%ds" % len(aValue), aValue)
k_ipad = self.__doXOr(keyb, 0x36)
k_opad = self.__doXOr(keyb, 0x5c)
k_ipad = self.__fill(k_ipad, 64, 54)
k_opad = self.__fill(k_opad, 64, 92)
m = hashlib.md5()
m.update(k_ipad)
m.update(value)
dg = m.digest()
m = hashlib.md5()
m.update(k_opad)
subStr = dg[0:16]
m.update(subStr)
dg = m.hexdigest()
return dg
#----------------------------------------------------------------------
def __digest(self, aValue):
value = struct.pack("%ds" % len(aValue), aValue)
h = sha.new()
h.update(value)
dg = h.hexdigest()
return dg
#----------------------------------------------------------------------
def generateSign(self, params):
#Parameter diurutkan berdasarkan nilai ASCII: {"accesskey":"ce2a18e0-dshs-4c44-4515-9aca67dd706e","amount":"100","channel":"borrow","coin":"qc","event":"addChannel","interestRateOfDay":"0.15","isLoop":"1","no":"test001","repaymentDay":"20","safePwd":"123456"}
#secretKey Setelah mengenkripsi:86429c69799d3d6ac5da5c2c514baa874d75a4ba
SHA_secret = self.__digest(self.secretKey)
#Hitung tandanya: 378348551685d6d5ddbdf02a4df71f43
return self.__hmacSign( paramsStr, SHA_secret)
#----------------------------------------------------------------------
def borrow(self, symbol_pair, type_, price, amount):
json = "{"accesskey":"ce2a18e0-dshs-4c44-4515-9aca67dd706e","amount":"100","channel":"borrow","coin":"qc","event":"addChannel","interestRateOfDay":"0.15","isLoop":"1","no":"test001","repaymentDay":"20","safePwd":"123456","sign":"378348551685d6d5ddbdf02a4df71f43"}";
try:
self.ws_sub_spot.send(json)
except websocket.WebSocketConnectionClosedException:
pass
Contoh tanggapan
// Hasil Kembali
{
"success":true,
"code":1000,
"channel":"borrow",
"message":"Proses berhasil",
"no":"0"
}
Nama parameter | Jenis | Rentang nilai |
---|---|---|
accesskey | String | accesskey |
channel | String | borrow |
event | String | penugasan langsungaddChannel |
marketName | String | 杠杆市场 |
coin | String | Bunga yang telah jatuh tempo |
amount | Double | 借入金额 |
interestRateOfDay | Double | Suku bunga harian [0.05-0.2]% |
repaymentDay | int | jangka waktu pinjaman [10/20/30]Hari |
isLoop | int | Apakah akan memperbarui secara otomatis [1/0](Perpanjangan otomatis setelah kedaluwarsa/Pembayaran otomatis saat jatuh tempo) |
no | String | Identitas unik permintaan digunakan untuk membedakan konten saat dikembalikan |
sign | String | Tanda tangan |
Nilai Kembali | Deskripsi |
---|---|
success | Apakah berhasil |
code | Kode Pengembalian |
message | Petunjuk |
channel | saluran yang diminta |
no | Identitas unik permintaan digunakan untuk membedakan konten saat dikembalikan |
pembayaran
Contoh permintaan
// request demo
{
"accesskey":"your accesskey",
"amount":100,
"channel":"repay",
"event":"addChannel",
"loanRecordId":296,
"repayAmount":50,
"repayType":0,
"sign":Tanda tangan
}
// java demo
public void repay() {
//TestapiKey:ce2a18e0-dshs-4c44-4515-9aca67dd706e
//TestsecretKey:c11a122s-dshs-shsa-4515-954a67dd706e
//Enkripsi:https://github.com/zb2017/api/blob/master/zb_netty_client_java/src/main/java/websocketx/client/EncryDigestUtil.java
//secretKeyDiperoleh dengan enkripsi sha1:86429c69799d3d6ac5da5c2c514baa874d75a4ba
String secret = EncryDigestUtil.digest("c11a122s-dshs-shsa-4515-954a67dd706e");
//Parameter diurutkan berdasarkan nilai ASCII
String params = "{"accesskey":"ce2a18e0-dshs-4c44-4515-9aca67dd706e","amount":"100","channel":"repay","event":"addChannel","loanRecordId":"292","no":"test001","repayAmount":"50","repayType":"0"}";
//tanda dienkripsi oleh HmacMD5:e8f84ef851933cee9c26417d26ae2122
String sign = EncryDigestUtil.hmacSign(params, secret);
//Selanjutnya kirim ke permintaan parameter server json
String json = "{"accesskey":"ce2a18e0-dshs-4c44-4515-9aca67dd706e","amount":"100","channel":"repay","event":"addChannel","loanRecordId":"292","no":"test001","repayAmount":"50","repayType":"0","sign":"e8f84ef851933cee9c26417d26ae2122"}";
ws.sendText(json);
}
// python demo
import hashlib
import zlib
import json
from time import sleep
from threading import Thread
import websocket
import urllib2, hashlib,struct,sha,time
zb_usd_url = "wss://api.zb.com/websocket"
class ZB_Sub_Spot_Api(object):
"""基于Websocket的API对象"""
def __init__(self):
"""Constructor"""
self.apiKey = 'ce2a18e0-dshs-4c44-4515-9aca67dd706e'
self.secretKey = 'c11a122s-dshs-shsa-4515-954a67dd706e'
self.ws_sub_spot = None # websocketObjek aplikasi Objek spot
#----------------------------------------------------------------------
def reconnect(self):
"""sambungkan kembali"""
# Tutup dulu koneksi sebelumnya
self.close()
# sambungkan kembali lagi
self.ws_sub_spot = websocket.WebSocketApp(self.host,
on_message=self.onMessage,
on_error=self.onError,
on_close=self.onClose,
on_open=self.onOpen)
self.thread = Thread(target=self.ws_sub_spot.run_forever)
self.thread.start()
#----------------------------------------------------------------------
def connect_Subpot(self, apiKey , secretKey , trace = False):
self.host = zb_usd_url
self.apiKey = apiKey
self.secretKey = secretKey
websocket.enableTrace(trace)
self.ws_sub_spot = websocket.WebSocketApp(self.host,
on_message=self.onMessage,
on_error=self.onError,
on_close=self.onClose,
on_open=self.onOpen)
self.thread = Thread(target=self.ws_sub_spot.run_forever)
self.thread.start()
#----------------------------------------------------------------------
def readData(self, evt):
"""Ekstrak dan dorong data yang diterima"""
# # Ekstrak dan dorong data yang diterima
# decompress = zlib.decompressobj(-zlib.MAX_WBITS)
# # Dekompresi data asli menjadi string
# inflated = decompress.decompress(evt) + decompress.flush()
# Parse strings via json
data = json.loads(evt)
return data
#----------------------------------------------------------------------
def close(self):
"""Interface tutup"""
if self.thread and self.thread.isAlive():
self.ws_sub_spot.close()
self.thread.join()
#----------------------------------------------------------------------
def onMessage(self, ws, evt):
"""Push informasi"""
print evt
#----------------------------------------------------------------------
def onError(self, ws, evt):
"""salah push"""
print 'onError'
print evt
#----------------------------------------------------------------------
def onClose(self, ws):
"""Putuskan Sambungan Interface"""
print 'onClose'
#----------------------------------------------------------------------
def onOpen(self, ws):
"""Buka interface"""
print 'onOpen'
#----------------------------------------------------------------------
def __fill(self, value, length, fillByte):
if len(value) >= length:
return value
else:
fillSize = length - len(value)
return value + chr(fillByte) * fillSize
#----------------------------------------------------------------------
def __doXOr(self, s, value):
slist = list(s)
for index in xrange(len(slist)):
slist[index] = chr(ord(slist[index]) ^ value)
return "".join(slist)
#----------------------------------------------------------------------
def __hmacSign(self, aValue, aKey):
keyb = struct.pack("%ds" % len(aKey), aKey)
value = struct.pack("%ds" % len(aValue), aValue)
k_ipad = self.__doXOr(keyb, 0x36)
k_opad = self.__doXOr(keyb, 0x5c)
k_ipad = self.__fill(k_ipad, 64, 54)
k_opad = self.__fill(k_opad, 64, 92)
m = hashlib.md5()
m.update(k_ipad)
m.update(value)
dg = m.digest()
m = hashlib.md5()
m.update(k_opad)
subStr = dg[0:16]
m.update(subStr)
dg = m.hexdigest()
return dg
#----------------------------------------------------------------------
def __digest(self, aValue):
value = struct.pack("%ds" % len(aValue), aValue)
h = sha.new()
h.update(value)
dg = h.hexdigest()
return dg
#----------------------------------------------------------------------
def generateSign(self, params):
#Parameter diurutkan berdasarkan nilai ASCII: {"accesskey":"ce2a18e0-dshs-4c44-4515-9aca67dd706e","amount":"100","channel":"repay","event":"addChannel","loanRecordId":"292","no":"test001","repayAmount":"50","repayType":"0"}
#secretKey Setelah mengenkripsi:86429c69799d3d6ac5da5c2c514baa874d75a4ba
SHA_secret = self.__digest(self.secretKey)
#Hitung tandanya: e8f84ef851933cee9c26417d26ae2122
return self.__hmacSign( paramsStr, SHA_secret)
#----------------------------------------------------------------------
def repay(self, symbol_pair, type_, price, amount):
json = "{"accesskey":"ce2a18e0-dshs-4c44-4515-9aca67dd706e","amount":"100","channel":"repay","event":"addChannel","loanRecordId":"292","no":"test001","repayAmount":"50","repayType":"0","sign":"e8f84ef851933cee9c26417d26ae2122"}";
try:
self.ws_sub_spot.send(json)
except websocket.WebSocketConnectionClosedException:
pass
Contoh tanggapan
// Hasil Kembali
{
"success":true,
"code":1000,
"channel":"repay",
"message":"Proses berhasil",
"no":"0"
}
Nama parameter | Jenis | Rentang nilai |
---|---|---|
accesskey | String | accesskey |
channel | String | repay |
event | String | penugasan langsungaddChannel |
loanRecordId | Long | Catatan Peminjamanid |
repayAmount | Double | Jumlah pembayaran |
repayType | int | Meteode pembayaran [0/1](Semua/Bagian) |
no | String | Identitas unik permintaan digunakan untuk membedakan konten saat dikembalikan |
sign | String | Tanda tangan |
Nilai Kembali | Deskripsi |
---|---|
success | Apakah berhasil |
code | Kode Pengembalian |
message | Petunjuk |
channel | saluran yang diminta |
no | Identitas unik permintaan digunakan untuk membedakan konten saat dikembalikan |
Dapatkan catatan pembayaran
Contoh permintaan
// request demo
{
"accesskey":"your accesskey",
"channel":"getRepayments",
"loanRecordId":296,
"pageIndex":1,
"pageSize":10,
"sign":Tanda tangan
}
// java demo
public void getRepayments() {
//TestapiKey:ce2a18e0-dshs-4c44-4515-9aca67dd706e
//TestsecretKey:c11a122s-dshs-shsa-4515-954a67dd706e
//Enkripsi:https://github.com/zb2017/api/blob/master/zb_netty_client_java/src/main/java/websocketx/client/EncryDigestUtil.java
//secretKeyDiperoleh dengan enkripsi sha1:86429c69799d3d6ac5da5c2c514baa874d75a4ba
String secret = EncryDigestUtil.digest("c11a122s-dshs-shsa-4515-954a67dd706e");
//Parameter diurutkan berdasarkan nilai ASCII
String params = "{"accesskey":"ce2a18e0-dshs-4c44-4515-9aca67dd706e","channel":"getRepayments","event":"addChannel","loanRecordId":"292","no":"test001","pageIndex":"1","pageSize":"10"}";
//tanda dienkripsi oleh HmacMD5:5be5380faa9ee8010f43bafabbae5e3d
String sign = EncryDigestUtil.hmacSign(params, secret);
//Selanjutnya kirim ke permintaan parameter server json
String json = "{"accesskey":"ce2a18e0-dshs-4c44-4515-9aca67dd706e","channel":"getRepayments","event":"addChannel","loanRecordId":"292","no":"test001","pageIndex":"1","pageSize":"10","sign":"5be5380faa9ee8010f43bafabbae5e3d"}";
ws.sendText(json);
}
// python demo
import hashlib
import zlib
import json
from time import sleep
from threading import Thread
import websocket
import urllib2, hashlib,struct,sha,time
zb_usd_url = "wss://api.zb.com/websocket"
class ZB_Sub_Spot_Api(object):
"""基于Websocket的API对象"""
def __init__(self):
"""Constructor"""
self.apiKey = 'ce2a18e0-dshs-4c44-4515-9aca67dd706e'
self.secretKey = 'c11a122s-dshs-shsa-4515-954a67dd706e'
self.ws_sub_spot = None # websocketObjek aplikasi Objek spot
#----------------------------------------------------------------------
def reconnect(self):
"""sambungkan kembali"""
# Tutup dulu koneksi sebelumnya
self.close()
# sambungkan kembali lagi
self.ws_sub_spot = websocket.WebSocketApp(self.host,
on_message=self.onMessage,
on_error=self.onError,
on_close=self.onClose,
on_open=self.onOpen)
self.thread = Thread(target=self.ws_sub_spot.run_forever)
self.thread.start()
#----------------------------------------------------------------------
def connect_Subpot(self, apiKey , secretKey , trace = False):
self.host = zb_usd_url
self.apiKey = apiKey
self.secretKey = secretKey
websocket.enableTrace(trace)
self.ws_sub_spot = websocket.WebSocketApp(self.host,
on_message=self.onMessage,
on_error=self.onError,
on_close=self.onClose,
on_open=self.onOpen)
self.thread = Thread(target=self.ws_sub_spot.run_forever)
self.thread.start()
#----------------------------------------------------------------------
def readData(self, evt):
"""Ekstrak dan dorong data yang diterima"""
# # Ekstrak dan dorong data yang diterima
# decompress = zlib.decompressobj(-zlib.MAX_WBITS)
# # Dekompresi data asli menjadi string
# inflated = decompress.decompress(evt) + decompress.flush()
# Parse strings via json
data = json.loads(evt)
return data
#----------------------------------------------------------------------
def close(self):
"""Interface tutup"""
if self.thread and self.thread.isAlive():
self.ws_sub_spot.close()
self.thread.join()
#----------------------------------------------------------------------
def onMessage(self, ws, evt):
"""Push informasi"""
print evt
#----------------------------------------------------------------------
def onError(self, ws, evt):
"""salah push"""
print 'onError'
print evt
#----------------------------------------------------------------------
def onClose(self, ws):
"""Putuskan Sambungan Interface"""
print 'onClose'
#----------------------------------------------------------------------
def onOpen(self, ws):
"""Buka interface"""
print 'onOpen'
#----------------------------------------------------------------------
def __fill(self, value, length, fillByte):
if len(value) >= length:
return value
else:
fillSize = length - len(value)
return value + chr(fillByte) * fillSize
#----------------------------------------------------------------------
def __doXOr(self, s, value):
slist = list(s)
for index in xrange(len(slist)):
slist[index] = chr(ord(slist[index]) ^ value)
return "".join(slist)
#----------------------------------------------------------------------
def __hmacSign(self, aValue, aKey):
keyb = struct.pack("%ds" % len(aKey), aKey)
value = struct.pack("%ds" % len(aValue), aValue)
k_ipad = self.__doXOr(keyb, 0x36)
k_opad = self.__doXOr(keyb, 0x5c)
k_ipad = self.__fill(k_ipad, 64, 54)
k_opad = self.__fill(k_opad, 64, 92)
m = hashlib.md5()
m.update(k_ipad)
m.update(value)
dg = m.digest()
m = hashlib.md5()
m.update(k_opad)
subStr = dg[0:16]
m.update(subStr)
dg = m.hexdigest()
return dg
#----------------------------------------------------------------------
def __digest(self, aValue):
value = struct.pack("%ds" % len(aValue), aValue)
h = sha.new()
h.update(value)
dg = h.hexdigest()
return dg
#----------------------------------------------------------------------
def generateSign(self, params):
#Parameter diurutkan berdasarkan nilai ASCII: {"accesskey":"ce2a18e0-dshs-4c44-4515-9aca67dd706e","channel":"getRepayments","event":"addChannel","loanRecordId":"292","no":"test001","pageIndex":"1","pageSize":"10"}
#secretKey Setelah mengenkripsi:86429c69799d3d6ac5da5c2c514baa874d75a4ba
SHA_secret = self.__digest(self.secretKey)
#Hitung tandanya: 5be5380faa9ee8010f43bafabbae5e3d
return self.__hmacSign( paramsStr, SHA_secret)
#----------------------------------------------------------------------
def getRepayments(self, symbol_pair, type_, price, amount):
json = "{"accesskey":"ce2a18e0-dshs-4c44-4515-9aca67dd706e","channel":"getRepayments","event":"addChannel","loanRecordId":"292","no":"test001","pageIndex":"1","pageSize":"10","sign":"5be5380faa9ee8010f43bafabbae5e3d"}";
try:
self.ws_sub_spot.send(json)
except websocket.WebSocketConnectionClosedException:
pass
Contoh tanggapan
// Hasil Kembali
{
"success":true,
"code":1000,
"data":[
{
"benJin":"50",
"id":78,
"statusShow":"Di kembalikan",
"status":1,
"liXi":"0.06",
"actureDate":1522982889000
}
],
"channel":"getLeverBills",
"message":"Proses berhasil",
"no":"0"
}
Nama parameter | Jenis | Rentang nilai |
---|---|---|
accesskey | String | accesskey |
channel | String | getRepayments |
event | String | penugasan langsungaddChannel |
loanRecordId | Long | Catatan Peminjamanid |
pageIndex | int | nomor halaman saat ini(Seperti: 1, halaman 1) |
pageSize | int | Kuantitas per halaman |
no | String | Identitas unik permintaan digunakan untuk membedakan konten saat dikembalikan |
sign | String | Tanda tangan |
Nilai Kembali | Deskripsi |
---|---|
success | Apakah berhasil |
code | Kode Pengembalian |
message | Petunjuk |
channel | saluran yang diminta |
no | Identitas unik permintaan digunakan untuk membedakan konten saat dikembalikan |
id | Catatan PembayaranID |
benJin | Modal |
liXi | Bunga |
status | Status |
statusShow | Nilai status dalam bahasa chinese |
actureDate | Tanggal Pelunasan Sebenarnya |
Dapatkan Catatan Investasi
Contoh permintaan
// request demo
{
"accesskey":"your accesskey",
"channel":"getFinanceRecords",
"coin":"qc",
"event":"addChannel",
"pageIndex":1,
"pageSize":10,
"sign":Tanda tangan
}
// java demo
public void getFinanceRecords() {
//TestapiKey:ce2a18e0-dshs-4c44-4515-9aca67dd706e
//TestsecretKey:c11a122s-dshs-shsa-4515-954a67dd706e
//Enkripsi:https://github.com/zb2017/api/blob/master/zb_netty_client_java/src/main/java/websocketx/client/EncryDigestUtil.java
//secretKeyDiperoleh dengan enkripsi sha1:86429c69799d3d6ac5da5c2c514baa874d75a4ba
String secret = EncryDigestUtil.digest("c11a122s-dshs-shsa-4515-954a67dd706e");
//Parameter diurutkan berdasarkan nilai ASCII
String params = "{"accesskey":"ce2a18e0-dshs-4c44-4515-9aca67dd706e","channel":"getFinanceRecords","coin":"qc","event":"addChannel","no":"test001","pageIndex":"1","pageSize":"10"}";
//signDiperoleh dengan enkripsi HmacMD5:e950df0cff23a392fb738c8eeb2ef9dc
String sign = EncryDigestUtil.hmacSign(params, secret);
//Selanjutnya kirim ke permintaan parameter server json
String json = "{"accesskey":"ce2a18e0-dshs-4c44-4515-9aca67dd706e","channel":"getFinanceRecords","coin":"qc","event":"addChannel","no":"test001","pageIndex":"1","pageSize":"10","sign":"e950df0cff23a392fb738c8eeb2ef9dc"}";
ws.sendText(json);
}
// python demo
import hashlib
import zlib
import json
from time import sleep
from threading import Thread
import websocket
import urllib2, hashlib,struct,sha,time
zb_usd_url = "wss://api.zb.com/websocket"
class ZB_Sub_Spot_Api(object):
"""基于Websocket的API对象"""
def __init__(self):
"""Constructor"""
self.apiKey = 'ce2a18e0-dshs-4c44-4515-9aca67dd706e'
self.secretKey = 'c11a122s-dshs-shsa-4515-954a67dd706e'
self.ws_sub_spot = None # websocketObjek aplikasi Objek spot
#----------------------------------------------------------------------
def reconnect(self):
"""sambungkan kembali"""
# Tutup dulu koneksi sebelumnya
self.close()
# sambungkan kembali lagi
self.ws_sub_spot = websocket.WebSocketApp(self.host,
on_message=self.onMessage,
on_error=self.onError,
on_close=self.onClose,
on_open=self.onOpen)
self.thread = Thread(target=self.ws_sub_spot.run_forever)
self.thread.start()
#----------------------------------------------------------------------
def connect_Subpot(self, apiKey , secretKey , trace = False):
self.host = zb_usd_url
self.apiKey = apiKey
self.secretKey = secretKey
websocket.enableTrace(trace)
self.ws_sub_spot = websocket.WebSocketApp(self.host,
on_message=self.onMessage,
on_error=self.onError,
on_close=self.onClose,
on_open=self.onOpen)
self.thread = Thread(target=self.ws_sub_spot.run_forever)
self.thread.start()
#----------------------------------------------------------------------
def readData(self, evt):
"""Ekstrak dan dorong data yang diterima"""
# # Ekstrak dan dorong data yang diterima
# decompress = zlib.decompressobj(-zlib.MAX_WBITS)
# # Dekompresi data asli menjadi string
# inflated = decompress.decompress(evt) + decompress.flush()
# Parse strings via json
data = json.loads(evt)
return data
#----------------------------------------------------------------------
def close(self):
"""Interface tutup"""
if self.thread and self.thread.isAlive():
self.ws_sub_spot.close()
self.thread.join()
#----------------------------------------------------------------------
def onMessage(self, ws, evt):
"""Push informasi"""
print evt
#----------------------------------------------------------------------
def onError(self, ws, evt):
"""salah push"""
print 'onError'
print evt
#----------------------------------------------------------------------
def onClose(self, ws):
"""Putuskan Sambungan Interface"""
print 'onClose'
#----------------------------------------------------------------------
def onOpen(self, ws):
"""Buka interface"""
print 'onOpen'
#----------------------------------------------------------------------
def __fill(self, value, length, fillByte):
if len(value) >= length:
return value
else:
fillSize = length - len(value)
return value + chr(fillByte) * fillSize
#----------------------------------------------------------------------
def __doXOr(self, s, value):
slist = list(s)
for index in xrange(len(slist)):
slist[index] = chr(ord(slist[index]) ^ value)
return "".join(slist)
#----------------------------------------------------------------------
def __hmacSign(self, aValue, aKey):
keyb = struct.pack("%ds" % len(aKey), aKey)
value = struct.pack("%ds" % len(aValue), aValue)
k_ipad = self.__doXOr(keyb, 0x36)
k_opad = self.__doXOr(keyb, 0x5c)
k_ipad = self.__fill(k_ipad, 64, 54)
k_opad = self.__fill(k_opad, 64, 92)
m = hashlib.md5()
m.update(k_ipad)
m.update(value)
dg = m.digest()
m = hashlib.md5()
m.update(k_opad)
subStr = dg[0:16]
m.update(subStr)
dg = m.hexdigest()
return dg
#----------------------------------------------------------------------
def __digest(self, aValue):
value = struct.pack("%ds" % len(aValue), aValue)
h = sha.new()
h.update(value)
dg = h.hexdigest()
return dg
#----------------------------------------------------------------------
def generateSign(self, params):
#Parameter diurutkan berdasarkan nilai ASCII: {"accesskey":"ce2a18e0-dshs-4c44-4515-9aca67dd706e","channel":"getFinanceRecords","coin":"qc","event":"addChannel","no":"test001","pageIndex":"1","pageSize":"10"}
#secretKey Setelah mengenkripsi:86429c69799d3d6ac5da5c2c514baa874d75a4ba
SHA_secret = self.__digest(self.secretKey)
#Hitung tandanya: e950df0cff23a392fb738c8eeb2ef9dc
return self.__hmacSign( paramsStr, SHA_secret)
#----------------------------------------------------------------------
def getFinanceRecords(self, symbol_pair, type_, price, amount):
json = "{"accesskey":"ce2a18e0-dshs-4c44-4515-9aca67dd706e","channel":"getFinanceRecords","coin":"qc","event":"addChannel","no":"test001","pageIndex":"1","pageSize":"10","sign":"e950df0cff23a392fb738c8eeb2ef9dc"}";
try:
self.ws_sub_spot.send(json)
except websocket.WebSocketConnectionClosedException:
pass
Contoh tanggapan
// Hasil Kembali
{
"success":true,
"code":1000,
"data":[
{
"id" : 156,
"userId" : 110803,
"userName" : "13427002684",
"fundType" : 15,
"coinName" : "QC",
"amount" : "10",
"hasAmount" : "0",
"status" : 0,
"statusShow" : "tidak dipinjam",
"createTime" : 1524541195000,
"interestRateOfDay" : "0.0012",
"repaymentDay" : 10,
"isLoop" : true,
"inTimes" : 0,
"sourceType" : 6
},
...
],
"channel":"getFinanceRecords",
"message":"Proses berhasil",
"no":"0"
}
Nama parameter | Jenis | Rentang nilai |
---|---|---|
accesskey | String | accesskey |
channel | String | getFinanceRecords |
event | String | penugasan langsungaddChannel |
coin | STirng | Bunga yang telah jatuh tempo |
pageIndex | int | nomor halaman saat ini(Seperti: 1, halaman 1) |
pageSize | int | Kuantitas per halaman |
no | String | Identitas unik permintaan digunakan untuk membedakan konten saat dikembalikan |
sign | String | Tanda tangan |
Nilai Kembali | Deskripsi |
---|---|
success | Apakah berhasil |
code | Kode Pengembalian |
message | Petunjuk |
channel | saluran yang diminta |
no | Identitas unik permintaan digunakan untuk membedakan konten saat dikembalikan |
id | InvestasiID |
userId | UserID |
userName | Nama pengguna |
fundType | Jenis koin |
coinName | Nama koin |
amount | Jumlah investasi |
hasAmount | Jumlah yang dipinjamkan |
status | Nilai status |
statusShow | Nilai status dalam bahasa chinese |
createTime | Waktu Rilis |
interestRateOfDay | Suku bunga harian |
repaymentDay | hari peminjaman |
isLoop | Apakah akan secara otomatis meminjamkan |
inTimes | Investasi yang dipinjam |
sourceType | jenis sumber: 8”Web”,5”handphoneAPP”,6”InterfaceAPI” |
WebSocket API V2
Pasar Cepat
Contoh permintaan
// request demo
{
"event":"addChannel",
"channel":"usdtqc_quick_depth",
}
// java demo
public void depth() {
val data = new TreeMap();
data.put("event", "addChannel");
data.put("channel", "usdtqc_quick_depth");
ws.sendText(JSONObject.toJSONString(data));
}
// python demo
import hashlib
import zlib
import json
from time import sleep
from threading import Thread
import websocket
import urllib2, hashlib,struct,sha,time
zb_usd_url = "wss://api.zb.com/websocket/usdt"
class ZB_Sub_Spot_Api(object):
"""基于Websocket的API对象"""
def __init__(self):
"""Constructor"""
self.ws_sub_spot = None # websocketObjek aplikasi Objek spot
#----------------------------------------------------------------------
def reconnect(self):
"""sambungkan kembali"""
# Tutup dulu koneksi sebelumnya
self.close()
# sambungkan kembali lagi
self.ws_sub_spot = websocket.WebSocketApp(self.host,
on_message=self.onMessage,
on_error=self.onError,
on_close=self.onClose,
on_open=self.onOpen)
self.thread = Thread(target=self.ws_sub_spot.run_forever)
self.thread.start()
#----------------------------------------------------------------------
def connect_Subpot(self, apiKey , secretKey , trace = False):
self.host = zb_usd_url
self.apiKey = apiKey
self.secretKey = secretKey
websocket.enableTrace(trace)
self.ws_sub_spot = websocket.WebSocketApp(self.host,
on_message=self.onMessage,
on_error=self.onError,
on_close=self.onClose,
on_open=self.onOpen)
self.thread = Thread(target=self.ws_sub_spot.run_forever)
self.thread.start()
#----------------------------------------------------------------------
def readData(self, evt):
"""Ekstrak dan dorong data yang diterima"""
# # Ekstrak dan dorong data yang diterima
# decompress = zlib.decompressobj(-zlib.MAX_WBITS)
# # Dekompresi data asli menjadi string
# inflated = decompress.decompress(evt) + decompress.flush()
# Parse strings via json
data = json.loads(evt)
return data
#----------------------------------------------------------------------
def close(self):
"""Interface tutup"""
if self.thread and self.thread.isAlive():
self.ws_sub_spot.close()
self.thread.join()
#----------------------------------------------------------------------
def onMessage(self, ws, evt):
"""Push informasi"""
print evt
#----------------------------------------------------------------------
def onError(self, ws, evt):
"""salah push"""
print 'onError'
print evt
#----------------------------------------------------------------------
def onClose(self, ws):
"""Putuskan Sambungan Interface"""
print 'onClose'
#----------------------------------------------------------------------
def onOpen(self, ws):
"""Buka interface"""
print 'onOpen'
#----------------------------------------------------------------------
def sendJson(self):
req = "{'event':'addChannel','channel':'usdtqc_quick_depth'}"
self.ws_sub_spot.send(req)
Contoh tanggapan
// Hasil Kembali
{
"lastTime": 1592277547320,
"dataType": quickDepth,
"channel": usdtqc_quick_depth,
"currentPrice": 7.0885,
"transction":[],
"listDown": [
[
7.0885,
12589.6168
]...
],
"listUp": [
[
7.0893,
64.843
]...
],
"market": usdtqc,
"high": 7.1477,
"rate": 1,
"low": 7.0851,
"currentIsBuy": false,
"dayNumber": 22236861.8995,
"totalBtc": 22236861.8995
}
Nama parameter | Jenis | Rentang nilai |
---|---|---|
event | String | penugasan langsungaddChannel |
channel | String | usdtqc_quick_depth |
length | String | Gear5 10 20(Opsional, default adalah 5 file) |
Nilai Kembali | Deskripsi |
---|---|
lastTime | Time |
dataType | Jenis data |
channel | Permintaan saat inichannel |
currentPrice | Harga transaksi terbaru |
transction | |
listDown | Beli pesanan |
listUp | Jual Order Depth |
market | Pasar |
high | harga tertinggi |
rate | Beli pesanan |
low | harga terendah |
currentIsBuy | Tipe transaksi |
dayNumber | Volume perdagangan |
totalBtc | Volume perdagangan |
Pengelompokan pasar cepat
同一组内的多个市场可以用一个WS链接进行订阅,在此场景下,WS访问地址是wss://api.zb.com/websocket/XXX,XXX是该组内任意一个币种名
misal ETH, LTC, EOS, qtum dan mata uang lainnya milik grup 3, lalu akses alamatnya wss://api.zb.com/websocket/eth
Ini dapat digunakan untuk berlangganan interface Kutipan Cepat dari semua pasangan transaksi mata uang dalam grup, misalnya.ltc_qc,qtum_usdt,eos_btc...
Contoh permintaan
// request demo
GET https://api.zb.com/data/v1/getGroupMarkets
// java demo
public void getGroupMarkets() {
//Dapatkan hasil pengembalian
String returnJson = HttpRequest.get("https://api.zb.com/data/v1/getGroupMarkets").send().bodyText();
}
// python demo
def get(self, url):
while True:
try:
r = requests.get(url)
except Exception:
time.sleep(0.5)
continue
if r.status_code != 200:
time.sleep(0.5)
continue
r_info = r.json()
r.close()
return r_info
def getGroupMarkets(self, market):
url = 'https://api.zb.com/data/v1/getGroupMarkets'
return self.get(url)
Contoh tanggapan
// Hasil Kembali
{
"wsgroup1": [
"usdtqc"
],
"wsgroup2": [
"btcusdt",
"btcqc",
"zbqc"
...
],
...
}
Perubahan Pesanan (Dorong 10 catatan pesanan yang tertunda dan selesai)
Contoh permintaan
// request demo
{
"accesskey": "ceb1569d-7c17-xxxx-b4a1-xxxxxxxxx",
"channel": "push_user_record",
"event": "addChannel",
"market": "zbqcdefault",
"sign":"Tanda tangan"
}
// java demo
public void push_user_record() {
//TestapiKey:ce2a18e0-dshs-4c44-4515-9aca67dd706e
//TestsecretKey:c11a122s-dshs-shsa-4515-954a67dd706e
//Enkripsi:https://github.com/zb2017/api/blob/master/zb_netty_client_java/src/main/java/websocketx/client/EncryDigestUtil.java
//secretKeyDiperoleh dengan enkripsi sha1:86429c69799d3d6ac5da5c2c514baa874d75a4ba
String secret = EncryDigestUtil.digest("c11a122s-dshs-shsa-4515-954a67dd706e");
//Parameter diurutkan berdasarkan nilai ASCII
String params = "{"accesskey":"ce2a18e0-dshs-4c44-4515-9aca67dd706e","binary":false,"channel":"push_user_record","event":"addChannel","isZip":false,"market":"zbqcdefault"}";
//tanda dienkripsi oleh HmacMD5:6c9157032c96795a411a3b8628f543f5
String sign = EncryDigestUtil.hmacSign(params, secret);
//Selanjutnya kirim ke permintaan parameter server json
String json = "{"market":"zbqcdefault","accesskey":"ce2a18e0-dshs-4c44-4515-9aca67dd706e","binary":false,"channel":"push_user_record","sign":"6c9157032c96795a411a3b8628f543f5","isZip":false,"event":"addChannel"}";
ws.sendText(json);
}
// python demo
import hashlib
import zlib
import json
from time import sleep
from threading import Thread
import websocket
import urllib2, hashlib,struct,sha,time
zb_usd_url = "wss://api.zb.com/websocket"
class ZB_Sub_Spot_Api(object):
"""基于Websocket的API对象"""
def __init__(self):
"""Constructor"""
self.apiKey = 'ce2a18e0-dshs-4c44-4515-9aca67dd706e'
self.secretKey = 'c11a122s-dshs-shsa-4515-954a67dd706e'
self.ws_sub_spot = None # websocketObjek aplikasi Objek spot
#----------------------------------------------------------------------
def reconnect(self):
"""sambungkan kembali"""
# Tutup dulu koneksi sebelumnya
self.close()
# sambungkan kembali lagi
self.ws_sub_spot = websocket.WebSocketApp(self.host,
on_message=self.onMessage,
on_error=self.onError,
on_close=self.onClose,
on_open=self.onOpen)
self.thread = Thread(target=self.ws_sub_spot.run_forever)
self.thread.start()
#----------------------------------------------------------------------
def connect_Subpot(self, apiKey , secretKey , trace = False):
self.host = zb_usd_url
self.apiKey = apiKey
self.secretKey = secretKey
websocket.enableTrace(trace)
self.ws_sub_spot = websocket.WebSocketApp(self.host,
on_message=self.onMessage,
on_error=self.onError,
on_close=self.onClose,
on_open=self.onOpen)
self.thread = Thread(target=self.ws_sub_spot.run_forever)
self.thread.start()
#----------------------------------------------------------------------
def readData(self, evt):
"""Ekstrak dan dorong data yang diterima"""
# # Ekstrak dan dorong data yang diterima
# decompress = zlib.decompressobj(-zlib.MAX_WBITS)
# # Dekompresi data asli menjadi string
# inflated = decompress.decompress(evt) + decompress.flush()
# Parse strings via json
data = json.loads(evt)
return data
#----------------------------------------------------------------------
def close(self):
"""Interface tutup"""
if self.thread and self.thread.isAlive():
self.ws_sub_spot.close()
self.thread.join()
#----------------------------------------------------------------------
def onMessage(self, ws, evt):
"""Push informasi"""
print evt
#----------------------------------------------------------------------
def onError(self, ws, evt):
"""salah push"""
print 'onError'
print evt
#----------------------------------------------------------------------
def onClose(self, ws):
"""Putuskan Sambungan Interface"""
print 'onClose'
#----------------------------------------------------------------------
def onOpen(self, ws):
"""Buka interface"""
print 'onOpen'
#----------------------------------------------------------------------
def __fill(self, value, length, fillByte):
if len(value) >= length:
return value
else:
fillSize = length - len(value)
return value + chr(fillByte) * fillSize
#----------------------------------------------------------------------
def __doXOr(self, s, value):
slist = list(s)
for index in xrange(len(slist)):
slist[index] = chr(ord(slist[index]) ^ value)
return "".join(slist)
#----------------------------------------------------------------------
def __hmacSign(self, aValue, aKey):
keyb = struct.pack("%ds" % len(aKey), aKey)
value = struct.pack("%ds" % len(aValue), aValue)
k_ipad = self.__doXOr(keyb, 0x36)
k_opad = self.__doXOr(keyb, 0x5c)
k_ipad = self.__fill(k_ipad, 64, 54)
k_opad = self.__fill(k_opad, 64, 92)
m = hashlib.md5()
m.update(k_ipad)
m.update(value)
dg = m.digest()
m = hashlib.md5()
m.update(k_opad)
subStr = dg[0:16]
m.update(subStr)
dg = m.hexdigest()
return dg
#----------------------------------------------------------------------
def __digest(self, aValue):
value = struct.pack("%ds" % len(aValue), aValue)
h = sha.new()
h.update(value)
dg = h.hexdigest()
return dg
#----------------------------------------------------------------------
def generateSign(self, params):
#Parameter diurutkan berdasarkan nilai ASCII: {"accesskey":"ce2a18e0-dshs-4c44-4515-9aca67dd706e","channel":"addSubUser","event":"addChannel","memo":"memo","no":"test001","password":"123456","subUserName":"test1"}
#secretKey Setelah mengenkripsi:86429c69799d3d6ac5da5c2c514baa874d75a4ba
SHA_secret = self.__digest(self.secretKey)
#Hitung tandanya: 475fdd83600e42140d2d0336b8d57ce4
return self.__hmacSign( paramsStr, SHA_secret)
#----------------------------------------------------------------------
def addSubUser(self, symbol_pair, type_, price, amount):
json = "{"accesskey":"ce2a18e0-dshs-4c44-4515-9aca67dd706e","channel":"addSubUser","event":"addChannel","memo":"memo","no":"test001","password":"123456","sign":"475fdd83600e42140d2d0336b8d57ce4","subUserName":"test1"}";
try:
self.ws_sub_spot.send(json)
except websocket.WebSocketConnectionClosedException:
pass
Contoh tanggapan
// Hasil Kembali
{
"record": [],
"hrecord": [
[
"id",
percayakan harga,
percayakan jumlah,
Jumlah volume yang di setujui,
Jumlah transaksi yang di setujui,
Jenis pesanan tertunda0-limit sell,1-limit buy,2-PostOnly sell,3-PostOnly buy,4-IOC sell,5-IOC buy,
mempercayakan waktu,
Status pesanan:(1. Batal, 2. Selesai/Batalkan pesanan setelah sebagian selesai, 3. Pesanan tertunda/Tidak ),
Biaya transaksi,
mengabaikan,
jenis sumber: 8Web,5handphoneAPP,6InterfaceAPI,
Jenis Akun 0 Spot 1 Leverage
]...
],
"precord": [
[
"id",
percayakan harga,
percayakan jumlah,
Jumlah volume yang di setujui,
Jumlah transaksi yang di setujui,
Jenis pesanan tertunda0-limit sell,1-limit buy,2-PostOnly sell,3-PostOnly buy,4-IOC sell,5-IOC buy,
mempercayakan waktu,
Status pesanan:(1. Batal, 2. Selesai/Batalkan pesanan setelah sebagian selesai, 3. Pesanan tertunda/Tidak ),
Biaya transaksi,
Memicu harga untuk mengejar high dan stop loss,
jenis sumber: 8Web,5handphoneAPP,6InterfaceAPI,
Harga pemicu untuk pembacaan bawah dan penghentian keuntungan,
percayakan harga,
menitipkan uang,
ID delegasi resmi,
true,
Harga pemicu sebenarnya, 0 tidak diketahui
]...
],
"dataType": "userRecord",
"count": 0,
"channel": "push_user_record"
"lastTime": 1590806778504
}
Nama parameter | Jenis | Rentang nilai |
---|---|---|
accesskey | String | accesskey |
channel | String | push_user_record |
event | String | penugasan langsungaddChannel |
market | String | zbqcdefault |
sign | String | Tanda tangan |
Nilai Kembali | Deskripsi |
---|---|
precord | komisi rencana |
record | Percayakan saat ini |
hrecord | Komisi history |
dataType | Jenis data |
channel | saluran yang diminta |
lastTime | time |
Perubahan Pesanan Inkremental (hanya mendorong catatan komisi yang diubah)
Contoh permintaan
// request demo
{
"accesskey": "ceb1569d-7c17-xxxx-b4a1-xxxxxxxxx",
"channel": "push_user_incr_record",
"event": "addChannel",
"market": "zbqcdefault",
"sign":"Tanda tangan"
}
// java demo
public void push_user_incr_record() {
//TestapiKey:ce2a18e0-dshs-4c44-4515-9aca67dd706e
//TestsecretKey:c11a122s-dshs-shsa-4515-954a67dd706e
//Enkripsi:https://github.com/zb2017/api/blob/master/zb_netty_client_java/src/main/java/websocketx/client/EncryDigestUtil.java
//secretKeyDiperoleh dengan enkripsi sha1:86429c69799d3d6ac5da5c2c514baa874d75a4ba
String secret = EncryDigestUtil.digest("c11a122s-dshs-shsa-4515-954a67dd706e");
//Parameter diurutkan berdasarkan nilai ASCII
String params = "{"accesskey":"ce2a18e0-dshs-4c44-4515-9aca67dd706e","channel":"push_user_incr_record","event":"addChannel","market":"zbqcdefault"}";
//tanda dienkripsi oleh HmacMD5:6c9157032c96795a411a3b8628f543f5
String sign = EncryDigestUtil.hmacSign(params, secret);
//Selanjutnya kirim ke permintaan parameter server json
String json = "{"market":"zbqcdefault","accesskey":"ce2a18e0-dshs-4c44-4515-9aca67dd706e","channel":"push_user_incr_record","sign":"6c9157032c96795a411a3b8628f543f5","event":"addChannel"}";
ws.sendText(json);
}
// python demo
import hashlib
import zlib
import json
from time import sleep
from threading import Thread
import websocket
import urllib2, hashlib,struct,sha,time
zb_usd_url = "wss://api.zb.com/websocket"
class ZB_Sub_Spot_Api(object):
"""基于Websocket的API对象"""
def __init__(self):
"""Constructor"""
self.apiKey = 'ce2a18e0-dshs-4c44-4515-9aca67dd706e'
self.secretKey = 'c11a122s-dshs-shsa-4515-954a67dd706e'
self.ws_sub_spot = None # websocketObjek aplikasi Objek spot
#----------------------------------------------------------------------
def reconnect(self):
"""sambungkan kembali"""
# Tutup dulu koneksi sebelumnya
self.close()
# sambungkan kembali lagi
self.ws_sub_spot = websocket.WebSocketApp(self.host,
on_message=self.onMessage,
on_error=self.onError,
on_close=self.onClose,
on_open=self.onOpen)
self.thread = Thread(target=self.ws_sub_spot.run_forever)
self.thread.start()
#----------------------------------------------------------------------
def connect_Subpot(self, apiKey , secretKey , trace = False):
self.host = zb_usd_url
self.apiKey = apiKey
self.secretKey = secretKey
websocket.enableTrace(trace)
self.ws_sub_spot = websocket.WebSocketApp(self.host,
on_message=self.onMessage,
on_error=self.onError,
on_close=self.onClose,
on_open=self.onOpen)
self.thread = Thread(target=self.ws_sub_spot.run_forever)
self.thread.start()
#----------------------------------------------------------------------
def readData(self, evt):
"""Ekstrak dan dorong data yang diterima"""
# # Ekstrak dan dorong data yang diterima
# decompress = zlib.decompressobj(-zlib.MAX_WBITS)
# # Dekompresi data asli menjadi string
# inflated = decompress.decompress(evt) + decompress.flush()
# Parse strings via json
data = json.loads(evt)
return data
#----------------------------------------------------------------------
def close(self):
"""Interface tutup"""
if self.thread and self.thread.isAlive():
self.ws_sub_spot.close()
self.thread.join()
#----------------------------------------------------------------------
def onMessage(self, ws, evt):
"""Push informasi"""
print evt
#----------------------------------------------------------------------
def onError(self, ws, evt):
"""salah push"""
print 'onError'
print evt
#----------------------------------------------------------------------
def onClose(self, ws):
"""Putuskan Sambungan Interface"""
print 'onClose'
#----------------------------------------------------------------------
def onOpen(self, ws):
"""Buka interface"""
print 'onOpen'
#----------------------------------------------------------------------
def __fill(self, value, length, fillByte):
if len(value) >= length:
return value
else:
fillSize = length - len(value)
return value + chr(fillByte) * fillSize
#----------------------------------------------------------------------
def __doXOr(self, s, value):
slist = list(s)
for index in xrange(len(slist)):
slist[index] = chr(ord(slist[index]) ^ value)
return "".join(slist)
#----------------------------------------------------------------------
def __hmacSign(self, aValue, aKey):
keyb = struct.pack("%ds" % len(aKey), aKey)
value = struct.pack("%ds" % len(aValue), aValue)
k_ipad = self.__doXOr(keyb, 0x36)
k_opad = self.__doXOr(keyb, 0x5c)
k_ipad = self.__fill(k_ipad, 64, 54)
k_opad = self.__fill(k_opad, 64, 92)
m = hashlib.md5()
m.update(k_ipad)
m.update(value)
dg = m.digest()
m = hashlib.md5()
m.update(k_opad)
subStr = dg[0:16]
m.update(subStr)
dg = m.hexdigest()
return dg
#----------------------------------------------------------------------
def __digest(self, aValue):
value = struct.pack("%ds" % len(aValue), aValue)
h = sha.new()
h.update(value)
dg = h.hexdigest()
return dg
#----------------------------------------------------------------------
def generateSign(self, params):
#Parameter diurutkan berdasarkan nilai ASCII: {"accesskey":"ce2a18e0-dshs-4c44-4515-9aca67dd706e","channel":"push_user_incr_record","event":"addChannel"}
#secretKey Setelah mengenkripsi:86429c69799d3d6ac5da5c2c514baa874d75a4ba
SHA_secret = self.__digest(self.secretKey)
#Hitung tandanya: 475fdd83600e42140d2d0336b8d57ce4
return self.__hmacSign( paramsStr, SHA_secret)
#----------------------------------------------------------------------
def addSubUser(self, symbol_pair, type_, price, amount):
json = "{"accesskey":"ce2a18e0-dshs-4c44-4515-9aca67dd706e","channel":"push_user_incr_record","event":"addChannel","sign":"475fdd83600e42140d2d0336b8d57ce4"}";
try:
self.ws_sub_spot.send(json)
except websocket.WebSocketConnectionClosedException:
pass
Contoh tanggapan
// Hasil Kembali
{
"market": "usdtqcdefault",
"record": [
"id",
percayakan harga,
percayakan jumlah,
Jumlah volume yang di setujui,
Jumlah transaksi yang di setujui,
Jenis pesanan tertunda0-limit sell,1-limit buy,2-PostOnly sell,3-PostOnly buy,4-IOC sell,5-IOC buy,
mempercayakan waktu,
Status pesanan:(1. Batal, 2. Selesai/Batalkan pesanan setelah sebagian selesai, 3. Pesanan tertunda/Tidak ),
Biaya transaksi,
mengabaikan,
jenis sumber: 8Web,5handphoneAPP,6InterfaceAPI,
Jenis Akun 0 Spot 1 Leverage,
ID detail pesanan,
Harga transaksi terbaru,
Kuantitas transaksi terbaru,
Waktu transaksi terakhir
],
"dataType": "userIncrRecord",
"count": 0,
"channel": "push_user_incr_record"
"lastTime": 1590806778504
}
Nama parameter | Jenis | Rentang nilai |
---|---|---|
accesskey | String | accesskey |
channel | String | push_user_incr_record |
event | String | penugasan langsungaddChannel |
market | String | zbqcdefault |
sign | String | Tanda tangan |
Nilai Kembali | Deskripsi |
---|---|
record | Percayakan saat ini |
dataType | Jenis data |
channel | saluran yang diminta |
lastTime | time |
Perubahan Akun Utama (push aset mata uang penuh)
Contoh permintaan
// request demo
{
"accesskey": "ceb1569d-7c17-xxxx-b4a1-xxxxxxxxx",
"channel": "push_user_asset",
"event": "addChannel",
"sign":"Tanda tangan"
}
// java demo
public void push_user_record() {
//TestapiKey:ce2a18e0-dshs-4c44-4515-9aca67dd706e
//TestsecretKey:c11a122s-dshs-shsa-4515-954a67dd706e
//Enkripsi:https://github.com/zb2017/api/blob/master/zb_netty_client_java/src/main/java/websocketx/client/EncryDigestUtil.java
//secretKeyDiperoleh dengan enkripsi sha1:86429c69799d3d6ac5da5c2c514baa874d75a4ba
String secret = EncryDigestUtil.digest("c11a122s-dshs-shsa-4515-954a67dd706e");
//Parameter diurutkan berdasarkan nilai ASCII
String params = "{"accesskey":"ce2a18e0-dshs-4c44-4515-9aca67dd706e","binary":false,"channel":"push_user_asset","event":"addChannel","isZip":false}";
//tanda dienkripsi oleh HmacMD5:6c9157032c96795a411a3b8628f543f5
String sign = EncryDigestUtil.hmacSign(params, secret);
//Selanjutnya kirim ke permintaan parameter server json
String json = "{"accesskey":"ce2a18e0-dshs-4c44-4515-9aca67dd706e","binary":false,"channel":"push_user_asset","sign":"6c9157032c96795a411a3b8628f543f5","isZip":false,"event":"addChannel"}";
ws.sendText(json);
}
// python demo
import hashlib
import zlib
import json
from time import sleep
from threading import Thread
import websocket
import urllib2, hashlib,struct,sha,time
zb_usd_url = "wss://api.zb.com/websocket"
class ZB_Sub_Spot_Api(object):
"""基于Websocket的API对象"""
def __init__(self):
"""Constructor"""
self.apiKey = 'ce2a18e0-dshs-4c44-4515-9aca67dd706e'
self.secretKey = 'c11a122s-dshs-shsa-4515-954a67dd706e'
self.ws_sub_spot = None # websocketObjek aplikasi Objek spot
#----------------------------------------------------------------------
def reconnect(self):
"""sambungkan kembali"""
# Tutup dulu koneksi sebelumnya
self.close()
# sambungkan kembali lagi
self.ws_sub_spot = websocket.WebSocketApp(self.host,
on_message=self.onMessage,
on_error=self.onError,
on_close=self.onClose,
on_open=self.onOpen)
self.thread = Thread(target=self.ws_sub_spot.run_forever)
self.thread.start()
#----------------------------------------------------------------------
def connect_Subpot(self, apiKey , secretKey , trace = False):
self.host = zb_usd_url
self.apiKey = apiKey
self.secretKey = secretKey
websocket.enableTrace(trace)
self.ws_sub_spot = websocket.WebSocketApp(self.host,
on_message=self.onMessage,
on_error=self.onError,
on_close=self.onClose,
on_open=self.onOpen)
self.thread = Thread(target=self.ws_sub_spot.run_forever)
self.thread.start()
#----------------------------------------------------------------------
def readData(self, evt):
"""Ekstrak dan dorong data yang diterima"""
# # Ekstrak dan dorong data yang diterima
# decompress = zlib.decompressobj(-zlib.MAX_WBITS)
# # Dekompresi data asli menjadi string
# inflated = decompress.decompress(evt) + decompress.flush()
# Parse strings via json
data = json.loads(evt)
return data
#----------------------------------------------------------------------
def close(self):
"""Interface tutup"""
if self.thread and self.thread.isAlive():
self.ws_sub_spot.close()
self.thread.join()
#----------------------------------------------------------------------
def onMessage(self, ws, evt):
"""Push informasi"""
print evt
#----------------------------------------------------------------------
def onError(self, ws, evt):
"""salah push"""
print 'onError'
print evt
#----------------------------------------------------------------------
def onClose(self, ws):
"""Putuskan Sambungan Interface"""
print 'onClose'
#----------------------------------------------------------------------
def onOpen(self, ws):
"""Buka interface"""
print 'onOpen'
#----------------------------------------------------------------------
def __fill(self, value, length, fillByte):
if len(value) >= length:
return value
else:
fillSize = length - len(value)
return value + chr(fillByte) * fillSize
#----------------------------------------------------------------------
def __doXOr(self, s, value):
slist = list(s)
for index in xrange(len(slist)):
slist[index] = chr(ord(slist[index]) ^ value)
return "".join(slist)
#----------------------------------------------------------------------
def __hmacSign(self, aValue, aKey):
keyb = struct.pack("%ds" % len(aKey), aKey)
value = struct.pack("%ds" % len(aValue), aValue)
k_ipad = self.__doXOr(keyb, 0x36)
k_opad = self.__doXOr(keyb, 0x5c)
k_ipad = self.__fill(k_ipad, 64, 54)
k_opad = self.__fill(k_opad, 64, 92)
m = hashlib.md5()
m.update(k_ipad)
m.update(value)
dg = m.digest()
m = hashlib.md5()
m.update(k_opad)
subStr = dg[0:16]
m.update(subStr)
dg = m.hexdigest()
return dg
#----------------------------------------------------------------------
def __digest(self, aValue):
value = struct.pack("%ds" % len(aValue), aValue)
h = sha.new()
h.update(value)
dg = h.hexdigest()
return dg
#----------------------------------------------------------------------
def generateSign(self, params):
#Parameter diurutkan berdasarkan nilai ASCII: {"accesskey":"ce2a18e0-dshs-4c44-4515-9aca67dd706e","channel":"addSubUser","event":"addChannel","memo":"memo","no":"test001","password":"123456","subUserName":"test1"}
#secretKey Setelah mengenkripsi:86429c69799d3d6ac5da5c2c514baa874d75a4ba
SHA_secret = self.__digest(self.secretKey)
#Hitung tandanya: 475fdd83600e42140d2d0336b8d57ce4
return self.__hmacSign( paramsStr, SHA_secret)
#----------------------------------------------------------------------
def addSubUser(self, symbol_pair, type_, price, amount):
json = "{"accesskey":"ce2a18e0-dshs-4c44-4515-9aca67dd706e","channel":"addSubUser","event":"addChannel","memo":"memo","no":"test001","password":"123456","sign":"475fdd83600e42140d2d0336b8d57ce4","subUserName":"test1"}";
try:
self.ws_sub_spot.send(json)
except websocket.WebSocketConnectionClosedException:
pass
Contoh tanggapan
// Hasil Kembali
{
"coins": [
{
"isCanWithdraw": true,
"canLoan": false,
"fundstype": 51,
"showName": "ZB",
"isCanRecharge": true,
"cnName": "ZB",
"enName": "ZB",
"available": 6011.29619163,
"freez": 20,
"unitTag": "ZB",
"key": "ZB",
"unitDecimal": 8
}
],
"dataType": "userAsset",
"channel": "push_user_asset",
"version": 1590806778504
}
Nama parameter | Jenis | Rentang nilai |
---|---|---|
accesskey | String | accesskey |
channel | String | push_user_asset |
event | String | penugasan langsungaddChannel |
sign | String | Tanda tangan |
Nilai Kembali | Deskripsi |
---|---|
coins | Informasi koin |
dataType | Jenis data |
channel | saluran yang diminta |
version | Tekan nomornya sekali dan tambahkan 1 |
Perubahan Tambahan Akun Utama (push aset mata uang yang diubah)
Contoh permintaan
// request demo
{
"accesskey": "ceb1569d-7c17-xxxx-b4a1-xxxxxxxxx",
"channel": "push_user_incr_asset",
"event": "addChannel",
"sign":"Tanda tangan"
}
// java demo
public void push_user_incr_asset() {
//TestapiKey:ce2a18e0-dshs-4c44-4515-9aca67dd706e
//TestsecretKey:c11a122s-dshs-shsa-4515-954a67dd706e
//Enkripsi:https://github.com/zb2017/api/blob/master/zb_netty_client_java/src/main/java/websocketx/client/EncryDigestUtil.java
//secretKeyDiperoleh dengan enkripsi sha1:86429c69799d3d6ac5da5c2c514baa874d75a4ba
String secret = EncryDigestUtil.digest("c11a122s-dshs-shsa-4515-954a67dd706e");
//Parameter diurutkan berdasarkan nilai ASCII
String params = "{"accesskey":"ce2a18e0-dshs-4c44-4515-9aca67dd706e","channel":"push_user_incr_asset","event":"addChannel"}";
//tanda dienkripsi oleh HmacMD5:6c9157032c96795a411a3b8628f543f5
String sign = EncryDigestUtil.hmacSign(params, secret);
//Selanjutnya kirim ke permintaan parameter server json
String json = "{"accesskey":"ce2a18e0-dshs-4c44-4515-9aca67dd706e","channel":"push_user_incr_asset","sign":"6c9157032c96795a411a3b8628f543f5","event":"addChannel"}";
ws.sendText(json);
}
// python demo
import hashlib
import zlib
import json
from time import sleep
from threading import Thread
import websocket
import urllib2, hashlib,struct,sha,time
zb_usd_url = "wss://api.zb.com/websocket"
class ZB_Sub_Spot_Api(object):
"""基于Websocket的API对象"""
def __init__(self):
"""Constructor"""
self.apiKey = 'ce2a18e0-dshs-4c44-4515-9aca67dd706e'
self.secretKey = 'c11a122s-dshs-shsa-4515-954a67dd706e'
self.ws_sub_spot = None # websocketObjek aplikasi Objek spot
#----------------------------------------------------------------------
def reconnect(self):
"""sambungkan kembali"""
# Tutup dulu koneksi sebelumnya
self.close()
# sambungkan kembali lagi
self.ws_sub_spot = websocket.WebSocketApp(self.host,
on_message=self.onMessage,
on_error=self.onError,
on_close=self.onClose,
on_open=self.onOpen)
self.thread = Thread(target=self.ws_sub_spot.run_forever)
self.thread.start()
#----------------------------------------------------------------------
def connect_Subpot(self, apiKey , secretKey , trace = False):
self.host = zb_usd_url
self.apiKey = apiKey
self.secretKey = secretKey
websocket.enableTrace(trace)
self.ws_sub_spot = websocket.WebSocketApp(self.host,
on_message=self.onMessage,
on_error=self.onError,
on_close=self.onClose,
on_open=self.onOpen)
self.thread = Thread(target=self.ws_sub_spot.run_forever)
self.thread.start()
#----------------------------------------------------------------------
def readData(self, evt):
"""Ekstrak dan dorong data yang diterima"""
# # Ekstrak dan dorong data yang diterima
# decompress = zlib.decompressobj(-zlib.MAX_WBITS)
# # Dekompresi data asli menjadi string
# inflated = decompress.decompress(evt) + decompress.flush()
# Parse strings via json
data = json.loads(evt)
return data
#----------------------------------------------------------------------
def close(self):
"""Interface tutup"""
if self.thread and self.thread.isAlive():
self.ws_sub_spot.close()
self.thread.join()
#----------------------------------------------------------------------
def onMessage(self, ws, evt):
"""Push informasi"""
print evt
#----------------------------------------------------------------------
def onError(self, ws, evt):
"""salah push"""
print 'onError'
print evt
#----------------------------------------------------------------------
def onClose(self, ws):
"""Putuskan Sambungan Interface"""
print 'onClose'
#----------------------------------------------------------------------
def onOpen(self, ws):
"""Buka interface"""
print 'onOpen'
#----------------------------------------------------------------------
def __fill(self, value, length, fillByte):
if len(value) >= length:
return value
else:
fillSize = length - len(value)
return value + chr(fillByte) * fillSize
#----------------------------------------------------------------------
def __doXOr(self, s, value):
slist = list(s)
for index in xrange(len(slist)):
slist[index] = chr(ord(slist[index]) ^ value)
return "".join(slist)
#----------------------------------------------------------------------
def __hmacSign(self, aValue, aKey):
keyb = struct.pack("%ds" % len(aKey), aKey)
value = struct.pack("%ds" % len(aValue), aValue)
k_ipad = self.__doXOr(keyb, 0x36)
k_opad = self.__doXOr(keyb, 0x5c)
k_ipad = self.__fill(k_ipad, 64, 54)
k_opad = self.__fill(k_opad, 64, 92)
m = hashlib.md5()
m.update(k_ipad)
m.update(value)
dg = m.digest()
m = hashlib.md5()
m.update(k_opad)
subStr = dg[0:16]
m.update(subStr)
dg = m.hexdigest()
return dg
#----------------------------------------------------------------------
def __digest(self, aValue):
value = struct.pack("%ds" % len(aValue), aValue)
h = sha.new()
h.update(value)
dg = h.hexdigest()
return dg
#----------------------------------------------------------------------
def generateSign(self, params):
#Parameter diurutkan berdasarkan nilai ASCII: {"accesskey":"ce2a18e0-dshs-4c44-4515-9aca67dd706e","channel":"push_user_incr_asset","event":"addChannel"}
#secretKey Setelah mengenkripsi:86429c69799d3d6ac5da5c2c514baa874d75a4ba
SHA_secret = self.__digest(self.secretKey)
#Hitung tandanya: 475fdd83600e42140d2d0336b8d57ce4
return self.__hmacSign( paramsStr, SHA_secret)
#----------------------------------------------------------------------
def addSubUser(self, symbol_pair, type_, price, amount):
json = "{"accesskey":"ce2a18e0-dshs-4c44-4515-9aca67dd706e","channel":"push_user_incr_asset","event":"addChannel","sign":"475fdd83600e42140d2d0336b8d57ce4"}";
try:
self.ws_sub_spot.send(json)
except websocket.WebSocketConnectionClosedException:
pass
Contoh tanggapan
// Hasil Kembali
{
"coins": [
{
"isCanWithdraw": true,
"canLoan": false,
"fundstype": 51,
"showName": "ZB",
"isCanRecharge": true,
"cnName": "ZB",
"enName": "ZB",
"available": 6011.29619163,
"freez": 20,
"unitTag": "ZB",
"key": "ZB",
"unitDecimal": 8
}],
"dataType": "userIncrAsset",
"channel": "push_user_incr_asset",
"version": 1590806778504
}
Nama parameter | Jenis | Rentang nilai |
---|---|---|
accesskey | String | accesskey |
channel | String | push_user_incr_asset |
event | String | penugasan langsungaddChannel |
sign | String | Tanda tangan |
Nilai Kembali | Deskripsi |
---|---|
coins | Informasi koin |
dataType | Jenis data |
channel | saluran yang diminta |
version | Tekan nomornya sekali dan tambahkan 1 |
Berlangganan Perubahan Aset Leveraged
Contoh permintaan
// request demo
{
"accesskey": "ceb1569d-7c17-xxxx-b4a1-xxxxxxxxx",
"binary": "false",
"channel": "push_user_lever_asset",
"event": "addChannel",
"isZip": "false",
"sign":"Tanda tangan"
}
// java demo
public void push_user_lever_asset() {
//TestapiKey:ce2a18e0-dshs-4c44-4515-9aca67dd706e
//TestsecretKey:c11a122s-dshs-shsa-4515-954a67dd706e
//Enkripsi:https://github.com/zb2017/api/blob/master/zb_netty_client_java/src/main/java/websocketx/client/EncryDigestUtil.java
//secretKeyDiperoleh dengan enkripsi sha1:86429c69799d3d6ac5da5c2c514baa874d75a4ba
String secret = EncryDigestUtil.digest("c11a122s-dshs-shsa-4515-954a67dd706e");
//Parameter diurutkan berdasarkan nilai ASCII
String params = "{"accesskey":"ce2a18e0-dshs-4c44-4515-9aca67dd706e","binary":false,"channel":"push_user_lever_asset","event":"addChannel","isZip":false}";
//tanda dienkripsi oleh HmacMD5:6c9157032c96795a411a3b8628f543f5
String sign = EncryDigestUtil.hmacSign(params, secret);
//Selanjutnya kirim ke permintaan parameter server json
String json = "{"accesskey":"ce2a18e0-dshs-4c44-4515-9aca67dd706e","binary":false,"channel":"push_user_lever_asset","sign":"6c9157032c96795a411a3b8628f543f5","isZip":false,"event":"addChannel"}";
ws.sendText(json);
}
// python demo
import hashlib
import zlib
import json
from time import sleep
from threading import Thread
import websocket
import urllib2, hashlib,struct,sha,time
zb_usd_url = "wss://api.zb.com/websocket"
class ZB_Sub_Spot_Api(object):
"""基于Websocket的API对象"""
def __init__(self):
"""Constructor"""
self.apiKey = 'ce2a18e0-dshs-4c44-4515-9aca67dd706e'
self.secretKey = 'c11a122s-dshs-shsa-4515-954a67dd706e'
self.ws_sub_spot = None # websocketObjek aplikasi Objek spot
#----------------------------------------------------------------------
def reconnect(self):
"""sambungkan kembali"""
# Tutup dulu koneksi sebelumnya
self.close()
# sambungkan kembali lagi
self.ws_sub_spot = websocket.WebSocketApp(self.host,
on_message=self.onMessage,
on_error=self.onError,
on_close=self.onClose,
on_open=self.onOpen)
self.thread = Thread(target=self.ws_sub_spot.run_forever)
self.thread.start()
#----------------------------------------------------------------------
def connect_Subpot(self, apiKey , secretKey , trace = False):
self.host = zb_usd_url
self.apiKey = apiKey
self.secretKey = secretKey
websocket.enableTrace(trace)
self.ws_sub_spot = websocket.WebSocketApp(self.host,
on_message=self.onMessage,
on_error=self.onError,
on_close=self.onClose,
on_open=self.onOpen)
self.thread = Thread(target=self.ws_sub_spot.run_forever)
self.thread.start()
#----------------------------------------------------------------------
def readData(self, evt):
"""Ekstrak dan dorong data yang diterima"""
# # Ekstrak dan dorong data yang diterima
# decompress = zlib.decompressobj(-zlib.MAX_WBITS)
# # Dekompresi data asli menjadi string
# inflated = decompress.decompress(evt) + decompress.flush()
# Parse strings via json
data = json.loads(evt)
return data
#----------------------------------------------------------------------
def close(self):
"""Interface tutup"""
if self.thread and self.thread.isAlive():
self.ws_sub_spot.close()
self.thread.join()
#----------------------------------------------------------------------
def onMessage(self, ws, evt):
"""Push informasi"""
print evt
#----------------------------------------------------------------------
def onError(self, ws, evt):
"""salah push"""
print 'onError'
print evt
#----------------------------------------------------------------------
def onClose(self, ws):
"""Putuskan Sambungan Interface"""
print 'onClose'
#----------------------------------------------------------------------
def onOpen(self, ws):
"""Buka interface"""
print 'onOpen'
#----------------------------------------------------------------------
def __fill(self, value, length, fillByte):
if len(value) >= length:
return value
else:
fillSize = length - len(value)
return value + chr(fillByte) * fillSize
#----------------------------------------------------------------------
def __doXOr(self, s, value):
slist = list(s)
for index in xrange(len(slist)):
slist[index] = chr(ord(slist[index]) ^ value)
return "".join(slist)
#----------------------------------------------------------------------
def __hmacSign(self, aValue, aKey):
keyb = struct.pack("%ds" % len(aKey), aKey)
value = struct.pack("%ds" % len(aValue), aValue)
k_ipad = self.__doXOr(keyb, 0x36)
k_opad = self.__doXOr(keyb, 0x5c)
k_ipad = self.__fill(k_ipad, 64, 54)
k_opad = self.__fill(k_opad, 64, 92)
m = hashlib.md5()
m.update(k_ipad)
m.update(value)
dg = m.digest()
m = hashlib.md5()
m.update(k_opad)
subStr = dg[0:16]
m.update(subStr)
dg = m.hexdigest()
return dg
#----------------------------------------------------------------------
def __digest(self, aValue):
value = struct.pack("%ds" % len(aValue), aValue)
h = sha.new()
h.update(value)
dg = h.hexdigest()
return dg
#----------------------------------------------------------------------
def generateSign(self, params):
#Parameter diurutkan berdasarkan nilai ASCII: {"accesskey":"ce2a18e0-dshs-4c44-4515-9aca67dd706e","channel":"addSubUser","event":"addChannel","memo":"memo","no":"test001","password":"123456","subUserName":"test1"}
#secretKey Setelah mengenkripsi:86429c69799d3d6ac5da5c2c514baa874d75a4ba
SHA_secret = self.__digest(self.secretKey)
#Hitung tandanya: 475fdd83600e42140d2d0336b8d57ce4
return self.__hmacSign( paramsStr, SHA_secret)
#----------------------------------------------------------------------
def addSubUser(self, symbol_pair, type_, price, amount):
json = "{"accesskey":"ce2a18e0-dshs-4c44-4515-9aca67dd706e","channel":"addSubUser","event":"addChannel","memo":"memo","no":"test001","password":"123456","sign":"475fdd83600e42140d2d0336b8d57ce4","subUserName":"test1"}";
try:
self.ws_sub_spot.send(json)
except websocket.WebSocketConnectionClosedException:
pass
Contoh tanggapan
// Hasil Kembali
{
"levers": [],
"dataType": "userLeverAsset",
"channel": "push_user_lever_asset"
"usdtcny": 7.0835
}
Nama parameter | Jenis | Rentang nilai |
---|---|---|
accesskey | String | accesskey |
binary | boolean | Apakah transmisi biner |
channel | String | push_user_lever_asset |
event | String | penugasan langsungaddChannel |
isZip | boolean | Apakah akan mengompresi transmisi |
sign | String | Tanda tangan |
Nilai Kembali | Deskripsi |
---|---|
levers | mengubah informasi |
dataType | Jenis data |
channel | saluran yang diminta |
usdtcny | Nilai tukar dollar AS |
订阅全仓杠杆资产变更
Contoh permintaan
// request demo
{
"accesskey": "ceb1569d-7c17-xxxx-b4a1-xxxxxxxxx",
"binary": "false",
"channel": "push_user_cross_asset",
"event": "addChannel",
"isZip": "false",
"sign":"Tanda tangan"
}
Contoh tanggapan
// Hasil Kembali
{
"coins": [
{
"loanIn": 11.1,
"fundType": 3,
"amount": 10,
"freeze": 0,
"overdrafr": 0,
"userId": 1124,
"key": "ltc",
"status": 0
}
......
]
"dataType": "userAsset",
"channel": "push_user_cross_asset"
"usdtcny": 7.0835
}
Nama parameter | Jenis | Rentang nilai |
---|---|---|
accesskey | String | accesskey |
binary | boolean | Apakah transmisi biner |
channel | String | push_user_cross_asset |
event | String | penugasan langsungaddChannel |
isZip | boolean | Apakah akan mengompresi transmisi |
sign | String | Tanda tangan |
Nilai Kembali | Deskripsi |
---|---|
coins | |
loanIn | meminjam |
fundType | Jenis koin |
amount | mengubah informasi |
freeze | Pembekuan koin |
overdraft | Bunga |
key | Nama koin |
dataType | Jenis data |
channel | saluran yang diminta |
usdtcny | Nilai tukar dollar AS |
Metode enkripsi
- accesskey=08b38d11-445f-447f-9372-d255e10b91bd
- secretKey=ad030fda-86c1-4d9e-b333-fefbc1fb89e8
Alat enkripsi online: http://tool.oschina.net/encrypt?type=2
Langkah pertama: menggunakansha1 加密 secretKey mendapatkan 5b1f87b2375ad8e46abf5e8ac4577c50dcee7989
tahap kedua: Kalkulasisign
- demoDapatkan informasi pengguna, dan sambungkan parameter yang sesuai untuk mendapatkan hasil akhir:
- rest:accesskey=08b38d11-445f-447f-9372-d255e10b91bd&method=getAccountInfo;
- ws:{"accesskey":"08b38d11-445f-447f-9372-d255e10b91bd","channel":"getaccountinfo","event":"addChannel","no":"1231231233431"}
- Untuk setiap interface, semua parameter (kecuali tanda dan reqTime) '?' Perlu dihitung sebagai teks yang jelas
- String terenkripsi tidak boleh memiliki spasi
- menggunakansecretKeymelewatisha1string terenkripsi:5b1f87b2375ad8e46abf5e8ac4577c50dcee7989 sebagai nilai hash
- Hitung akhirnyasign, rest:48a1af2ea626dde38134ff8a51d8d0c3;ws:9ee1b7201261fd530630cc9bc384a3b1
Masalah umum
MembukaAPI?
- Masuk dan akses tautan ini untuk Pengaturan APIhttps://vip.zb.com/u/safe/api
- Tekan Pengaturan API---->Tekan untuk aktifkan API---->Objek API berbasis websocket---->Mengaktifkan
- Jika Anda mengikat IP Trade API, Anda hanya dapat menggunakan IP terikat untuk perdagangan, jika tidak, tidak ada batasan.
Apa gunanya kunci yang dihasilkan??
- Kunci pribadi adalah kunci yang digunakan untuk operasi API, yang diperlukan saat memanggil interface API. Kunci pribadi hanya ditampilkan sekali saat dibuat, dan perlu dibuat ulang jika Anda lupa
Mengapa kesalahan 1003 terjadi?
- Periksa apakah enkripsi diurutkan berdasarkan nilai ASCII dan apakah parameter enkripsi tidak ada atau memiliki rangkaian karakter yang berlebihan, dll.
- Prompt 1002 kesalahan parameter tidak valid
- Parameter transfer tidak valid
- Bisakah K-line chart memperoleh data bulan atau tahun yang lalu?
- Sistem hanya menyediakan data hingga 1000 K-line. Jika ingin mendapatkan data waktu yang lebih lama, Anda dapat menggunakan satuan jam atau hari.
api的ip是否需要绑定?
- Apakah IP API perlu diikat?
- IP yang terikat harus merupakan IP statis dari jaringan publik dan klien PC yang dikembangkan secara pribadi tidak perlu mengikat IP. Setelah mengikat IP, hanya IP yang mengikat yang dapat mengakses API, jika tidak, tidak ada batasan.
- Transaksi API tetap kosong tidak akan memiliki batasan
Apakah API mendukung penarikan acak??
- Tidak didukung, Anda harus terlebih dahulu memverifikasi alamat penarikan di situs web resmi zb sebelum Anda dapat menarik diri dari API
- Diperlukan untuk memberikan kata sandi saat melakukan penarikan melalui API
Dapatkah saya memberikan kunci publik atau kunci pribadi kepada orang lain??
- Harap jangan membocorkan kunci publik atau kunci rahasia Anda kepada orang lain, jika tidak maka akan mengakibatkan hilangnya aset Anda.
qcApakah itu RMB
- 不是,qc和人民币是1:1换算的
- Mengapa ada kesalahan internal 1002
- Terkadang, volume permintaan yang berlebihan dapat menyebabkan kesalahan ini, harap ingat untuk penggunaan normal
Kode Kesalahan
restReturn Code
Return Code | Deskripsi |
---|---|
1000 | panggilan sukses |
1001 | Pesan error |
1002 | Kesalahan internal |
1003 | Verifikasi gagal |
1004 | Kata sandi transaksi terkunci |
1005 | Kata sandi transaksi salah, silakan periksa dan masukkan kembali。 |
1006 | Otentikasi nama asli menunggu persetujuan atau tidak disetujui |
1009 | Interface ini sedang dalam maintenance |
1010 | tutup sementara |
1012 | Izin tidak memadai |
1013 | Tidak dapat diperdagangkan, jika Anda memiliki pertanyaan, silakan hubungi layanan pelanggan online |
1014 | Tidak dapat menjual selama periode pra-penjualan |
2001 | Saldo akun CNY tidak mencukupi |
2002 | Saldo akun BTC tidak mencukupi |
2003 | Saldo akun LTC tidak mencukupi |
2005 | Saldo akun ETH tidak mencukupi |
2006 | ETCSaldo anda tidak mencukupi |
2007 | BTSSaldo anda tidak mencukupi |
2008 | EOSSaldo anda tidak mencukupi |
2009 | BCCSaldo anda tidak mencukupi |
3001 | Pesanan tidak ditemukan atau selesai |
3002 | Jumlah tidak sah |
3003 | Jumlah tidak valid |
3004 | User tidak ada |
3005 | Parameter tidak sah |
3006 | IP tidak valid atau tidak sesuai dengan IP yang terikat |
3007 | Waktu permintaan kedaluwarsa |
3008 | Transaksi tidak ditemukan |
3009 | Harga melebihi batas |
3010 | Gagal melakukan pemesanan, karena Anda telah mengatur untuk melarang perdagangan pasar ini. |
3011 | Harga yang dipercayakan tidak normal, harap ubah dan pesan lagi |
3012 | Duplikat customerOrderId kustom |
4001 | APIInterface terkunci selama satu jam |
4002 | Terlalu sering meminta |
websocketReturn Code
Return Code | Deskripsi |
---|---|
1000 | panggilan sukses |
1001 | Pesan error |
1002 | Kesalahan internal |
1003 | Verifikasi gagal |
1004 | Kata sandi transaksi terkunci |
1005 | Kata sandi transaksi salah, silakan periksa dan masukkan kembali。 |
1006 | Otentikasi nama asli menunggu persetujuan atau tidak disetujui |
1007 | saluran tidak ada |
1009 | Interface ini sedang dalam maintenance |
1010 | tutup sementara |
1012 | Izin tidak memadai |
1013 | Tidak dapat diperdagangkan, jika Anda memiliki pertanyaan, silakan hubungi layanan pelanggan online |
1014 | Tidak dapat menjual selama periode pra-penjualan |
2001 | Saldo akun CNY tidak mencukupi |
2002 | Saldo akun BTC tidak mencukupi |
2003 | Saldo akun LTC tidak mencukupi |
2005 | Saldo akun ETH tidak mencukupi |
2006 | ETCSaldo anda tidak mencukupi |
2007 | BTSSaldo anda tidak mencukupi |
2008 | EOSSaldo anda tidak mencukupi |
2009 | BCCSaldo anda tidak mencukupi |
3001 | Pesanan tidak ditemukan atau selesai |
3002 | Jumlah tidak sah |
3003 | Jumlah tidak valid |
3004 | User tidak ada |
3005 | Parameter tidak sah |
3006 | IP tidak valid atau tidak sesuai dengan IP yang terikat |
3007 | Waktu permintaan kedaluwarsa |
3008 | Transaksi tidak ditemukan |
3009 | Harga melebihi batas |
3010 | Gagal melakukan pemesanan, karena Anda telah mengatur untuk melarang perdagangan pasar ini. |
3011 | Harga yang dipercayakan tidak normal, harap ubah dan pesan lagi |
3012 | Duplikat customerOrderId kustom |
4001 | APIInterface terkunci selama satu jam |
4002 | Terlalu sering meminta |
Hubungi kami
ZB中币现面向全球征集做市商,做市商享有maker返佣、taker超低费率,如果您对做市商计划感兴趣,请联系[email protected]或您的大客户经理。 请将以下信息发至[email protected]:
有效联系方式(微信或电话)
简要介绍团队情况及过往做市情况(30天内成交量、做市策略等)