Skip to main content

humblebundle.py

PyPI Python versions Typed License: MIT

Unofficial, typed Python client for humblebundle.com.

It answers five questions, and nothing else:

Question Call
Which bundles are live right now? client.bundles("games")
What is inside one bundle? client.bundle("survival-fittest") / client.items(...)
What is in this month's Humble Choice? client.choices()
What is in the Humble Store? client.store() / client.store_search("witcher") / client.store_product("cult-of-the-lamb")
What did the site actually send? product.raw

Everything is immutable, typed, JSON-serialisable and documented in-place — the library is designed to be used by people and by AI agents (see llms.txt and AGENTS.md).

pip install humblebundle.py

Requires Python 3.10+. The only runtime dependency is requests.

Quick start

from humblebundle import HumbleBundleClient

client = HumbleBundleClient()          # reuse it; it holds a pooled HTTP session

for bundle in client.bundles("games").values():
    ends = bundle.end_date.date() if bundle.end_date else "no end date"
    print(f"{bundle.title} — {bundle.price} — ends {ends}")

items = client.items("survival-fittest")
for item in items.values():
    print(item.title, item.msrp, ", ".join(item.developers))

choice = client.choices()
for game in choice.values():
    print(game.title, game.price)

store = client.store()
for section in store.sections:
    print(section.title, len(section.products))

for product in client.store_search("witcher", sort="top-discounts").values():
    print(product.title, product.price, f"-{product.discount_percent}%")

game = client.store_product("cult-of-the-lamb")
print(game.title, game.developers, game.genres, game.price)

Prefer a context manager when you want the session closed deterministically:

with HumbleBundleClient(timeout=10) as client:
    print(client.bundles("books").titles)

Short scripts can skip the class entirely:

import humblebundle

print(humblebundle.bundles("books").titles)
print(humblebundle.items("survival-fittest").first)

What you get back

bundles() returns a ProductCollection[Bundle]; items() returns a ProductCollection[BundleItem]; choices() returns a HumbleChoice, which is a mapping of game key to ChoiceGame; store() returns a Store and store_search() a StoreSearch, both mappings of product key to StoreProduct, and store_product() returns a single StoreProductDetail.

ProductCollection is a read-only mapping with extras:

bundles = client.bundles(["games", "books"])

len(bundles)                       # count
bundles["some_bundle"]             # lookup by key
bundles.first                      # first product or None
bundles.titles                     # {key: title}
bundles.search("survival")         # case-insensitive filter, returns a new collection
bundles.to_dict()                  # JSON-ready nested dict

Models

Model Returned by Highlights
Bundle bundles(), bundle() title, price, retail_value, included_item_titles, platforms, end_date, tiers, items()
BundleItem items() title, description, msrp, developers, publishers, platforms, delivery_methods, media, tier_key
ChoiceGame choices() title, price, developers, genres, platforms, media, end_date
Store store() url, sections, promotions, products, section(name)
StoreSection Store.sections key, title, layout, card_count, products
StoreProduct Store, StoreSearch title, price, base_price, discount_percent, platforms, delivery_methods, on_sale
StoreProductDetail store_product() everything in StoreProduct plus description, developers, publishers, genres, media, editions, distributions, critic_reviews, ratings, requirements
StoreSearch store_search() query, page, pages, total, sort, refinements, facets, next_page()
StoreSort store_search(sort=...) RELEVANCE, TOP_DISCOUNTS, ALPHABETICAL, NEWEST
Money price / msrp / retail_value amount (float), currency (ISO-4217)
Tier Bundle.tiers key, price, items

Every model:

  • is frozen — safe to share, cache and compare;
  • is mapping-like — product["title"], dict(product), product.keys();
  • is JSON-ready — to_dict() converts Money to {"amount", "currency"} and dates to ISO-8601 strings;
  • keeps the source payload in .raw and exposes it in JSON with to_dict(include_raw=True).

Dates are timezone-aware UTC datetime objects. Bundle.is_expired and Bundle.supports("windows") are provided for convenience.

humblebundle schema prints a machine-readable description of every model and field — handy for LLM tooling and for keeping docs honest.

Command line

Installing the package adds a humblebundle command:

humblebundle bundles games
humblebundle bundles books software --limit 5
humblebundle bundle survival-fittest
humblebundle bundle survival-fittest --items --fields key,title,msrp
humblebundle items survival-fittest --json
humblebundle choices --json
humblebundle store
humblebundle store --section featured-deals --limit 10
humblebundle store-product cult-of-the-lamb --json
humblebundle store-search witcher --sort top-discounts --genre rpg
humblebundle schema                # JSON model description for AI agents
humblebundle --version

Output is a human-readable table by default; --json prints a stable payload with --fields projection and --raw for the untouched source data. Errors go to stderr, exit code 0 on success and 1 when the library raises. The same command works without installation via python -m humblebundle.

Error handling

from humblebundle import (
    AgeVerificationError,
    AuthenticationError,
    BundleNotFoundError,
    FetchError,
    HumbleBundleError,
    PageDataError,
    RateLimitError,
    StoreProductNotFoundError,
)

try:
    bundle = client.bundle("survival-fittest")
except RateLimitError as exc:
    print("slow down:", exc.status_code, exc.url)
except BundleNotFoundError:
    print("that bundle page had no bundle data")
except PageDataError:
    print("humblebundle.com changed its page structure")
except FetchError as exc:
    print("network or HTTP failure:", exc.status_code, exc.url)
except HumbleBundleError:
    print("anything else from this library")

Store-specific failures are StoreProductNotFoundError (the product page had no product data) and AgeVerificationError (an age-gated product could not be unlocked). FetchError.status_code / .url carry the offending response details.

Configuration

HumbleBundleClient(
    timeout=30.0,        # per-request timeout, seconds
    retries=3,           # extra attempts for 429/5xx and connection errors
    user_agent=None,     # override the browser User-Agent
    session=None,        # reuse your own requests.Session
    source=None,         # replace the transport (any object with get_text(path))
    base_url=...,        # point at a mirror
    age_gate_birthdate="1990-01-01",   # answer the store's age gate automatically
    store_search_action=None,          # override the discovered search action id
)

Age-gated store products (adult titles) show a birthday form instead of the product. The client answers it with a plain cookie and re-fetches the page; pass age_gate_birthdate=None to opt out and get AgeVerificationError instead, or store_product(..., birthdate="YYYY-MM-DD") to answer for one product only.

Transient failures (HTTP 429/500/502/503/504, connection errors, timeouts) are retried with exponential backoff and honour Retry-After. Permanent failures raise FetchError/RateLimitError immediately.

Async

For asyncio code, AsyncHumbleBundleClient runs the synchronous transport in a worker thread, so the event loop is never blocked:

import asyncio
from humblebundle import AsyncHumbleBundleClient

async def main():
    async with AsyncHumbleBundleClient(timeout=15) as client:
        bundles, choice = await asyncio.gather(
            client.bundles("games"),
            client.choices(),
        )
        print(len(bundles), len(choice))

asyncio.run(main())

Logging

The library never configures logging and never prints. Enable diagnostics when you want them:

import humblebundle

humblebundle.configure_logging("DEBUG")   # stderr handler on the "humblebundle" logger
humblebundle.silence()                    # back to silent

Account access (optional)

Public data needs no login. client.login(username, password, authy_token=...) exists for account-specific pages and mirrors Humble's Android app endpoints; it may require a 2FA token or a solved reCAPTCHA. Prefer public data.

How it works

humblebundle.com is a Next.js (App Router) application. Page data is streamed inside the React Server Components ("flight") payload as a series of self.__next_f.push([1, "..."]) calls rather than in <script type="application/json"> islands.

flowchart LR
    A[HttpClient] -->|HTML| B[_rsc.extract_flight]
    B -->|flight stream| C[_rsc.parse_flight]
    C -->|rows| D[_rsc.resolve]
    D -->|plain dicts| E[_parser]
    E -->|feed / tiers / products| F[models]
    F --> G[ProductCollection / HumbleChoice / Store]

Store search is the one exception: the site answers it through a Next.js server action (a multipart POST to /search that carries a build-specific action id). The id is read from the JavaScript chunks on first use and cached, and the POST is sent with http.client because Cloudflare blocks the requests/urllib3 TLS fingerprint on that endpoint.

  • _rsc — extracts, splits and resolves the flight payload (no Humble-specific knowledge);
  • _parser — locates the blocks we need (feedItems, tiers.bundleItems, subscriptionProducts);
  • models — typed, frozen value objects;
  • client / get — the public API.

Migrating from 0.2

humblebundle.get.bundles(...), get.bundle(...) and get.choices(...) still work, and top-level humblebundle.bundles/bundle/choices are unchanged. The changes worth knowing:

0.2 1.0
_Product objects with dynamic attributes Bundle / BundleItem / ChoiceGame (declared fields, same attribute names)
product.price was a float product.price is Money; use product.price.amount
bundle.stepin() bundle.items() (stepin() still works, emits DeprecationWarning)
bundles() returned dict returns ProductCollection (a read-only Mapping; dict(bundles) works)
choices() returned dict returns HumbleChoice (a Mapping)
title-cased aliases (Title, highlights) kept as properties where they existed

See CHANGELOG.md for the full list.

Development

python -m pip install -e ".[dev]"
python -m pytest
python -m ruff check .
python -m mypy

The test suite is hermetic: it builds synthetic Next.js payloads and never touches the network. See CONTRIBUTING.md.

Notes and fair use

  • Only public page data is read; no login or account access is required.
  • Only the current Humble Choice month is available — Humble removed the per-month pages, so choices(month=..., year=...) records a label but cannot fetch history.
  • humblebundle.com asks automated clients to be considerate: keep request volume low, reuse one client, and cache results in your own code.
  • This project is not affiliated with Humble Bundle.

License

MIT — see LICENSE.txt.

Metadata

Release files for humblebundle.py 1.0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for humblebundle.py 1.0.2
File Size Uploaded Provenance Actions
humblebundle_py-1.0.2.tar.gz 99.4 kB Without provenance Details for humblebundle_py-1.0.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for humblebundle.py 1.0.2
File Interpreter ABI Platform Actions
humblebundle_py-1.0.2-py3-none-any.whl Python 3 none any Details for humblebundle_py-1.0.2-py3-none-any.whl

Total release size: 159.4 kB

Release files / humblebundle_py-1.0.2.tar.gz

Download URL humblebundle_py-1.0.2.tar.gz
Size 99.4 kB
Tags Source
SHA-256 checksum
How to use checksums
ce4a7d769605831d7dc3442afc70da6f2e25ee1ccadb078d14342d4a65f227f9
BLAKE2b-256 checksum
How to use checksums
1216a17b3107b596acf25d28d6af9b9ac38950f05dddd0afc8e4ef7218e43497
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.10.11

Release files / humblebundle_py-1.0.2-py3-none-any.whl

Download URL humblebundle_py-1.0.2-py3-none-any.whl
Size 59.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
82bb4ece601b63b3ca222d5edd5ee6cbbed1a8f647f9bfa53eccdfed96c08ccd
BLAKE2b-256 checksum
How to use checksums
3b6d369e4cca98d2b0832e3e5d5a704d55264a7f456a8603a40ce9d42a502ef7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.10.11

Security for humblebundle.py 1.0.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page