Skip to main content

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 flows
  • SessionsClient – current session, validation, listing, revocation
  • PaymentsClient – checkout sessions, wallet deposits, crypto invoices
  • UsageClient – feature usage snapshots, recording, aggregated history
  • SecureMessagesClient – encrypted message creation and retrieval
  • MetricsClient – 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

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

spaps-0.1.2.tar.gz (77.4 kB view details)

Uploaded Source

Built Distribution

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

spaps-0.1.2-py3-none-any.whl (43.4 kB view details)

Uploaded Python 3

File details

Details for the file spaps-0.1.2.tar.gz.

File metadata

  • Download URL: spaps-0.1.2.tar.gz
  • Upload date:
  • Size: 77.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.13

File hashes

Hashes for spaps-0.1.2.tar.gz
Algorithm Hash digest
SHA256 61daf78f117784f754dffbc1b2d88a863260f30d5e68de4573bddeaf933c3fe1
MD5 a60f71f94e8f0452eebdf65fcc30dbe1
BLAKE2b-256 b85ebeed912c64f0bb7db4737eeb8031d94254fdd181c2cc2867560215bb07a3

See more details on using hashes here.

File details

Details for the file spaps-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: spaps-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 43.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.13

File hashes

Hashes for spaps-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 083fdde57ac07a84c4aa8e8752238dac7a4ec675bcf5b1ed5132d097416db4b6
MD5 d775264b097c985cf7c5f48da41c97a3
BLAKE2b-256 a7f54f45751cf15269b62132701db1d833fdc277296491052311ddb558812347

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