Skip to content

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 4000).

_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 True, use https:// instead of http://.

False
session ClientSession | None

An existing :class:aiohttp.ClientSession to reuse. If None, a session will be created internally and closed by :meth:close.

None

close async

close() -> None

Close the underlying HTTP session if it was created internally.

get_version async

get_version() -> Version

Get the RainbowMiner version (/version).

get_info async

get_info() -> Any

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_remote_ip() -> str | None

Get the server's remote IP address (/remoteip).

Returns:

Type Description
str | None

The remote IP string, or None if the server is not reachable

str | None

remotely.

get_console async

get_console(*, ts: int | None = None) -> Console

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 "*" for the content (meaning "unchanged").

None

Returns:

Name Type Description
A Console

class:~rainbowminer_api_client.models.console.Console object.

get_cpu_info async

get_cpu_info() -> CPUInfo

Get CPU information (/cpuinfo).

get_sys_info async

get_sys_info() -> SysInfo

Get system information (/sysinfo).

get_uptime async

get_uptime() -> Uptime

Get RainbowMiner uptime (/uptime).

get_system_uptime async

get_system_uptime() -> Uptime

Get the operating system uptime (/systemuptime).

is_server async

is_server() -> bool

Check whether the server runs in server mode (/isserver).

get_active_miners async

get_active_miners() -> list[ActiveMiner]

Get currently active miners (/activeminers).

get_running_miners async

get_running_miners() -> list[RunningMiner]

Get currently running miners (/runningminers).

get_failed_miners async

get_failed_miners() -> list[FailedMiner]

Get miners that failed to start (/failedminers).

get_remote_miners async

get_remote_miners(
    *, mode: str | None = None
) -> list[RemoteMiner] | list[RemoteMinerEntry]

Get remote miners connected to a server (/remoteminers).

Parameters:

Name Type Description Default
mode str | None

If "miners", returns flattened per-miner entries (:class:RemoteMinerEntry). Otherwise returns per-worker summaries (:class:RemoteMiner).

None

Returns:

Type Description
list[RemoteMiner] | list[RemoteMinerEntry]

A list of miner objects whose type depends on mode.

get_miners_needing_benchmark async

get_miners_needing_benchmark() -> list[Any]

Get miners that need benchmarking (/minersneedingbenchmark).

get_miner_info async

get_miner_info() -> list[MinerInfo]

Get miner capability info (/minerinfo).

get_miner_speeds async

get_miner_speeds() -> list[MinerSpeed]

Get miner hashrate speeds (/minerspeeds).

get_pools async

get_pools() -> list[Pool]

Get active/enabled pools (/pools).

get_all_pools async

get_all_pools() -> list[AllPool]

Get all known pools (/allpools).

get_new_pools async

get_new_pools() -> list[NewPool]

Get newly discovered pools (/newpools).

get_algorithms async

get_algorithms() -> list[str]

Get supported algorithms (/algorithms).

The API returns a list of algorithm name strings (e.g. ["Ethash", "Kawpow"]).

get_miners async

get_miners() -> list[Miner]

Get available miner definitions (/miners).

get_fastest_miners async

get_fastest_miners() -> list[FastestMiner]

Get the fastest miners per algorithm/device (/fastestminers).

get_avail_miners async

get_avail_miners() -> list[str]

Get the list of available miner base names (/availminers).

get_avail_miner_stats async

get_avail_miner_stats() -> list[AvailMinerStat]

Get available miners with stat counts (/availminerstats).

get_disabled async

get_disabled() -> list[str]

Get the list of disabled miners/pools (/disabled).

get_wtm_urls async

get_wtm_urls() -> dict[str, str]

Get WhatToMine URLs per device model (/getwtmurls).

load_config_json async

load_config_json(
    *, config_name: str | None = None
) -> LoadConfigJsonResult

Load a raw config file as JSON string (/loadconfigjson).

Parameters:

Name Type Description Default
config_name str | None

Config file name (default "Config").

None

Returns:

Name Type Description
A LoadConfigJsonResult

class:~rainbowminer_api_client.models.config.LoadConfigJsonResult.

load_config async

load_config(
    *,
    config_name: str | None = None,
    pool_name: str | None = None,
) -> Any

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 "Config").

