Skip to main content

Official Python SDK for Billingrails API

Project description

Billingrails Python SDK

Official Python SDK for Billingrails - Flexible, composable, and intuitive API-first commerce platform.

PyPI Version License

Installation

pip install billingrails

Quick Start

from billingrails import Billingrails

# Initialize the client
client = Billingrails(
    api_key="your-api-key",
    base_url="https://api.billingrails.com"
)

# List accounts
list_response = client.accounts.list()
print(list_response["accounts"])

# Create an account
create_response = client.accounts.create({
    "name": "John Doe",
    "email": "john@example.com",
    "country": "US",
    "default_currency": "USD"
})
print(create_response["account"])

# Retrieve an account
retrieve_response = client.accounts.retrieve("acc_123")
print(retrieve_response["account"])

# Update an account
update_response = client.accounts.update("acc_123", {
    "name": "Jane Doe"
})
print(update_response["account"])

# Get account balances
balances_response = client.accounts.get_balances("acc_123")
print(balances_response["balances"])

# Debit an account
debit_response = client.accounts.debit("acc_123", {
    "amount": 1000,  # Amount in cents
    "currency": "USD"
})
print(debit_response["balances"])

Configuration

Basic Configuration

client = Billingrails(api_key="your-api-key")

Advanced Configuration

client = Billingrails(
    api_key="your-api-key",
    base_url="https://api.billingrails.com",
    timeout=30,  # Request timeout in seconds
    max_retries=3  # Maximum number of retries for failed requests
)

Error Handling

from billingrails import Billingrails
import requests

client = Billingrails(api_key="your-api-key")

try:
    retrieve_response = client.accounts.retrieve("acc_123")
except requests.exceptions.HTTPError as e:
    print(f"HTTP error occurred: {e}")
except requests.exceptions.RequestException as e:
    print(f"Error occurred: {e}")

Development

# Install in development mode
pip install -e .

# Install development dependencies
pip install -r requirements-dev.txt

# Run tests
pytest

# Format code
black billingrails/
isort billingrails/

# Type checking
mypy billingrails/

License

MIT - See LICENSE file for details

Support

For support, please contact ugo@billingrails.com or visit our documentation.

Todo

  • Improve error handling

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

billingrails-0.1.3.tar.gz (20.8 kB view details)

Uploaded Source

Built Distribution

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

billingrails-0.1.3-py3-none-any.whl (60.4 kB view details)

Uploaded Python 3

File details

Details for the file billingrails-0.1.3.tar.gz.

File metadata

  • Download URL: billingrails-0.1.3.tar.gz
  • Upload date:
  • Size: 20.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for billingrails-0.1.3.tar.gz
Algorithm Hash digest
SHA256 ad3b8347d61f694b3ec42236ef6f6044f19970dc77ff65fd1be6a1520cb422fe
MD5 8f60e49c4302af4237aad1ab242ed953
BLAKE2b-256 45d8228ff0d8561886d4d74f404df7c1b8739186aa42be41ca20889d105590f2

See more details on using hashes here.

File details

Details for the file billingrails-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: billingrails-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 60.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for billingrails-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 77c9f3e3016a4b72de3fa9b3069e8ff4a72a54367e3899fa58a4f539ea33fe51
MD5 77f7647d9e34be2b88997a33b89724bd
BLAKE2b-256 cd8c3b0a363ef87cc22c96bc077861b5b47947c2b27fc63e6c09c5a2e839616e

See more details on using hashes here.

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