This README contains details about the sgminer RPC API
# sgminer RPC API Documentation
It also includes some detailed information at the end,
*Work in Progress!*
about using miner.php
This README contains details about the sgminer RPC API and also includes some detailed information
at the end, about using [miner.php](#miner-php).
If you start sgminer with the "--api-listen" option, it will listen on a
simple TCP/IP socket for single string API requests from the same machine
---
running sgminer and reply with a string and then close the socket each time
If you add the "--api-network" option, it will accept API requests from any
## API Configuration
network attached computer.
If you start sgminer with the `--api-listen` option, it will listen on a simple TCP/IP socket for single string API requests from the same machine running sgminer and reply with a string and then close the socket each time If you add the `--api-network` option, it will accept API requests from any network attached computer.
You can only access the comands that reply with data in this mode.
By default, you cannot access any privileged command that affects the miner -
You can only access the comands that reply with data in this mode. By default, you cannot access any privileged command that affects the miner - you will receive an access denied status message see `--api-allow` below.
you will receive an access denied status message see --api-allow below.
You can specify IP addresses/prefixes that are only allowed to access the API with the `--api-allow` option.
You can specify IP addresses/prefixes that are only allowed to access the API
with the "--api-allow" option e.g. --api-allow W:192.168.0.1,10.0.0/24
```
will allow 192.168.0.1 or any address matching 10.0.0.*, but nothing else
--api-allow W:192.168.0.1,10.0.0/24
IP addresses are automatically padded with extra '.0's as needed
```
Without a /prefix is the same as specifying /32
0/0 means all IP addresses.
The example above will allow 192.168.0.1 or any address matching 10.0.0.*, but nothing else. IP addresses are automatically padded with extra '.0's as needed Without a /prefix is the same as specifying /32 0/0 means all IP addresses. The `W:` on the front gives that address/subnet privileged access to commands that modify sgminer (thus all API commands). Without it those commands return an access denied status. See `--api-groups` below to define other groups like `W:`. Privileged access is checked in the order the IP addresses were supplied to `--api-allow`. The first match determines the privilege level. Using the `--api-allow` option overides the `--api-network` option if they are both specified. With `--api-allow`, 127.0.0.1 is not by default given access unless specified.
The 'W:' on the front gives that address/subnet privileged access to commands
that modify sgminer (thus all API commands)
If you start sgminer also with the `--api-mcast` option, it will listen for a multicast message and reply to it with a message containing it's API port number, but only if the IP address of the sender is allowed API access.
Without it those commands return an access denied status.
See --api-groups below to define other groups like W:
More groups (like the privileged group `W:`) can be defined using the `--api-groups` command. Valid groups are only the letters A-Z (except R & W are predefined) and are not case sensitive. The `R:` group is the same as not privileged access. The `W:` group is (as stated) privileged access (thus all API commands). To give an IP address/subnet access to a group you use the group letter in front of the IP address instead of `W:` e.g. `P:192.168.0/32`. An IP address/subnet can only be a member of one group
Privileged access is checked in the order the IP addresses were supplied to
"--api-allow"
A sample API group would be:
The first match determines the privilege level.
Using the "--api-allow" option overides the "--api-network" option if they
With "--api-allow", 127.0.0.1 is not by default given access unless specified
```
If you start sgminer also with the "--api-mcast" option, it will listen for
This would create a group `P` that can do all current pool commands and all non-priviliged commands - the asterisk (\*) means all non-priviledged commands. Without the asterisk (\*), the group would only have access to the pool commands.
a multicast message and reply to it with a message containing it's API port
number, but only if the IP address of the sender is allowed API access
Defining multiple groups example:
More groups (like the privileged group W:) can be defined using the
```
--api-groups command
--api-groups Q:quit:restart:*,S:save
Valid groups are only the letters A-Z (except R & W are predefined) and are
```
not case sensitive
The R: group is the same as not privileged access
This would define 2 groups: `Q:`, that can `quit` and `restart` as well as all non-priviledged commands, and `S:`, that can only `save` and no other commands.
The W: group is (as stated) privileged access (thus all API commands)
To give an IP address/subnet access to a group you use the group letter
For API configuration options, see `doc/configuration.md`.
in front of the IP address instead of W: e.g. P:192.168.0/32
An IP address/subnet can only be a member of one group
Returns each available GPU, PGA and ASC with their details. **Note** that this will not return PGAs or ASCs if PGA or ASC mining is not enabled.
*Syntax:* `devs`
*Arguments:* None
*Access*: `Non-priviledged`
*Returns:*
```
GPU=0,Accepted=NN,MHS av=NNN,...,Intensity=D|
Last Share Time=NNN, <-standandlongtimeinsec(or0ifnone)oflastacceptedshare
Last Share Pool=N, <-poolnumber(or-1ifnone)
Last Valid Work=NNN, <-standandlongtimeinsecoflastworkreturnedthatwasn'tanHW
```
### gpu
Returns the details of a single GPU in the same format and details as [devs](#devs).
*Syntax:* `gpu|<N>`
*Arguments:* `number` GPU Number
*Access*: `Non-priviledged`
*Returns:*
```
GPU=0,Accepted=NN,MHS av=NNN,...,Intensity=D|
Last Share Time=NNN, <-standandlongtimeinsec(or0ifnone)oflastacceptedshare
Last Share Pool=N, <-poolnumber(or-1ifnone)
Last Valid Work=NNN, <-standandlongtimeinsecoflastworkreturnedthatwasn'tanHW
```
### pga
Returns the details of a single PGA in the same format and details as [devs](#devs). **Note** that this is only available if PGA mining is enabled. Use [pgacount](#pgacount) or [config](#config) first to see if there are any PGA devices.
*Syntax:* `pga|<N>`
*Arguments:* `number` PGA Number
*Access*: `Non-priviledged`
*Returns:*
```
PGA=0,Accepted=NN,MHS av=NNN,...,Intensity=D|
Last Share Time=NNN, <-standandlongtimeinsec(or0ifnone)oflastacceptedshare
Last Share Pool=N, <-poolnumber(or-1ifnone)
Last Valid Work=NNN, <-standandlongtimeinsecoflastworkreturnedthatwasn'tanHW
```
### gpucount
Returns the number of GPU devices.
*Syntax:* `gpucount`
*Arguments:* None
*Access*: `Non-priviledged`
*Returns:*
```
Count=N| <-numberofGPUs
```
### pgacount
Returns the number of PGA devices.
*Syntax:* `pgacount`
*Arguments:* None
*Access*: `Non-priviledged`
*Returns:*
```
Count=N| <-numberofPGAs
```
---
```
switchpool|N (*)
none There is no reply section just the STATUS section
none There is no reply section just the STATUS section
stating the results of switching pool N to the
stating the results of switching pool N to the
highest priority (the pool is also enabled)
highest priority (the pool is also enabled)
@ -503,6 +600,7 @@ gpuenable|N (*)
A warning reply means lock stats are not compiled
A warning reply means lock stats are not compiled
into sgminer
into sgminer
The API writes all the lock stats to stderr
The API writes all the lock stats to stderr
```
When you enable, disable or restart a GPU, PGA or ASC, you will also get
When you enable, disable or restart a GPU, PGA or ASC, you will also get
Thread messages in the sgminer status window
Thread messages in the sgminer status window
@ -553,17 +651,7 @@ miner.php - an example web page to access the API
See the end of this API readme for details of how to tune the display
See the end of this API readme for details of how to tune the display
and also to use the option to display a multi-rig summary
and also to use the option to display a multi-rig summary
----------
## API Version History
Feature Changelog for external applications using the API:
API V
Modified API commands:
'version' - add 'Miner'
----------
API V4.0 (sgminer v5.0)
API V4.0 (sgminer v5.0)
@ -999,8 +1087,8 @@ Commands:
----------------------------------------
----------------------------------------
miner.php
## miner.php
=========
miner.php is a PHP based interface to the sgminer RPC API
miner.php is a PHP based interface to the sgminer RPC API