title: Python SDK
description: Install and use the official Wontopos Python SDK.
Python SDK
The official Python SDK supports both synchronous and asynchronous usage. Requires Python 3.9+.
Installation
pip install wontopos Initialize the client
import os
import wontopos
client = wontopos.Client(
api_key=os.environ["WONTOPOS_API_KEY"],
) Configuration options
client = wontopos.Client(
api_key="wont_...",
base_url="https://api.wontopos.com",
timeout=30.0,
max_retries=3,
) Basic usage
List marketplace APIs
apis = client.marketplace.list(category="payments", limit=20)
for api in apis.data:
print(api.name) Create a subscription
subscription = client.subscriptions.create(
api_id="api_abc123",
plan="pro",
) Async support
An async client is available for use with asyncio:
import asyncio
import wontopos
async def main():
async with wontopos.AsyncClient(
api_key=os.environ["WONTOPOS_API_KEY"],
) as client:
apis = await client.marketplace.list(limit=10)
for api in apis.data:
print(api.name)
asyncio.run(main()) Context manager
Use the async client as a context manager to ensure connections are properly closed.
Error handling
from wontopos import WontoposError, AuthenticationError, RateLimitError
try:
apis = client.marketplace.list()
except AuthenticationError:
print("Invalid API key")
except RateLimitError as e:
print(f"Retry after: {e.retry_after}")
except WontoposError as e:
print(f"{e.status_code}: {e.message}") Auto-pagination
for api in client.marketplace.list_auto_paging(category="payments"):
print(api.name)