Python SDK Getting Started
Ce contenu n’est pas encore disponible dans votre langue.
The Acme Python SDK provides a convenient way to interact with the API from Python applications.
Installation
Section titled “Installation”pip install acme-sdkQuick Start
Section titled “Quick Start”from acme import AcmeClient
# Initialize the clientclient = AcmeClient(api_key="sk_live_abc123...")
# List usersusers = client.users.list(limit=10)for user in users: print(f"{user.name}: {user.email}")
# Get a specific useruser = client.users.get("usr_abc123")print(user.name)
# Create a new usernew_user = client.users.create( email="alice@example.com", name="Alice Smith")print(f"Created user: {new_user.id}")Configuration
Section titled “Configuration”from acme import AcmeClient
client = AcmeClient( api_key="sk_live_abc123...", timeout=30, # Request timeout in seconds max_retries=3 # Number of retry attempts)Error Handling
Section titled “Error Handling”from acme import AcmeClientfrom acme.exceptions import AcmeError, NotFoundError, RateLimitError
client = AcmeClient(api_key="sk_live_abc123...")
try: user = client.users.get("usr_invalid")except NotFoundError: print("User not found")except RateLimitError as e: print(f"Rate limited. Retry after {e.retry_after} seconds")except AcmeError as e: print(f"API error: {e.message}")Async Support
Section titled “Async Support”import asynciofrom acme import AsyncAcmeClient
async def main(): client = AsyncAcmeClient(api_key="sk_live_abc123...") users = await client.users.list() print(users)
asyncio.run(main())