API

所有API均为JSON格式, 对于每个API的调用我们建议至少等待3秒钟以得到反馈信息. 当前的API版本: 1.2.7

  • General
  • Public
  • Private
General

一般语法

https://api.nicehash.com/api?method=methodname&parameter1=parameter1value&parameter2=parameter2value...

变更日志

版本 1.2.7:
- 函数stats.provider.ex返回了空白的款项数据
- 函数stats.provider.ex返回了有效的款项数据

版本 1.2.6:
- 函数stats.provider.ex返回每个算法的当前的收益能力
- 为函数stats.provider.ex添加了可选的参数
- 为每一矿机函数stats.provider.workers返回连接的服务器位置(stratum proxy)

版本 1.2.5:
- 函数stats.provider不再需要位置参数(合并状态)
- 为函数stats.provider.ex添加了详细的数据(包括历史数据)
- 添加了函数stats.provider.workers

版本 1.2.4:
- 函数stats.global.current现拥有位置参数选项

版本 1.2.3:
- 函数methods stats.global.current和函数stats.global.24h不再必须定义位置信息参数
- 函数methods stats.global.current和函数stats.global.24h不再返回多算法统计数据信息

算法

算法使用以下数字标记:

0 = Scrypt
1 = SHA256
2 = ScryptNf
3 = X11
4 = X13
5 = Keccak
6 = X15
7 = Nist5
8 = NeoScrypt
9 = Lyra2RE
10 = WhirlpoolX
11 = Qubit
12 = Quark
13 = Axiom
14 = Lyra2REv2
15 = ScryptJaneNf16
16 = Blake256r8
17 = Blake256r14
18 = Blake256r8vnl
19 = Hodl
20 = DaggerHashimoto
21 = Decred
22 = CryptoNight
23 = Lbry
24 = Equihash
25 = Pascal
26 = X11Gost
27 = Sia
28 = Blake2s
29 = Skunk
30 = CryptoNightV7

订单

订单类型使用以下数字标记:

0 = 标准订单
1 = 固定订单

Public

无函数

https://api.nicehash.com/api

获取API版本, 通过该链接了解API的相关变动.

参数:
- 无

返回值:

{"result":{"api_version":"1.0.1"},"method":null}

stats.global.current

https://api.nicehash.com/api?method=stats.global.current

获取所有算法的当前收益能力(价格)和算力速度, 每30秒刷新一次数据.

参数:
- location: 0代表欧洲, 1代表美国, 该参数可选且如不提供函数将返回组合数据.

返回值:

{"result":{"stats":[{"profitability_above_ltc":"8.27","price":"0.1683","profitability_ltc":"0.1554","algo":0,"speed":"27.0678"},{"price":"0.0117","profitability_btc":"0.0114","profitability_above_btc":"2.39","algo":1,"speed":"1597723.0669"},{"profitability_above_ltc":"89.98","price":"0.5906","profitability_ltc":"0.1554","algo":2,"speed":"0.0038"},{"profitability_above_ltc":"610.26","price":"0.2007","profitability_ltc":"0.1554","algo":3,"speed":"24.9009"},{"profitability_above_ltc":"119.72","price":"0.0854","profitability_ltc":"0.1554","algo":4,"speed":"0.5826"},{"profitability_above_ltc":"190.79","price":"0.0009","profitability_ltc":"0.1554","algo":5,"speed":"2.6436"},{"profitability_above_ltc":"123.75","price":"0.0994","profitability_ltc":"0.1554","algo":6,"speed":"0.0275"},{"profitability_above_ltc":"-100.00","price":"0.0000","profitability_ltc":"0.1554","algo":7,"speed":"0.0000"},{"profitability_above_ltc":"405.27","price":"2.6180","profitability_ltc":"0.1554","algo":8,"speed":"0.1194"},{"profitability_above_ltc":"293.06","price":"0.4888","profitability_ltc":"0.1554","algo":9,"speed":"0.0346"}]},"method":"stats.global.current"}

stats.global.24h

https://api.nicehash.com/api?method=stats.global.24h

获取过去24小时所有算法的收益能力(价格).

