SpareSpare Docs
GuidesAPI Reference

Python SDK

Install, configure, and use the spare-api Python package.

The Python SDK mirrors the TypeScript client surface for server-side integrations.

Coming soon, under review

This SDK is under review and not yet published, so the package is not installable yet. The steps below show the intended usage. Until release, integrate over the REST API.

Installation

Install

pip install spare-api

Configuration

import os
from spare_api import Configuration, SpareApiClient

config = Configuration(
    app_id=os.environ["SPARE_APP_ID"],
    api_key=os.environ["SPARE_API_KEY"],
    tenant="UAE",
    environment="sandbox",
)

client = SpareApiClient(auth_provider=config)

Common operations

# List providers
providers = client.providers.list()

# Create payment request
payment_request = client.payment_requests.create(
    amount=100_00,
    currency="AED",
    description="Invoice #1",
    redirect_url="https://yourapp.com/callback",
)

# Create consent
consent = client.payment_consents.create_from_payment_request(
    payment_request_id=payment_request.data.id,
)

Error handling

from spare_api import SpareApiError

try:
    client.payment_requests.get(payment_request_id="invalid")
except SpareApiError as exc:
    print(exc.status, exc.message)

Resources

On this page