Perbarui Log

waktu mulai berlakuInterfaceRingkasan
2022-03-28rest cancelAllOrdersAfter/getSpotBills新增接口:rest cancelAllOrdersAfter/getSpotBills 定时取消委托/获取现货账单
2022-03-17rest cancelOrder修改接口:Rest cancelOrder 接口新添加下单数量、下单价格、成交总额、成交数量
2022-03-17ws kline/ws push_user_cross_asset新增接口:websocket k线接口和全仓杠杆推送接口
2022-03-01setExpressState/setRepayState新增接口:setExpressState/setRepayState
2021-09-18klineWebsocket API push_user_incr_record Interface baru menambahkan empat bidang dari ID transaksi terbaru, harga, kuantitas, dan waktu
2021-07-16klineBidang simbol nilai pengembalian interface diubah menjadi huruf besar
2021-07-16all interfaceSemua 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-16getFeeInfoHapus API untuk 'createSubUserKey
2021-03-16restPasarUbah HTTP ke HTTPS
2020-12-31push_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.

github Kode sampel

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 KembaliDeskripsi
priceScale价格小数位数
minAmountJumlah transaksi minimum dalam mata uang transaksi
minSizeKuantitas transaksi minimum dalam mata uang harga
amountScaleTempat 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 KembaliDeskripsi
highharga tertinggi
lowharga terendah
buyBeli 1
sellJual 1
lastHarga transaksi terbaru
openharga pembukaan
riseRatePerubahan 24 jam
volVolume (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 parameterJenisRentang nilai
marketStringSampel:btc_qc

Nilai KembaliDeskripsi
highharga tertinggi
lowharga terendah
buyBeli 1
sellJual 1
lastHarga transaksi terbaru
openharga pembukaan
riseRatePerubahan 24 jam
volVolume (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 parameterJenisRentang nilai
marketStringSampel:btc_qc
sizeintRentang posisi dari 1 hingga 50, jika ada kedalaman kombinasi, itu hanya mengembalikan 5 posisi
mergefloatdepth default

Nilai KembaliDeskripsi
asksJual Order Depth
bidsBeli pesanan
timestampStempel 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 parameterJenisRentang nilai
marketStringSampel:btc_qc
sincelong50 buah data setelah ID transaksi yang ditentukan

Nilai KembaliDeskripsi
dateWaktu transaksi(stempel waktu)
priceHarga transaksi
amountJumlah transaksi
tidGenerate transaksiID
trade_typeJenis Pesanan: Tanya dan TawarID
typeJenis 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 parameterJenisRentang nilai
marketStringSampel:btc_qc
typeString1min/3min/5min/15min/30min/1day/3day/1week/1hour/2hour/4hour/6hour/12hour
sincelongSetelah stempel waktu ini
sizeintBatas pengembalian data (default 1000, hanya mengembalikan 1000 data jika ada lebih dari 1000 data)

Nilai KembaliDeskripsi
dataKonten K line
1472107500000Stempel waktu
3840.46Buka
3843.56Tinggi
3839.58Rendah
3843.3menerima
492.456Volume
moneyTypeBeli mata uang
symbolJual 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 parameterJenisRentang nilai
methodStringpenugasan langsunggetAccountInfo
accesskeyStringaccesskey
signStringMinta string tanda tangan terenkripsi
reqTimelongwaktu saat ini dalam milidetik

Nilai KembaliDeskripsi
auth_google_enabledApakah akan mengaktifkan verifikasi google
auth_mobile_enabledApakah akan mengaktifkan verifikasi ponsel
trade_password_enabledApakah atau tidak mengaktifkan kata sandi transaksi
usernameNama pengguna
keyBunga yang telah jatuh tempo
enameBahasa inggris koin
cnNameNama koin Cina
showNameGunakan nama baru jika diganti namanya,jika tidak samaename
unitTagSimbol koin
isCanRechargeApakah tersedia untuk deposit?
isCanWithdrawApakah tersedia untuk ditarik?
canLoanApakah layak secara finansial?
izin
leverPermmanajemen margin:Manajemen investasi、Manajemen Pinjaman
assetPermAset query:query informasi dan aset akun
entrustPermEntrust Trade:委托、Cancel、Permintaan pesanan transaksi
moneyPermDeposit dan Penarikan:Dapatkan deposit、Alamat penarikan dan catatan,Memulai bisnis penarikan

获取现货账单

Contoh permintaan


// request demo
GET https://trade.zb.com/api/getSpotBills?accesskey=youraccesskey&currency=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 parameterJenisApakah perlu?Rentang nilai
methodStringyespenugasan langsung getSpotBills
accesskeyStringyesaccesskey
currencyStringnoNama koin
startDateStringnoWaktu mulai
endDateStringnoAkhir waktu
dataTypeStringno0: <= 48h; 1: > 48h
pageIndexStringnoStandarnya adalah 1
pageSizeStringnoStandarnya adalah 10,(10 ~ 50)

Nilai KembaliDeskripsi
codeKode Pengembalian
messagePetunjuk
balanceSaldo
changeAmountperubahan iniCOINJumlah
currencyNameNama koin
date日期
idID
remarkRemark
showDatewaktu
totalSaldo
typeDescJenis 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&currency=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&currency=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&currency=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&currency=bch&method=getUserAddress'
        params = 'accesskey=' + self._access_key_ + '&currency=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&currency=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 parameterJenisRentang nilai
methodStringpenugasan langsunggetUserAddress
accesskeyStringaccesskey
currencyStringBunga yang telah jatuh tempo
signStringMinta string tanda tangan terenkripsi
reqTimelongwaktu saat ini dalam milidetik

Nilai KembaliDeskripsi
keyAlamat

Dapatkan beberapa alamat setoran berantai

Contoh permintaan


// request demo
GET https://trade.zb.com/api/getPayinAddress?accesskey=youraccesskey&currency=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&currency=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&currency=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&currency=usdt&method=getPayinAddress'
        params = 'accesskey=' + self._access_key_ + '&currency=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&currency=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 parameterJenisRentang nilai
methodStringpenugasan langsunggetPayinAddress
accesskeyStringaccesskey
currencyStringBunga yang telah jatuh tempo
signStringMinta string tanda tangan terenkripsi
reqTimelongwaktu saat ini dalam milidetik

Nilai KembaliDeskripsi
blockChainBlock
canDepositApakah akan menyetor
canWithdrawDapat menarik koin
isUseMemoApakah akan menggunakan memo atau tag. Jika 'benar', informasi setoran menggunakan 'akun+memo', jika tidak menggunakan alamat
addressAlamat deposit, ketika isUseMemo=false
accountAkun, ketika isUseMemo=true
memomemo atau tag, ketika isUseMemo=true

获取提现地址

Dapatkan alamat penarikan verifikasi pengguna

Contoh permintaan


// request demo
GET https://trade.zb.com/api/getWithdrawAddress?accesskey=youraccesskey&currency=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&currency=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&currency=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&currency=btc&method=getWithdrawAddress'
        params = 'accesskey=' + self._access_key_ + '&currency=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&currency=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 parameterJenisRentang nilai
methodStringpenugasan langsunggetWithdrawAddress
accesskeyStringaccesskey
currencyStringBunga yang telah jatuh tempo
signStringMinta string tanda tangan terenkripsi
reqTimelongwaktu saat ini dalam milidetik

Nilai KembaliDeskripsi
keyAlamat

Dapatkan alamat penarikan

Contoh permintaan


// request demo
GET https://trade.zb.com/api/getWithdrawRecord?accesskey=youraccesskey&currency=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&currency=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&currency=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&currency=bch&method=getWithdrawRecord&pageIndex=1&pageSize=10'
        params = 'accesskey=' + self._access_key_ + '&currency=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&currency=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 parameterJenisRentang nilai
methodStringpenugasan langsunggetWithdrawRecord
accesskeyStringaccesskey
currencyStringBunga yang telah jatuh tempo
pageIndexintnomor halaman saat ini(Seperti: 1, halaman 1)
pageSizeintKuantitas per halaman
signStringMinta string tanda tangan terenkripsi
reqTimelongwaktu saat ini dalam milidetik

Nilai KembaliDeskripsi
codeKode Pengembalian
messagePetunjuk
amountJumlah penarikan
feesBiaya jaringan
idCatatan penarikanid
manageTimeStempel waktu untuk waktu pemrosesan penarikan
statusStatus penarikan(0Kirimkan,1Gagal,2Berhasil,3Cancel,5dikonfirmasi)
submitTimeStempel waktu untuk waktu pengiriman penarikan
toAddressAlamat penerima penarikan
merchantOrderNoNomor pesanan merchant
hashNomor transaksi penarikan

Dapatkan catatan deposit

Contoh permintaan


// request demo
GET https://trade.zb.com/api/getChargeRecord?accesskey=youraccesskey&currency=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&currency=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&currency=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&currency=bch&method=getChargeRecord&pageIndex=1&pageSize=10'
        params = 'accesskey=' + self._access_key_ + '&currency=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&currency=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 parameterJenisRentang nilai
methodStringpenugasan langsunggetChargeRecord
accesskeyStringaccesskey
currencyStringBunga yang telah jatuh tempo
pageIndexintnomor halaman saat ini(Seperti: 1, halaman 1)
pageSizeintKuantitas per halaman
signStringMinta string tanda tangan terenkripsi
reqTimelongwaktu saat ini dalam milidetik

Nilai KembaliDeskripsi
codeKode Pengembalian
messagePetunjuk
amountJumlah deposit
confirmTimesKonfirmasi Deposit
currencyJenis koin setoran(modal)
descriptionDeskripsi status catatan setoran
hashDeposit ID
idCatatan depositid
itransferApakah transfer internal,1iya0tidak
statusStatus(0Menunggu kepastian,1Deposit gagal,2Deposit sukses)
submit_timeWaktu Deposit
addressAlamat 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 parameterJenisRentang nilai
methodStringpenugasan langsunggetFeeInfo
currencyStringBunga yang telah jatuh tempo
Nilai KembaliDeskripsi
chainNameBlockchain
feeDapatkan biaya penarikan
mainChainNamemainChainName
canDepositBisa di isi ulang?
canWithdrawApakah mungkin untuk menarik?

Penarikan

Contoh permintaan


// request demo
GET https://trade.zb.com/api/withdraw?accesskey=youraccesskey&amount=0.0004&currency=etc&fees=0.0003⁢ransfer=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&currency=ada&fees=0.05⁢ransfer=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&currency=ada&fees=0.05⁢ransfer=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&currency=ada&fees=0.05⁢ransfer=0&method=withdraw&receiveAddr=Alamatstring&safePwd=123456bb'
        params = 'accesskey=' + self._access_key_ + '&amount=1.5&currency=ada&fees=0.05⁢ransfer=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&currency=ada&fees=0.05⁢ransfer=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 parameterJenisRentang nilai
accesskeyStringaccesskey
amountfloatJumlah penarikan
currencyStringBunga yang telah jatuh tempo
feesfloatBiaya Penarikan Penambang
itransferintSetuju atau tidakbitbanktransfer internal(0Tidak setuju,1Setuju,Tidak setuju secara default)
methodStringpenugasan langsungwithdraw
receiveAddrStringAlamat penerima(Itu harus alamat yang diverifikasi,btsjika,menggunakan"Akun_Remark"format seperti itu)
safePwdStringKata Sandi Transaksi
signStringMinta string tanda tangan terenkripsi
reqTimelongwaktu saat ini dalam milidetik

Nilai KembaliDeskripsi
codeKode Pengembalian
messagePetunjuk
idCatatan 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&currency=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&currency=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&currency=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_) &lt; 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&currency=zb_qc&method=order&price=1.0&tradeType=1'
        params = 'accesskey=' + self._access_key_ + '&acctType=0&amount=0.001&currency=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&currency=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 parameterJenisRentang nilai
methodStringpenugasan langsungorder
accesskeyStringaccesskey
acctTypeintMargin 0/1/2[Spot/Leverage Terisolasi/Leverage posisi silang](Pilihan lain,Standarnya adalah: 0 Spot)
enableExpressint自动借币 true/false(Pilihan lain,Standarnya adalah: false)
enableRepayintpembayaran otomatis true/false(Pilihan lain,Standarnya adalah: false)
amountfloatJumlah transaksi
currencyStringTransaksi koin/harga koin
customerOrderIdStringCustom 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.
orderTypeintjenis pesanan1/2[PostOnly/IOC]Opsional, kosong, atau pesanan batas lainnya
pricefloatHarga
tradeTypeintTipe transaksi1/0[buy/sell]
signStringMinta string tanda tangan terenkripsi
reqTimelongwaktu saat ini dalam milidetik

Nilai KembaliDeskripsi
codeKode Pengembalian
messagePetunjuk
idNomor 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_) &lt; 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 parameterJenisRentang nilai
methodStringpenugasan langsungorderMoreV2
accesskeyStringaccesskey
marketStringTransaksi koin/harga koin
tradeParamsStringParameter perdagangan, format array [[harga, Jumlah],[harga, Jumlah]], hingga 20
tradeTypeintTipe transaksi1/0[buy/sell]
signStringMinta string tanda tangan terenkripsi
reqTimelongwaktu saat ini dalam milidetik
acctTypeintMargin 0/1/2[Spot/Leverage Terisolasi/Leverage posisi silang](Pilihan lain,Standarnya adalah: 0 Spot)

Nilai KembaliDeskripsi
codeKode Pengembalian
messagePetunjuk
datanomor urut id array

Cancel Order

Contoh permintaan


// request demo
GET https://trade.zb.com/api/cancelOrder?accesskey=youraccesskey&currency=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&currency=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&currency=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&currency=zb_qc&id=20180522105585216&method=cancelOrder'
        params = 'accesskey=' + self._access_key_ + '&currency=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&currency=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 parameterJenisRentang nilai
methodStringpenugasan langsungcancelOrder
accesskeyStringaccesskey
currencyStringTransaksi koin/harga koin
idlongNomor pesanan yang dipercayakan
signStringMinta string tanda tangan terenkripsi
reqTimelongwaktu saat ini dalam milidetik
customerOrderIdStringCustom ID(4-36 karakter, angka atau huruf, hanya satu ID Pesanan dan ID pelanggan yang dapat diisi)

Nilai KembaliDeskripsi
codeKode Pengembalian
messagePetunjuk
amountJumlah pesanan
priceHarga
completeMontyJumlah transaksi yang di setujui
completeAmountJumlah volume yang di setujui

定时取消委托

定时一分钟后取消委托,再次访问刷新时间

Contoh permintaan


// request demo
GET https://trade.zb.com/api/cancelAllOrdersAfter?accesskey=youraccesskey&currency=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 parameterJenisRentang nilai
methodStringpenugasan langsung cancelAllOrdersAfter
accesskeyStringaccesskey
currencyStringTransaksi koin/harga koin

Nilai KembaliDeskripsi
codeKode Pengembalian
messagePetunjuk

dapatkan pesanan

Dapatkan satu pesanan beli atau jual pesanan

Contoh permintaan


// request demo
GET https://trade.zb.com/api/getOrder?accesskey=youraccesskey&currency=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&currency=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&currency=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&currency=zb_qc&id=20180522105585216&method=getOrder'
        params = 'accesskey=' + self._access_key_ + '&currency=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&currency=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 parameterJenisRentang nilai
methodStringpenugasan langsunggetOrder
accesskeyStringaccesskey
idlongNomor pesanan yang dipercayakan
currencyStringTransaksi koin/harga koin
signStringMinta string tanda tangan terenkripsi
reqTimelongwaktu saat ini dalam milidetik
customerOrderIdStringCustom ID(4-36 karakter, angka atau huruf, hanya satu ID Pesanan dan ID pelanggan yang dapat diisi)

Nilai KembaliDeskripsi
currencyTipe transaksi
idNomor pesanan yang dipercayakan
priceHarga
statusStatus pesanan:(1. Batal, 2. Selesai/Batalkan pesanan setelah sebagian selesai, 3. Pesanan tertunda/Tidak )
total_amountJumlah pesanan
trade_amountJumlah volume yang di setujui
trade_datemempercayakan waktu
trade_moneyJumlah transaksi yang di setujui
typeJenis pesanan tertunda0-limit sell,1-limit buy,2-PostOnly sell,3-PostOnly buy,4-IOC sell,5-IOC buy
feesBiaya transaksi
useZbFeeApakah 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&currency=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&currency=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&currency=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&currency=zb_qc&method=getOrders&pageIndex=1&tradeType=1'
        params = 'accesskey=' + self._access_key_ + '&currency=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&currency=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 parameterJenisRentang nilai
