Skip to main content

Unofficial Python SDK for the Hack The Box (labs.hackthebox.com) API, reverse-engineered from live traffic.

Project description

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

htb_sdk-0.2.1.tar.gz (149.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

htb_sdk-0.2.1-py3-none-any.whl (34.7 kB view details)

Uploaded Python 3

File details

Details for the file htb_sdk-0.2.1.tar.gz.

File metadata

  • Download URL: htb_sdk-0.2.1.tar.gz
  • Upload date:
  • Size: 149.5 kB
  • Tags: Source
  • Uploaded using 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}

File hashes

Hashes for htb_sdk-0.2.1.tar.gz
Algorithm Hash digest
SHA256 412377ce80fcaf46a104874e44150c2a3615c74801a6bb7eb48955371c6723a1
MD5 d563297db103ae9f254b5fd127d62ea5
BLAKE2b-256 3544b215b7f117b5c01b1d8cbee8a530c38e7c814bc3947221b9ec7bcc9cebfb

See more details on using hashes here.

File details

Details for the file htb_sdk-0.2.1-py3-none-any.whl.

File metadata

  • Download URL: htb_sdk-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 34.7 kB
  • Tags: Python 3
  • Uploaded using 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}

File hashes

Hashes for htb_sdk-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 9a6233d3cd85febe760263fb7046e20743fe810394aee0631fc828e397faa499
MD5 7c7c3c9d97721437763387e49e29df6f
BLAKE2b-256 7f99dd93932a109aaaa722c4da6c543cc4523a894e3ef8d9ecdf4b4c4b30ad80

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page