Sweet Potato Authentication & Payment Service Python client
Project description
id: spaps-python-sdk title: Sweet Potato Python Client category: sdk tags:
- sdk
- python
- client ai_summary: | Explains installation, configuration, and usage patterns for the spaps Python SDK, including environment setup, async support, and integration guidance for backend services. last_updated: 2025-02-14
Sweet Potato Python Client
Python SDK for the Sweet Potato Authentication & Payment Service (SPAPS).
This package is under active development. Follow the TDD plan in TDD_PLAN.md
to track progress and upcoming milestones.
Installation
Install from PyPI:
pip install spaps
For local development inside this repository:
pip install -e .[dev]
Development
pytest
Available clients
AuthClient– wallet, email/password, and magic link flowsSessionsClient– current session, validation, listing, revocationPaymentsClient– checkout sessions, wallet deposits, crypto invoicesUsageClient– feature usage snapshots, recording, aggregated historySecureMessagesClient– encrypted message creation and retrievalMetricsClient– health and metrics convenience helpers
Quickstart
from spaps_client import SpapsClient
spaps = SpapsClient(base_url="http://localhost:3300", api_key="test_key_local_dev_only")
# Authenticate (tokens are persisted automatically)
spaps.auth.sign_in_with_password(email="user@example.com", password="Secret123!")
# Call downstream services using the stored access token
current = spaps.sessions.get_current_session()
print(current.session_id)
checkout = spaps.payments.create_checkout_session(
price_id="price_123",
mode="subscription",
success_url="https://example.com/success",
cancel_url="https://example.com/cancel",
)
print(checkout.checkout_url)
spaps.close()
Configure retry/backoff and structured logging when constructing the client:
from spaps_client import SpapsClient, RetryConfig, default_logging_hooks
spaps = SpapsClient(
base_url="http://localhost:3300",
api_key="test_key_local_dev_only",
retry_config=RetryConfig(max_attempts=4, backoff_factor=0.2),
logging_hooks=default_logging_hooks(),
)
Async Quickstart
import asyncio
from spaps_client import AsyncSpapsClient
async def main():
client = AsyncSpapsClient(base_url="http://localhost:3300", api_key="test_key_local_dev_only")
try:
await client.auth.sign_in_with_password(email="user@example.com", password="Secret123!")
current = await client.sessions.list_sessions()
print(len(current.sessions))
finally:
await client.aclose()
asyncio.run(main())
Useful Scripts
npm run test:python-client # run pytest from repo root
npm run lint:python-client # ruff linting
npm run typecheck:python-client # mypy type checking
npm run build:python-client # build wheel/sdist and run twine check
npm run publish:python-client # build and upload via twine (requires PYPI_TOKEN)
Refer to docs/RELEASE_CHECKLIST.md for the full release process.
Refer to the repository root documentation for integration details.
Documentation
- Quickstart (Python section)
- Python Backend Integration Guide
- API references under
docs/api/include Python usage snippets for sessions, payments, usage, whitelist, and secure messages.
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 spaps-0.1.0.tar.gz.
File metadata
- Download URL: spaps-0.1.0.tar.gz
- Upload date:
- Size: 40.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c3f9b6e022250cff6b0dbca2a908d30ee24a80c877f521eba34444a0c39b0c0b
|
|
| MD5 |
e6da2db7473dcd9d3cb915e552f370b8
|
|
| BLAKE2b-256 |
5c6a024f2ceafff80edc68d01e613a6b488e47f781d6995716d22ed6ee20c9af
|
File details
Details for the file spaps-0.1.0-py3-none-any.whl.
File metadata
- Download URL: spaps-0.1.0-py3-none-any.whl
- Upload date:
- Size: 43.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7110f42589a4c7e86c8076f203b9667d9d90a1123c1a1e14bab2d4849adbb62d
|
|
| MD5 |
b68ae668d9beb1221663f78d8c83c7fd
|
|
| BLAKE2b-256 |
31a5e3a08ae458921daedbf8e6dda896786a2bc07079d6abf225349afbcd6609
|