参数:
- 无

返回值:

{"result":{"stats":[{"price":"0.1962","algo":0,"speed":"23.8031"},{"price":"0.0118","algo":1,"speed":"1576060.6047"},{"price":"0.3759","algo":2,"speed":"0.0041"},{"price":"0.1998","algo":3,"speed":"25.0689"},{"price":"0.2213","algo":4,"speed":"1.5202"},{"price":"0.0008","algo":5,"speed":"2.4735"},{"price":"0.1559","algo":6,"speed":"0.0324"},{"price":"0.0000","algo":7,"speed":"0.0000"},{"price":"2.9811","algo":8,"speed":"0.1268"},{"price":"0.4853","algo":9,"speed":"0.0304"}]},"method":"stats.global.24h"}

stats.provider

https://api.nicehash.com/api?method=stats.provider&addr=1P5PNW6Wd53QiZLdCs9EXNHmuPTX3rD6hW

获取所有算法的算力买家的当前状态, 每30秒刷新一次, 该参数同时返回最新56个款项.

参数:
- addr - Provider's BTC address.

返回值:

{"result":{"stats":[{"balance":"0.00010688","rejected_speed":"0.0000","algo":0,"accepted_speed":"0.0820"},{"balance":"0.00000000","rejected_speed":"0.0000","algo":2,"accepted_speed":"0.0000"},{"balance":"0.00000000","rejected_speed":"0.0000","algo":3,"accepted_speed":"0.0000"},{"balance":"0.00000000","rejected_speed":"0.0000","algo":4,"accepted_speed":"0.0000"},{"balance":"0.00000000","rejected_speed":"0.0000","algo":6,"accepted_speed":"0.0000"},{"balance":"0.00000000","rejected_speed":"0.0000","algo":7,"accepted_speed":"0.0000"}],"payments":[{"amount":"0.01604289","fee":"0.00032741","TXID":"e47ce45771b4bb80b52cb787c95eca0bb0779cb5cb7a9af437d1b13e450db7a5","time":"2015-01-22 17:03:27"}],"addr":"16dZdWFr6bhy5bxwsyUyunuWED8zWfQiYA"},"method":"stats.provider"}

stats.provider.ex

https://api.nicehash.com/api?method=stats.provider.ex&addr=17a212wdrvEXWuipCV5gcfxdALfMdhMoqh

获取关于算力卖家的所有算法的过去7天的历史数据和款项.

参数:
- addr - Provider's BTC address;
- from - 获取从某一时刻起(UNIX时间戳)的历史数据, 该参数可选且默认值为0, 即返回所有历史数据.

返回值 (已做修改, 以使其更易理解)

{"method":"stats.provider.ex",
"result":{
	"addr":"17a212wdrvEXWuipCV5gcfxdALfMdhMoqh",
	"current":[{
		"algo":3, // 算法代码(3 = X11)
		"name":"X11", // 算法名称
		"suffix":"MH", // 速度单位(kH, MH, GH, TH,...)
		"profitability":"0.00045845", // 以BTC/算力速度单位/天标识的当前收益能力
		"data":[{ // 速度主体可能包含以下几方面:
			  // a (已接受), rt (已拒绝 target), rs (已拒绝 stale),
			  // rd (已拒绝 duplicate) and ro (已拒绝 other)
			  // 如该区域为空,  则速度为0
			"a":"23.09", // 已接受速度(单位为MH/s, 算法X11)
			"rs":"0.54", // 已拒绝算力速度 - stable
			},
			"0.0001234" // 余额(未支付)
		]},
		... // 其它算法点击这里
	],
	"past":[{
		"algo":3,
		"data":[
			[4863234, // 时间戳; 放大到300获得UNIX时间戳
			{"a":"28.6"}, // 速度主体
			"0" // 余额(未支付)
			],[4863235,{"a":"27.4"},"0.00000345"],
			... // 下次带有inc时间戳
		]},
		... // 其它算法点击这里
	],
	"payments":[], // 阵列空白
	}
}

stats.provider.payments

https://api.nicehash.com/api?method=stats.provider.payments&addr=17a212wdrvEXWuipCV5gcfxdALfMdhMoqh

