Skip to main content

Pythonic wrapper for the Planhat REST API

Project description

PyPlanhat SDK

Modern async-first Python SDK for the Planhat API.

Features

  • 🚀 Async-first architecture with auto-generated sync support
  • 📦 Built with modern Python tooling (httpx, pydantic, uv)
  • 🔒 Type-safe with full mypy support
  • Comprehensive error handling with custom exception hierarchy
  • 🧪 Extensively tested with 90%+ coverage

Installation

pip install pyplanhat

Quick Start

Async Usage

import asyncio
from pyplanhat import AsyncPyPlanhat

async def main():
    async with AsyncPyPlanhat(api_key="your-api-key") as client:
        # API calls here (Phase 1+)
        pass

asyncio.run(main())

Sync Usage

from pyplanhat import PyPlanhat

with PyPlanhat(api_key="your-api-key") as client:
    # API calls here (Phase 1+)
    pass

Configuration

Set environment variables for convenient testing:

export PLANHAT_API_KEY="your-api-key"
export PLANHAT_API_BASE_URL="https://api.planhat.com"  # optional

Or pass directly to the client:

client = AsyncPyPlanhat(
    api_key="your-api-key",
    base_url="https://api.planhat.com"
)

Development

This project is currently in Phase 0 development. The foundation is being built using a phased approach with OpenCode agents.

Setup

# Clone repository
git clone https://github.com/ddlaws0n/pyplanhat.git
cd pyplanhat

# Install dependencies
uv sync --all-groups

# Run tests
uv run pytest -v

# Format code
uv run ruff format .

# Lint code
uv run ruff check .

# Type check
uv run mypy src/

Architecture

PyPlanhat uses an async-first DRY architecture:

  1. ✏️ Write async code in src/pyplanhat/_async/
  2. 🔄 Generate sync code: python scripts/generate_sync.py
  3. ✅ Both versions tested identically
  4. 📦 Zero duplication of business logic

The synchronous version is automatically generated from the async source using unasync, ensuring perfect parity between both APIs.

Development Guidelines

See CLAUDE.md for detailed development guidelines and workflow.

Key principles:

  • Never edit files in _sync/ directories (they're auto-generated)
  • Always run python scripts/generate_sync.py after modifying async code
  • Maintain test parity between async and sync test suites
  • Follow the phased plan in docs/pyplanhat/PLAN.md

Project Structure

src/pyplanhat/
├── _async/              # Async source code (write here)
│   ├── client.py        # Main async client
│   └── resources/       # Async resource implementations
├── _sync/               # Generated sync code (never edit)
│   ├── client.py        # Generated sync client
│   └── resources/       # Generated sync resources
├── _exceptions.py       # Custom exception hierarchy
└── __init__.py         # Public API exports

tests/
├── _async/             # Async tests (write here)
└── _sync/              # Generated sync tests (never edit)

Roadmap

  • Phase 0: Foundation (exception hierarchy, client shell, code generation) ✅ In Progress
  • Phase 1: Companies resource implementation
  • Phase 2: EndUsers and Conversations resources
  • Phase 3: Documentation (mkdocs, API reference)
  • Phase 4: Release to PyPI

Contributing

This project follows strict architectural patterns and phased development. Please review:

  1. CLAUDE.md - Development workflow and commands
  2. docs/pyplanhat/PLAN.md - Phased development plan
  3. docs/pyplanhat/ARCHITECTURE.md - Architecture details

License

MIT License - see LICENSE for details.

Support

For issues, questions, or contributions, please open an issue on GitHub.

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

pyplanhat-0.1.0.tar.gz (139.8 kB view details)

Uploaded Source

Built Distribution

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

pyplanhat-0.1.0-py3-none-any.whl (13.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pyplanhat-0.1.0.tar.gz
  • Upload date:
  • Size: 139.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for pyplanhat-0.1.0.tar.gz
Algorithm Hash digest
SHA256 7c97e40e7a46c10870e4fc0992bc170b13e24a3313d3ad37ec8addfd372ad69d
MD5 2b009b9cd6c4b819786b529f183cc45f
BLAKE2b-256 7c2f345cec619d0eb96a1203d4df222ccaed16f5297174f64ba48db01069dcb8

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyplanhat-0.1.0.tar.gz:

Publisher: release.yml on ddlaws0n/pyplanhat

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

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

File metadata

  • Download URL: pyplanhat-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 13.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for pyplanhat-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 37ec3b01c21f2ce3fa4abda0c0096824992d6514ffb44d3a0fd11ef1c9fd9b1d
MD5 f6eec89a7d01374daa04955411d989ac
BLAKE2b-256 6980830898e86808459d2104c0571ea13789792696c46c8e9cbef581435c21a5

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyplanhat-0.1.0-py3-none-any.whl:

Publisher: release.yml on ddlaws0n/pyplanhat

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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