Skip to main content

Python Client SDK Generated by Speakeasy.

Project description

FlexPrice Python SDK

Type-safe Python client for the FlexPrice API: billing, metering, and subscription management for SaaS and usage-based products.

Requirements

  • Python 3.10+

Installation

pip install flexprice-py

With uv or poetry:

uv add flexprice-py
# or
poetry add flexprice-py

Quick start

Initialize the client with your server URL and API key, then ingest an event:

from flexprice_py import Flexprice

with Flexprice(
    server_url="https://api.cloud.flexprice.io",
    api_key_auth="YOUR_API_KEY",
) as flexprice:
    # Ingest an event
    result = flexprice.events.ingest_event(
        request={
            "event_name": "Sample Event",
            "external_customer_id": "customer-123",
            "properties": {"source": "python_app", "environment": "test"},
            "source": "python_app",
        }
    )
    print(result)

Async usage

The same client supports async when used as an async context manager:

import asyncio
from flexprice_py import Flexprice

async def main():
    async with Flexprice(
        server_url="https://api.cloud.flexprice.io",
        api_key_auth="YOUR_API_KEY",
    ) as flexprice:
        result = await flexprice.events.ingest_event_async(
            request={
                "event_name": "Sample Event",
                "external_customer_id": "customer-123",
                "properties": {"source": "python_async", "environment": "test"},
                "source": "python_async",
            }
        )
        print(result)

asyncio.run(main())

Authentication

  • Pass your API key as api_key_auth when creating the client. The SDK sends it in the x-api-key header.
  • Prefer environment variables (e.g. FLEXPRICE_API_KEY) and load them in code; get keys from your FlexPrice dashboard or docs.

Features

  • Full API coverage (customers, plans, events, invoices, payments, entitlements, etc.)
  • Sync and async support
  • Type-safe request/response models (Pydantic)
  • Built-in retries and error handling

For a full list of operations, see the API reference or the generated docs/sdks/ in this repo.

Troubleshooting

  • Missing or invalid API key: Ensure api_key_auth is set (or set FLEXPRICE_API_KEY and pass it in). Keys are for server-side use only.
  • Wrong server URL: Use https://api.cloud.flexprice.io (no trailing slash). The SDK appends paths as needed.
  • 4xx/5xx on ingest: Event ingest returns 202 Accepted; for errors, check request fields (event_name, external_customer_id, properties, source) against the API docs.

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

flexprice_py-0.0.45.tar.gz (222.0 kB view details)

Uploaded Source

Built Distribution

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

flexprice_py-0.0.45-py3-none-any.whl (527.8 kB view details)

Uploaded Python 3

File details

Details for the file flexprice_py-0.0.45.tar.gz.

File metadata

  • Download URL: flexprice_py-0.0.45.tar.gz
  • Upload date:
  • Size: 222.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.12

File hashes

Hashes for flexprice_py-0.0.45.tar.gz
Algorithm Hash digest
SHA256 530432688e888eeaee06b1a9229d8e61affa0b92e1590b7f598149b8f43cc5aa
MD5 9e00a1740f95ba18ce2791ebb85385ad
BLAKE2b-256 a46dbcea3549e258fd790586f9aed53ecd9ce601591c4e4211aa3e5cba8800d8

See more details on using hashes here.

File details

Details for the file flexprice_py-0.0.45-py3-none-any.whl.

File metadata

  • Download URL: flexprice_py-0.0.45-py3-none-any.whl
  • Upload date:
  • Size: 527.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.12

File hashes

Hashes for flexprice_py-0.0.45-py3-none-any.whl
Algorithm Hash digest
SHA256 5f0ccbfc428ab2fdaae0abf5e888269cd00c9c4ad157661431d7959746383ae0
MD5 021b7e2924f8e7c671bb80a416a9336b
BLAKE2b-256 141dd5ac5ae50d69a7fb828975f211880b4bcc0db3c8659b6fcf27e91e773b5f

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