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.1.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.1-py3-none-any.whl (7.5 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for thm_enterprise-0.1.1.tar.gz
Algorithm Hash digest
SHA256 f04f74157ed9926bb1a2753ef50765ffb7e8182dca0d3791cc36a8f8635b321c
MD5 96c530ed6adff17c7abc9e6050cac550
BLAKE2b-256 da6bf0cb956a63cb19d6829f8de5c42b4dc25c75dcbac96c89fe61ebaf8353cb

See more details on using hashes here.

Provenance

The following attestation bundles were made for thm_enterprise-0.1.1.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.1-py3-none-any.whl.

File metadata

  • Download URL: thm_enterprise-0.1.1-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.7

File hashes

Hashes for thm_enterprise-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 649aa520f3cb0924d0692aebb030aa23dde90ecbfe8a434f766acd896e763e15
MD5 44e1333bd920908de42f144413babb76
BLAKE2b-256 498d0ad485ef433067f4be3192e4debd5ec71cc99f3f2805e720ccb2f6449ed3

See more details on using hashes here.

Provenance

The following attestation bundles were made for thm_enterprise-0.1.1-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