methodStringpenugasan langsunggetOrders
accesskeyStringaccesskey
tradeTypeintTipe transaksi1/0[buy/sell]
currencyStringTransaksi koin/harga koin
pageIndexintnomor halaman saat ini(Seperti: 1, halaman 1)
signStringMinta string tanda tangan terenkripsi
reqTimelongwaktu saat ini dalam milidetik

Nilai KembaliDeskripsi
currencyTipe transaksi
idNomor pesanan yang dipercayakan
priceHarga
statusStatus pesanan:(1. Batal, 2. Selesai/Batalkan pesanan setelah sebagian selesai, 3. Pesanan tertunda/Tidak )
total_amountJumlah pesanan
trade_amountJumlah volume yang di setujui
trade_datemempercayakan waktu
trade_moneyJumlah transaksi yang di setujui
typeJenis pesanan tertunda0-limit sell,1-limit buy,2-PostOnly sell,3-PostOnly buy,4-IOC sell,5-IOC buy
feesBiaya transaksi
useZbFeeApakah 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&currency=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&currency=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&currency=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&currency=bch_qc&method=getOrdersIgnoreTradeType&pageIndex=1&pageSize=10'
        params = 'accesskey=' + self._access_key_ + '&currency=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&currency=zb_qc&pageIndex=1&pageSize=10&sign=035c3a682574790044dc7aa4cffa0259&amp;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 parameterJenisRentang nilai
methodStringpenugasan langsunggetOrdersIgnoreTradeType
accesskeyStringaccesskey
currencyStringTransaksi koin/harga koin
pageIndexintnomor halaman saat ini(Seperti: 1, halaman 1)
pageSizeintKuantitas per halaman
signStringMinta string tanda tangan terenkripsi
reqTimelongwaktu saat ini dalam milidetik

Nilai KembaliDeskripsi
currencyTipe transaksi
idNomor pesanan yang dipercayakan
priceHarga
statusStatus pesanan:(1. Batal, 2. Selesai/Batalkan pesanan setelah sebagian selesai, 3. Pesanan tertunda/Tidak )
total_amountJumlah pesanan
trade_amountJumlah volume yang di setujui
trade_datemempercayakan waktu
trade_moneyJumlah transaksi yang di setujui
typeJenis pesanan tertunda0-limit sell,1-limit buy,2-PostOnly sell,3-PostOnly buy,4-IOC sell,5-IOC buy
feesBiaya transaksi
useZbFeeApakah 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&currency=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&currency=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&currency=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&currency=zb_qc&method=getUnfinishedOrdersIgnoreTradeType&pageIndex=1&pageSize=10'
        params = 'accesskey=' + self._access_key_ + '&currency=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&currency=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 parameterJenisRentang nilai
methodStringpenugasan langsunggetUnfinishedOrdersIgnoreTradeType
accesskeyStringaccesskey
currencyStringTransaksi koin/harga koin
pageIndexintnomor halaman saat ini(Seperti: 1, halaman 1)
pageSizeintKuantitas per halaman
signStringMinta string tanda tangan terenkripsi
reqTimelongwaktu saat ini dalam milidetik

Nilai KembaliDeskripsi
currencyTipe transaksi
idNomor pesanan yang dipercayakan
priceHarga
statusStatus pesanan:(1. Batal, 2. Selesai/Batalkan pesanan setelah sebagian selesai, 3. Pesanan tertunda/Tidak ))
total_amountJumlah pesanan
trade_amountJumlah volume yang di setujui
trade_datemempercayakan waktu
trade_moneyJumlah transaksi yang di setujui
typeJenis pesanan tertunda0-limit sell,1-limit buy,2-PostOnly sell,3-PostOnly buy,4-IOC sell,5-IOC buy
feesBiaya transaksi
useZbFeeApakah itu biaya pengurangan ZB

Dapatkan pesanan yang terisi atau terisi sebagian

Contoh permintaan


// request demo
GET https://trade.zb.com/api/getFinishedAndPartialOrders?accesskey=youraccesskey&currency=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 parameterJenisRentang nilai
methodStringpenugasan langsunggetFinishedAndPartialOrders
accesskeyStringaccesskey
currencyStringTransaksi koin/harga koin
pageIndexintnomor halaman saat ini(Seperti: 1, halaman 1)
pageSizeintKuantitas per halaman
signStringMinta string tanda tangan terenkripsi
reqTimelongwaktu saat ini dalam milidetik

Nilai KembaliDeskripsi
currencyTipe transaksi
idNomor pesanan yang dipercayakan
priceHarga
statusStatus pesanan:(1. Batal, 2. Selesai/Batalkan pesanan setelah sebagian selesai, 3. Pesanan tertunda/Tidak ))
total_amountJumlah pesanan
trade_amountJumlah volume yang di setujui
trade_datemempercayakan waktu
trade_moneyJumlah transaksi yang di setujui
typeJenis pesanan tertunda0-limit sell,1-limit buy,2-PostOnly sell,3-PostOnly buy,4-IOC sell,5-IOC buy
feesBiaya transaksi
useZbFeeApakah 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 parameterJenisRentang nilai
memoStringRemark
passwordStringKata sandi
subUserNameStringNama pengguna sub akun(tidak lebih dari6angka atau huruf)
accesskeyStringaccesskey
reqTimeLongwaktu saat ini dalam milidetik
signStringTanda tangan

Nilai KembaliDeskripsi
codeKode Pengembalian
desPetunjuk
isSucApakah 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 parameterJenisRentang nilai
accesskeyStringaccesskey
reqTimeLongwaktu saat ini dalam milidetik
signStringTanda tangan

Nilai KembaliDeskripsi
codeKode Pengembalian
desPetunjuk
isSucApakah berhasil
isOpenApiApakah akan membukaAPI
userNameNama pengguna
isFreezApa di bekukan
memoRemark

Internal transfer antara akun utama dan sub-akun

Contoh permintaan


// request demo
https://trade.zb.com/api/doTransferFunds?accesskey=youraccesskey&method=doTransferFunds&amount=1&currency=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&currency=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&currency=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&currency=doge&[email protected]&method=doTransferFunds&toUserName=lianlianyi@test12'
        params = 'accesskey=' + self._access_key_ + '&amount=1&currency=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&currency=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 parameterJenisRentang nilai
amountDoubleJumlah
currencyStringBunga yang telah jatuh tempo
fromUserNameStringNama Pengguna Pengalih
toUserNameStringNama Pengguna Penerima
accesskeyStringaccesskey
reqTimeLongwaktu saat ini dalam milidetik
signStringTanda tangan

Nilai KembaliDeskripsi
codeKode Pengembalian
desPetunjuk
isSucApakah 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 parameterJenisRentang nilai
methodStringpenugasan langsung getLeverAssetsInfo
accesskeyStringaccesskey
signStringMinta string tanda tangan terenkripsi
reqTimelongwaktu saat ini dalam milidetik

Nilai KembaliDeskripsi
codeKode Pengembalian
desPetunjuk
isSucApakah berhasil
keyNama pasar
fshowNameGunakan nama baru jika diganti namanya,jika tidak samafname
cshowNameGunakan nama baru jika diganti namanya,jika tidak samacname
showNameJika ada perubahan nama, itu akan menjadi nama perdagangan baru,jika tidak samakey
fLoanInJumlah pinjaman mata uang Prancis
repayLevelTingkat likuidasi
unwindPriceHarga likuidasi
fUnitDecimalTitik desimal
repayLockApakah pembayaran dikunci
cLoanInJumlah pinjaman
cAvailableKoin yang tersedia
fAvailableMata uang fiat tersedia
cLoanOutJumlah koin yang di pinjamkan keluar
cCanLoanInTersedia untuk dipinjam
fLoanOutMata uang fiat dapat dipinjamkan
levelTingkat margin
fFreezeFiat di bekukan
cFreezePembekuan koin
fCanLoanInMata uang fiat dapat dipinjam
cUnitDecimalTitik desimal koin
cOverdraft币欠息
repayLeverShowResiko 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 parameterJenisRentang nilai
methodStringpenugasan langsung getLeverBills
accesskeyStringaccesskey
coinStringBunga yang telah jatuh tempo
dataTypeintJenis data[0/1](Data dalam 30 hari/Data 30 hari yang lalu)
pageIndexintnomor halaman saat ini(Seperti: 1, halaman 1)
pageSizeintKuantitas per halaman
signStringMinta string tanda tangan terenkripsi
reqTimelongwaktu saat ini dalam milidetik

