humble

Humble Bundle access through a real browser.

Humble Bundle access.

Humble publishes no API for library or key access, so this half of the tool drives a real browser and issues Humble’s own XHR calls from inside the authenticated page.

Example:

from humble_steam_key_redeemer.humble import HumbleBrowser, HumbleClient

with HumbleBrowser(settings) as browser:
    client = HumbleClient(browser)
    if client.is_logged_in():
        orders = client.order_details()
exception humble_steam_key_redeemer.humble.HumbleAPIError[source]

Bases: RuntimeError

Raised when Humble rejects a request or returns an unusable response.

class humble_steam_key_redeemer.humble.HumbleBrowser(settings)[source]

Bases: object

A Playwright browser session scoped to Humble Bundle.

Parameters:

settings (Settings) – Runtime configuration.

start()[source]

Start the browser session, restoring a saved session when present.

When cdp_endpoint is configured, attaches to that already-running browser instead of launching a new one. That lets the tool reuse a browser a person is already signed into — including one an agent is driving — rather than requiring a separate sign-in in an isolated profile.

Return type:

Self

Returns:

This browser session.

Raises:

HumbleBrowserError – If the browser cannot be started or reached.

property is_attached: bool

Whether this session attached to an existing browser.

save_session()[source]

Persist the browser session for reuse.

Only Humble’s own cookies are kept. Attaching to an everyday browser means the context holds bearer credentials for every site signed in there, and writing those to disk — then loading them into a browser this tool launches — would spread them well beyond what redeeming keys needs.

Session cookies are bearer credentials, so the file is written with owner-only permissions.

Return type:

Path

Returns:

The path written.

clear_session()[source]

Delete any saved Humble session.

Return type:

None

close()[source]

Close the browser and release Playwright resources.

Return type:

None

property page: Page

The active page.

goto(url)[source]

Navigate to a URL.

Parameters:

url (str) – Destination URL.

Return type:

None

evaluate(script, argument=None)[source]

Run JavaScript in the page with an argument passed as data.

The argument crosses into the page over Playwright’s structured channel, so its contents are never parsed as code regardless of what characters it contains.

Parameters:
  • script (str) – A JavaScript function expression taking one argument.

  • argument (Any) – Value passed to that function.

Return type:

Any

Returns:

The script’s return value.

cookie(name)[source]

Return the value of a cookie by name.

Parameters:

name (str) – Cookie name.

Return type:

str | None

Returns:

The cookie value, or None when absent.

exception humble_steam_key_redeemer.humble.HumbleBrowserError[source]

Bases: RuntimeError

Raised when the browser cannot be started or driven.

class humble_steam_key_redeemer.humble.HumbleClient(browser, timeout_ms=30000)[source]

Bases: object

Reads orders and reveals keys through an authenticated browser session.

Parameters:
is_logged_in()[source]

Report whether the session is signed in to Humble.

Return type:

bool

Returns:

True when the library page loads without redirecting.

is_logged_in_quietly()[source]

Report whether the session is signed in, without navigating.

Polling is_logged_in() while someone is signing in destroys the form they are typing into, because it navigates. This asks the same question with a request instead, so a login page or a two-factor prompt is left alone.

Return type:

bool

Returns:

True when Humble serves the library without redirecting.

order_keys()[source]

List the gamekeys of every order on the account.

Return type:

list[str]

Returns:

Humble order identifiers.

Raises:

HumbleAPIError – If the order list cannot be read.

order_details(gamekeys=None)[source]

Fetch full order details.

Parameters:

gamekeys (list[str] | None) – Specific orders to fetch. Defaults to every order.

Return type:

list[dict[str, Any]]

Returns:

Raw order payloads as returned by Humble.

Raises:

HumbleAPIError – If the details cannot be read.

post(url, payload)[source]

Send an authenticated form POST from within the page.

Parameters:
  • url (str) – Target URL.

  • payload (dict[str, Any]) – Form fields.

Return type:

tuple[int, dict[str, Any] | None]

Returns:

The HTTP status and decoded JSON body, if any.

reveal_key(record)[source]

Reveal a key on Humble so Steam can redeem it.

Revealing is irreversible: it forfeits the ability to generate a gift link for that entry, which is why callers must confirm first.

Parameters:

record (KeyRecord) – The key to reveal.

Return type:

str | None

Returns:

The revealed key value, or None if Humble declined.

Raises:

HumbleAPIError – If Humble reports an error.

humble_steam_key_redeemer.humble.iter_tpkds(order)[source]

Yield every key entry nested anywhere inside an order payload.

Humble nests key entries under several differently-named keys depending on the bundle’s age and type, so the payload is walked rather than indexed.

Parameters:

order (Any) – A decoded Humble order payload.

Return type:

list[dict[str, Any]]

Returns:

Every mapping that looks like a key entry.

humble_steam_key_redeemer.humble.to_key_records(orders)[source]

Convert raw Humble order payloads into key records.

Parameters:

orders (list[dict[str, Any]]) – Decoded order payloads.

Return type:

list[KeyRecord]

Returns:

Key records, deduplicated on Humble’s identifiers.