None
pool_name str | None

Pool name filter (only for config_name="Pools").

None

Returns:

Type Description
Any

The loaded config section (type depends on config_name).

get_config async

get_config() -> Config

Get the merged running config (/config).

get_user_config async

get_user_config() -> UserConfig

Get user config overrides (/userconfig).

get_oc_profiles async

get_oc_profiles() -> list[OCProfile]

Get overclock profiles (/ocprofiles).

get_download_list async

get_download_list() -> list[DownloadItem]

Get the download queue (/downloadlist).

get_all_devices async

get_all_devices() -> list[AllDevice]

Get all hardware devices (/alldevices).

get_devices async

get_devices() -> list[Device]

Get selected/enabled devices (/devices).

get_platforms async

get_platforms() -> dict[str, Any]

Get OpenCL platform info (/platforms).

get_device_combos async

get_device_combos() -> list[DeviceCombo]

Get device combinations (/devicecombos).

get_device_config async

get_device_config() -> list[DeviceConfigEntry]

Get device selection/exclusion state (/getdeviceconfig).

get_stats async

get_stats() -> dict[str, Any]

Get the stats cache (/stats).

The stats cache is highly dynamic; it is returned as a plain dict.

get_totals async

get_totals() -> list[Total]

Get profit/power totals (/totals).

get_totals_csv async

get_totals_csv() -> BinaryResponse

Get totals as CSV (/totalscsv).

Returns:

Name Type Description
A BinaryResponse

class:~rainbowminer_api_client._http.BinaryResponse with

BinaryResponse

content_type="text/csv".

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").

'Date'
order str | None

"desc" for descending, otherwise ascending.

None
limit int | None

Maximum number of rows to return.

None
offset int | None

Number of rows to skip (used with limit).

None

Returns:

Name Type Description
An EarningsResult

class:~rainbowminer_api_client.models.balances.EarningsResult.

get_earnings_csv async

get_earnings_csv() -> BinaryResponse

Get earnings as CSV (/earnings?as_csv=true).

Returns:

Name Type Description
A BinaryResponse

class:~rainbowminer_api_client._http.BinaryResponse with

BinaryResponse

content_type="text/csv".

get_session_vars async

get_session_vars() -> dict[str, Any]

Get scalar session variables (/sessionvars).

get_session async

get_session() -> dict[str, Any]

Get the full session hashtable (/session).

get_gc async

get_gc() -> dict[str, Any]

Get the sync-cache contents (/gc).

get_watchdog_timers async

get_watchdog_timers() -> list[Any]

Get watchdog timers (/watchdogtimers).

get_crash_counter async

get_crash_counter() -> list[Any]

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:~rainbowminer_api_client.models.balances.Balance

list[Balance] | BinaryResponse

objects, or a :class:~rainbowminer_api_client._http.BinaryResponse

list[Balance] | BinaryResponse

if as_csv=True.

get_payouts async

get_payouts() -> list[Payout]

Get payout history (/payouts).

get_rates async

get_rates(
    *, format: str | None = None
) -> dict[str, float | int] | list[RateTableRow]

Get currency exchange rates (/rates).

Parameters:

Name Type Description Default
format str | None

If "table", returns a list of :class:~rainbowminer_api_client.models.misc.RateTableRow objects. Otherwise returns a currency → rate dict.

None

Returns:

Type Description
dict[str, float | int] | list[RateTableRow]

Either a dict or a list of rate table rows, depending on format.

get_asyncloader_jobs async

get_asyncloader_jobs() -> list[AsyncloaderJob]

Get async loader jobs (/asyncloaderjobs).

get_dec_sep async

get_dec_sep() -> str

Get the system's decimal separator (/decsep).

get_miner_log async

get_miner_log(
    *, logfile: str | None = None
) -> MinerLogResult

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:~rainbowminer_api_client.models.miners.MinerLogResult.

get_miner_stats async

get_miner_stats() -> list[MinerStat]

Get benchmark stats for all miners (/minerstats).

get_activity async

get_activity(
    *, as_csv: bool = False
) -> list[Any] | BinaryResponse

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:~rainbowminer_api_client._http.BinaryResponse if

list[Any] | BinaryResponse

as_csv=True.

