Skip to main content

suqo-python

PyPI License

Python SDK for the Suqo API.

pip install suqo

Python 3.9+. Only dependency is requests.

Quick start

from suqo import SuqoClient

client = SuqoClient(
    api_key="su_key_...",       # or set SUQO_API_KEY
    base_url="https://...",     # or set SUQO_BASE_URL
)

for subscription in client.subscriptions.iter():
    print(subscription["subscription_id"], subscription["status"])

Responses are plain dicts matching the API payloads.

Methods

Call Does
products.list() / .iter() Your catalogue, with plans and billing periods nested
subscriptions.list() / .iter() All subscriptions; list() also returns status totals
subscriptions.get(id) One subscription
subscriptions.create(...) New subscription, returns a checkout_url
subscriptions.cancel(id) Cancel at end of the current period
subscriptions.resume(id) Undo a pending cancellation
subscriptions.update_billing_cycle(id, date) Move the next billing date
customers.list() / .iter() / .get(id) Your buyers

Creating a subscription

pbp_id identifies a billing period — find one under product["plan"][n]["billing_periods"].

created = client.subscriptions.create(
    pbp_id="pbp_3n9k2x",
    return_url="https://yourapp.com/thanks",
    client={
        "phone": "9841000100",
        "full_name": "Ram Shrestha",
        "email": "ram@client.com",
    },
)

created["checkout_url"]   # send the buyer here to pay

client also takes an optional address, plus optional billing and shipping blocks:

"billing": {
    "billing_business_name": "ABC Pvt Ltd.",
    "billing_email": "ram@client.com",
    "billing_address": "Kathmandu, Nepal",
    "billing_pan_vat": "301234567",     # optional
},
"shipping": {
    "phone": "9841000100",
    "full_name": "Ram Shrestha",
    "email": "ram@client.com",
    "address": "Kathmandu, Nepal",      # optional
},

Pagination

.iter() walks every page for you, fetching lazily:

for customer in client.customers.iter():
    ...

.list() returns one page with the raw envelope (count, next, previous, results). Both accept page and page_size (max 100). There are no server-side filters — filter in Python.

Errors

from suqo import ValidationError

try:
    client.subscriptions.create(pbp_id="bad", return_url="...", client={...})
except ValidationError as exc:
    exc.errors        # {"pbp_id": ["does not exist or is not visible."]}
    exc.status_code   # 400

ValidationError (400), AuthenticationError (401), PermissionDeniedError (403), NotFoundError (404), RateLimitError (429) and ServerError (5xx) all subclass SuqoAPIError, which carries status_code, payload and response.

GETs retry 429s and 5xxs three times with backoff. POSTs never retry — a replayed create would make a second subscription.

Configuration

SuqoClient(
    api_key=None,     # required; falls back to SUQO_API_KEY
    base_url=None,    # required; falls back to SUQO_BASE_URL
    timeout=30,
    max_retries=3,    # GET only; 0 disables
    session=None,     # inject your own requests.Session
)

api_key and base_url are both required — there is no default host, so which environment you talk to is always an explicit choice. Missing either raises ValueError at construction.

Also works as a context manager, closing the session on exit.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

suqo-0.2.0.tar.gz (8.0 kB view details)

Uploaded Source

Built Distribution

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

suqo-0.2.0-py3-none-any.whl (7.6 kB view details)

Uploaded Python 3

File details

Details for the file suqo-0.2.0.tar.gz.

File metadata

  • Download URL: suqo-0.2.0.tar.gz
  • Upload date:
  • Size: 8.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for suqo-0.2.0.tar.gz
Algorithm Hash digest
SHA256 f6e1edf39cfecc9a2ef9d47b23a78e7f0bea05b81c712f6639b7d29f1c12052d
MD5 658c0d05107ae46deeab7a7b2f938a19
BLAKE2b-256 149aa36dfe52e1ffa77cb31af356623e2ee365a1420d591fa1922b0f129ba627

See more details on using hashes here.

Provenance

The following attestation bundles were made for suqo-0.2.0.tar.gz:

Publisher: publish.yml on Code-Pros-AI/suqo-sdk-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 suqo-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: suqo-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 7.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for suqo-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 eb0afd1e50dc1c7fb74af0ad29526d233c20373434645edf2624cde886c47ff1
MD5 b328199bed4a7caff756c4b91d2da0f0
BLAKE2b-256 442c8e96a8be8da28dfd14f33b009705bcc59f7f8881ccc00038ab05c7e368f9

See more details on using hashes here.

Provenance

The following attestation bundles were made for suqo-0.2.0-py3-none-any.whl:

Publisher: publish.yml on Code-Pros-AI/suqo-sdk-python

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

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 files

0.1.0

2 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page