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
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
89e848caabb68a415cc5c3ec056140bd911b4570c3fabb3d4443a5f166142b86
|
|
| MD5 |
17add674cc1eab5691777d79011fe1bd
|
|
| BLAKE2b-256 |
8c1ab90da186cec8c00b40dd7d446ebb462d277433dcd1f8f2f0afe1a6879716
|
Provenance
The following attestation bundles were made for thm_enterprise-0.1.2.tar.gz:
Publisher:
publish.yml on voidstarr/thm-enterprise
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
thm_enterprise-0.1.2.tar.gz -
Subject digest:
89e848caabb68a415cc5c3ec056140bd911b4570c3fabb3d4443a5f166142b86 - Sigstore transparency entry: 1272589431
- Sigstore integration time:
-
Permalink:
voidstarr/thm-enterprise@8dc0efaafe51a327bd7cda8406d4d1c1c6437702 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/voidstarr
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@8dc0efaafe51a327bd7cda8406d4d1c1c6437702 -
Trigger Event:
push
-
Statement type:
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ed6eaeb4983f694ba1895242dea1e542f2c919c8b7ef2cd2b516f6b4fe15465c
|
|
| MD5 |
88154c005eeb014ebcd896f3e8f03f38
|
|
| BLAKE2b-256 |
d46fa94cf53cb1b89d566f7ed7f1962b5fcf54d0cca97d5d92b7caeb54fc60e8
|
Provenance
The following attestation bundles were made for thm_enterprise-0.1.2-py3-none-any.whl:
Publisher:
publish.yml on voidstarr/thm-enterprise
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
thm_enterprise-0.1.2-py3-none-any.whl -
Subject digest:
ed6eaeb4983f694ba1895242dea1e542f2c919c8b7ef2cd2b516f6b4fe15465c - Sigstore transparency entry: 1272589470
- Sigstore integration time:
-
Permalink:
voidstarr/thm-enterprise@8dc0efaafe51a327bd7cda8406d4d1c1c6437702 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/voidstarr
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@8dc0efaafe51a327bd7cda8406d4d1c1c6437702 -
Trigger Event:
push
-
Statement type: