Python bindings for Hive
Project description
PyHive — Hive API client for Python
PyHive (package: PyHiveLMS) is a lightweight synchronous Python client for the Hive LMS API, featuring Pydantic V2-based models for type safety and validation.
It provides:
- A simple
HiveClientthat manages authentication and the session lifecycle. - Built-in support for Hive SSO and username/password authentication.
- Generator-based list endpoints for efficient paging and iteration.
- Model convenience helpers for working with programs, subjects, modules, exercises, assignments, queues, and users.
- Filter-friendly APIs that accept both IDs and model instances.
Supported Hive Versions
5.1.26.2.06.4.0
Install
Install from PyPI in a virtual environment:
pip install PyHiveLMS
Quickstart
The main entry point is HiveClient. Use it as a context manager to keep authentication and HTTP resources scoped cleanly.
SSO login (recommended)
Use HiveClient.from_sso(...) to authenticate via Hive SSO. This workflow opens a browser-based login page and completes authentication automatically.
from pyhive import HiveClient
with HiveClient.from_sso(hive_url="https://hive.org", verify=False) as client:
programs = list(client.get_programs())
print(programs)
Username/password login
Authenticate directly with Hive credentials when SSO is not desirable.
from pyhive import HiveClient
with HiveClient("username", "password", "https://hive.org") as client:
subjects = list(client.get_subjects())
print(subjects)
Core features
Iterable model helpers
Models expose convenience methods and iterators so you can fetch related objects naturally.
Subjectsupportssubject.get_modules()and can be iterated to yield its modules.Assignmentsupportsassignment.get_responses()and can be iterated to yield its responses.
Filter-friendly list APIs
List endpoints accept filter keyword arguments that are forwarded to Hive.
subjects = client.get_subjects(parent_program__id__in=[123])
assignments = client.get_assignments(user__id__in=[456])
Many methods also accept either an ID or a model instance.
exercise_fields = client.get_exercise_fields(exercise)
Type hints
Public model classes are available from pyhive.types for type-safe code and editor completion. All models are Pydantic V2 BaseModel subclasses with automatic validation and serialization.
from pyhive import HiveClient
from pyhive.types import Program, Subject, User
with HiveClient("username", "password", "https://hive.org") as client:
program = client.get_program(123)
subjects = client.get_subjects(parent_program=program)
for subject in subjects:
print(subject.id, subject.name)
Convenience helpers
Call methods directly on models for common domain operations.
with HiveClient("username", "password", "https://hive.org") as client:
# Create a new module in a subject
subject = client.get_subjects(parent_program__id__in=[123])[0]
new_module = subject.create_module(
name="Limits and Continuity",
order=10,
segel_brief="Introduction to limits.",
)
print(new_module.id, new_module.name)
# Create a new exercise in a module
new_exercise = new_module.create_exercise(
name="Derivative Rules",
order=1,
description="Practice basic derivative rules.",
)
print(new_exercise.id, new_exercise.name)
# Create a new user
new_user = client.create_user(
username="student123",
email="student@example.com",
first_name="John",
last_name="Doe",
)
print(new_user.id, new_user.username)
Common methods
HiveClient(username, password, hive_url, **kwargs)HiveClient.from_sso(hive_url, **kwargs)get_programs(...)get_program(program_id)get_subjects(...)get_modules(...)get_exercises(...)get_exercise(exercise_id)get_exercise_fields(exercise)get_assignments(...)get_assignment(assignment_id)get_assignment_responses(assignment)get_users(...)get_classes(...)
Return values are typed model objects or generators of model objects.
CLI
PyHive includes a CLI exposed as the pyhive console script with the following commands:
pyhive versions: Display supported Hive API versions.pyhive token: Authenticate via SSO and output a valid access token.pyhive register <service_name> <redirect_uri>: Register a new service with the Hive server and generate client keys.
Testing
Run the package tests with pytest:
pip install -e .
pytest -q
Notes
- Network and HTTP errors are surfaced through the underlying HTTP client.
- Pass
verify=Falseonly when necessary for self-signed or development servers. - The package is intended for synchronous Hive API usage with a minimal convenience layer.
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 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 pyhivelms-1.4.0-py3-none-any.whl.
File metadata
- Download URL: pyhivelms-1.4.0-py3-none-any.whl
- Upload date:
- Size: 77.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
36276f23f77d17ca8bea6b8ba5136a531ea88b9258e9308b96cf118c59eba5ba
|
|
| MD5 |
e6cd234707c53afd343bebcef6095517
|
|
| BLAKE2b-256 |
2ef4cdc0fcbded29128efb6b9ae20f53f02ed08d7459dd89a7cb0b060d552244
|
Provenance
The following attestation bundles were made for pyhivelms-1.4.0-py3-none-any.whl:
Publisher:
publish.yml on System-B15/pyhive
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pyhivelms-1.4.0-py3-none-any.whl -
Subject digest:
36276f23f77d17ca8bea6b8ba5136a531ea88b9258e9308b96cf118c59eba5ba - Sigstore transparency entry: 1248659845
- Sigstore integration time:
-
Permalink:
System-B15/pyhive@5267bab0eaf1be6e7f2a2d309dd0ad52b141ab13 -
Branch / Tag:
refs/tags/v1.4.0 - Owner: https://github.com/System-B15
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@5267bab0eaf1be6e7f2a2d309dd0ad52b141ab13 -
Trigger Event:
push
-
Statement type: