Skip to main content

Easy-to-use Python client for the Ed Stem API

Project description

pyedstem

Typed Python client for the Ed Stem API.

pyedstem provides a small, sync-first interface for common Ed Stem tasks such as listing active courses, retrieving discussion threads, reading lessons, and posting answers back to Ed using the XML document format the API expects.

Installation

Install with pip

pip install pyedstem

Add to a uv project

uv add pyedstem

Configuration

You can create a client directly with an API token:

from pyedstem import EdStemClient

client = EdStemClient(api_token="your-edstem-token")

Or load configuration from environment variables:

  • EDSTEM_API_TOKEN — required
  • EDSTEM_BASE_URL — optional, defaults to https://edstem.org/api
  • EDSTEM_TIMEOUT_SECONDS — optional, defaults to 30.0
from pyedstem import EdStemClient

with EdStemClient.from_env() as client:
    current_user = client.user.get_current_user()

Quick start

List active courses

from pyedstem import EdStemClient

with EdStemClient.from_env() as client:
    active_courses = client.courses.list_active()

for course in active_courses:
    print(course.id, course.code, course.name)

Fetch unanswered discussion threads

from pyedstem import EdStemClient

course_id = 12345

with EdStemClient.from_env() as client:
    threads = client.workflows.list_course_unanswered_threads(course_id)

for thread in threads:
    print(f"#{thread.number}: {thread.title}")

Post an answer

from pyedstem import EdStemClient

with EdStemClient.from_env() as client:
    client.threads.post_answer(
        thread_id=67890,
        markdown="Hi there,\n\nThanks for the question...",
    )

Features

  • typed models for common Ed Stem responses
  • sync-first client API with resource groups
  • workflow helpers for active-course and unanswered-thread automation
  • markdown-to-Ed document conversion for answer posting
  • opt-in live contract tests for undocumented API drift detection

Development

Clone the repository, then install development dependencies with uv:

uv sync --group dev

Run the test suite:

uv run pytest tests

Live contract tests

The repository includes an opt-in live suite under tests/live/ that probes documented Ed endpoints so API changes can be detected early.

Safe read-only live tests:

EDSTEM_RUN_LIVE_TESTS=1 uv run pytest tests/live/test_endpoint_contracts.py tests/live/test_restricted_endpoint_contracts.py

Opt-in write test for posting answers:

EDSTEM_RUN_WRITE_TESTS=1 \
EDSTEM_WRITE_TEST_THREAD_ID=12345 \
uv run pytest tests/live/test_write_endpoint_contracts.py

Only enable the write suite when it is safe to mutate real Ed data.

Publishing

Build distribution artifacts with:

uv build

Publish to PyPI with:

uv publish

uv publish expects PyPI credentials or trusted publishing to be configured in the environment where you run the release.

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

pyedstem-0.1.0.tar.gz (14.2 kB view details)

Uploaded Source

Built Distribution

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

pyedstem-0.1.0-py3-none-any.whl (15.4 kB view details)

Uploaded Python 3

File details

Details for the file pyedstem-0.1.0.tar.gz.

File metadata

  • Download URL: pyedstem-0.1.0.tar.gz
  • Upload date:
  • Size: 14.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.2 {"installer":{"name":"uv","version":"0.10.2","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","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

Hashes for pyedstem-0.1.0.tar.gz
Algorithm Hash digest
SHA256 874f8c545a47fc26b929a11e55af8f3fc644e62e4b06b810a06ee0be45bcdcb4
MD5 fc3d345c0e0392ffc06ebb5123dca222
BLAKE2b-256 27a721e0ab2ec5201850041895a42b695a6ea273c2ee6a763b5d78c4ced25f90

See more details on using hashes here.

File details

Details for the file pyedstem-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: pyedstem-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 15.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.2 {"installer":{"name":"uv","version":"0.10.2","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","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

Hashes for pyedstem-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4f98f9a028530175524356e0a35bf70be29416e8306ded74b8d858a433faeaaf
MD5 e541471f5f2583de886e0f814b62bf5e
BLAKE2b-256 c916562c90f352cccd14b20b071c8b4e563fe465cff3bd06a76de1ee070b5c14

See more details on using hashes here.

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