Added API docs and bug fixes.

This commit is contained in:
XMRig 2018-04-18 09:58:06 +07:00
parent d04a1fcb8f
commit bc67216f7f
8 changed files with 261 additions and 5 deletions

53
doc/API.md Normal file
View file

@ -0,0 +1,53 @@
# HTTP API
If you want use API you need choice a port where is internal HTTP server will listen for incoming connections. API will not available if miner built without `libmicrohttpd`.
Example configuration:
```json
"api": {
"port": 44444,
"access-token": "TOKEN",
"worker-id": null,
"ipv6": false,
"restricted": false
},
```
* **port** Port for incoming connections `http://<miner ip>:<port>`.
* **access-token** [Bearer](https://gist.github.com/xmrig/c75fdd1f8e0f3bac05500be2ab718f8e#file-api-html-L54) access token to secure access to API.
* **worker-id** Optional worker name, if not set will be detected automatically.
* **ipv6** Enable (`true`) or disable (`false`) IPv6 for API.
* **restricted** Use `false` to allow remote configuration.
If you prefer use command line options instead of config file, you can use options: `--api-port`, `--api-access-token`, `--api-worker-id`, `--api-ipv6` and `api-no-restricted`.
## Endpoints
### GET /1/summary
Get miner summary information. [Example](api/1/summary.json).
### GET /1/threads
Get detailed information about miner threads. [Example](api/1/threads.json).
## Restricted endpoints
All API endpoints below allow access to sensitive information and remote configure miner. You should set `access-token` and allow unrestricted access (`"restricted": false`).
### GET /1/config
Get current miner configuration. [Example](api/1/config.json).
### PUT /1/config
Update current miner configuration. Common use case, get current configuration, make changes, and upload it to miner.
Curl example:
```
curl -v --data-binary @config.json -X PUT -H "Content-Type: application/json" -H "Authorization: Bearer SECRET" http://127.0.0.1:44444/1/config
```

63
doc/api/1/config.json Normal file
View file

@ -0,0 +1,63 @@
{
"algo": "cryptonight",
"api": {
"port": 44444,
"access-token": "TOKEN",
"worker-id": null,
"ipv6": false,
"restricted": false
},
"av": 1,
"background": false,
"colors": true,
"cpu-affinity": null,
"cpu-priority": null,
"donate-level": 5,
"huge-pages": true,
"hw-aes": null,
"log-file": null,
"max-cpu-usage": 75,
"pools": [
{
"url": "pool.monero.hashvault.pro:3333",
"user": "48edfHu7V9Z84YzzMa6fUueoELZ9ZRXq9VetWzYGzKt52XU5xvqgzYnDK9URnRoJMk1j8nLwEVsaSWJ4fhdUyZijBGUicoD",
"pass": "x",
"keepalive": false,
"nicehash": false,
"variant": -1
},
{
"url": "pool.supportxmr.com:3333",
"user": "48edfHu7V9Z84YzzMa6fUueoELZ9ZRXq9VetWzYGzKt52XU5xvqgzYnDK9URnRoJMk1j8nLwEVsaSWJ4fhdUyZijBGUicoD",
"pass": "x",
"keepalive": false,
"nicehash": false,
"variant": -1
}
],
"print-time": 60,
"retries": 5,
"retry-pause": 5,
"safe": false,
"threads": [
{
"low_power_mode": 1,
"affine_to_cpu": 0
},
{
"low_power_mode": 1,
"affine_to_cpu": 1
},
{
"low_power_mode": 1,
"affine_to_cpu": 2
},
{
"low_power_mode": 1,
"affine_to_cpu": 3
}
],
"user-agent": null,
"syslog": false,
"watch": false
}

73
doc/api/1/summary.json Normal file
View file

@ -0,0 +1,73 @@
{
"id": "92f3104f9a2ee78c",
"worker_id": "Ubuntu-1604-xenial-64-minimal",
"version": "2.6.0-beta3",
"kind": "cpu",
"ua": "XMRig/2.6.0-beta3 (Linux x86_64) libuv/1.8.0 gcc/5.4.0",
"cpu": {
"brand": "Intel(R) Core(TM) i7-4770 CPU @ 3.40GHz",
"aes": true,
"x64": true,
"sockets": 1
},
"algo": "cryptonight",
"hugepages": true,
"donate_level": 5,
"hashrate": {
"total": [
296.24,
296.23,
295.97
],
"highest": 296.5,
"threads": [
[
73.39,
73.39,
73.28
],
[
74.72,
74.72,
74.71
],
[
74.72,
74.72,
74.71
],
[
73.39,
73.39,
73.27
]
]
},
"results": {
"diff_current": 9990,
"shares_good": 30,
"shares_total": 30,
"avg_time": 31,
"hashes_total": 311833,
"best": [
278199,
181923,
103717,
96632,
56154,
51580,
45667,
33159,
29581,
29514
],
"error_log": []
},
"connection": {
"pool": "pool.monero.hashvault.pro:3333",
"uptime": 953,
"ping": 35,
"failures": 0,
"error_log": []
}
}

65
doc/api/1/threads.json Normal file
View file

@ -0,0 +1,65 @@
{
"hugepages": [
4,
4
],
"memory": 8388608,
"threads": [
{
"type": "cpu",
"algo": "cryptonight",
"av": 1,
"low_power_mode": 1,
"affine_to_cpu": 0,
"priority": -1,
"soft_aes": false,
"hashrate": [
73.39,
73.4,
73.28
]
},
{
"type": "cpu",
"algo": "cryptonight",
"av": 1,
"low_power_mode": 1,
"affine_to_cpu": 1,
"priority": -1,
"soft_aes": false,
"hashrate": [
74.72,
74.72,
74.7
]
},
{
"type": "cpu",
"algo": "cryptonight",
"av": 1,
"low_power_mode": 1,
"affine_to_cpu": 2,
"priority": -1,
"soft_aes": false,
"hashrate": [
74.71,
74.72,
74.7
]
},
{
"type": "cpu",
"algo": "cryptonight",
"av": 1,
"low_power_mode": 1,
"affine_to_cpu": 3,
"priority": -1,
"soft_aes": false,
"hashrate": [
73.39,
73.4,
73.28
]
}
]
}