Python SDK

The official Taxu Python library provides convenient access to the Taxu API with full async/await support, type hints, and comprehensive documentation.

What is the Taxu Python SDK?

The Taxu Python SDK is a modern Python library that brings enterprise-grade tax and compliance capabilities to your Python applications. With native async/await support and full type hints, it integrates seamlessly into FastAPI, Django, Flask, and other Python frameworks.

Perfect for data science teams, fintech startups, and enterprise applications, the Python SDK handles tax calculations, form generation, e-filing, and compliance monitoring with a clean, Pythonic API that feels natural to Python developers.

Ideal For:

  • • FastAPI and Django applications
  • • Data science and ML platforms
  • • Financial automation tools
  • • High-concurrency web services

Developer Benefits:

  • • Full async/await support for performance
  • • Type hints for IDE autocomplete
  • • mypy compatible for type safety
  • • Works with popular Python frameworks

Installation

Install the package using pip:

pip
pip install taxu

Requirements: Python 3.7 or higher

Authentication

Initialize the client with your API key from your Taxu dashboard:

python
import taxu

client = taxu.Client(api_key='your_api_key_here')

Security: Use environment variables for API keys in production.

Basic Usage

File a Form 1099-NEC with the Python SDK:

python
filing = client.tax.file_1099_nec(
    tax_year=2024,
    payer={
        'name': 'Acme Corp',
        'ein': '12-3456789',
        'address': '123 Business St'
    },
    recipient={
        'name': 'John Contractor',
        'ssn': '123-45-6789',
        'address': '456 Worker Ave'
    },
    non_employee_compensation=15000
)

print(filing.id)  # fil_1234567890

Async Support

The Python SDK supports async/await for non-blocking operations:

python
async def main():
    client = taxu.AsyncClient(api_key='your_api_key')
    
    calculation = await client.tax.calculate(
        income=75000,
        filing_status='single'
    )
    
    print(f"Tax owed: ${calculation.total_tax}")

asyncio.run(main())

Non-Blocking I/O

Perfect for high-concurrency applications and web servers

Type Safety

Full type hints support with mypy and modern IDEs

More Examples

Calculate Federal Tax

result = taxu.Client(api_key='your_api_key').tax.calculate(
    income=85000,
    deductions=12000,
    filing_status='single',
    state='CA'
)

print(f"Federal tax: ${result.federal_tax}")
print(f"State tax: ${result.state_tax}")
print(f"Effective rate: {result.effective_rate}%")

Upload Tax Document

with open('w2.pdf', 'rb') as file:
    document = taxu.Client(api_key='your_api_key').documents.upload(
        file=file,
        type='w2',
        tax_year=2024
    )

print(f"Document ID: {document.id}")
print(f"Status: {document.status}")

Error Handling

Handle API errors gracefully with Python exceptions:

from taxu.exceptions import (
    TaxuError,
    AuthenticationError,
    ValidationError,
    RateLimitError
)

try:
    filing = taxu.Client(api_key='your_api_key').tax.file_1099_nec(...)
except AuthenticationError:
    print("Invalid API key")
except ValidationError as e:
    print(f"Validation error: {e.message}")
except RateLimitError:
    print("Rate limit exceeded")
except TaxuError as e:
    print(f"API error: {e}")

Next Steps

New Section

This is a new section added to the documentation:

# New code snippet here
print("This is a new section")