Nilai KembaliDeskripsi
codeKode Pengembalian
messagePetunjuk
idtagihanID
userIdUserID
dateWaktu pembuatan tagihan
typeJenis tagihan
billTypeValueJenis tagihan sesuai dengan bahasa Cina
changeCoinperubahan iniCOINJumlah
coinBalanceberubahCOINSaldo
changeFiatJumlah mata uang fiat berubah kali ini
fiatBalanceSaldo mata uang fiat
fundsTypeCOINJenis
marketNameNama pasar
showCoinmenunjukkanCOINvariasi
showFiatTampilkan 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 parameterJenisRentang nilai
methodStringpenugasan langsung transferInLever
accesskeyStringaccesskey
coinStringBunga yang telah jatuh tempo
marketNameStringNama pasar
amountdoubleJumlah Transfer,Tempat desimal tidak boleh melebihi4,Melebihi sistem secara otomatis di potong4Bit
signStringMinta string tanda tangan terenkripsi
reqTimelongwaktu saat ini dalam milidetik

Nilai KembaliDeskripsi
codeKode Pengembalian
messagePetunjuk

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 parameterJenisRentang nilai
methodStringpenugasan langsung transferOutLever
accesskeyStringaccesskey
coinStringBunga yang telah jatuh tempo
marketNameStringNama pasar
amountdoubleJumlah transfer keluar,Tempat desimal tidak boleh melebihi8,Melebihi sistem secara otomatis di potong8Bit
signStringMinta string tanda tangan terenkripsi
reqTimelongwaktu saat ini dalam milidetik

Nilai KembaliDeskripsi
codeKode Pengembalian
messagePetunjuk

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 parameterJenisRentang nilai
methodStringpenugasan langsung loan
accesskeyStringaccesskey
coinStringBunga yang telah jatuh tempo
amountdoubleJumlah investasi,Tempat desimal tidak boleh melebihi4,Melebihi sistem secara otomatis di potong4Bit
interestRateOfDaydoubleSuku bunga harian [0.05-0.2] Persen,Tempat desimal tidak boleh melebihi3,Melebihi sistem secara otomatis di potong3Bit
repaymentDayintHari pinjaman [10/20/30]
isLoopbooleanApakah akan secara otomatis meminjamkan [1/0]
signStringMinta string tanda tangan terenkripsi
reqTimelongwaktu saat ini dalam milidetik

Nilai KembaliDeskripsi
codeKode Pengembalian
messagePetunjuk
idInvestasiID

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 parameterJenisRentang nilai
methodStringpenugasan langsung cancelLoan
accesskeyStringaccesskey
loanIdStringInvestasiID
signStringMinta string tanda tangan terenkripsi
reqTimelongwaktu saat ini dalam milidetik

Nilai KembaliDeskripsi
codeKode Pengembalian
messagePetunjuk

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 parameterJenisRentang nilai
methodStringpenugasan langsung getLoans
accesskeyStringaccesskey
coinStringBunga yang telah jatuh tempo
pageIndexintnomor halaman saat ini(Seperti: 1, halaman 1)
pageSizeintKuantitas per halaman
signStringMinta string tanda tangan terenkripsi
reqTimelongwaktu saat ini dalam milidetik

Nilai KembaliDeskripsi
codeKode Pengembalian
messagePetunjuk
amountJumlah
balanceJumlah pinjaman yang tersedia
coinNameBunga yang telah jatuh tempo
repaymentDayjangka waktu pinjaman
interestRateOfDaySuku 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 parameterJenisRentang nilai
methodStringpenugasan langsung getLoanRecords
accesskeyStringaccesskey
loanIdStringInvestasiid(Jumlah Pinjaman Jangan transfer jika meminjam)
marketNameStringPasar
statusintStatus(1pembayaran kembali 2Dilunasi 3 Perlu Dilikuidasi 4 Pembayaran likuidasi 5Pembayaran otomatis sedang berlangsung 6pembayaran otomatis)
pageIndexintnomor halaman saat ini(Seperti: 1, halaman 1)
pageSizeintKuantitas per halaman
signStringMinta string tanda tangan terenkripsi
reqTimelongwaktu saat ini dalam milidetik

Nilai KembaliDeskripsi
codeKode Pengembalian
messagePetunjuk
idCatatan PeminjamanID
loanIdInvestasiID
inUserIdPeminjamID
inUserNameNama Pengguna Peminjam
outUserId借出者ID
outUserNamePemberi pinjaman
fundTypeJenis koin
amount借入金额
statusStatus 1pembayaran kembali 2Dilunasi 3Perlu Dilikuidasi 4 Pembayaran likuidasi 5pembayaran otomatis
createTimewaktu sukses pinjaman
rewardJumlah Hadiah
balanceAmountJumlah yang tersedia
rateRate bunga
hasRepayJumlah Pokok yang Dibayarkan
hasLxBunga yang dibayarkan
dikouLxBunga telah di potong
zheLxHarga yang dikonversi
arrearsLxBunga yang telah jatuh tempo
nextRepayDatewaktu pembayaran berikutnya
riskManagepengendalian risiko
inUserLockApakah peminjam terkunci
withoutLxAmountJumlah bebas bunga
withoutLxDaysHari tanpa bunga
balanceWithoutLxDaysSisa hari bebas bunga
rateFormJenis bunga
rateAddValTingkatkan Jangkauan
repayDateWaktu Pembayaran
marketNamePasar
fwfScaletarif biaya layanan
investMarkPerbaharui Otomatis
sourceTypejenis 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 parameterJenisRentang nilai
methodStringpenugasan langsung borrow
accesskeyStringaccesskey
marketNameString杠杆市场
coinStringBunga yang telah jatuh tempo
amountdouble借入金额,Tempat desimal tidak boleh melebihi4,Melebihi sistem secara otomatis di potong4Bit
interestRateOfDaydoubleSuku bunga harian [0.05-0.2] Persen,Tempat desimal tidak boleh melebihi3,Melebihi sistem secara otomatis di potong3Bit
repaymentDayintjangka waktu pinjaman [10/20/30]Hari
isLoopintApakah akan memperbarui secara otomatis [1/0](Perpanjangan otomatis setelah kedaluwarsa/Pembayaran otomatis saat jatuh tempo)
signStringMinta string tanda tangan terenkripsi
reqTimelongwaktu saat ini dalam milidetik

Nilai KembaliDeskripsi
codeKode Pengembalian
messagePetunjuk

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 parameterJenisRentang nilai
methodStringpenugasan langsung autoBorrow
accesskeyStringaccesskey
marketNameString杠杆市场
coinStringBunga yang telah jatuh tempo
amountdouble借入金额,Tempat desimal tidak boleh melebihi4,Melebihi sistem secara otomatis di potong4Bit
interestRateOfDaydoubleSuku bunga harian [0.05-0.2] Persen,Tempat desimal tidak boleh melebihi3,Melebihi sistem secara otomatis di potong3Bit
repaymentDayintjangka waktu pinjaman [10/20/30]Hari
safePwdStringKata Sandi Transaksi
signStringMinta string tanda tangan terenkripsi
reqTimelongwaktu saat ini dalam milidetik

Nilai KembaliDeskripsi
codeKode Pengembalian
messagePetunjuk

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 parameterJenisRentang nilai
methodStringpenugasan langsung repay
accesskeyStringaccesskey
loanRecordIdStringCatatan Peminjamanid
repayAmountdoubleJumlah pembayaran
repayTypeintMeteode pembayaran [0/1](Semua/Bagian)
signStringMinta string tanda tangan terenkripsi
reqTimelongwaktu saat ini dalam milidetik

Nilai KembaliDeskripsi
codeKode Pengembalian
messagePetunjuk

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 parameterJenisRentang nilai
methodStringpenugasan langsung doAllRepay
accesskeyStringaccesskey
marketNameStringpasar leveragebtcqc
coinStringMata uang (opsional jika jumlah pembayaran tidak diisi)
repayAmountStringJumlah pembayaran (opsional, pembayaran penuh default)
signStringMinta string tanda tangan terenkripsi
reqTimelongwaktu saat ini dalam milidetik

Nilai KembaliDeskripsi
codeKode Pengembalian
messagePetunjuk

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 parameterJenisRentang nilai
methodStringpenugasan langsung getRepayments
accesskeyStringaccesskey
loanRecordIdStringCatatan Peminjamanid
pageIndexintnomor halaman saat ini(Seperti: 1, halaman 1)
pageSizeintKuantitas per halaman
signStringMinta string tanda tangan terenkripsi
reqTimelongwaktu saat ini dalam milidetik

