礦池API
基礎信息
接口地址
● 密鑰獲取方式
a. 提供在蜘蛛官網註冊的郵箱,聯系蜘蛛工作人員開通第三方API權限,開通成功後登錄官網在個人中心下面能看到"獲取API密鑰入口"
● 線上環境
a. 官網線上:https://api.spiderpool.com/
說明
● H、KH、MH、GH、TH、PH、EH,算力單位間相差1000
註意
● 所有接口采用私鑰簽名,公鑰驗簽的方式請求
● 統一請求格式
{
"dataJson": "",
"accessKey": "",
"timestamp": 1628381288000,
"sign": ""
}
● 如訪問/v2/addUser接口
{
"dataJson": "{"userName":"test001","password":"123456"}",
"accessKey": "D1504708600B44B499489C16CE7C32A5",
"timestamp": 1628381288000,
"sign": "N0n0iqKLUtssteqhbsOHGv2N7UaJh+YnPio90fciAM4hn2L82jAhafG/ynxdgFnBf2ZJ2R2C1d0uRvSNSHnEJKA8rvMx6ytQa2E4gpD8LG0kkdzYwgv9pyEFOGsS4+cUdV+nF/WJiPDRqfx8Cb0gPjBuCj+HboVx5++HOe2v+sA="
}
● 統一返回格式
{
"code": "",
"msg": "",
"data": object,
}
code="SUCCESS" 為操作成功,其余失敗
● java 版請求示例
long timestamp = System.currentTimeMillis();
String spiderUrl = "https://api.spiderpool.com/v2/subaccount/createSubaccount";
JSONObject jsonObject = new JSONObject();
jsonObject.put("coin", "eth");
jsonObject.put("subaccount", "chizg101");
jsonObject.put("walletAddress", "0x9ed670910a8e5895428bb85e600d7d388a904a22");
Map<String, Object> param = new HashMap<>();
String dataJsonStr = jsonObject.toJSONString() + "|" + timestamp;
String sign = RSACoder.sign(dataJsonStr.getBytes(StandardCharsets.UTF_8), privateKey);
param.put("dataJson", jsonObject.toJSONString());
param.put("accessKey", "5A842DAA0B8A4746B362FBF382A04CD9");
param.put("timestamp", timestamp);
param.put("sign", sign);
String jsonBody = JSON.toJSONString(param);
String reslut = HttpclientUtil.postRequest(spiderUrl, jsonBody,null,true);
● python 版請求示例
import requests
from Crypto.PublicKey import RSA
from Crypto.Signature import PKCS1_v1_5
from Crypto.Hash import MD5
import base64
import time
import calendar
datajson = "{'subAccountName':'test0414dan08','coin':'eth'}"
timestamp = str(int(round(calendar.timegm(time.gmtime())*1000)))
data = datajson + "|%s" % (timestamp)
#私钥
privatekey='''MIICdgIBADANBgkqhkiG9w0BAQEFAASCAmAwggJcAgEAAoGBAJpigNWb2r6fbue9CfnaRyundft0WS4e/hhtdCef74UdH9stDtRidv24hieP7uXdq8KHVmzqAqiNVAHsg4WttwO9Fyz0YPuJZ/mXLqI0S4SOzGZ7hqErDOOF1Z9WE/ykapGAT/SBc5q0lLN6Z3iz7AygZYy4UxrH3cR2BsrUEyGnAgMBAAECgYBNTxpY3Uzyu//bh+xg849EKv2Hx8GIuPhg3x6VYR+eNvFm3e9ZJ12SvD5hvU/SR+jk5sS+kYh3Qx5YQEm0PUMxjyRkBpZUVitkBpRvBaQKfRvS9D65rUlUYhgHnyhwdvmIvJYob9dB+HkOgZMqEwWrWqe4B8E4i8ei9fwLkVSn0QJBAPHUljaXd4gvtkJVExlKB4u7irTEVjwTi9Nbh2pUWk3jgb1/Ua0kbNtQ0vEiBtQ6ROOSqbPoBCiH5YwR0KKjw2UCQQCjbj9Z98wUEXIao2EQ11U4T281B9vqUSYPBR4u7UVEDkeEyxL0gzXmqJc8pAmgCygSi0Ggg5xxD5TjoW+4xg4bAkEAjeE9qBXBiWMEuXIUXHf0aWTEgj3WojSNiplen2GSAbSCv9zc3IpMW3fV6qcd/pGZLTM04Vo0Zlskr8Mb9u/BiQJAcR60Nt+voAxbQFjprLB/ShShUsF31H4Kq8bNF4ofsXV4x0+QdTIEsvzqgYzBJMfUGtHMwP+X3yH72ns5S1m7FQJAKCWFdZzN9D+2HX7yZsc4/Q7l+J//LpZJjLsVhcDh3RGRU3QX6SzCWlLwOq4FX+nUYej2B3rr0ymr+tiy/k7fbQ==
'''
private_keyBytes = base64.b64decode(privatekey)
prikey = RSA.importKey(private_keyBytes)
signer = PKCS1_v1_5.new(prikey)
hash_obj = MD5.new(data.encode('utf-8'))
signtrue = base64.b64encode(signer.sign(hash_obj))
sign = str(signtrue)[2:-1]
url = "https://api.spiderpool.com/v2/subaccount/createSubaccount"
data = {
"dataJson": datajson,
"accessKey": "5A842DAA0B8A4746B362FBF382A04CD9",
"timestamp": timestamp,
"sign": sign
}
result = requests.post(url,json=data)
print(result.text)
● node 版請求示例
const http = require('http');
const crypto = require('crypto');
const privateKey = "MIICeAIBADANBgkqhkiG9w0BAQEFAASCAmIwggJeAgEAAoGBAM8WblrosGzrRPSo+xBiL1zMCimpq64nqw66Wh4Z3lG1WIAfe+mes3oFzLsiOuPALCUZHbaMQ9fC7gcgQIL8PtlPRnuqxO1VrKDPE1hCN2cy+7HuSgWMrhnkgP11eVrDFEV4c9ugA1pl9e/4s2F3QCuCKCCrDh+lFTcwLOB+/jqbAgMBAAECgYEAme0ZX9c/c+Y4XgbQfvAMNlSvZSJpqsxveEYJwAAIYQGDY9CDITZGP3faImqiDTGFXpnZnRuLPe/1TzSo3vOxniuW2Bdyu7gn39b6/bmwveIUVzHG3K5VUMV5r8uGiFoPkbl9jQmBBluAWhPsEdMMibdW+WGXsMiLigVdocCDF9ECQQD7SQMY4op0UuaUjFY3oPs5zTXzupopMFxMFxIn4WnZYTruRXFnJnzS2r+Cm6t+TdjXES0kHjky2ml5FSVfVLMjAkEA0vkgZTh/jGFSQ619Fa3TYzSa8TNGw309pXnXWQRKJO6USmWKOfdONp1u0aN/QlsFCGi8OmjTxeL8KsNWAEHuKQJAHqWr/Af9LOzDdJCdH1HB8i3GC8DRdn6QczNJIpYKa9nA7ziG+TaneKv3OX2078Wc0bYllEcfYMVkocDjevoAkwJBAIuVCDnwB3N5cFQWlIujVhhs1ZZ/tnHgisjQtAnRLL0CnFoclDeFx9maj5dj9O6SCeJmaSK7+GEUrIIeeufwtwECQQCq5yGYqnuXHQSra6qSpoC+65AyROVdDhXWRPdroFFbtTdE9EdaKImgac4B2ARKMGsKSXNXSXStHneN1R7n+iX/"
const signer = (json) => {
const privateKeys = "-----BEGIN PRIVATE KEY-----\n" + privateKey + "\n-----END PRIVATE KEY-----"
const sign = crypto.createSign('md5');
sign.update(json);
return sign.sign(privateKeys, 'base64');
}
const jsonObject = JSON.stringify({
queryTime: 1620732754
})
const timestamp = new Date().valueOf()
const dataJsonStr = `${jsonObject}|${timestamp}`
const sign = signer(dataJsonStr)
const postData = JSON.stringify({
dataJson: jsonObject,
accessKey: "AF7180A7203F49779052F1D1336EBE3C",
timestamp: timestamp,
sign: sign
});
const options = {
hostname: 'https://api.spiderpool.com',
path: '/v2/game/getData',
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Content-Length': Buffer.byteLength(postData)
}
};
const req = http.request(options, (res) => {
res.setEncoding('utf8');
res.on('data', (chunk) => {
console.log(`響應主體: ${chunk}`);
});
});
// 將數據寫入請求主體。
req.write(postData);
req.end();
● PHP版請求實例
$private = 'PRIVATE_KEY';
$dataJson = json_encode([
'walletAddress' => 'eth_address',
'subaccount' => 'sub_account_name',
'coin' => 'eth',
]);
$timestamp = round(microtime(true) * 1000);
if (openssl_sign($dataJson . '|' . $timestamp, $signature, $private, OPENSSL_ALGO_MD5)) {
$signature = base64_encode($signature);
$httpClient = new \GuzzleHttp\Client(['timeout' => 10]);
$response = $httpClient->post('https://api.spiderpool.com/v2/subaccount/createSubaccount', [
\GuzzleHttp\RequestOptions::BODY => json_encode([
'dataJson' => $dataJson,
'accessKey' => 'ACCESS_KEY',
'timestamp' => $timestamp,
'sign' => $signature,
]),
]);
dd($response->getBody()->getContents());
}
dd('fail');
API
創建子賬號
備註:建立BTC子帳號會同時建立FB子帳號,但建立FB子帳號不會同時建立BTC子帳號
請求 AUTH
AUTH
POST /v2/subaccount/createSubaccount
參數
正確響應:
{
"code": "SUCCESS"
}
錯誤響應:
{
"code": "......", // INVALID_SUBACCOUNT / SUBACCOUNT_EXIST / IVAILD_WALLETADDRESS
"msg": "......"
}
修改子賬號
請求 AUTH
AUTH
POST /v2/subaccount/modifyWalletAddress
參數
正確響應:
{
"code": "SUCCESS"
}
錯誤響應:
{
"code": "......", // INVALID_SUBACCOUNT / SUBACCOUNT_EXIST / IVAILD_WALLETADDRESS
"msg": "......"
}
觀察者模式
請求 AUTH
AUTH
POST /v2/subaccount/subAccountObserverLink
參數
正確響應:
{
"code":"SUCCESS",
"data":{
"subaccount":"btctestchizg002",
"sign":"v92480670d100d4c67f9e22d6ae612fd3e78aebb6e1b1fcdba994ba454ade6482",
"coin":"btc"
}
}
錯誤響應:
{
"code": "......", // INVALID_SUBACCOUNT / SUBACCOUNT_EXIST / IVAILD_WALLETADDRESS
"msg": "......"
}
獲取子賬號收益詳細信息
請求 AUTH
AUTH
POST /v2/subaccount/getSubaccountProfitDetailInfo
參數
正確響應:
{
"code": "SUCCESS",
"data": {
"total": 35,
"dayProfitList": [
{
"dayDate": 1569600000000,
"avgHashrate": "90057979829",
"dayProfit": 0.647981779,
},
......
]
}
}
獲取子賬號支付記錄
請求 AUTH
AUTH
POST /v2/subaccount/getSubaccountPaymentRecord
參數
正確響應:
{
"code": "SUCCESS",
"data": {
"list": [
{
"paymentDate": 1564531200000, // 支付時間
"paymentAddress": "mv8W2k7UMkqbHbfbvRXcEzaehPGvZCmkV5" // 支付地址
"paymentMoney": 0.0666348000, // 支付金額
"txId": "097a39595c261f141de2174d8639fd9c18122236b14f9d08c91e82aea2a87e61" // 交易Id
}
],
"total": 1 // 總記錄數
}
}
獲取子賬號算力詳細信息
請求 AUTH
AUTH
POST /v2/subaccount/getSubaccountHashrateDetailInfo
參數
正確響應:
{
"code": "SUCCESS",
"data": {
"coin": "btc",
"subaccount": "btc_test001",
"startTime": 1569674700000,
"timeInterval": 600, // 每條數據時間間隔,單位:秒,btc為600秒
"hashrates": ["86989808092", "87758098015", "88708080889", "87167897971", ......]
}
}
獲取子賬號收益信息
請求 AUTH
AUTH
POST /v2/subaccount/getSubaccountProfitInfo
參數
正確響應:
{
"code": "SUCCESS",
"data": {
"yesterdayProfit": 0.61505330, // 24小時收益
"unpaidProfit": 0.57536600, // 未支付收益
"totalProfit": 26.026078521, // 總收益
"dayEstimateProfit": 0.57536600 // 今日收益。fb币种不支持此数据
}
}
獲取子賬號日收益信息
請求 AUTH
AUTH
POST
/v2/sp/subaccount/getDayProfitDetailInfo
參數
正確響應:
{
"code": 200,
"msg": "Success",
"t": 1717677079167,
"data": {
"day": 1716854400,
"coin": "btc",
"userName": "test",
"avgShareAccept": 6792538500482.84, // 日均算力 H/s
"dayProfit": 0.0000052632731696429, // 總收益 BTC
"ppsDayProfit": 0.00000505032710936514,//pps收益 BTC
"pplnsDayProfit": 0.00000021294606027776,// 手續費收益 BTC
"difficult": "84381461788831" //fb币种暂不支持此数据
}
}
獲取子賬號小時收益信息
請求 AUTH
AUTH
POST /v2/sp/
subaccount/
getHourProfitDetailInfo
參數
正確響應:
{
"code": 200,
"msg": "Success",
"t": 1717677390714,
"data": {
"day": 1716861600,
"coin": "btc",
"userName": "test",
"ppsDayProfit": 0.00000021294606027776 // PPS收益
}
}
獲取子賬號信息
請求 AUTH
AUTH
POST /v2/subaccount/getSubaccountInfo
參數
正確響應:
{
"code": "SUCCESS",
"data": [
{
"coin": "btc",
"subaccount": "test001",
"walletAddress": "33Vxq5DN4vAXkv7swDp4zNZJWkazsDgwLq"
"realtimeHashrate": "9789798686766", // 實時算力
"avgHashrate1440": "88667987952", // 24小時平均算力
"activeWorkerNum": 100,//在線礦工數
"inactiveWorkerNum": 10//離線礦工數
},
......
]
}
獲取子賬號礦工信息
請求 AUTH
AUTH
POST /v2/worker/getSubaccountWorkerDetailInfo
參數
正確響應:
{
"code": "SUCCESS",
"data": [
{
"workerName": "test001",
"realtimeHashrate": "2079080822",
"avgHashrate1440": "20979879837", // 24小時平均算力
"avgRejectrate1440": 0.001, // 24小時拒絕率
"status": "active", // 狀態:active在線;inactive離線;lost失聯
"lastShareTime": 1578653368 // 最新share時間
},
......
]
}
獲取子賬號礦機算力詳細信息
請求
POST /v2/worker/getSubaccountWorkerHashrateDetailInfo
參數
正確響應:
{
"code": "SUCCESS",
"data": {
"coin": "btc",
"subaccount": "subaccount01",
"worker": "test01",
"startTime": 1581742800000,
"timeInterval": 1800,
"hashrates": [
"32369622321725", // 平均算力 (H/s)
"30336747489926"
]
}
}
獲取昨日BTC塊收益與手續費收益比例
請求
POST
/v2/subaccount/getFPPSRate
參數
正確響應:
{
"code":"SUCCESS",
"data":{
"rate":"0.0329531088",
"day":1711324800,
"coin":"btc"
}
}
獲取整小時平均算力
請求
POST
/v2/account/getSubaccountHourHashrate
參數
正確響應:
{
"code":"SUCCESS",
"data":[
{
"hourTime":1711353600,
"shareAccept":11.102, // TH/s
"userName":"test01"
}
]
}
獲取優先上鏈費用
請求
POST
/v2/sp/txPriorityChain/getChainingFee
參數
正確響應:
{
"code": 200,
"msg": "Success",
"t": 1718250294397,
"data": {
"coin": "btc", //幣種
"curTxSize": 110, //交易體積
"unconfirmedPreTxSize": 110, //未確認交易體積
"unit": "btc", //支付費用幣種
"totalFee": 0.00009721, //實際支付費用
"theoreticalPayAmount": 0.00003584, //理論支付費用
"txHash": "d0b0c82931c5c34fccb1f4acd42cadc999450921a1a3925ba6dce20ce10598f9", //交易hash
"informEmail": "test@test.com", //用戶郵箱
"timeout": 6000 //下單過期時間 秒
},
"success": true
}
優先上鏈
請求
POST
/v2/sp/txPriorityChain/submit
參數
正確響應:
{
"code": 200,
"msg": "Success",
"t": 1718253030928,
"data": {
"coin": "btc", //幣種
"txHash": "d0b0c82931c5c34fccb1f4acd42cadc999450921a1a3925ba6dce20ce10598f9", //交易hash
"curTxSize": 110, //交易體積
"unconfirmedPreTxSize": 110, //未確認交易體積
"currency": "btc", //支付費用幣種
"totalFee": 0.00009721, //實際支付費用
"theoreticalPayAmount": 0.00003584, //理論支付費用
"informEmail": "test@test.com", //用戶郵箱
"status": 3, //訂單狀態 3: 已支付 4: 加速中 5: 已上鏈
"createTime": 1718253029277 //下單時間
},
"success": true
}
優先上鏈訂單列表
請求
POST
/v2/sp/txPriorityChain/queryOrderPage
參數
正確響應:
{
"code": 200,
"msg": "Success",
"t": 1718254361407,
"data": {
"total": 3,
"list": [
{
"coin": "BTC", //幣種
"txHash": "d0b0c82931c5c34fccb1f4acd42cadc999450921a1a3925ba6dce20ce10598f9", //交易hash
"curTxSize": 110, //交易體積
"unconfirmedPreTxSize": 110, //未確認交易體積
"currency": "BTC", //支付費用幣種
"totalFee": 0.00009721, //實際支付費用
"theoreticalPayAmount": 0.00003584, //理論支付費用
"informEmail": "test@test.com", //用戶郵箱
"status": 5, //訂單狀態 3: 已支付 4: 加速中 5: 已上鏈
"blockHeight": 847608, //區塊高度
"blockTime": 1718185820, //爆塊時間
"createTime": 1718253029000 //下單時間
}
]
},
"success": true
}
優先上鏈訂單詳情
請求
POST
/v2/sp/txPriorityChain/orderDetail
參數
正確響應:
{
"code": 200,
"msg": "Success",
"t": 1718253030928,
"data": {
"coin": "BTC", //幣種
"txHash": "d0b0c82931c5c34fccb1f4acd42cadc999450921a1a3925ba6dce20ce10598f9", //交易hash
"curTxSize": 110, //交易體積
"unconfirmedPreTxSize": 110, //未確認交易體積
"currency": "BTC", //支付費用幣種
"totalFee": 0.00009721, //實際支付費用
"theoreticalPayAmount": 0.00003584, //理論支付費用
"informEmail": "test@test.com", //用戶郵箱
"status": 3, //訂單狀態 3: 已支付 4: 加速中 5: 已上鏈
"blockHeight": 847608, //區塊高度
"blockTime": 1718185820, //爆塊時間
"createTime": 1718253029277 //下單時間
},
"success": true
}
優先上鏈賬戶信息
請求
POST
/v2/sp/txPriorityChain/accountInfo
參數
正確響應:
{
"code": 200,
"msg": "Success",
"t": 1718254872915,
"data": [
{
"currency": "BTC", //幣種
"availableBalance": 4.99882903, //可用余額
"totalConsumeAmount": 0.00117097 //總消費金額
}
],
"success": true
}
最后更新于