矿池API

基础信息

接口地址

● 密钥获取方式

a. 提供在蜘蛛官网注册的手机号,联系蜘蛛工作人员开通第三方API权限,开通成功后登录官网在个人中心下面能看到"获取API密钥入口"

● 线上环境

a. 官网线上:https://www.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://cloudapi.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://cloudapi.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://cloudapi.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://cloudapi.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

创建子账号

请求 AUTH

POST /v2/subaccount/createSubaccount

参数

参数名参数类型必填默认值描述

coin

String

true

-

币种,如,btc

subaccount

String

true

-

子账号(6~20由字母数字组成的)

walletAddress

String

false

-

钱包地址(请根据链环境填符合规则的地址)

  • 正确响应:

{
    "code": "SUCCESS"
}
  • 错误响应:

{
    "code": "......", // INVALID_SUBACCOUNT / SUBACCOUNT_EXIST / IVAILD_WALLETADDRESS
    "msg": "......"
}

修改子账号

请求 AUTH

POST /v2/subaccount/modifyWalletAddress

参数

参数名参数类型必填默认值描述

coin

String

true

-

币种缩写,如,btc、eth

subaccount

String

true

-

子账号名称

newWalletAddress

String

true

-

新的钱包地址(请根据链环境填符合规则的地址)

  • 正确响应:

{
    "code": "SUCCESS"
}
  • 错误响应:

{
    "code": "......", // INVALID_SUBACCOUNT / SUBACCOUNT_EXIST / IVAILD_WALLETADDRESS
    "msg": "......"
}

观察者模式

请求 AUTH

POST /v2/subaccount/subAccountObserverLink

参数

参数名参数类型必填默认值描述

coin

String

true

-

币种缩写,如,btc

subaccount

String

true

-

子账号名称

type

String

true

-

类型:newSign 新增、resetSign 重置、deleteSign 删除

  • 正确响应:

{
	"code":"SUCCESS",
	"data":{
		"subaccount":"btctestchizg002",
		"sign":"v92480670d100d4c67f9e22d6ae612fd3e78aebb6e1b1fcdba994ba454ade6482",
		"coin":"btc"
	}
}
  • 错误响应:

{
    "code": "......", // INVALID_SUBACCOUNT / SUBACCOUNT_EXIST / IVAILD_WALLETADDRESS
    "msg": "......"
}

获取子账号收益详细信息

请求 AUTH

(4:30 开始跑定时,建议5:30以后取数据) POST /v2/subaccount/getSubaccountProfitDetailInfo

参数

参数名参数类型必填默认值描述

coin

String

true

-

币种缩写,如,btc

subaccount

String

true

-

子账号名称

startTimestamp

Integer

false

0

查询起始时间戳(秒)

endTimestamp

Integer

false

当前时间 查询结束时间戳(秒)

pageNumber

Integer

false

1

页号

pageSize

Integer

false

10

每页展示条数

  • 正确响应:

{
    "code": "SUCCESS",
    "data": {
        "total": 35,
        "dayProfitList": [
            {
                "dayDate": 1569600000000,
                "avgHashrate": "90057979829",
                "dayProfit": 0.647981779,
            },
            ......
        ]
    }
}

获取子账号支付记录

请求 AUTH

POST /v2/subaccount/getSubaccountPaymentRecord

参数

参数名参数类型必填默认值描述

coin

String

true

-

币种缩写,如,btc

subaccount

String

true

-

子账号名称

startTimestamp

Integer

false

0

查询起始时间戳(毫秒)

endTimestamp

Integer

false

当前时间

查询结束时间戳(毫秒)

pageNumber

Integer

false

1

页号

pageSize

Integer

false

10

每页展示条数

  • 正确响应:

{
    "code": "SUCCESS",
        "data": {
        "list": [
            {
                "paymentDate": 1564531200000, // 支付时间
                "paymentAddress": "mv8W2k7UMkqbHbfbvRXcEzaehPGvZCmkV5" // 支付地址
                "paymentMoney": 0.0666348000, // 支付金额
                "txId": "097a39595c261f141de2174d8639fd9c18122236b14f9d08c91e82aea2a87e61" // 交易Id
 
            }
        ],
            "total": 1 // 总记录数
    }
}

获取子账号算力详细信息

请求 AUTH

POST /v2/subaccount/getSubaccountHashrateDetailInfo

参数

参数名参数类型必填默认值描述

coin

String

true

-

币种缩写,如,btc,eth

subaccount

String

true

-

子账号名称

mode

String

false

hourly

mode=hourly表示24小时图,mode=daily表示30天图

  • 正确响应:

{
    "code": "SUCCESS",
    "data": {
         "coin": "btc",
         "subaccount": "btc_test001",
         "startTime": 1569674700000,
         "timeInterval": 600, // 每条数据时间间隔,单位:秒,btc为600秒
         "hashrates": ["86989808092", "87758098015", "88708080889", "87167897971", ......]
    }
}

获取子账号收益信息

