Skip to main content

Python client library for the Paylio API

Project description

Paylio Python SDK

PyPI version CI

The Paylio Python SDK provides convenient access to the Paylio API from applications written in Python.

Documentation

See the Paylio API docs.

Requirements

  • Python 3.9+

Installation

pip install paylio

Usage

import paylio

client = paylio.PaylioClient("sk_live_xxx")

# Retrieve current subscription
sub = client.subscription.retrieve("user_123")
print(sub.status)       # "active"
print(sub.plan.name)    # "Pro Plan"
print(sub.plan.amount)  # 999

List subscription history

history = client.subscription.list("user_123", page=1, page_size=10)
for item in history.items:
    print(item.plan_name, item.status)

if history.has_more:
    next_page = client.subscription.list("user_123", page=2)

Cancel a subscription

# Cancel at end of billing period (safe default)
result = client.subscription.cancel("subscription_uuid")
print(result.success)  # True

# Cancel immediately
result = client.subscription.cancel("subscription_uuid", cancel_now=True)

Context manager

with paylio.PaylioClient("sk_live_xxx") as client:
    sub = client.subscription.retrieve("user_123")

Configuration

client = paylio.PaylioClient(
    "sk_live_xxx",
    base_url="https://api.paylio.pro/flying/v1",
)

Error handling

import paylio

client = paylio.PaylioClient("sk_live_xxx")

try:
    sub = client.subscription.retrieve("user_123")
except paylio.AuthenticationError:
    print("Invalid API key")
except paylio.NotFoundError:
    print("Subscription not found")
except paylio.RateLimitError:
    print("Rate limited, try again later")
except paylio.InvalidRequestError as e:
    print(f"Bad request: {e.message}")
except paylio.APIError as e:
    print(f"API error: {e.message} (status {e.http_status})")
except paylio.APIConnectionError:
    print("Network error")

Error types

Error HTTP Status Description
AuthenticationError 401 Invalid or missing API key
InvalidRequestError 400 Bad request parameters
NotFoundError 404 Resource not found
RateLimitError 429 Rate limit exceeded
APIError 5xx Server error
APIConnectionError Network or connection failure

All errors inherit from PaylioError.

Development

pip install -e ".[dev]"
pytest
ruff check .
mypy .

License

MIT

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

paylio-0.1.6.tar.gz (13.7 kB view details)

Uploaded Source

Built Distribution

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

paylio-0.1.6-py3-none-any.whl (9.3 kB view details)

Uploaded Python 3

File details

Details for the file paylio-0.1.6.tar.gz.

File metadata

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

File hashes

Hashes for paylio-0.1.6.tar.gz
Algorithm Hash digest
SHA256 0eaf7a56966990921be907ab049faffc09989b05c937c1feb6aa0021af0af1ab
MD5 1f1dc6af1f6f5d33f162eb6099bf197e
BLAKE2b-256 872d9f21848670b608416e33c16e2a1c968938caa834ec7e2912222dbe34e291

See more details on using hashes here.

Provenance

The following attestation bundles were made for paylio-0.1.6.tar.gz:

Publisher: publish.yml on paylio-org/paylio-python

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

File details

Details for the file paylio-0.1.6-py3-none-any.whl.

File metadata

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

File hashes

Hashes for paylio-0.1.6-py3-none-any.whl
Algorithm Hash digest
SHA256 6846689dcf1f2ad4e98518ee8e8d4a28b318113ff0a583799be6032e0b1fdddd
MD5 6981d857035991ad121ac7c02ca07368
BLAKE2b-256 833767de353d8017374d37f0a2da501e758662e0c17580117db14deec35aa08c

See more details on using hashes here.

Provenance

The following attestation bundles were made for paylio-0.1.6-py3-none-any.whl:

Publisher: publish.yml on paylio-org/paylio-python

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