Skip to main content

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 HiveClient that 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.2
  • 6.2.0
  • 6.4.0
  • 7.1.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.

  • Subject supports subject.get_modules() and can be iterated to yield its modules.
  • Assignment supports assignment.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=False only when necessary for self-signed or development servers.
  • The package is intended for synchronous Hive API usage with a minimal convenience layer.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

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

pyhivelms-2.1.1-py3-none-any.whl (92.5 kB view details)

Uploaded Python 3

File details

Details for the file pyhivelms-2.1.1-py3-none-any.whl.

File metadata

  • Download URL: pyhivelms-2.1.1-py3-none-any.whl
  • Upload date:
  • Size: 92.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for pyhivelms-2.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 17717938879c5f766934cb057136889e5688fa0429103ca8929faa633c5984dc
MD5 8eab3930ca4dccfa0be184c91b0c7dec
BLAKE2b-256 fffb2a57d50c2b3d372573b59c74b00bb100620586b1e8c44e10113bb4981d03

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyhivelms-2.1.1-py3-none-any.whl:

Publisher: publish.yml on System-B15/pyhive

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

Release history Release notifications | RSS feed

This release

2.1.1 This release

1 file

2.1.0

1 file

2.0.0

1 file

1.5.0

1 file

1.4.0

1 file

1.3.2

1 file

1.3.1

1 file

1.3.0

1 file

1.2.3

1 file

1.2.2

1 file

1.2.1

1 file

1.1.1

1 file

1.1.0

1 file

1.0.2

1 file

1.0.1

1 file

1.0.0

1 file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page