get_computer_stats async

get_computer_stats() -> ComputerStats

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_ports() -> dict[str, Any]

Get miner port assignments (/minerports).

get_current_profit async

get_current_profit() -> CurrentProfit

Get current profit, earnings, rates, power, and uptime (/currentprofit).

get_status async

get_status() -> Status

Get the current mining status (/status).

get_clients async

get_clients(
    *, include_server: bool = False
) -> list[Client]

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:~rainbowminer_api_client.models.misc.Client.

get_mrr_stats async

get_mrr_stats() -> list[MrrStat]

Get MiningRigRentals algorithm stats (/mrrstats).

get_mrr_rigs async

get_mrr_rigs() -> list[MrrRig]

Get MiningRigRentals rig data (/mrrrigs).

get_mrr_control async

get_mrr_control() -> list[MrrControl]

Get MiningRigRentals control settings (/mrrcontrol).

get_setup async

get_setup() -> SetupJson

Get the aggregated setup configuration (/setup.json).

set_cmd_key async

set_cmd_key(cmd_key: str) -> str

Set the command menu key (/cmdkey).

Parameters:

Name Type Description Default
cmd_key str

The command key to set.

required

Returns:

Type Description
str

The new command key value.

save_config_json async

save_config_json(
    *, config_name: str | None = None, data: str
) -> SaveResult

Save a raw JSON config string (/saveconfigjson).

Parameters:

Name Type Description Default
config_name str | None

Config file name (default "Config").

None
data str

The JSON config content as a string.

required

Returns:

Name Type Description
A SaveResult

class:~rainbowminer_api_client.models.config.SaveResult.

save_config async

save_config(
    *, config_name: str | None = None, **fields: Any
) -> SaveResult

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 "Config").

None
**fields Any

Config field name → value pairs to save.

{}

Returns:

Name Type Description
A SaveResult

class:~rainbowminer_api_client.models.config.SaveResult.

stop async

stop() -> str

Stop the RainbowMiner server (/stop).

reboot async

reboot() -> str

Reboot the machine running RainbowMiner (/reboot).

pause async

pause(*, action: str | None = None) -> bool

Pause or unpause mining (/pause).

Parameters:

Name Type Description Default
action str | None

One of "set", "reset", "pause", "unpause". If None, the server pauses unconditionally.

None

Returns:

Type Description
bool

The new pause state (True = paused).

lock_miners async

lock_miners() -> bool

Toggle miner selection lock (/lockminers).

Returns:

Type Description
bool

The new lock state (True = locked).

reset_workers async

reset_workers() -> str

Reset offline workers on api.rbminer.net (/resetworkers).

apply_oc async

apply_oc() -> str

Apply overclock profiles (/applyoc).

update async

update() -> bool

Trigger a RainbowMiner self-update (/update).

update_balance async

update_balance() -> bool

Trigger a balance update (/updatebalance).

update_mrr async

update_mrr() -> bool

Trigger a MiningRigRentals update (/updatemrr).

watchdog_reset async

watchdog_reset() -> bool

Reset watchdog timers (/watchdogreset).

toggle_miner async

toggle_miner(
    *, name: str, algorithm: str, device_model: str
) -> ToggleResult

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 - as separator).

required
device_model str

The device model identifier.

required

Returns:

Name Type Description
A ToggleResult

class:~rainbowminer_api_client.models.misc.ToggleResult.

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 coin_symbol).

None
coin_symbol str | None

Coin symbol (alternative to algorithm).

None

Returns:

Name Type Description
A ToggleResult

class:~rainbowminer_api_client.models.misc.ToggleResult.

save_miner_stats async

save_miner_stats(
    *, miner_name: str | None = None
) -> BinaryResponse

Download miner stats as a ZIP archive (/saveminerstats).

Parameters:

Name Type Description Default
miner_name str | None

Miner base name, or None/"all" for all miners.

None

Returns:

Name Type Description
A BinaryResponse

class:~rainbowminer_api_client._http.BinaryResponse with

BinaryResponse

content_type="application/zip".

get_debug_zip async

get_debug_zip() -> BinaryResponse

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:~rainbowminer_api_client._http.BinaryResponse with

BinaryResponse

content_type="application/zip".