Python client library for the Cohost External API
Project description
cohost-client
Python client library for the Cohost External API.
Installation
pip install cohost-client
Quick Start
from cohost_client import configure_client
from cohost_client.generated.api import customers, listings, bookings
# Configure once at startup
configure_client(api_key="your-api-key")
# List customers
result = customers.list_customers(page=1, page_size=20)
for customer in result.items:
print(customer.email)
# Log in a customer and use their token
login_result = customers.customer_login(email="user@example.com", password="secret")
configure_client(bearer_token=login_result.access_token)
# Get listings
listing = listings.get_listing_detail(listing_id=123)
print(listing.name)
Authentication
Two auth schemes are supported:
- API Key (
X-API-Key): for all/api/v1/external/*endpoints — set viaconfigure_client(api_key=...)orset_api_key(...). - JWT Bearer: for customer-facing endpoints — set via
configure_client(bearer_token=...)orset_bearer_token(...).
Self-Update
The generated API code is built from the live OpenAPI spec. To regenerate when the backend changes:
# Check if the spec has changed (exits 1 if outdated)
cohost-update --check
# Fetch latest spec and regenerate all code
cohost-update
Or using Make:
make generate
Development
Prerequisites
- Python 3.10+ (use pyenv to manage versions)
make
First-time setup
# Create and activate a virtual environment
python -m venv .venv
source .venv/bin/activate # Windows: .venv\Scripts\activate
# Install the package and all dev dependencies
make install
Do not use
pip install --target ./vendor. The project uses a standard virtual environment — thevendor/directory is ignored by git.
Common tasks
# Run the full code generation pipeline (fetch spec → clean → models → api)
make generate
# Run tests against your checkout (after `make install` — uses local `cohost_client/`)
make test
# Run tests against a built wheel only (no local package on PYTHONPATH)
make test-installed
# Optional: live tests against staging — put secrets in `.env` (gitignored)
cp .env.example .env
# Edit `.env` and set COHOST_API_KEY (and optionally COHOST_TEST_* for login)
pytest -m live
# Or export in the shell instead of `.env`
# export COHOST_API_KEY="your-staging-api-key"
# export COHOST_TEST_EMAIL="user@example.com"
# export COHOST_TEST_PASSWORD="your-password"
# Check if the remote spec has changed without regenerating (exits 1 if outdated)
make update-check
# Build the distribution packages (sdist + wheel)
make build
How It Works
See docs/plan.md for full architecture details.
The library is structured as:
cohost_client/client.py— HTTP layer (auth, error handling)cohost_client/generated/models/— Pydantic v2 models (auto-generated)cohost_client/generated/api/— Typed API functions grouped by tag (auto-generated)cohost_client/cli.py—cohost-updateCLI for self-update
Project details
Release history Release notifications | RSS feed
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 cohost_client-0.1.0.tar.gz.
File metadata
- Download URL: cohost_client-0.1.0.tar.gz
- Upload date:
- Size: 13.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: Hatch/1.16.5 cpython/3.10.19 HTTPX/0.28.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2af4e4b40a6247a97b3b6e2a38f64bb9fcc888349b9543d9ec9b98a0b0d2d053
|
|
| MD5 |
78f29fe6e2a970083db785b0a45e35d1
|
|
| BLAKE2b-256 |
d333c3d9c13bc29e939af6979ad2089a0535cfbe71f1b0fef5c99abfa2087090
|
File details
Details for the file cohost_client-0.1.0-py3-none-any.whl.
File metadata
- Download URL: cohost_client-0.1.0-py3-none-any.whl
- Upload date:
- Size: 32.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: Hatch/1.16.5 cpython/3.10.19 HTTPX/0.28.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c75ad6da144fddb41281acbbb1d547461cc2453fe785469aaa93ffda0d209b3b
|
|
| MD5 |
f38b1a3138a4db5452196817bf921566
|
|
| BLAKE2b-256 |
0b70978ca8fbc60ec60d7cc570840ff3f6aa73e9035ad8042fcc53cbc49505e0
|