This release is a pre-release and may not be stable for production use.
timeback-oneroster
Python client for the OneRoster v1.2 API.
Installation
# pip
pip install timeback-oneroster
# uv (add to a project)
uv add timeback-oneroster
# uv (install into current environment)
uv pip install timeback-oneroster
Quick Start
from timeback_oneroster import OneRosterClient
async def main():
client = OneRosterClient(
env="staging", # or "production"
client_id="your-client-id",
client_secret="your-client-secret",
)
# List all schools
schools = await client.schools.list()
for school in schools:
print(school.name)
# Get a specific user
user = await client.users.get("user-sourced-id")
print(f"{user.given_name} {user.family_name}")
await client.close()
Client Structure
client = OneRosterClient(options)
# Rostering
client.users # All users
client.students # Students (filtered users)
client.teachers # Teachers (filtered users)
client.classes # Classes
client.schools # Schools
# client.courses # Coming soon
# client.enrollments # Coming soon
# client.terms # Coming soon
Resource Operations
Each resource supports:
# List all items
users = await client.users.list()
# List with type-safe filtering (recommended)
active_teachers = await client.users.list(
where={"status": "active", "role": "teacher"}
)
# With operators
teachers_or_aides = await client.users.list(
where={"role": {"in_": ["teacher", "aide"]}}
)
# Not equal
non_deleted = await client.users.list(
where={"status": {"ne": "deleted"}}
)
# Sorting
sorted_users = await client.users.list(
where={"status": "active"},
sort="familyName",
order_by="asc",
)
# Legacy filter string (still supported)
active_users = await client.users.list(filter="status='active'")
# Get by sourcedId
user = await client.users.get("user-id")
# Create (where supported)
create_result = await client.classes.create({
"title": "Math 101",
"course": {"sourcedId": "course-id"},
"school": {"sourcedId": "school-id"},
})
print(create_result.sourced_id_pairs.allocated_sourced_id)
# Update (where supported)
await client.classes.update("class-id", {"title": "Math 102"})
# Delete (where supported)
await client.classes.delete("class-id")
Nested Resources
# Schools
classes = await client.schools("school-id").classes()
students = await client.schools("school-id").students()
teachers = await client.schools("school-id").teachers()
courses = await client.schools("school-id").courses()
# Classes
students = await client.classes("class-id").students()
teachers = await client.classes("class-id").teachers()
enrollments = await client.classes("class-id").enrollments()
# Enroll a student
await client.classes("class-id").enroll({"sourcedId": "student-id", "role": "student"})
# Users
classes = await client.users("user-id").classes()
demographics = await client.users("user-id").demographics()
# Students / Teachers
classes = await client.students("student-id").classes()
classes = await client.teachers("teacher-id").classes()
Filtering
The client supports type-safe filtering with the where parameter:
# Simple equality
users = await client.users.list(where={"status": "active"})
# Multiple conditions (AND)
users = await client.users.list(
where={"status": "active", "role": "teacher"}
)
# Operators
users = await client.users.list(where={"score": {"gte": 90}}) # >=
users = await client.users.list(where={"score": {"gt": 90}}) # >
users = await client.users.list(where={"score": {"lte": 90}}) # <=
users = await client.users.list(where={"score": {"lt": 90}}) # <
users = await client.users.list(where={"status": {"ne": "deleted"}}) # !=
users = await client.users.list(where={"email": {"contains": "@school.edu"}}) # substring
# Match any of multiple values (OR)
users = await client.users.list(
where={"role": {"in_": ["teacher", "aide"]}}
)
# Exclude multiple values
users = await client.users.list(
where={"status": {"not_in": ["deleted", "inactive"]}}
)
# Explicit OR across fields
users = await client.users.list(
where={"OR": [{"role": "teacher"}, {"status": "active"}]}
)
Pagination
For large datasets, use streaming:
# Collect all users
all_users = await client.users.stream().to_list()
# With limits
first_100 = await client.users.stream(max_items=100).to_list()
# With filtering
active_users = await client.users.stream(
where={"status": "active"}
).to_list()
# Get first item only
first_user = await client.users.stream().first()
Configuration
OneRosterClient(
# Environment-based (recommended)
env="production", # or "staging"
client_id="...",
client_secret="...",
# Or explicit URLs
base_url="https://api.example.com",
auth_url="https://auth.example.com/oauth2/token",
client_id="...",
client_secret="...",
# Optional
timeout=30.0, # Request timeout in seconds
)
Environment Variables
If credentials are not provided explicitly, the client reads from:
ONEROSTER_CLIENT_IDONEROSTER_CLIENT_SECRETONEROSTER_BASE_URL(optional)ONEROSTER_TOKEN_URL(optional)
Error Handling
from timeback_oneroster import OneRosterError, NotFoundError, AuthenticationError
try:
user = await client.users.get("invalid-id")
except NotFoundError as e:
print(f"User not found: {e.sourced_id}")
except AuthenticationError:
print("Invalid credentials")
except OneRosterError as e:
print(f"API error: {e}")
Async Context Manager
async with OneRosterClient(client_id="...", client_secret="...") as client:
schools = await client.schools.list()
# Client is automatically closed
FastAPI Integration
from fastapi import FastAPI, Depends
from timeback_oneroster import OneRosterClient
app = FastAPI()
async def get_oneroster():
client = OneRosterClient(
env="production",
client_id="...",
client_secret="...",
)
try:
yield client
finally:
await client.close()
@app.get("/schools")
async def list_schools(client: OneRosterClient = Depends(get_oneroster)):
return await client.schools.list()
Metadata
Release files for timeback-oneroster 0.2.1b20260314013725
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| timeback_oneroster-0.2.1b20260314013725.tar.gz | 45.5 kB | Without provenance | Details for timeback_oneroster-0.2.1b20260314013725.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| timeback_oneroster-0.2.1b20260314013725-py3-none-any.whl | Python 3 | none | any | Details for timeback_oneroster-0.2.1b20260314013725-py3-none-any.whl |
Total release size: 109.6 kB
Release files / timeback_oneroster-0.2.1b20260314013725.tar.gz
| Download URL | timeback_oneroster-0.2.1b20260314013725.tar.gz |
|---|---|
| Size | 45.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
2d6e6d1f6f95ec22e80d86254454d88433cf480259c4b065bdb1edbccc659185
|
|
BLAKE2b-256 checksum How to use checksums |
3eafe07a9921cb871b62503e43a15c923e0537af56c6b32a98a7f7a23dce4791
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.10.10 {"installer":{"name":"uv","version":"0.10.10","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / timeback_oneroster-0.2.1b20260314013725-py3-none-any.whl
| Download URL | timeback_oneroster-0.2.1b20260314013725-py3-none-any.whl |
|---|---|
| Size | 64.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
5c8a69a1a6d09ad4ad793e671695f869424b52346df6b2d8118a1adc058c65e3
|
|
BLAKE2b-256 checksum How to use checksums |
43afdd263a9f2f2651a35838d63eec9ada9c700060e71fcae63f3b1794e18753
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.10.10 {"installer":{"name":"uv","version":"0.10.10","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Security for timeback-oneroster 0.2.1b20260314013725
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.