Skip to main content

Pythonic client for the TryHackMe Enterprise API

Project description

thm-enterprise

Python client for the TryHackMe Enterprise API.

Requires a Business or Classroom plan API key.

Installation

pip install thm-enterprise

Quick Start

from thm_enterprise import TryHackMe

thm = TryHackMe(api_key="your-api-key")

# List all users on your seats / api-users
for user in thm.get_users():
    print(user.username, user.email, user.total_points)

# Get room scoreboard (scores + per-question attempts)
for entry in thm.get_scoreboard("dvwa"):
    print(entry.username, entry.score)

# Check available rooms
rooms = thm.get_rooms()

# Get questions for a room
tasks = thm.get_room_questions("dvwa")
for task in tasks:
    for q in task.questions:
        print(f"Task {task.task_no} Q{q.question_no}: {q.question}")

API Coverage

Method Endpoint Description
get_registration_url(token) GET /external/api/register Build a registration URL for an API-user
authenticate_user(ext_user_id, room_code) POST /external/api/authenticate Authenticate/register a user and get a redirect URL
add_seat(email) PUT /api/v2/external/seats/users Add a user to a company seat
remove_seat(email) DELETE /api/v2/external/seats/users Remove a user from a company seat
get_users() GET /external/api/users List all seated and API users
get_user_by_email(email) Convenience lookup by email
get_rooms() GET /external/api/rooms List all accessible rooms
room_exists(room_code) GET /external/api/roomExists Check if a room exists
get_room_questions(room_code) GET /external/api/questions Get tasks and questions for a room
remove_user_from_room(ext_user_id, room_code) POST /external/api/leaveRoom Remove a user from a room
get_scoreboard(room_code) GET /api/v2/external/scoreboard Get scores and attempts for a room
get_time_report(emails, from_date, to_date) POST /api/v2/external/reports/time Get time spent per user between two dates

Error Handling

All API errors raise typed exceptions:

from thm_enterprise import TryHackMe, AuthenticationError, BadRequestError, NotFoundError

thm = TryHackMe(api_key="your-api-key")

try:
    thm.get_scoreboard("nonexistent-room")
except AuthenticationError:
    print("Invalid or expired API key")
except NotFoundError:
    print("Room not found")
except BadRequestError as e:
    print(f"Bad request: {e.message}")

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

thm_enterprise-0.1.2.tar.gz (7.3 kB view details)

Uploaded Source

Built Distribution

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

thm_enterprise-0.1.2-py3-none-any.whl (7.5 kB view details)

Uploaded Python 3

File details

Details for the file thm_enterprise-0.1.2.tar.gz.

File metadata

  • Download URL: thm_enterprise-0.1.2.tar.gz
  • Upload date:
  • Size: 7.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for thm_enterprise-0.1.2.tar.gz
Algorithm Hash digest
SHA256 89e848caabb68a415cc5c3ec056140bd911b4570c3fabb3d4443a5f166142b86
MD5 17add674cc1eab5691777d79011fe1bd
BLAKE2b-256 8c1ab90da186cec8c00b40dd7d446ebb462d277433dcd1f8f2f0afe1a6879716

See more details on using hashes here.

Provenance

The following attestation bundles were made for thm_enterprise-0.1.2.tar.gz:

Publisher: publish.yml on voidstarr/thm-enterprise

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file thm_enterprise-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: thm_enterprise-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 7.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for thm_enterprise-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 ed6eaeb4983f694ba1895242dea1e542f2c919c8b7ef2cd2b516f6b4fe15465c
MD5 88154c005eeb014ebcd896f3e8f03f38
BLAKE2b-256 d46fa94cf53cb1b89d566f7ed7f1962b5fcf54d0cca97d5d92b7caeb54fc60e8

See more details on using hashes here.

Provenance

The following attestation bundles were made for thm_enterprise-0.1.2-py3-none-any.whl:

Publisher: publish.yml on voidstarr/thm-enterprise

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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