Nilai KembaliDeskripsi
codeKode Pengembalian
messagePetunjuk
idCatatan PembayaranID
benJinModal
liXiBunga
statusStatus
statusShowNilai status dalam bahasa chinese
actureDateTanggal 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 parameterJenisRentang nilai
methodStringpenugasan langsung getFinanceRecords
accesskeyStringaccesskey
coinStringBunga yang telah jatuh tempo
pageIndexintnomor halaman saat ini(Seperti: 1, halaman 1)
pageSizeintKuantitas per halaman
signStringMinta string tanda tangan terenkripsi
reqTimelongwaktu saat ini dalam milidetik

Nilai KembaliDeskripsi
codeKode Pengembalian
messagePetunjuk
idInvestasiID
userIdUserID
userNameNama pengguna
fundTypeJenis koin
coinNameNama koin
amountJumlah investasi
hasAmountJumlah yang dipinjamkan
statusNilai status
statusShowNilai status dalam bahasa chinese
createTimeWaktu Rilis
interestRateOfDaySuku bunga harian
repaymentDayhari peminjaman
isLoopApakah akan secara otomatis meminjamkan
inTimesInvestasi yang dipinjam
sourceTypejenis 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 parameterJenisRentang nilai
methodStringpenugasan langsung changeInvestMark
accesskeyStringaccesskey
investMarkintJenis Pembaruan[0/1](Tidak otomatis/Perbaharui Otomatis)
loanRecordIdStringmeminjamkanId,banyak dalam bahasa inggris‘,’Terbagi
signStringMinta string tanda tangan terenkripsi
reqTimelongwaktu saat ini dalam milidetik

Nilai KembaliDeskripsi
codeKode Pengembalian
messagePetunjuk

变更是否自动放贷

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 parameterJenisRentang nilai
methodStringpenugasan langsung changeLoop
accesskeyStringaccesskey
isLoopintJenis pinjaman[0/1](Tidak otomatis/pinjaman otomatis)
loanIdStringPinjamanid
signStringMinta string tanda tangan terenkripsi
reqTimelongwaktu saat ini dalam milidetik

Nilai KembaliDeskripsi
codeKode Pengembalian
messagePetunjuk

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 parameterJenisRentang nilai
methodStringpenugasan langsung getCrossAssets
accesskeyStringaccesskey
signStringMinta string tanda tangan terenkripsi
reqTimelongwaktu saat ini dalam milidetik

Nilai KembaliDeskripsi
codeKode Pengembalian
loanInmeminjam
totalTotal aset
riskRateTingkat risiko
fundTypeBunga yang telah jatuh tempo ID
amountKoin yang tersedia
freezePembekuan koin
overdraftBunga
keyNama koin
canTransferOutJumlah 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 parameterJenisRentang nilai
methodStringpenugasan langsung getCrossBills
accesskeyStringaccesskey
coinStringBunga yang telah jatuh tempo
dataTypeintJenis data[0/1](Data dalam 30 hari/Data 30 hari yang lalu)
pageIndexintnomor halaman saat ini(Seperti: 1, halaman 1)
pageSizeintKuantitas per halaman
signStringMinta string tanda tangan terenkripsi
reqTimelongwaktu saat ini dalam milidetik

Nilai KembaliDeskripsi
codeKode Pengembalian
messagePetunjuk
balanceSaldo
showFiat...
createTimeWaktu pembuatan tagihan
typeNameJenis tagihan sesuai dengan bahasa Cina
showCoinmenunjukkanCOINvariasi
idtagihanID
typeJenis tagihan
changedperubahan 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 parameterJenisRentang nilai
methodStringpenugasan langsung transferInCross
accesskeyStringaccesskey
coinStringBunga yang telah jatuh tempo
amountdoubleJumlah Transfer,Tempat desimal tidak boleh melebihi4,Melebihi sistem secara otomatis di potong4Bit
signStringMinta string tanda tangan terenkripsi
reqTimelongwaktu saat ini dalam milidetik

Nilai KembaliDeskripsi
codeKode Pengembalian
messagePetunjuk

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 parameterJenisRentang nilai
methodStringpenugasan langsung transferOutCross
accesskeyStringaccesskey
coinStringBunga yang telah jatuh tempo
amountdoubleJumlah transfer keluar,Tempat desimal tidak boleh melebihi8,Melebihi sistem secara otomatis di potong8Bit
signStringMinta string tanda tangan terenkripsi
reqTimelongwaktu saat ini dalam milidetik

Nilai KembaliDeskripsi
codeKode Pengembalian
messagePetunjuk

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 parameterJenisRentang nilai
methodStringpenugasan langsung doCrossLoan
accesskeyStringaccesskey
coinStringBunga yang telah jatuh tempo
amountdouble借入金额,Tempat desimal tidak boleh melebihi4,Melebihi sistem secara otomatis di potong4Bit
safePwdStringKata sandi dana
signStringMinta string tanda tangan terenkripsi
reqTimelongwaktu saat ini dalam milidetik

Nilai KembaliDeskripsi
codeKode Pengembalian
messagePetunjuk

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 parameterJenisRentang nilai
methodStringpenugasan langsung doCrossRepay
accesskeyStringaccesskey
coinsStringMata uang (opsional jika jumlah pembayaran tidak diisi)
repayAmountdoubleJumlah pembayaran (opsional, pembayaran penuh default)
signStringMinta string tanda tangan terenkripsi
reqTimelongwaktu saat ini dalam milidetik

Nilai KembaliDeskripsi
codeKode Pengembalian
messagePetunjuk

自动借币

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 parameterJenisRentang nilai
methodStringpenugasan langsung setExpressState
accesskeyStringaccesskey
enableExpressStringtrue/false
signStringMinta string tanda tangan terenkripsi
reqTimelongwaktu saat ini dalam milidetik

Nilai KembaliDeskripsi
codeKode Pengembalian
messagePetunjuk

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 parameterJenisRentang nilai
methodStringpenugasan langsung setRepayState
accesskeyStringaccesskey
enableRepayStringtrue/false
signStringMinta string tanda tangan terenkripsi
reqTimelongwaktu saat ini dalam milidetik

Nilai KembaliDeskripsi
codeKode Pengembalian
messagePetunjuk

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 parameterJenisRentang nilai
methodStringpenugasan langsung getCrossRepayRecords
accesskeyStringaccesskey
coinStringqc
pageIndexintnomor halaman saat ini(Seperti: 1, halaman 1)
pageSizeintKuantitas per halaman
accesskeyStringaccesskey
signStringMinta string tanda tangan terenkripsi
reqTimelongwaktu saat ini dalam milidetik

Nilai KembaliDeskripsi
codeKode Pengembalian
messagePetunjuk
fundTypeStringBunga yang telah jatuh tempoID
newStatusintStatus sebelum pelunasan,1 pembayaran kembali,2 Dilunasi,3 Likuidasi paksa,4 Pembayaran likuidasi
oldStatusintStatus setelah pembayaran
sourceTypejenis sumber: 8”Web”,5”handphoneAPP”,6”InterfaceAPI”
benJinintModal
crossLoanrecordIdStringID Catatan Pinjaman Lintas Gudang
repayDateintWaktu Pembayaran
idintid
userNameintNama pengguna
liXiintBunga
userIdintuser 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.

github Kode sampel

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 parameterJenisRentang nilai
eventStringpenugasan langsungaddChannel
channelStringmarkets

Nilai KembaliDeskripsi
priceScale价格小数位数
minAmountJumlah transaksi minimum dalam mata uang transaksi
minSizeKuantitas transaksi minimum dalam mata uang harga
amountScaleTempat 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 parameterJenisRentang nilai
eventStringpenugasan langsungaddChannel
channelStringzbqc_ticker

Nilai KembaliDeskripsi
dateWaktu server saat mengembalikan data
highharga tertinggi
lowharga terendah
buyBeli 1
sellJual 1
lastHarga transaksi terbaru
openharga pembukaan
riseRatePerubahan 24 jam
volVolume perdagangan(Terbaru24Jam)
channelPermintaan 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 parameterJenisRentang nilai
eventStringpenugasan langsungaddChannel
channelStringltcbtc_depth

Nilai KembaliDeskripsi
asksJual Order Depth
bidsBeli pesanan
channelPermintaan 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 parameterJenisRentang nilai
eventStringpenugasan langsungaddChannel
channelStringltcbtc_trades

