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-1.0.0.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-1.0.0-py3-none-any.whl (53.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: teachworks_sdk-1.0.0.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-1.0.0.tar.gz
Algorithm Hash digest
SHA256 9246ead59dbdcaf975ebf448854f763cb627656b159db30e5becb30af8d51aa4
MD5 25441023255acc092062b3d49ff78cf0
BLAKE2b-256 e2e05bc84ffccf614f6534aebab98a214f89f86396d661c8d0d537e05c05420a

See more details on using hashes here.

File details

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

File metadata

  • Download URL: teachworks_sdk-1.0.0-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-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b40fc2c44d8f6ad24977705d85122cf900cc2df079fa098d8cca1a07113a9b32
MD5 79f6cc482093c29e53e966ea1319ea62
BLAKE2b-256 becabe93442a401712ec61cf65483a262923721156812890056b24a47811180f

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