xmrig/doc/API.md

67 lines
2.3 KiB
Markdown
Raw Normal View History

2018-04-18 02:58:06 +00:00
# HTTP API
2019-08-06 05:48:00 +00:00
If you want use HTTP API you need enable it (`"enabled": true,`) then choice `port` and optionaly `host`. API not available if miner built without HTTP support (`-DWITH_HTTP=OFF`).
Offical HTTP client for API: http://workers.xmrig.info/
2018-04-18 02:58:06 +00:00
Example configuration:
```json
"api": {
2019-08-06 05:48:00 +00:00
"id": null,
"worker-id": null,
2018-04-18 02:58:06 +00:00
},
2019-08-06 05:48:00 +00:00
"http": {
"enabled": false,
"host": "127.0.0.1",
"port": 0,
"access-token": null,
"restricted": true
}
2018-04-18 02:58:06 +00:00
```
2019-08-06 05:48:00 +00:00
#### Global API options
* **id** Miner ID, if not set created automatically.
2018-04-18 02:58:06 +00:00
* **worker-id** Optional worker name, if not set will be detected automatically.
2019-08-06 05:48:00 +00:00
#### HTTP API options,
* **enabled** Enable (`true`) or disable (`false`) HTTP API.
* **host** Host for incoming connections `http://<host>:<port>`, to allow connections from all interfaces use `0.0.0.0` (IPv4) or `::` (IPv4+IPv6).
* **port** Port for incoming connections `http://<host>:<port>`, zero port is valid option and means random port.
* **access-token** [Bearer](https://gist.github.com/xmrig/c75fdd1f8e0f3bac05500be2ab718f8e#file-api-html-L54) access token to secure access to API. Miner support this token only via `Authorization` header.
2018-04-18 02:58:06 +00:00
* **restricted** Use `false` to allow remote configuration.
2019-08-06 05:48:00 +00:00
If you prefer use command line options instead of config file, you can use options: `--api-id`, `--api-worker-id`, `--http-enabled`, `--http-host`, `--http-access-token`, `--http-port`, `--http-no-restricted`.
Versions before 2.15 was use another options for API https://github.com/xmrig/xmrig/issues/1007
2018-04-18 02:58:06 +00:00
## 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
2019-08-06 05:48:00 +00:00
```