Nilai KembaliDeskripsi
dateJam transaksi
priceHarga transaksi
amountJumlah transaksi
tidGenerate transaksiID
channelPermintaan 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 parameterJenisRentang nilai
eventStringpenugasan langsungaddChannel
channelStringbtcusdt_kline_1day (1week, 3day, 1day, 12hour, 6hour, 4hour, 2hour, 1hour, 30min, 15min, 5min, 3min, 1min)

Nilai KembaliDeskripsi
channelPermintaan 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 parameterJenisRentang nilai
accesskeyStringaccesskey
amountfloatJumlah transaksi
channelStringTransaksi koin/harga koin_order(btcusdt_order)
eventStringpenugasan langsungaddChannel
noStringIdentitas unik permintaan digunakan untuk membedakan konten saat dikembalikan
pricefloatHarga
tradeTypeintTipe transaksi1/0[buy/sell]
acctTypeintMargin 0/1/2[Spot/Leverage Terisolasi/Leverage posisi silang](Pilihan lain,Standarnya adalah: 0 Spot)
signStringMinta string tanda tangan terenkripsi

Nilai KembaliDeskripsi
codeKode Pengembalian
messagePetunjuk
entrustIdNomor pesanan yang dipercayakan
channelsaluran yang diminta
noIdentitas 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 parameterJenisRentang nilai
accesskeyStringaccesskey
channelStringTransaksi koin/harga koin_cancelorder(btcusdt_cancelorder)
eventStringpenugasan langsungaddChannel
idlong委托单id
noStringIdentitas unik permintaan digunakan untuk membedakan konten saat dikembalikan
signStringMinta string tanda tangan terenkripsi

Nilai KembaliDeskripsi
codeKode Pengembalian
messagePetunjuk
entrustIdNomor pesanan yang dipercayakan
channelsaluran yang diminta
noIdentitas 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 parameterJenisRentang nilai
accesskeyStringaccesskey
channelStringTransaksi koin/harga koin_getorder(btcusdt_getorder)
eventStringpenugasan langsungaddChannel
idlongNomor pesanan yang dipercayakan
noStringIdentitas unik permintaan digunakan untuk membedakan konten saat dikembalikan
signStringMinta string tanda tangan terenkripsi

Nilai KembaliDeskripsi
idNomor pesanan yang dipercayakan
currencyTipe transaksi
trade_amountJumlah volume yang di setujui
trade_moneyJumlah transaksi yang di setujui
total_amountJumlah pesanan
trade_datemempercayakan waktu
codeKode Pengembalian
messagePetunjuk
channelsaluran yang diminta
noIdentitas 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 parameterJenisRentang nilai
accesskeyStringaccesskey
channelStringTransaksi koin/harga koin_getorders(btcusdt_getorders)
eventStringpenugasan langsungaddChannel
noStringIdentitas unik permintaan digunakan untuk membedakan konten saat dikembalikan
pageIndexintnomor halaman saat ini(Seperti: 1, halaman 1)
tradeTypeintTipe transaksi1/0[buy/sell]

Nilai KembaliDeskripsi
currencyTipe transaksi
idNomor pesanan yang dipercayakan
priceHarga
statusStatus pesanan:(1. Batal, 2. Selesai/Batalkan pesanan setelah sebagian selesai, 3. Pesanan tertunda/Tidak )
total_amountJumlah pesanan
trade_amountJumlah volume yang di setujui
trade_datemempercayakan waktu
trade_moneyJumlah transaksi yang di setujui
typeJenis pesanan tertunda0-limit sell,1-limit buy,2-PostOnly sell,3-PostOnly buy,4-IOC sell,5-IOC buy
feesBiaya transaksi
useZbFeeApakah itu biaya pengurangan ZB
codeKode Pengembalian
messagePetunjuk
channelsaluran yang diminta
noIdentitas 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 parameterJenisRentang nilai
accesskeyStringaccesskey
channelStringTransaksi koin/harga koin_getordersignoretradetype(btcusdt_getordersignoretradetype)
eventStringpenugasan langsungaddChannel
noStringIdentitas unik permintaan digunakan untuk membedakan konten saat dikembalikan
pageIndexintnomor halaman saat ini(Seperti: 1, halaman 1)
pageSizeintKuantitas per halaman

Nilai KembaliDeskripsi
currencyTipe transaksi
idNomor pesanan yang dipercayakan
priceHarga
statusStatus pesanan:(1. Batal, 2. Selesai/Batalkan pesanan setelah sebagian selesai, 3. Pesanan tertunda/Tidak )
total_amountJumlah pesanan
trade_amountJumlah volume yang di setujui
trade_datemempercayakan waktu
trade_moneyJumlah transaksi yang di setujui
codeKode Pengembalian
messagePetunjuk
channelsaluran yang diminta
noIdentitas 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 parameterJenisRentang nilai
accesskeyStringaccesskey
channelStringgetaccountinfo
eventStringpenugasan langsungaddChannel
noStringIdentitas unik permintaan digunakan untuk membedakan konten saat dikembalikan
signStringTanda tangan

Nilai KembaliDeskripsi
auth_google_enabledApakah akan mengaktifkan verifikasi google
auth_mobile_enabledApakah akan mengaktifkan verifikasi ponsel
trade_password_enabledApakah atau tidak mengaktifkan kata sandi transaksi
usernameNama pengguna
enameBahasa inggris koin
cnNameNama koin Cina
unitTagSimbol koin
keyBunga yang telah jatuh tempo
codeKode Pengembalian
messagePetunjuk
channelsaluran yang diminta
noIdentitas 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 parameterJenisRentang nilai
accesskeyStringaccesskey
channelStringaddSubUser
eventStringpenugasan langsungaddChannel
memoStringRemark
passwordStringKata sandi
subUserNameStringNama pengguna sub akun(tidak lebih dari6angka atau huruf)
noStringIdentitas unik permintaan digunakan untuk membedakan konten saat dikembalikan
signStringTanda tangan

Nilai KembaliDeskripsi
successApakah berhasil
codeKode Pengembalian
messagePetunjuk
channelsaluran yang diminta
noIdentitas 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 parameterJenisRentang nilai
accesskeyStringaccesskey
channelStringgetSubUserList
eventStringpenugasan langsungaddChannel
noStringIdentitas unik permintaan digunakan untuk membedakan konten saat dikembalikan
signStringTanda tangan

Nilai KembaliDeskripsi
successApakah berhasil
codeKode Pengembalian
messagePetunjuk
channelsaluran yang diminta
noIdentitas unik permintaan digunakan untuk membedakan konten saat dikembalikan
isOpenApiApakah akan membukaAPI
userNameNama pengguna
isFreezApa di bekukan
memoRemark

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 parameterJenisRentang nilai
accesskeyStringaccesskey
channelStringdoTransferFunds
eventStringpenugasan langsungaddChannel
amountStringJumlah
currencyStringBunga yang telah jatuh tempo
fromUserNameStringNama Pengguna Pengalih
toUserNameStringNama Pengguna Penerima
noStringIdentitas unik permintaan digunakan untuk membedakan konten saat dikembalikan
signStringTanda tangan

Nilai KembaliDeskripsi
successApakah berhasil
codeKode Pengembalian
messagePetunjuk
channelsaluran yang diminta
noIdentitas 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 parameterJenisRentang nilai
accesskeyStringaccesskey
channelStringgetuserLeverAsset
eventStringpenugasan langsungaddChannel
noStringIdentitas unik permintaan digunakan untuk membedakan konten saat dikembalikan
signStringTanda tangan

Nilai KembaliDeskripsi
codeKode Pengembalian
desPetunjuk
isSucApakah berhasil
fLoanInJumlah pinjaman mata uang Prancis
repayLevelTingkat likuidasi
unwindPriceHarga likuidasi
fUnitDecimalTitik desimal
repayLockApakah pembayaran dikunci
cLoanInJumlah pinjaman
cAvailableKoin yang tersedia
fAvailableMata uang fiat tersedia
cLoanOutJumlah koin yang di pinjamkan keluar
cCanLoanInTersedia untuk dipinjam
fLoanOutMata uang fiat dapat dipinjamkan
levelTingkat margin
fFreezeFiat di bekukan
cFreezePembekuan koin
fCanLoanInMata uang fiat dapat dipinjam
cUnitDecimalTitik desimal koin
cOverdraft币欠息
repayLeverShowResiko 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 parameterJenisRentang nilai
accesskeyStringaccesskey
channelStringgetLeverBills
eventStringpenugasan langsungaddChannel
coinStringBunga yang telah jatuh tempo
pageIndexintnomor halaman saat ini(Seperti: 1, halaman 1)
pageSizeintKuantitas per halaman
noStringIdentitas unik permintaan digunakan untuk membedakan konten saat dikembalikan
signStringTanda tangan

