Skip to main content

Official Python SDK for the InvoiceAI API

Project description

InvoiceAI Python SDK

Official Python SDK for the InvoiceAI API. Manage invoices, clients, products, quotes, and more.

Installation

pip install invoiceai

Quick Start

from invoiceai import InvoiceAI

# Initialize with your API key
client = InvoiceAI(api_key="your_api_key_here")

# Or with JWT token
client = InvoiceAI(access_token="your_jwt_token")

# List all invoices
invoices = client.invoices.list()
print(invoices["invoices"])

# Create a client
new_client = client.clients.create(
    name="John Doe",
    email="john@example.com",
    company="Acme Inc",
    address="123 Main St, Johannesburg"
)

Configuration

client = InvoiceAI(
    # Authentication (choose one)
    api_key="your_api_key",        # API key authentication
    access_token="jwt_token",       # JWT token authentication
    
    # Optional settings
    base_url="https://urcvstsuqtlqhjgqudtn.supabase.co/functions/v1/api",
    timeout=30,                     # Request timeout in seconds
)

API Reference

Invoices

# List all invoices
invoices = client.invoices.list(
    limit=50,       # Default: 50
    offset=0,       # For pagination
    status="paid"   # Filter by status
)

# Get single invoice
invoice = client.invoices.get("invoice-uuid")

# Create invoice
new_invoice = client.invoices.create(
    client_id="client-uuid",
    invoice_number="INV-2024-001",
    issue_date="2024-01-15",
    due_date="2024-02-15",
    subtotal_cents=100000,
    vat_cents=15000,
    total_cents=115000,
    status="draft",
    notes="Payment due within 30 days"
)

# Update invoice
updated = client.invoices.update("invoice-uuid", status="paid")

# Delete invoice
client.invoices.delete("invoice-uuid")

Clients

# List all clients
clients = client.clients.list(limit=50, offset=0)

# Get single client
client_data = client.clients.get("client-uuid")

# Create client
new_client = client.clients.create(
    name="John Doe",
    email="john@example.com",
    company="Acme Inc",
    address="123 Main St, Johannesburg",
    phone="+27 11 123 4567"
)

# Update client
updated = client.clients.update("client-uuid", phone="+27 11 987 6543")

# Delete client
client.clients.delete("client-uuid")

Products

# List all products
products = client.products.list(limit=50, offset=0)

# Get single product
product = client.products.get("product-uuid")

# Create product
new_product = client.products.create(
    name="Web Development Service",
    description="Custom website development",
    price_cents=500000,
    vat_rate=15,
    unit="hour"
)

# Update product
updated = client.products.update("product-uuid", price_cents=550000)

# Delete product
client.products.delete("product-uuid")

Quotes

# List all quotes
quotes = client.quotes.list(limit=50, offset=0, status="draft")

# Get single quote
quote = client.quotes.get("quote-uuid")

# Create quote
new_quote = client.quotes.create(
    client_id="client-uuid",
    quote_number="QT-2024-001",
    issue_date="2024-01-15",
    expiry_date="2024-02-15",
    subtotal_cents=100000,
    vat_cents=15000,
    total_cents=115000,
    status="draft",
    notes="Quote valid for 30 days"
)

# Update quote
updated = client.quotes.update("quote-uuid", status="accepted")

# Delete quote
client.quotes.delete("quote-uuid")

Profile

# Get business profile
profile = client.profile.get()

# Update profile
updated = client.profile.update(
    business_name="My Business",
    business_address="123 Main St, Johannesburg",
    business_phone="+27 11 123 4567",
    business_email="info@mybusiness.co.za",
    vat_number="4123456789",
    bank_name="FNB",
    bank_account_number="62000000000",
    bank_branch_code="250655"
)

Stats

# Get dashboard statistics
stats = client.stats.get()
# Returns: total_invoices, total_clients, total_products,
#          revenue_this_month, pending_invoices, overdue_invoices

Error Handling

from invoiceai import InvoiceAI, InvoiceAIError

try:
    invoice = client.invoices.get("invalid-uuid")
except InvoiceAIError as e:
    print(f"API Error: {e.message}")
    print(f"Status: {e.status}")
    print(f"Code: {e.code}")

Async Support

from invoiceai import AsyncInvoiceAI
import asyncio

async def main():
    client = AsyncInvoiceAI(api_key="your_api_key")
    
    # All methods support async/await
    invoices = await client.invoices.list()
    print(invoices)

asyncio.run(main())

Type Hints

The SDK includes full type hints for all methods and responses.

from invoiceai.types import Invoice, Client, Product, Quote, Profile, Stats

Requirements

  • Python 3.8+
  • requests >= 2.28.0
  • aiohttp >= 3.8.0 (for async support)

License

MIT License - see LICENSE file for details.

Support

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

invoiceai-1.0.0.tar.gz (8.1 kB view details)

Uploaded Source

Built Distribution

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

invoiceai-1.0.0-py3-none-any.whl (7.1 kB view details)

Uploaded Python 3

File details

Details for the file invoiceai-1.0.0.tar.gz.

File metadata

  • Download URL: invoiceai-1.0.0.tar.gz
  • Upload date:
  • Size: 8.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.14

File hashes

Hashes for invoiceai-1.0.0.tar.gz
Algorithm Hash digest
SHA256 114a4c82f5b2d84b6c48ef5962f18f155482a50267c6836f1cae0b2226953b44
MD5 8384a640c2528eb9c002dee6da4d859f
BLAKE2b-256 ff98a355b83b12710d15800fe55cb3d2c1a2d5c3578c881b45cc1d0a40bded94

See more details on using hashes here.

File details

Details for the file invoiceai-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: invoiceai-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 7.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.14

File hashes

Hashes for invoiceai-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 bb32f5dbce803e9ef1925cdffb310e34b706c5789f53f8d1ce0cc7694afa2882
MD5 f9e2d3d5219d67fd253f7a3d4d4b54fe
BLAKE2b-256 399ce3ff5c867a3b0a308043009a978d34f4e2d112c82569c8b0e916e53316ee

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