A modern, pythonic Katana Manufacturing ERP API client with automatic retries, rate limiting, and smart pagination
Project description
Katana Manufacturing ERP - Python API Client
A modern, pythonic Python client for the Katana Manufacturing ERP API. Built from a comprehensive OpenAPI 3.1.0 specification with 100% endpoint coverage and automatic resilience.
โจ Features
- ๐ฏ Production Ready: Automatic retries, rate limiting, and error handling
- ๐ Zero Configuration: Works out of the box with environment variables
- ๐ฆ Complete API Coverage: All 76+ Katana API endpoints with full type hints
- ๐ Smart Pagination: Automatic pagination with built-in safety limits
- ๐ก๏ธ Transport-Layer Resilience: httpx-native approach, no decorators needed
- โก Async/Sync Support: Use with asyncio or traditional synchronous code
- ๐ Rich Observability: Built-in logging and metrics
๐ Quick Start
Installation
# Clone the repository
git clone https://github.com/dougborg/katana-openapi-client.git
cd katana-openapi-client
# Install with Poetry (recommended)
poetry install
# Or with pip
pip install -e .
๐ Configuration
Create a .env file with your Katana API credentials:
KATANA_API_KEY=your-api-key-here
# Optional: defaults to https://api.katanamrp.com/v1
KATANA_BASE_URL=https://api.katanamrp.com/v1
Basic Usage
KatanaClient (Recommended)
The modern, pythonic client with automatic resilience:
import asyncio
from katana_public_api_client import KatanaClient
from katana_public_api_client.generated.api.product import get_all_products
from katana_public_api_client.generated.api.sales_order import get_all_sales_orders
async def main():
# Automatic configuration from .env file
async with KatanaClient() as client:
response = await get_all_products.asyncio_detailed(
client=client,
limit=50
)
print(f"Status: {response.status_code}")
print(f"Products: {len(response.parsed.data)}")
# Automatic pagination happens transparently
all_products_response = await get_all_products.asyncio_detailed(
client=client,
is_sellable=True
)
print(f"Total sellable products: {len(all_products_response.parsed.data)}")
# Direct API usage with automatic resilience
orders_response = await get_all_sales_orders.asyncio_detailed(
client=client,
status="open"
)
orders = orders_response.parsed.data if orders_response.parsed else []
print(f"Open orders: {len(orders)}")
asyncio.run(main())
Generated Client (Direct)
For maximum control and custom resilience patterns:
import asyncio
from katana_public_api_client import AuthenticatedClient
from katana_public_api_client.generated.api.product import get_all_products
async def main():
client = AuthenticatedClient(
base_url="https://api.katanamrp.com/v1",
token="your-api-key"
)
async with client:
response = await get_all_products.asyncio_detailed(
client=client,
limit=50
)
if response.status_code == 200:
products = response.parsed.data
print(f"Found {len(products)} products")
asyncio.run(main())
๐ API Coverage
The client provides access to all major Katana functionality:
| Category | Endpoints | Description |
|---|---|---|
| Products & Inventory | 25+ | Products, variants, materials, stock levels |
| Orders | 20+ | Sales orders, purchase orders, fulfillment |
| Manufacturing | 15+ | BOMs, manufacturing orders, operations |
| Business Relations | 10+ | Customers, suppliers, addresses |
| Configuration | 6+ | Locations, webhooks, custom fields |
Total: 76+ endpoints with 150+ fully-typed data models.
๐ฏ Why KatanaClient?
Automatic Resilience
Every API call through KatanaClient automatically includes:
- Smart Retries: Exponential backoff for network errors and 5xx responses
- Rate Limit Handling: Automatic retry with
Retry-Afterheader support - Error Recovery: Intelligent retry logic that doesn't retry 4xx client errors
- Observability: Rich logging for debugging and monitoring
Pythonic Design
# No decorators, no wrapper methods needed
async with KatanaClient() as client:
# Just use the generated API methods directly
response = await get_all_products.asyncio_detailed(
client=client,
limit=100
)
# Automatic retries, rate limiting, logging - all transparent!
Transport-Layer Architecture
Uses httpx's native transport layer for resilience - the most pythonic approach:
- Zero Dependencies: Built on httpx's standard extension points
- Maximum Compatibility: Works with any httpx-based code
- Easy Testing: Simple to mock and test
- Performance: Minimal overhead compared to decorators
๐ง Advanced Usage
Custom Configuration
import logging
from katana_public_api_client import KatanaClient
# Custom configuration
async with KatanaClient(
api_key="custom-key",
base_url="https://custom.katana.com/v1",
timeout=60.0,
max_retries=3,
logger=logging.getLogger("katana")
) as client:
# Your API calls here
pass
Automatic Pagination
from katana_public_api_client import KatanaClient
from katana_public_api_client.generated.api.product import get_all_products
async with KatanaClient() as client:
# Get all products with automatic pagination
all_products_response = await get_all_products.asyncio_detailed(
client=client,
is_sellable=True
)
sellable_products = all_products_response.parsed.data
print(f"Found {len(sellable_products)} sellable products")
Direct API Usage
from katana_public_api_client import KatanaClient
from katana_public_api_client.generated.api.inventory import get_all_inventory_points
from katana_public_api_client.generated.api.manufacturing_order import get_all_manufacturing_orders
from katana_public_api_client.generated.api.product import get_all_products, get_product
from katana_public_api_client.generated.api.sales_order import get_all_sales_orders, get_sales_order
async with KatanaClient() as client:
# Direct API methods with automatic pagination and resilience
products = await get_all_products.asyncio_detailed(
client=client, is_sellable=True
)
orders = await get_all_sales_orders.asyncio_detailed(
client=client, status="open"
)
inventory = await get_all_inventory_points.asyncio_detailed(
client=client
)
manufacturing = await get_all_manufacturing_orders.asyncio_detailed(
client=client, status="planned"
)
# Individual item lookup
product = await get_product.asyncio_detailed(
client=client, id=123
)
order = await get_sales_order.asyncio_detailed(
client=client, id=456
)
๏ฟฝ Project Structure
katana-openapi-client/
โโโ katana-openapi.yaml # OpenAPI 3.1.0 specification
โโโ katana_public_api_client/ # Generated Python client
โ โโโ katana_client.py # KatanaClient with transport-layer resilience
โ โโโ client.py # Base generated client classes
โ โโโ api/ # 76+ API endpoint modules
โ โโโ models/ # 150+ data models
โ โโโ types.py # Type definitions
โโโ docs/ # Documentation
โโโ tests/ # Test suite
โโโ scripts/ # Development utilities
๐งช Testing
# Run all tests
poetry run poe test
# Run with coverage
poetry run poe test-coverage
# Run specific test categories
poetry run poe test-unit # Unit tests only
poetry run poe test-integration # Integration tests only
๐ Documentation
- KatanaClient Guide - Complete KatanaClient usage guide
- API Reference - Generated API documentation
- Migration Guide - Upgrading from previous versions
- Testing Guide - Testing patterns and examples
๐ Development
Quick Start
# Install dependencies
poetry install
# Install pre-commit hooks (important!)
poetry run poe pre-commit-install
# See all available tasks
poetry run poe help
# Quick development check
poetry run poe check
# Auto-fix common issues
poetry run poe fix
๐ Development Workflow
Development Setup
# Install dependencies
poetry install
# Install pre-commit hooks (important!)
poetry run poe pre-commit-install
# See all available tasks
poetry run poe help
# Quick development check
poetry run poe check
# Auto-fix common issues
poetry run poe fix
Code Quality Tasks
# Formatting
poetry run poe format # Format all code and documentation
poetry run poe format-check # Check formatting without changes
poetry run poe format-python # Format Python code only
# Linting and Type Checking
poetry run poe lint # Run all linters (ruff, mypy, yaml)
poetry run poe lint-ruff # Fast linting with ruff
poetry run poe lint-mypy # Type checking with mypy
# Testing
poetry run poe test # Run all tests
poetry run poe test-coverage # Run tests with coverage
poetry run poe test-unit # Unit tests only
poetry run poe test-integration # Integration tests only
OpenAPI and Client Generation
# Regenerate client from OpenAPI spec
poetry run poe regenerate-client
# Validate OpenAPI specification
poetry run poe validate-openapi
# Full preparation workflow
poetry run poe prepare # Format + lint + test + validate
Pre-commit Hooks
# Install pre-commit hooks (run once after clone)
poetry run poe pre-commit-install
# Run pre-commit on all files manually
poetry run poe pre-commit-run
# Update pre-commit hook versions
poetry run poe pre-commit-update
CI/Development Workflows
# Full CI pipeline (what runs in GitHub Actions)
poetry run poe ci
# Pre-commit preparation
poetry run poe prepare
# Clean build artifacts
poetry run poe clean
Configuration
All tool configurations are consolidated in pyproject.toml following modern Python
packaging standards:
- Poetry: Package metadata and dependencies
- Ruff: Code formatting and linting (replaces Black, isort, flake8)
- MyPy: Type checking configuration
- Pytest: Test discovery and execution settings
- Coverage: Code coverage reporting
- Poe: Task automation and scripts
- Semantic Release: Automated versioning and releases
๐ License
This project is licensed under the MIT License - see the LICENSE file for details.
๐ค Contributing
Contributions are welcome! Please read our Contributing Guide for details on our code of conduct and the process for submitting pull requests.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file katana_openapi_client-0.4.0.tar.gz.
File metadata
- Download URL: katana_openapi_client-0.4.0.tar.gz
- Upload date:
- Size: 178.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f389061a102016ef01593652d427e037982679a391a17c88247392dbf2ea4ea6
|
|
| MD5 |
6ffcc0fa6620ed53bdc134d3bb27b7c7
|
|
| BLAKE2b-256 |
1292b015a1ec96d7a784a59f89c0ddbe4409097846de026da4caedf0bce30363
|
Provenance
The following attestation bundles were made for katana_openapi_client-0.4.0.tar.gz:
Publisher:
release.yml on dougborg/katana-openapi-client
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
katana_openapi_client-0.4.0.tar.gz -
Subject digest:
f389061a102016ef01593652d427e037982679a391a17c88247392dbf2ea4ea6 - Sigstore transparency entry: 372709513
- Sigstore integration time:
-
Permalink:
dougborg/katana-openapi-client@ef41c57a1b44302373d6fb0d2af61c6e51ba0c55 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/dougborg
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@ef41c57a1b44302373d6fb0d2af61c6e51ba0c55 -
Trigger Event:
push
-
Statement type:
File details
Details for the file katana_openapi_client-0.4.0-py3-none-any.whl.
File metadata
- Download URL: katana_openapi_client-0.4.0-py3-none-any.whl
- Upload date:
- Size: 481.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
521e270ec4e1ad389b647175a4c60686063f56fba668068fc4b4303fab5e6179
|
|
| MD5 |
7f682754beb6ac703a90d73ad549e067
|
|
| BLAKE2b-256 |
a8f7deec9a7c1fcedd4bb784b0b8a48cb1e2a35ac58b51b9521846fcf322b992
|
Provenance
The following attestation bundles were made for katana_openapi_client-0.4.0-py3-none-any.whl:
Publisher:
release.yml on dougborg/katana-openapi-client
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
katana_openapi_client-0.4.0-py3-none-any.whl -
Subject digest:
521e270ec4e1ad389b647175a4c60686063f56fba668068fc4b4303fab5e6179 - Sigstore transparency entry: 372709538
- Sigstore integration time:
-
Permalink:
dougborg/katana-openapi-client@ef41c57a1b44302373d6fb0d2af61c6e51ba0c55 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/dougborg
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@ef41c57a1b44302373d6fb0d2af61c6e51ba0c55 -
Trigger Event:
push
-
Statement type: