An SDK for the Hive LMS API
Project description
HiveLMS Python Client
An SDK for the Hive LMS HTTP API, implemented in Python using Pydantic v2 models and a small HTTP client wrapper around requests.
This library is generated from the authoritative OpenAPI spec in schema.json and aims to provide a clean, typed, and well‑structured interface to all public Hive endpoints.
Installation
The package is intended to be installed via uv or pip from source for now.
# Using uv
uv sync --extra dev
# Or using pip directly (from the project root)
pip install .
Python 3.12+ is required.
Quick Start
Creating a client
The main entry point is HiveClient, which exposes per‑resource handlers (assignments, course, queues, schedule, tags, etc.).
from hivelms_client.hive_client import HiveClient
client = HiveClient(
host="hive.test",
username="admin",
password="Password1",
use_https=True,
)
By default the client will:
- Authenticate with the Hive token endpoint
- Store the access token
- Attach it automatically to subsequent requests
If you already have a token, you can construct a low‑level HiveHttpClient directly and inject it into handlers, but HiveClient is usually all you need.
Handlers and Resources
Each top‑level Hive resource has a corresponding handler class under hivelms_client/handlers/. For example:
assignments→AssignmentsHandlercourse→CourseHandler(and nested sub‑handlers likemodules,exercises,subjects,programs)queues→QueuesHandler(and nesteditemshandler)schedule→ScheduleHandler(and nestedlessonshandler)tags→TagsHandlertime→TimeHandlerhelps→HelpHandlerandHelpResponsesHandlermanagement→ManagementHandler
These are all accessible as attributes on HiveClient:
client.assignments_handler # AssignmentsHandler
client.course_handler # CourseHandler
client.queues_handler # QueuesHandler
client.schedule_handler # ScheduleHandler
client.tags_handler # TagsHandler
client.time_handler # TimeHandler
client.notification_handler # NotificationHandler
client.management_handler # ManagementHandler
Sub‑resource handlers
Nested API paths are modeled as nested handlers. For example:
- Queue items:
/queues/{queue_id}/items/... - Course modules:
/course/modules/... - Schedule lessons:
/schedule/lessons/...
These appear as attributes on their parent handler:
# Queue items
queue_items = client.queues_handler.items
queue_items.delete(queue_id=123, item_id=456)
# Course modules
modules = client.course_handler.modules
modules.create(body=module_request)
# Schedule lessons
lessons = client.schedule_handler.lessons
lessons.get(lesson_id=456)
The method names follow a consistent convention:
search– GET a collectionget– GET a single resource or a GET actioncreate– POST createupdate– PUTpatch– PATCHdelete– DELETE- Other verbs (e.g.
lock,duplicate) are used for action‑style endpoints.
Within sub‑resource handlers, method names omit the subresource name where it would be redundant (e.g. QueueItemsHandler.delete(...) instead of delete_item).
Models
All request and response bodies are defined as Pydantic models under hivelms_client/models/, organized per top‑level resource:
assignments/course/help/management/notification/queues/schedule/tag/time/hive_common/– shared/common models
The models are generated directly from schema.json and:
- Use precise types and constraints (e.g.
Annotated[str, Field(min_length=1, max_length=255)]) - Represent enums via the
HiveOptionbase class (orLiteral[...]for single‑option enums) - Use
InlineBytesfor binary fields
Creation and patch models follow a naming convention:
*CreationRequestfor creation requests (from*Requestin the OpenAPI spec)*PatchRequestfor patch requests (fromPatched*Requestin the OpenAPI spec)
Example (simplified):
from hivelms_client.models.assignments.assignment import AssignmentInput
request = AssignmentInput(
name="Homework 1",
# ... other fields ...
)
created = client.assignments_handler.create(request)
print(created.id)
HTTP Client Layer
Under the hood, handlers use HiveHttpClient (defined in hivelms_client/http_client.py) to perform HTTP requests.
Key features:
- Wraps
requests.Session - Adds base URL and
path_prefixsupport - Manages authentication headers
- Exposes a
get_subclient(path_prefix: str)helper to build nested clients for sub‑resources - Raises rich exceptions from
hivelms_client.exceptionson error responses
You normally won’t need to instantiate HiveHttpClient yourself; the HiveClient does it for you.
Example Usage
Working with queues
from hivelms_client.hive_client import HiveClient
from hivelms_client.models.queues.queue_items import QueueItemInput
client = HiveClient(host="hive.test", username="admin", password="Password1")
# Search queues
queues = client.queues_handler.search()
for queue in queues:
print(queue.id, queue.name)
# Get a single queue
queue = client.queues_handler.get(queues[0].id)
# Work with queue items via the sub‑handler
items = client.queues_handler.items
created_item = items.create(
queue_id=queue.id,
item=QueueItemInput(title="New item", description="Investigate bug"),
)
items.delete(queue_id=queue.id, item_id=created_item.id)
Working with courses and modules
from hivelms_client.models.course.module import ModuleInput
module_request = ModuleInput(name="Getting Started", parent_subject=1, order="1")
module = client.course_handler.modules.create(module_request)
# Fetch module details
module = client.course_handler.modules.get(module.id)
Working with schedule lessons
# List lessons
lessons = client.schedule_handler.lessons.search()
# Get a specific lesson
lesson = client.schedule_handler.lessons.get(lessons[0].id)
Testing
The project uses pytest for tests. To run the full test suite:
uv run pytest
Tests use a running Hive instance at https://hive.test and a snapshot of server data in tests/data/server_data.json. Fixtures in tests/conftest.py provide ready‑to‑use admin and student clients.
Contributing & Regeneration
The OpenAPI schema in schema.json is the single source of truth for the client.
High‑level workflow for extending the client:
- Update
schema.json(or pull the latest version). - Generate/update Pydantic models under
hivelms_client/models/. - Add or update handlers under
hivelms_client/handlers/to cover new endpoints. - Wire new handlers into
HiveClient. - Add tests under
tests/for each new handler method. - Run
uv run pytestbefore submitting changes.
See .github/copilot-instructions.md and .agent/conventions.md for detailed internal conventions and codegen rules.
License
This project is licensed under the terms specified in the repository (see the root LICENSE file, if present). If no license file is present, consult the project maintainers before reusing the code in other projects.
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 Distributions
Built Distributions
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 hivelms_client-1.0.0-py3-none-any.whl.
File metadata
- Download URL: hivelms_client-1.0.0-py3-none-any.whl
- Upload date:
- Size: 79.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.10.4 {"installer":{"name":"uv","version":"0.10.4","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Arch Linux","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
224a5677e469a269914476233b972b5507cf6395b485aabdb3286b11a40218d0
|
|
| MD5 |
f33479857282e38e1d14eb2a509eb672
|
|
| BLAKE2b-256 |
c1a4faf88a7f4a7f0fbfa201d49033f99d8937ca1ef9d58c65aa366b705adf46
|
File details
Details for the file hivelms_client-1.0.0-1-py3-none-any.whl.
File metadata
- Download URL: hivelms_client-1.0.0-1-py3-none-any.whl
- Upload date:
- Size: 78.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.10.4 {"installer":{"name":"uv","version":"0.10.4","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Arch Linux","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
80cb43528ed1e9f6932a75aa392a00c037bb69bb58bf1885b21675eed06b43cc
|
|
| MD5 |
3060e18ef20a85474aff2ef90ac308ea
|
|
| BLAKE2b-256 |
cdea14e03e487d7bcb6667fc0526ae2e43be86b93e81226daae1ae005e7cebf8
|