Nilai KembaliDeskripsi
successApakah berhasil
codeKode Pengembalian
messagePetunjuk
channelsaluran yang diminta
noIdentitas unik permintaan digunakan untuk membedakan konten saat dikembalikan
idtagihanID
userIdUserID
dateWaktu pembuatan tagihan
typeJenis tagihan
billTypeValueJenis tagihan sesuai dengan bahasa Cina
changeCoinperubahan iniCOINJumlah
coinBalanceberubahCOINSaldo
changeFiatJumlah mata uang fiat berubah kali ini
fiatBalanceSaldo mata uang fiat
fundsTypeCOINJenis
marketNameNama pasar
showCoinmenunjukkanCOINvariasi
showFiatTampilkan 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 parameterJenisRentang nilai
accesskeyStringaccesskey
channelStringtransferInLever
eventStringpenugasan langsungaddChannel
coinStringBunga yang telah jatuh tempo
marketNameStringPasar
amountDoubleJumlah Transfer
noStringIdentitas unik permintaan digunakan untuk membedakan konten saat dikembalikan
signStringTanda tangan

Nilai KembaliDeskripsi
successApakah berhasil
codeKode Pengembalian
messagePetunjuk
channelsaluran yang diminta
noIdentitas 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 parameterJenisRentang nilai
accesskeyStringaccesskey
channelStringtransferOutLever
eventStringpenugasan langsungaddChannel
coinStringBunga yang telah jatuh tempo
marketNameStringPasar
amountDoubleJumlah transfer keluar
noStringIdentitas unik permintaan digunakan untuk membedakan konten saat dikembalikan
signStringTanda tangan

Nilai KembaliDeskripsi
successApakah berhasil
codeKode Pengembalian
messagePetunjuk
channelsaluran yang diminta
noIdentitas 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 parameterJenisRentang nilai
accesskeyStringaccesskey
channelStringloan
eventStringpenugasan langsungaddChannel
coinStringBunga yang telah jatuh tempo
amountDoubleJumlah investasi
interestRateOfDayDoubleSuku bunga harian [0.05-0.2]%
repaymentDayintHari pinjaman [10/20/30]
isLoopintApakah akan secara otomatis meminjamkan [1/0]
noStringIdentitas unik permintaan digunakan untuk membedakan konten saat dikembalikan
signStringTanda tangan

Nilai KembaliDeskripsi
successApakah berhasil
codeKode Pengembalian
messagePetunjuk
channelsaluran yang diminta
noIdentitas unik permintaan digunakan untuk membedakan konten saat dikembalikan
data
loanIdInvestasiID

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 parameterJenisRentang nilai
accesskeyStringaccesskey
channelStringcancelLoan
eventStringpenugasan langsungaddChannel
loanIdLongInvestasiID
noStringIdentitas unik permintaan digunakan untuk membedakan konten saat dikembalikan
signStringTanda tangan

Nilai KembaliDeskripsi
successApakah berhasil
codeKode Pengembalian
messagePetunjuk
channelsaluran yang diminta
noIdentitas 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 parameterJenisRentang nilai
accesskeyStringaccesskey
channelStringgetLoans
eventStringpenugasan langsungaddChannel
coinStringBunga yang telah jatuh tempo
pageIndexintnomor halaman saat ini(Seperti: 1, halaman 1)
pageSizeintKuantitas per halaman
noStringIdentitas unik permintaan digunakan untuk membedakan konten saat dikembalikan
signStringTanda tangan

Nilai KembaliDeskripsi
successApakah berhasil
codeKode Pengembalian
messagePetunjuk
channelsaluran yang diminta
noIdentitas unik permintaan digunakan untuk membedakan konten saat dikembalikan
amountJumlah
balanceJumlah pinjaman yang tersedia
coinNameBunga yang telah jatuh tempo
repaymentDayjangka waktu pinjaman
interestRateOfDaySuku 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 parameterJenisRentang nilai
accesskeyStringaccesskey
channelStringgetLoanRecords
eventStringpenugasan langsungaddChannel
loanIdLongInvestasiid(Jumlah Pinjaman Jangan transfer jika meminjam)
marketNameStringPasar
statusintStatus(1pembayaran kembali 2Dilunasi 3 Perlu Dilikuidasi 4 Pembayaran likuidasi 5Pembayaran otomatis sedang berlangsung 6pembayaran otomatis)
pageIndexintnomor halaman saat ini(Seperti: 1, halaman 1)
pageSizeintKuantitas per halaman
noStringIdentitas unik permintaan digunakan untuk membedakan konten saat dikembalikan
signStringTanda tangan

Nilai KembaliDeskripsi
successApakah berhasil
codeKode Pengembalian
messagePetunjuk
channelsaluran yang diminta
noIdentitas unik permintaan digunakan untuk membedakan konten saat dikembalikan
idCatatan PeminjamanID
loanIdInvestasiID
inUserIdPeminjamID
inUserNameNama Pengguna Peminjam
outUserId借出者ID
outUserNamePemberi pinjaman
fundTypeJenis koin
amount借入金额
statusStatus 1pembayaran kembali 2Dilunasi 3Perlu Dilikuidasi 4 Pembayaran likuidasi 5pembayaran otomatis
createTimewaktu sukses pinjaman
rewardJumlah Hadiah
balanceAmountJumlah yang tersedia
rateRate bunga
hasRepayJumlah Pokok yang Dibayarkan
hasLxBunga yang dibayarkan
dikouLxBunga telah di potong
zheLxHarga yang dikonversi
arrearsLxBunga yang telah jatuh tempo
nextRepayDatewaktu pembayaran berikutnya
riskManagepengendalian risiko
inUserLockApakah peminjam terkunci
withoutLxAmountJumlah bebas bunga
withoutLxDaysHari tanpa bunga
balanceWithoutLxDaysSisa hari bebas bunga
rateFormJenis bunga
rateAddValTingkatkan Jangkauan
repayDateWaktu Pembayaran
marketNamePasar
fwfScaletarif biaya layanan
investMarkPerbaharui Otomatis
sourceTypejenis 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 parameterJenisRentang nilai
accesskeyStringaccesskey
channelStringborrow
eventStringpenugasan langsungaddChannel
marketNameString杠杆市场
coinStringBunga yang telah jatuh tempo
amountDouble借入金额
interestRateOfDayDoubleSuku bunga harian [0.05-0.2]%
repaymentDayintjangka waktu pinjaman [10/20/30]Hari
isLoopintApakah akan memperbarui secara otomatis [1/0](Perpanjangan otomatis setelah kedaluwarsa/Pembayaran otomatis saat jatuh tempo)
noStringIdentitas unik permintaan digunakan untuk membedakan konten saat dikembalikan
signStringTanda tangan

Nilai KembaliDeskripsi
successApakah berhasil
codeKode Pengembalian
messagePetunjuk
channelsaluran yang diminta
noIdentitas 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 parameterJenisRentang nilai
accesskeyStringaccesskey
channelStringrepay
eventStringpenugasan langsungaddChannel
loanRecordIdLongCatatan Peminjamanid
repayAmountDoubleJumlah pembayaran
repayTypeintMeteode pembayaran [0/1](Semua/Bagian)
noStringIdentitas unik permintaan digunakan untuk membedakan konten saat dikembalikan
signStringTanda tangan

Nilai KembaliDeskripsi
successApakah berhasil
codeKode Pengembalian
messagePetunjuk
channelsaluran yang diminta
noIdentitas 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 parameterJenisRentang nilai
accesskeyStringaccesskey
channelStringgetRepayments
eventStringpenugasan langsungaddChannel
loanRecordIdLongCatatan Peminjamanid
pageIndexintnomor halaman saat ini(Seperti: 1, halaman 1)
pageSizeintKuantitas per halaman
noStringIdentitas unik permintaan digunakan untuk membedakan konten saat dikembalikan
signStringTanda tangan

Nilai KembaliDeskripsi
successApakah berhasil
codeKode Pengembalian
messagePetunjuk
channelsaluran yang diminta
noIdentitas unik permintaan digunakan untuk membedakan konten saat dikembalikan
idCatatan PembayaranID
benJinModal
liXiBunga
statusStatus
statusShowNilai status dalam bahasa chinese
actureDateTanggal 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 parameterJenisRentang nilai
accesskeyStringaccesskey
channelStringgetFinanceRecords
eventStringpenugasan langsungaddChannel
coinSTirngBunga yang telah jatuh tempo
pageIndexintnomor halaman saat ini(Seperti: 1, halaman 1)
pageSizeintKuantitas per halaman
noStringIdentitas unik permintaan digunakan untuk membedakan konten saat dikembalikan
signStringTanda tangan