获取算力卖家的款项.

参数:
- addr - Provider's BTC address;
- from - 获取从某一时刻起(UNIX时间戳)的历史数据, 该参数可选且默认值为0, 即返回所有历史数据.

返回值 (已做修改, 以使其更易理解)

{
"method":"stats.provider.payments",
"result":{
	"addr":"17a212wdrvEXWuipCV5gcfxdALfMdhMoqh",
	"nh_wallet": false,
	"attack_written_off": "0",
	"attack_amount": "0",
	"attack_repaid": "0",
	"payments":[{
		"amount":"0.00431400",
		"fee":"0.00023000",
		"TXID":"txidhere",
		"time":1453538732, // UNIX时间错
		"type":0 // 款项类型(0代表标准NiceHash款项)
	... // 其它款项点击这里
	}],
	}
}

stats.provider.workers

https://api.nicehash.com/api?method=stats.provider.workers&addr=17a212wdrvEXWuipCV5gcfxdALfMdhMoqh&algo=3

Get detailed stats for provider's workers (rigs).

参数:
- addr - Provider's BTC address;
- algo - 算法使用ID标记.

返回值 (已做修改, 以使其更易理解)

{
"method":"stats.provider.workers",
"result":{
	"addr":"17a212wdrvEXWuipCV5gcfxdALfMdhMoqh",
	"algo":3,
	"workers":[[
		"rigname", // 矿机名称
		{"a":"11.02","rs":"0.54"}, // 速度主体
		15, // 连接时长(分)
		1, // 1 = xnsub开启, 0 = xnsub关闭
		"0.1", // 难度
		0, // 连接的服务器位置(0代表欧洲, 1代表美国, 2代表相关, 3代表日本)
	],
	... // 其它矿机点击这里	
	]
}
}

orders.get

https://api.nicehash.com/api?method=orders.get&location=0&algo=3

获取指定算法的所有订单信息, 每30秒刷新一次.

参数:
- location - 0代表欧洲(NiceHash), 1代表美国(WestHash);
- algo - 算法使用ID标记.

返回值:

{"result":{"orders":[{"type":0,"id":5877,"price":"0.0505","algo":1,"alive":true,"limit_speed":"1.0","workers":0,"accepted_speed":0.0}]},"method":"orders.get"}

multialgo.info

https://api.nicehash.com/api?method=multialgo.info

获取关于多算法挖矿的信息.

参数:
- 无

返回值:

{"result":{"multialgo":[{"default_factor":1.0,"port":4333,"name":"Scrypt","algo":0},{"default_factor":0.5,"port":4335,"name":"Scrypt-A.-Nf.","algo":2},{"default_factor":5.5,"port":4336,"name":"X11","algo":3},{"default_factor":4.0,"port":4337,"name":"X13","algo":4},{"default_factor":500.0,"port":4338,"name":"Keccak","algo":5},{"default_factor":3.5,"port":4339,"name":"X15","algo":6},{"default_factor":16.0,"port":4340,"name":"Nist5","algo":7},{"default_factor":0.3,"port":4341,"name":"NeoScrypt","algo":8},{"default_factor":1.25,"port":4342,"name":"Lyra2RE","algo":9}]},"method":"multialgo.info"}

simplemultialgo.info

https://api.nicehash.com/api?method=simplemultialgo.info

获取关于多算法挖矿的信息. 阅读更多请点击这里.

参数:
- 无

返回值:

{"result":{"simplemultialgo":[{"paying":"0.147686","port":3333,"name":"scrypt","algo":0},{"paying":"0.00000781","port":3334,"name":"sha256","algo":1},{"paying":"0.001512","port":3335,"name":"scryptnf","algo":2},{"paying":"0.330078","port":3336,"name":"X11","algo":3},{"paying":"0.38065","port":3337,"name":"x13","algo":4},{"paying":"0.001615","port":3338,"name":"keccak","algo":5},{"paying":"0.00121","port":3339,"name":"x15","algo":6},{"paying":"0","port":3340,"name":"nist5","algo":7},{"paying":"6.053761","port":3341,"name":"neoscrypt","algo":8},{"paying":"0.30008","port":3342,"name":"lyra2re","algo":9},{"paying":"0.0063","port":3343,"name":"whirlpoolx","algo":10},{"paying":"0.195998","port":3344,"name":"qubit","algo":11},{"paying":"0.274617","port":3345,"name":"quark","algo":12},{"paying":"424","port":3346,"name":"axiom","algo":13},{"paying":"0.42777","port":3347,"name":"lyra2rev2","algo":14}]},"method":"simplemultialgo.info"}

