Skip to main content

Python SDK for the Teachworks API.

Project description

Teachworks SDK

A Python SDK for the Teachworks API. This package provides a typed, validated, and well-organized interface to Teachworks, built around a resilient TeachworksSession that manages authentication, rate limits, pagination, and error handling.

Installation

pip install teachworks-sdk

Quick Start

from teachworks_sdk import TeachworksSession

with TeachworksSession(api_key="your-api-key") as session:
    # List all locations
    locations = session.locations.list()
    for location in locations:
        print(location.id, location.name)

    # Fetch all students across pages
    students = session.students.list(all_pages=True)

    # Retrieve a single record
    employee = session.employees.retrieve(123)

Features

  • 23 API resources - Customers, students, employees, lessons, invoices, payments, and more
  • Automatic pagination - Fetch all pages with all_pages=True
  • Rate limiting - Built-in request throttling and retry with exponential backoff
  • Typed responses - Pydantic models with full type hints
  • Relationship resolution - Lazy-load related resources
  • Session caching - Identity map prevents duplicate fetches
  • Comprehensive logging - DEBUG, INFO, WARNING, and ERROR logging with flexible configuration

Documentation

Document Description
Usage Guide Configuration, error handling, caching, filtering patterns
Logging Guide Comprehensive logging configuration and troubleshooting
API Reference Complete list of resources and methods
Types Reference All model types and their properties

Basic Examples

Error Handling

from teachworks_sdk import TeachworksSession, TeachworksAPIError

try:
    location = session.locations.retrieve(999999)
except TeachworksAPIError as exc:
    print(exc.status_code, exc.message)

Typed Filtering

from teachworks_sdk import TeachworksSession, Types
from datetime import date

lessons = session.lessons.list(
    query=Types.LessonListParams(
        employee_id=42,
        from_date=date(2024, 1, 1)
    )
)

Relationship Resolution

participant = session.lesson_participants.retrieve(42)
student = participant.resolve(session).student()

Logging

import logging

# Enable SDK logging with your app's configuration
logging.basicConfig(level=logging.INFO)

# Or enable DEBUG logging for SDK only
logging.getLogger("teachworks").setLevel(logging.DEBUG)

# See the Logging Guide for advanced configuration

Development

python -m venv .venv
source .venv/bin/activate
pip install -e .

License

MIT

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

teachworks_sdk-0.2.1.tar.gz (56.4 kB view details)

Uploaded Source

Built Distribution

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

teachworks_sdk-0.2.1-py3-none-any.whl (53.7 kB view details)

Uploaded Python 3

File details

Details for the file teachworks_sdk-0.2.1.tar.gz.

File metadata

  • Download URL: teachworks_sdk-0.2.1.tar.gz
  • Upload date:
  • Size: 56.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.2

File hashes

Hashes for teachworks_sdk-0.2.1.tar.gz
Algorithm Hash digest
SHA256 4bb5c1c4f1901b783e08e451d3a345e83364f25c81c0a452bc4de87d4f114411
MD5 e8e074913e02c837ed9706a38683dc8c
BLAKE2b-256 98f1819d5672fa619f6d01cf53df2ec5d59355ee6f19b1c3cca6129e91ab53eb

See more details on using hashes here.

File details

Details for the file teachworks_sdk-0.2.1-py3-none-any.whl.

File metadata

  • Download URL: teachworks_sdk-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 53.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.2

File hashes

Hashes for teachworks_sdk-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 999c0f5a276239fb9a90e787a8377f78a5ff33db84c471605d336bede538e762
MD5 ba335aa2668e332d9e5624c00c37af49
BLAKE2b-256 e3b3d87b52af4c75605034aa98b8b785a3d2deb4da0bd6b7afa6633f80c9f25c

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