Skip to main content

htb-sdk

CI PyPI Python

Unofficial, typed Python SDK for Hack The Box — reverse-engineered from the live labs.hackthebox.com API.

pip install htb-sdk
from htb import HTBClient, Difficulty

htb = HTBClient(token="...")          # or set HTB_TOKEN

htb.user.me()
box = htb.machines.list(per_page=1)[0]
htb.machines.spawn(box["id"])
htb.machines.submit_flag(box["id"], "HTB{...}", Difficulty.MEDIUM)
htb.machines.terminate(box["id"])

htb.get("/api/v4/season/list")        # raw access to any endpoint

Get an App Token at Profile → Settings → App Tokens on app.hackthebox.com.

17 typed resource namespaces — machines, challenges, sherlocks, fortresses, prolabs, endgames, tracks, seasons, teams, universities, rankings, user, connection, pwnbox, tokens, walkthroughs, platform. Full map: docs/ENDPOINTS.md.

CLI & MCP

Both are auto-generated from the SDK — every method is a command and a tool.

Both ship in the base install — no extras needed.

htb machines list --per-page 5           # Rich table
htb machines spawn 351                   # write ops too
htb machines list --json | jq .          # raw JSON for scripting
htb raw GET /api/v4/season/list          # any endpoint

htb-mcp                                   # FastMCP server (stdio), reads HTB_TOKEN

Docs & examples

Runnable scripts in examples/; full CLI reference in docs/cli.md. Browse the typed API interactively:

uv sync --group docs && uv run mkdocs serve   # http://127.0.0.1:8000

Develop

uv sync --all-groups
uv run pytest            # add --e2e for live tests (needs HTB_TOKEN)

The API map is reverse-engineered from real browser traffic + frontend JS; re-run the pipeline in capture/ when HTB changes their API.

License

MIT

Release files for htb-sdk 0.2.1

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

Source distribution (sdist)

Source distribution for htb-sdk 0.2.1
File Size Uploaded
htb_sdk-0.2.1.tar.gz 149.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for htb-sdk 0.2.1
File Interpreter ABI Platform
htb_sdk-0.2.1-py3-none-any.whl Python 3 none any Details

Total release size: 184.2 kB

Release files / htb_sdk-0.2.1.tar.gz

Download URL htb_sdk-0.2.1.tar.gz
Size 149.5 kB
Tags Source
SHA-256 checksum
How to use checksums
412377ce80fcaf46a104874e44150c2a3615c74801a6bb7eb48955371c6723a1
BLAKE2b-256 checksum
How to use checksums
3544b215b7f117b5c01b1d8cbee8a530c38e7c814bc3947221b9ec7bcc9cebfb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.11.19 {"installer":{"name":"uv","version":"0.11.19","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / htb_sdk-0.2.1-py3-none-any.whl

Download URL htb_sdk-0.2.1-py3-none-any.whl
Size 34.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9a6233d3cd85febe760263fb7046e20743fe810394aee0631fc828e397faa499
BLAKE2b-256 checksum
How to use checksums
7f99dd93932a109aaaa722c4da6c543cc4523a894e3ef8d9ecdf4b4c4b30ad80
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.11.19 {"installer":{"name":"uv","version":"0.11.19","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release history Release notifications | RSS feed

This release

0.2.1 This release

2 release files

0.2.0

2 release files

0.1.0

2 release files

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