buy.info

https://api.nicehash.com/api?method=buy.info

获取购买算力所需的相关信息 NiceHashBot.

参数:
- 无

返回值:

{"result":{"algorithms":[{"down_step":"-0.0010","min_limit":"0.1","speed_text":"GH","name":"Scrypt","algo":0,"multi":"1"},{"down_step":"-0.0001","min_limit":"5","speed_text":"TH","name":"SHA256","algo":1,"multi":"0.001"},{"down_step":"-0.0020","min_limit":"0.01","speed_text":"GH","name":"ScryptNf","algo":2,"multi":"1"},{"down_step":"-0.0010","min_limit":"0.05","speed_text":"GH","name":"X11","algo":3,"multi":"1"},{"down_step":"-0.0010","min_limit":"0.02","speed_text":"GH","name":"X13","algo":4,"multi":"1"},{"down_step":"-0.0001","min_limit":"10","speed_text":"GH","name":"Keccak","algo":5,"multi":"1"},{"down_step":"-0.0010","min_limit":"0.02","speed_text":"GH","name":"X15","algo":6,"multi":"1"},{"down_step":"-0.0010","min_limit":"0.1","speed_text":"GH","name":"Nist5","algo":7,"multi":"1"},{"down_step":"-0.0100","min_limit":"0.01","speed_text":"GH","name":"NeoScrypt","algo":8,"multi":"1"},{"down_step":"-0.0020","min_limit":"0.01","speed_text":"GH","name":"Lyra2RE","algo":9,"multi":"1"},{"down_step":"-0.0001","min_limit":"2","speed_text":"GH","name":"WhirlpoolX","algo":10,"multi":"1"},{"down_step":"-0.0005","min_limit":"0.06","speed_text":"GH","name":"Qubit","algo":11,"multi":"1"},{"down_step":"-0.0010","min_limit":"0.05","speed_text":"GH","name":"Quark","algo":12,"multi":"1"},{"down_step":"-0.0001","min_limit":"1","speed_text":"kH","name":"Axiom","algo":13,"multi":"1000000"},{"down_step":"-0.0010","min_limit":"0.04","speed_text":"GH","name":"Lyra2REv2","algo":14,"multi":"1"},{"down_step":"-0.0010","min_limit":"0.01","speed_text":"MH","name":"ScryptJaneNf16","algo":15,"multi":"1000"}],"down_time":600},"method":"buy.info"}
Private

orders.get&my

https://api.nicehash.com/api?method=orders.get&my&id=8&key=a8dd01d7-a4de-44ad-8e8f-ddaa7a2e0bd4&location=0&algo=0

获取用户拥有的指定算法的所有订单信息, 每30秒刷新一次.

参数:
- id - API ID;
- key - API密匙或只读API密匙;
- location - 0代表欧洲(NiceHash), 1代表美国(WestHash);
- algo - 算法使用ID标记.

返回值:

{"result":{"orders":[{"type":0,"btc_avail":"0.01751439","limit_speed":"0.0","pool_user":"worker","pool_port":3333,"alive":false,"workers":0,"pool_pass":"x","accepted_speed":0.0,"id":1879,"algo":0,"price":"1.0000","btc_paid":"0.00000000","pool_host":"testpool.com","end":1413294447421}]},"method":"orders.get"}

orders.create

https://api.nicehash.com/api?method=orders.create&id=8&key=3583b1df-5e93-4ba0-96d7-7d621fe15a17&location=0&algo=0&amount=0.01&price=2.9&limit=0&pool_host=testpool.com&pool_port=3333&pool_user=worker&pool_pass=x