请求 AUTH

POST /v2/subaccount/getSubaccountProfitInfo

参数

参数名参数类型必填默认值描述

coin

String

true

-

币种缩写,如,btc

subaccount

String

true

-

子账号名称

  • 正确响应:

{
    "code": "SUCCESS",
    "data": {
            "yesterdayProfit": 0.61505330, // 24小时收益
            "unpaidProfit": 0.57536600,    // 未支付收益
            "totalProfit": 26.026078521,   // 总收益
            "dayEstimateProfit": 0.57536600 // 今日收益
    }
}

获取子账号日收益信息

请求 AUTH

POST /v2/sp/subaccount/getDayProfitDetailInfo

参数

参数名参数类型必填默认值描述

coin

String

true

-

币种缩写,如,btc

subaccount

String

true

-

子账号名称

timeStamp

int

true

秒级时间戳 UTC+0

  • 正确响应:

{
    "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"
    }
}

获取子账号小时收益信息

请求 AUTH

POST /v2/sp/subaccount/getHourProfitDetailInfo

参数

参数名参数类型必填默认值描述

coin

String

true

-

币种缩写,如,btc

subaccount

String

true

-

子账号名称

timeStamp

int

true

秒级时间戳

  • 正确响应:

{
    "code": 200,
    "msg": "Success",
    "t": 1717677390714,
    "data": {
        "day": 1716861600,
        "coin": "btc",     
        "userName": "test",
        "ppsDayProfit": 0.00000021294606027776  // PPS收益
    }
}

获取子账号信息

请求 AUTH

POST /v2/subaccount/getSubaccountInfo

参数

参数名参数类型必填默认值描述

coin

String

false

-

币种缩写,如,btc

subaccount

String

false

-

子账号名称

isGetSubaccountDetailInfo

Boolean

false

-

是否查详情

  • 正确响应:

{
    "code": "SUCCESS", 
    "data": [
      {
        "coin": "btc",
        "subaccount": "test001",
        "walletAddress": "33Vxq5DN4vAXkv7swDp4zNZJWkazsDgwLq"
        "realtimeHashrate": "9789798686766", // 实时算力
        "avgHashrate1440": "88667987952", // 24小时平均算力
        "activeWorkerNum": 100,//在线矿工数
        "inactiveWorkerNum": 10//离线矿工数
      },
    ......
]
}

获取子账号矿工信息

请求 AUTH

POST /v2/worker/getSubaccountWorkerDetailInfo

参数

参数名参数类型必填默认值描述

coin

String

true

-

币种缩写,如,btc,eth

subaccount

String

true

-

子账号名称

  • 正确响应:

{
  "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

参数

参数名参数类型必填默认值描述

coin

String

true

-

币种缩写,如,btc

subaccount

String

true

-

子账号名称

worker

String

true

-

矿机名称

mode

String

false

hourly mode=hourly表示24小时图,mode=daily表示30天图(仅BTC支持)

  • 正确响应:

{
    "code": "SUCCESS",
    "data": {
       	       "coin": "btc",
               "subaccount": "subaccount01",
                "worker": "test01",
      		"startTime": 1581742800000,
		"timeInterval": 1800,
		"hashrates": [
			"32369622321725",  // 平均算力 (H/s)
			"30336747489926"
		]
	}
}

获取昨日BTC块收益与手续费收益比例

请求

POST /v2/subaccount/getFPPSRate

参数

参数名参数类型必填默认值描述

coin

String

true

-

币种缩写,如,btc

day

Int

false

-

时间(秒)

  • 正确响应:

{
	"code":"SUCCESS",
	"data":{
		"rate":"0.0329531088",
		"day":1711324800,
		"coin":"btc"
	}
}

获取整小时平均算力

请求

POST /v2/account/getSubaccountHourHashrate

参数

参数名参数类型必填默认值描述

coin

String

true

-

币种缩写,如,btc

hourTime

Int

true

-

时间(秒) 整点时间戳

userName

String

false

子账号(不传查所有)

  • 正确响应:

{
	"code":"SUCCESS",
	"data":[
		{
			"hourTime":1711353600,
			"shareAccept":11.102, // TH/s
			"userName":"test01"
		}
	]
}

获取优先上链费用

请求

POST /v2/sp/txPriorityChain/getChainingFee

参数

参数名参数类型必填默认值描述

txHash

String

true

交易hash

informEmail

String

true

用户邮箱

  • 正确响应:

{
	"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

参数

参数名参数类型必填默认值描述

txHash

String

true

交易hash

informEmail

String

true

用户邮箱

curTxSize

Integer

true

当前交易体积

totalFee

BigDecimal

true

支付费用

  • 正确响应:

{
	"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

参数

参数名参数类型必填默认值描述

pageNumber

Integer

true

当前页

pageSize

Integer

true

每页数量

  • 正确响应:

{
	"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

参数

参数名参数类型必填默认值描述

txHash

String

true

交易hash

  • 正确响应:

{
	"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
}

最后更新于