Easy-to-use Python client for the Ed Stem API
Project description
pyedstem
Typed Python client for the Ed Stem API.
Documentation: alexdrbanana.github.io/pyedstem
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— requiredEDSTEM_BASE_URL— optional, defaults tohttps://edstem.org/apiEDSTEM_TIMEOUT_SECONDS— optional, defaults to30.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 recent discussion threads
from pyedstem import EdStemClient
course_id = 12345
with EdStemClient.from_env() as client:
threads = client.threads.list(course_id, limit=20, sort="date")
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
- 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.
Documentation
Full documentation is available at:
alexdrbanana.github.io/pyedstem
If you're contributing to the project and want to preview the docs locally:
uv sync --group dev --group docs
uv run mkdocs serve
Then open the local URL shown by MkDocs.
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
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 pyedstem-0.3.0.tar.gz.
File metadata
- Download URL: pyedstem-0.3.0.tar.gz
- Upload date:
- Size: 43.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4b24af56b2aefe82a361fe639f33b566c33184b997b680e67a1f51a7cf75d1d9
|
|
| MD5 |
e92f0a66a415da4759c4812b30e8b11e
|
|
| BLAKE2b-256 |
148e46141ccbe29df6b32dd41b65b346ac86f52366c868c6a97dab9685f424df
|
Provenance
The following attestation bundles were made for pyedstem-0.3.0.tar.gz:
Publisher:
publish.yml on AlexDrBanana/pyedstem
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pyedstem-0.3.0.tar.gz -
Subject digest:
4b24af56b2aefe82a361fe639f33b566c33184b997b680e67a1f51a7cf75d1d9 - Sigstore transparency entry: 1101542849
- Sigstore integration time:
-
Permalink:
AlexDrBanana/pyedstem@cd110a03647da7d8581bda511a40fbdbb04fd055 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/AlexDrBanana
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@cd110a03647da7d8581bda511a40fbdbb04fd055 -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file pyedstem-0.3.0-py3-none-any.whl.
File metadata
- Download URL: pyedstem-0.3.0-py3-none-any.whl
- Upload date:
- Size: 13.6 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 |
99f4e7a0f8ade9598a90708fc8b9d74ab7f18f9ae7b0f01c931ef95305b6d3c3
|
|
| MD5 |
3be66f5e4503e259aa92e40883eb1ca6
|
|
| BLAKE2b-256 |
f9ae956ee4ca583ef206823c9f05dca4448662c712814375f17b9180924e2f3d
|
Provenance
The following attestation bundles were made for pyedstem-0.3.0-py3-none-any.whl:
Publisher:
publish.yml on AlexDrBanana/pyedstem
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pyedstem-0.3.0-py3-none-any.whl -
Subject digest:
99f4e7a0f8ade9598a90708fc8b9d74ab7f18f9ae7b0f01c931ef95305b6d3c3 - Sigstore transparency entry: 1101542850
- Sigstore integration time:
-
Permalink:
AlexDrBanana/pyedstem@cd110a03647da7d8581bda511a40fbdbb04fd055 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/AlexDrBanana
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@cd110a03647da7d8581bda511a40fbdbb04fd055 -
Trigger Event:
workflow_dispatch
-
Statement type: