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.7.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.7-py3-none-any.whl (9.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: paylio-0.1.7.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.7.tar.gz
Algorithm Hash digest
SHA256 9940317164e068a2224b7c564203dc8e20987617d60959840dcd76984ca20240
MD5 d95fa7054a17335d6f08fa121f1d46e9
BLAKE2b-256 12805d4e900380fb0044d94226c8668c86a4dad61ce7aae2535a2becd1b62af5

See more details on using hashes here.

Provenance

The following attestation bundles were made for paylio-0.1.7.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.7-py3-none-any.whl.

File metadata

  • Download URL: paylio-0.1.7-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.7-py3-none-any.whl
Algorithm Hash digest
SHA256 ba21e8e8ccfb23cd57e11dba6bce6015bd44e97a26f4036e6ea6a58df7f6398f
MD5 c3ee82e26fbf078318496b08238f2212
BLAKE2b-256 f6fd311217bb09b25432e148ce9620c0f29480dbdee2c9620a78c16d6d928b7f

See more details on using hashes here.

Provenance

The following attestation bundles were made for paylio-0.1.7-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