RainbowMinerClient¶
rainbowminer_api_client.client.RainbowMinerClient ¶
RainbowMinerClient(
host: str = _DEFAULT_HOST,
port: int = _DEFAULT_PORT,
*,
username: str | None = None,
password: str | None = None,
timeout: float = _DEFAULT_TIMEOUT,
tls: bool = False,
session: ClientSession | None = None,
)
Async client for a RainbowMiner API server.
The client wraps an :class:~rainbowminer_api_client._http.HttpTransport
and provides one typed method per API endpoint. Use it as an async
context manager for automatic session cleanup, or call :meth:close
manually.
Configure the client.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
host
|
str
|
Hostname or IP address of the RainbowMiner server. |
_DEFAULT_HOST
|
port
|
int
|
TCP port the API server listens on (default |
_DEFAULT_PORT
|
username
|
str | None
|
Optional username for HTTP Basic auth. |
None
|
password
|
str | None
|
Optional password for HTTP Basic auth. |
None
|
timeout
|
float
|
Request timeout in seconds. |
_DEFAULT_TIMEOUT
|
tls
|
bool
|
If |
False
|
session
|
ClientSession | None
|
An existing :class: |
None
|
get_info
async
¶
Get server info (/info).
The /info payload is opaque and server-defined; it is returned as
a raw Python object (typically a dict).
get_remote_ip
async
¶
get_console
async
¶
Get the console output and running miner logs (/console).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ts
|
int | None
|
Last-seen console timestamp. If it matches the server's
current timestamp, the server returns |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
A |
Console
|
class: |
get_system_uptime
async
¶
Get the operating system uptime (/systemuptime).
get_active_miners
async
¶
Get currently active miners (/activeminers).
get_running_miners
async
¶
Get currently running miners (/runningminers).
get_failed_miners
async
¶
Get miners that failed to start (/failedminers).
get_remote_miners
async
¶
Get remote miners connected to a server (/remoteminers).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mode
|
str | None
|
If |
None
|
Returns:
| Type | Description |
|---|---|
list[RemoteMiner] | list[RemoteMinerEntry]
|
A list of miner objects whose type depends on |
get_miners_needing_benchmark
async
¶
Get miners that need benchmarking (/minersneedingbenchmark).
get_miner_speeds
async
¶
Get miner hashrate speeds (/minerspeeds).
get_algorithms
async
¶
Get supported algorithms (/algorithms).
The API returns a list of algorithm name strings (e.g.
["Ethash", "Kawpow"]).
get_fastest_miners
async
¶
Get the fastest miners per algorithm/device (/fastestminers).
get_avail_miners
async
¶
Get the list of available miner base names (/availminers).
get_avail_miner_stats
async
¶
Get available miners with stat counts (/availminerstats).
get_wtm_urls
async
¶
Get WhatToMine URLs per device model (/getwtmurls).
load_config_json
async
¶
Load a raw config file as JSON string (/loadconfigjson).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config_name
|
str | None
|
Config file name (default |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
A |
LoadConfigJsonResult
|
class: |
load_config
async
¶
Load a config section (/loadconfig).
The return type varies by config_name: "Config" returns a
:class:Config, "Miners" returns list[MinerConfig],
"Pools" returns a :class:PoolsConfig, and others return a raw
object. The result is therefore typed as Any.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config_name
|
str | None
|
Config section name (default |
None
|
pool_name
|
str | None
|
Pool name filter (only for |
None
|
Returns:
| Type | Description |
|---|---|
Any
|
The loaded config section (type depends on |
get_download_list
async
¶
Get the download queue (/downloadlist).
get_all_devices
async
¶
Get all hardware devices (/alldevices).
get_device_combos
async
¶
Get device combinations (/devicecombos).
get_device_config
async
¶
Get device selection/exclusion state (/getdeviceconfig).
get_stats
async
¶
Get the stats cache (/stats).
The stats cache is highly dynamic; it is returned as a plain dict.
get_totals_csv
async
¶
Get totals as CSV (/totalscsv).
Returns:
| Name | Type | Description |
|---|---|---|
A |
BinaryResponse
|
class: |
BinaryResponse
|
|
get_earnings
async
¶
get_earnings(
*,
filter: Mapping[str, Any] | None = None,
sort: str = "Date",
order: str | None = None,
limit: int | None = None,
offset: int | None = None,
) -> EarningsResult
Get earnings with optional filtering, sorting, and paging (/earnings).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
filter
|
Mapping[str, Any] | None
|
A mapping of field-name → value to filter by. |
None
|
sort
|
str
|
Sort field name (default |
'Date'
|
order
|
str | None
|
|
None
|
limit
|
int | None
|
Maximum number of rows to return. |
None
|
offset
|
int | None
|
Number of rows to skip (used with |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
An |
EarningsResult
|
class: |
get_earnings_csv
async
¶
Get earnings as CSV (/earnings?as_csv=true).
Returns:
| Name | Type | Description |
|---|---|---|
A |
BinaryResponse
|
class: |
BinaryResponse
|
|
get_session_vars
async
¶
Get scalar session variables (/sessionvars).
get_watchdog_timers
async
¶
Get watchdog timers (/watchdogtimers).
get_crash_counter
async
¶
Get crash counter entries (/crashcounter).
get_balances
async
¶
get_balances(
*,
raw: bool = False,
add_total: bool = False,
add_wallets: bool = False,
add_btc: bool = False,
consolidate: bool = False,
as_csv: bool = False,
) -> list[Balance] | BinaryResponse
Get balance information (/balances).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
raw
|
bool
|
Return raw balances without filtering. |
False
|
add_total
|
bool
|
Include total pool balance entries. |
False
|
add_wallets
|
bool
|
Include wallet balance entries. |
False
|
add_btc
|
bool
|
Add BTC-converted fields to each entry. |
False
|
consolidate
|
bool
|
Consolidate balances by name (converted to BTC). |
False
|
as_csv
|
bool
|
Return the balances as CSV instead of JSON. |
False
|
Returns:
| Type | Description |
|---|---|
list[Balance] | BinaryResponse
|
A list of :class: |
list[Balance] | BinaryResponse
|
objects, or a :class: |
list[Balance] | BinaryResponse
|
if |
get_rates
async
¶
Get currency exchange rates (/rates).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
format
|
str | None
|
If |
None
|
Returns:
| Type | Description |
|---|---|
dict[str, float | int] | list[RateTableRow]
|
Either a dict or a list of rate table rows, depending on |
get_asyncloader_jobs
async
¶
Get async loader jobs (/asyncloaderjobs).
get_miner_log
async
¶
Get the contents of a specific miner log file (/getminerlog).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
logfile
|
str | None
|
The log file name to retrieve. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
A |
MinerLogResult
|
class: |
get_miner_stats
async
¶
Get benchmark stats for all miners (/minerstats).
get_activity
async
¶
Get mining activity history (/activity).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
as_csv
|
bool
|
Return the activity as CSV instead of JSON. |
False
|
Returns:
| Type | Description |
|---|---|
list[Any] | BinaryResponse
|
A list of activity objects (raw dicts, since the CSV and JSON |
list[Any] | BinaryResponse
|
shapes differ), or a |
list[Any] | BinaryResponse
|
class: |
list[Any] | BinaryResponse
|
|
get_computer_stats
async
¶
Get computer statistics (/computerstats).
The server returns null (HTTP 404) when computer stats are not yet
available; in that case an empty :class:ComputerStats is returned.
get_miner_ports
async
¶
Get miner port assignments (/minerports).
get_current_profit
async
¶
Get current profit, earnings, rates, power, and uptime (/currentprofit).
get_clients
async
¶
Get connected RainbowMiner clients (/clients).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
include_server
|
bool
|
Include the server itself in the list (only valid when the server runs in server mode). |
False
|
Returns:
| Type | Description |
|---|---|
list[Client]
|
A list of :class: |
get_mrr_stats
async
¶
Get MiningRigRentals algorithm stats (/mrrstats).
get_mrr_control
async
¶
Get MiningRigRentals control settings (/mrrcontrol).
set_cmd_key
async
¶
save_config_json
async
¶
Save a raw JSON config string (/saveconfigjson).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config_name
|
str | None
|
Config file name (default |
None
|
data
|
str
|
The JSON config content as a string. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
A |
SaveResult
|
class: |
save_config
async
¶
Save config fields (/saveconfig).
Extra keyword arguments are sent as form fields to the server.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config_name
|
str | None
|
Config section name (default |
None
|
**fields
|
Any
|
Config field name → value pairs to save. |
{}
|
Returns:
| Name | Type | Description |
|---|---|---|
A |
SaveResult
|
class: |
pause
async
¶
lock_miners
async
¶
Toggle miner selection lock (/lockminers).
Returns:
| Type | Description |
|---|---|
bool
|
The new lock state ( |
reset_workers
async
¶
Reset offline workers on api.rbminer.net (/resetworkers).
toggle_miner
async
¶
Enable or disable a miner (/action/toggleminer).
Toggling a disabled miner re-enables it, and vice versa.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Miner base name. |
required |
algorithm
|
str
|
Algorithm(s) the miner runs (dual-algo miners use
|
required |
device_model
|
str
|
The device model identifier. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
A |
ToggleResult
|
class: |
toggle_pool
async
¶
toggle_pool(
*,
name: str,
algorithm: str | None = None,
coin_symbol: str | None = None,
) -> ToggleResult
Enable or disable a pool (/action/togglepool).
Either algorithm or coin_symbol must be provided.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Pool name. |
required |
algorithm
|
str | None
|
Algorithm identifier (alternative to |
None
|
coin_symbol
|
str | None
|
Coin symbol (alternative to |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
A |
ToggleResult
|
class: |
save_miner_stats
async
¶
Download miner stats as a ZIP archive (/saveminerstats).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
miner_name
|
str | None
|
Miner base name, or |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
A |
BinaryResponse
|
class: |
BinaryResponse
|
|
get_debug_zip
async
¶
Download a debug log archive (/debug).
The ZIP contains recent log files with sensitive data (wallets, API keys, IPs) redacted.
Returns:
| Name | Type | Description |
|---|---|---|
A |
BinaryResponse
|
class: |
BinaryResponse
|
|