Nilai KembaliDeskripsi
successApakah berhasil
codeKode Pengembalian
messagePetunjuk
channelsaluran yang diminta
noIdentitas unik permintaan digunakan untuk membedakan konten saat dikembalikan
idInvestasiID
userIdUserID
userNameNama pengguna
fundTypeJenis koin
coinNameNama koin
amountJumlah investasi
hasAmountJumlah yang dipinjamkan
statusNilai status
statusShowNilai status dalam bahasa chinese
createTimeWaktu Rilis
interestRateOfDaySuku bunga harian
repaymentDayhari peminjaman
isLoopApakah akan secara otomatis meminjamkan
inTimesInvestasi yang dipinjam
sourceTypejenis 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 parameterJenisRentang nilai
eventStringpenugasan langsungaddChannel
channelStringusdtqc_quick_depth
lengthStringGear5 10 20(Opsional, default adalah 5 file)

Nilai KembaliDeskripsi
lastTimeTime
dataTypeJenis data
channelPermintaan saat inichannel
currentPriceHarga transaksi terbaru
transction
listDownBeli pesanan
listUpJual Order Depth
marketPasar
highharga tertinggi
rateBeli pesanan
lowharga terendah
currentIsBuyTipe transaksi
dayNumberVolume perdagangan
totalBtcVolume 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 parameterJenisRentang nilai
accesskeyStringaccesskey
channelStringpush_user_record
eventStringpenugasan langsungaddChannel
marketStringzbqcdefault
signStringTanda tangan

Nilai KembaliDeskripsi
precordkomisi rencana
recordPercayakan saat ini
hrecordKomisi history
dataTypeJenis data
channelsaluran yang diminta
lastTimetime

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 parameterJenisRentang nilai
accesskeyStringaccesskey
channelStringpush_user_incr_record
eventStringpenugasan langsungaddChannel
marketStringzbqcdefault
signStringTanda tangan

Nilai KembaliDeskripsi
recordPercayakan saat ini
dataTypeJenis data
channelsaluran yang diminta
lastTimetime

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 parameterJenisRentang nilai
accesskeyStringaccesskey
channelStringpush_user_asset
eventStringpenugasan langsungaddChannel
signStringTanda tangan

Nilai KembaliDeskripsi
coinsInformasi koin
dataTypeJenis data
channelsaluran yang diminta
versionTekan 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 parameterJenisRentang nilai
accesskeyStringaccesskey
channelStringpush_user_incr_asset
eventStringpenugasan langsungaddChannel
signStringTanda tangan

Nilai KembaliDeskripsi
coinsInformasi koin
dataTypeJenis data
channelsaluran yang diminta
versionTekan 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 parameterJenisRentang nilai
accesskeyStringaccesskey
binarybooleanApakah transmisi biner
channelStringpush_user_lever_asset
eventStringpenugasan langsungaddChannel
isZipbooleanApakah akan mengompresi transmisi
signStringTanda tangan

Nilai KembaliDeskripsi
leversmengubah informasi
dataTypeJenis data
channelsaluran yang diminta
usdtcnyNilai 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 parameterJenisRentang nilai
accesskeyStringaccesskey
binarybooleanApakah transmisi biner
channelStringpush_user_cross_asset
eventStringpenugasan langsungaddChannel
isZipbooleanApakah akan mengompresi transmisi
signStringTanda tangan

Nilai KembaliDeskripsi
coins
loanInmeminjam
fundTypeJenis koin
amountmengubah informasi
freezePembekuan koin
overdraftBunga
keyNama koin
dataTypeJenis data
channelsaluran yang diminta
usdtcnyNilai 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

Masukkan deskripsi gambar

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 Masukkan deskripsi gambar

Masalah umum

  1. 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.
  2. 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
  3. Mengapa kesalahan 1003 terjadi?

    • Periksa apakah enkripsi diurutkan berdasarkan nilai ASCII dan apakah parameter enkripsi tidak ada atau memiliki rangkaian karakter yang berlebihan, dll.
  4. Prompt 1002 kesalahan parameter tidak valid
    • Parameter transfer tidak valid
  5. 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.
  6. 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
  7. 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
  8. 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.
  9. qcApakah itu RMB

    • 不是,qc和人民币是1:1换算的
  10. Mengapa ada kesalahan internal 1002
    • Terkadang, volume permintaan yang berlebihan dapat menyebabkan kesalahan ini, harap ingat untuk penggunaan normal

Kode Kesalahan

restReturn Code

Return CodeDeskripsi
1000panggilan sukses
1001Pesan error
1002Kesalahan internal
1003Verifikasi gagal
1004Kata sandi transaksi terkunci
1005Kata sandi transaksi salah, silakan periksa dan masukkan kembali。
1006Otentikasi nama asli menunggu persetujuan atau tidak disetujui
1009Interface ini sedang dalam maintenance
1010tutup sementara
1012Izin tidak memadai
1013Tidak dapat diperdagangkan, jika Anda memiliki pertanyaan, silakan hubungi layanan pelanggan online
1014Tidak dapat menjual selama periode pra-penjualan
2001Saldo akun CNY tidak mencukupi
2002Saldo akun BTC tidak mencukupi
2003Saldo akun LTC tidak mencukupi
2005Saldo akun ETH tidak mencukupi
2006ETCSaldo anda tidak mencukupi
2007BTSSaldo anda tidak mencukupi
2008EOSSaldo anda tidak mencukupi
2009BCCSaldo anda tidak mencukupi
3001Pesanan tidak ditemukan atau selesai
3002Jumlah tidak sah
3003Jumlah tidak valid
3004User tidak ada
3005Parameter tidak sah
3006IP tidak valid atau tidak sesuai dengan IP yang terikat
3007Waktu permintaan kedaluwarsa
3008Transaksi tidak ditemukan
3009Harga melebihi batas
3010Gagal melakukan pemesanan, karena Anda telah mengatur untuk melarang perdagangan pasar ini.
3011Harga yang dipercayakan tidak normal, harap ubah dan pesan lagi
3012Duplikat customerOrderId kustom
4001APIInterface terkunci selama satu jam
4002Terlalu sering meminta

websocketReturn Code

Return CodeDeskripsi
1000panggilan sukses
1001Pesan error
1002Kesalahan internal
1003Verifikasi gagal
1004Kata sandi transaksi terkunci
1005Kata sandi transaksi salah, silakan periksa dan masukkan kembali。
1006Otentikasi nama asli menunggu persetujuan atau tidak disetujui
1007saluran tidak ada
1009Interface ini sedang dalam maintenance
1010tutup sementara
1012Izin tidak memadai
1013Tidak dapat diperdagangkan, jika Anda memiliki pertanyaan, silakan hubungi layanan pelanggan online
1014Tidak dapat menjual selama periode pra-penjualan
2001Saldo akun CNY tidak mencukupi
2002Saldo akun BTC tidak mencukupi
2003Saldo akun LTC tidak mencukupi
2005Saldo akun ETH tidak mencukupi
2006ETCSaldo anda tidak mencukupi
2007BTSSaldo anda tidak mencukupi
2008EOSSaldo anda tidak mencukupi
2009BCCSaldo anda tidak mencukupi
3001Pesanan tidak ditemukan atau selesai
3002Jumlah tidak sah
3003Jumlah tidak valid
3004User tidak ada
3005Parameter tidak sah
3006IP tidak valid atau tidak sesuai dengan IP yang terikat
3007Waktu permintaan kedaluwarsa
3008Transaksi tidak ditemukan
3009Harga melebihi batas
3010Gagal melakukan pemesanan, karena Anda telah mengatur untuk melarang perdagangan pasar ini.
3011Harga yang dipercayakan tidak normal, harap ubah dan pesan lagi
3012Duplikat customerOrderId kustom
4001APIInterface terkunci selama satu jam
4002Terlalu sering meminta

Hubungi kami

ZB中币现面向全球征集做市商,做市商享有maker返佣、taker超低费率,如果您对做市商计划感兴趣,请联系[email protected]或您的大客户经理。 请将以下信息发至[email protected]:

  1. 有效联系方式(微信或电话)

  2. 简要介绍团队情况及过往做市情况(30天内成交量、做市策略等)