创建新的订单, 使用API只可创建标准订单.

参数:
- id - API ID;
- key - API密匙;
- location - 0代表欧洲(NiceHash), 1代表美国(WestHash);
- algo - 算法使用ID标记;
- amount - BTC数额
- price - 以BTC/GH/天BTC/TH/天为单位表示的价格;
- limit - 以GH/s或TH/s单位表示的速度限制 (0代表无限制);
- pool_host - 矿池主机名或IP;
- pool_port - 矿池端口;
- pool_user - 矿池用户名;
- pool_pass - 矿池密码;
- code - 该参数可选, 如启用2FA则必须提供相关信息, 可使用NiceHash2FA Java应用程序生成代码.

返回值:

{"result":{"success":"Order #5569 created."},"method":"orders.create"}

orders.refill

https://api.nicehash.com/api?method=orders.refill&id=8&key=3583b1df-5e93-4ba0-96d7-7d621fe15a17&location=0&algo=0&order=123&amount=0.01

使用额外BTC补充订单.

参数:
- id - API ID;
- key - API密匙;
- location - 0代表欧洲(NiceHash), 1代表美国(WestHash);
- algo - 算法使用ID标记;
- order - 订单ID;
- amount - 补充订单BTC数额.

返回值:

{"result":{"success":"Order #123 refilled."},"method":"orders.refill"}

orders.remove

https://api.nicehash.com/api?method=orders.remove&id=8&key=3583b1df-5e93-4ba0-96d7-7d621fe15a17&location=0&algo=0&order=1880

移除现有订单.

参数:
- id - API ID;
- key - API密匙;
- location - 0代表欧洲(NiceHash), 1代表美国(WestHash);
- algo - 算法使用ID标记;
- order - 订单ID/代码.

返回值:

{"result":{"success":"Order removed."},"method":"orders.remove"}

orders.set.price

https://api.nicehash.com/api?method=orders.set.price&id=8&key=3583b1df-5e93-4ba0-96d7-7d621fe15a17&location=0&algo=0&order=1881&price=2.1

为现有订单设置新价格, 只可提升价格.

参数:
- id - API ID;
- key - API密匙;
- location - 0代表欧洲(NiceHash), 1代表美国(WestHash);
- algo - 算法使用ID标记;
- order - 订单ID/代码.
- price - 为BTC/GH/天或BTC/TH/天单位表示的价格.

返回值:

{"result":{"success":"New order price set to: 2.10"},"method":"orders.set.price"}

orders.set.price.decrease

https://api.nicehash.com/api?method=orders.set.price.decrease&id=8&key=3583b1df-5e93-4ba0-96d7-7d621fe15a17&location=0&algo=0&order=1881

降低现有订单的价格, 每10分钟可降低一次, 阅读 帮助 获取更多信息.

参数:
- id - API ID;
- key - API密匙;
- location - 0代表欧洲(NiceHash), 1代表美国(WestHash);
- algo - 算法使用ID标记;
- order - 订单ID/代码.

返回值:

{"result":{"success":"New order price set to: 2.10"},"method":"orders.set.price.decrease"}

orders.set.limit

https://api.nicehash.com/api?method=orders.set.limit&id=8&key=3583b1df-5e93-4ba0-96d7-7d621fe15a17&location=0&algo=0&order=1881&limit=1.0

为现有订单设置新限制.

参数:
- id - API ID;
- key - API密匙;
- location - 0代表欧洲(NiceHash), 1代表美国(WestHash);
- algo - 算法使用ID标记;
- order - 订单ID/代码.
- limit - 以GH/s或TH/s单位表示的速度限制 (0代表无限制);

返回值:

{"result":{"success":"New order limit set to: 1.00"},"method":"orders.set.limit"}

balance

https://api.nicehash.com/api?method=balance&id=8&key=3583b1df-5e93-4ba0-96d7-7d621fe15a17

获取当前已确认的比特币余额.

参数:
- id - API ID;
- key - API密匙或只读API密匙.

返回值:

{"result":{"balance_confirmed":"0.00500000","balance_pending":"0.00000000"},"method":"balance"}