katana_public_api_client.helpers¶
katana_public_api_client.helpers
¶
Domain classes for the Katana API client.
These domain classes provide ergonomic, domain-specific methods that reduce boilerplate and serve as the foundation for MCP tools.
Example
async with KatanaClient() as client: ... # Product catalog operations ... products = await client.products.list(is_sellable=True) ... product = await client.products.get(123) ... results = await client.products.search("widget") ... ... # Inventory and stock operations ... stock = await client.inventory.check_stock("WIDGET-001") ... low_stock = await client.inventory.list_low_stock(threshold=10)
Classes¶
Base(client)
¶
Base class for all domain classes.
Provides common functionality and access to the KatanaClient instance.
Parameters:
-
client(KatanaClient) –The KatanaClient instance to use for API calls.
Parameters:
-
client(KatanaClient) –The KatanaClient instance to use for API calls.
Source code in katana_public_api_client/helpers/base.py
Functions¶
Inventory(client)
¶
Bases: Base
Inventory and stock operations.
Provides methods for checking stock levels, movements, adjustments, and transfers. For product catalog CRUD, use client.products instead.
Example
async with KatanaClient() as client: ... # Check stock levels (MCP tool support) ... stock = await client.inventory.check_stock("WIDGET-001") ... low_stock = await client.inventory.list_low_stock(threshold=10) ... ... # Stock movements and adjustments ... movements = await client.inventory.get_movements() ... await client.inventory.create_adjustment( ... {"product_id": 123, "quantity": 10} ... )
Source code in katana_public_api_client/helpers/base.py
Functions¶
check_stock(sku)
async
¶
Check stock levels for a specific SKU.
Used by: MCP tool check_inventory
Parameters:
-
sku(str) –The SKU to check stock for.
Returns:
-
Product | None–Product model with stock information, or None if SKU not found.
Example
product = await client.inventory.check_stock("WIDGET-001") if product: ... stock = product.stock_information ... print(f"Available: {stock.available}, In Stock: {stock.in_stock}")
Source code in katana_public_api_client/helpers/inventory.py
get_inventory_points(**filters)
async
¶
Get inventory points for all products.
This will use the inventory API to get current stock levels, reorder points, and safety stock levels.
Parameters:
-
**filters(Any, default:{}) –Filtering parameters.
Returns:
Note
To be implemented using katana_public_api_client.api.inventory
Source code in katana_public_api_client/helpers/inventory.py
get_negative_stock()
async
¶
Get products with negative stock.
Returns:
Note
To be implemented using katana_public_api_client.api.inventory
Source code in katana_public_api_client/helpers/inventory.py
list_low_stock(threshold=None)
async
¶
Find products below their reorder point.
Used by: MCP tool list_low_stock_items
Parameters:
-
threshold(int | None, default:None) –Optional stock threshold. Products with stock below this will be returned. If None, uses each product's reorder point.
Returns:
Example
low_stock = await client.inventory.list_low_stock(threshold=10) for product in low_stock: ... stock = product.stock_information ... print(f"{product.sku}: {stock.in_stock} units")
Source code in katana_public_api_client/helpers/inventory.py
set_reorder_point(product_id, quantity)
async
¶
Set reorder point for a product.
Parameters:
Note
To be implemented using katana_public_api_client.api.inventory
Source code in katana_public_api_client/helpers/inventory.py
set_safety_stock(product_id, quantity)
async
¶
Set safety stock level for a product.
Parameters:
Note
To be implemented using katana_public_api_client.api.inventory
Source code in katana_public_api_client/helpers/inventory.py
Materials(client)
¶
Bases: Base
Material catalog management.
Provides CRUD operations for materials in the Katana catalog.
Example
async with KatanaClient() as client: ... # CRUD operations ... materials = await client.materials.list() ... material = await client.materials.get(123) ... new_material = await client.materials.create({"name": "Steel"})
Source code in katana_public_api_client/helpers/base.py
Functions¶
create(material_data)
async
¶
Create a new material.
Parameters:
-
material_data(CreateMaterialRequest) –CreateMaterialRequest model with material details.
Returns:
-
KatanaMaterial–Created KatanaMaterial domain model object.
Example
from katana_public_api_client.models import CreateMaterialRequest new_material = await client.materials.create( ... CreateMaterialRequest(name="Steel") ... )
Source code in katana_public_api_client/helpers/materials.py
delete(material_id)
async
¶
Delete a material.
Parameters:
-
material_id(int) –The material ID to delete.
Example
await client.materials.delete(123)
Source code in katana_public_api_client/helpers/materials.py
get(material_id)
async
¶
Get a specific material by ID.
Parameters:
-
material_id(int) –The material ID.
Returns:
-
KatanaMaterial–KatanaMaterial domain model object.
Example
material = await client.materials.get(123)
Source code in katana_public_api_client/helpers/materials.py
list(**filters)
async
¶
List all materials with optional filters.
Parameters:
-
**filters(Any, default:{}) –Filtering parameters.
Returns:
-
list[KatanaMaterial]–List of KatanaMaterial domain model objects.
Example
materials = await client.materials.list(limit=100)
Source code in katana_public_api_client/helpers/materials.py
update(material_id, material_data)
async
¶
Update an existing material.
Parameters:
-
material_id(int) –The material ID to update.
-
material_data(UpdateMaterialRequest) –UpdateMaterialRequest model with fields to update.
Returns:
-
KatanaMaterial–Updated KatanaMaterial domain model object.
Example
from katana_public_api_client.models import UpdateMaterialRequest updated = await client.materials.update( ... 123, UpdateMaterialRequest(name="Aluminum") ... )
Source code in katana_public_api_client/helpers/materials.py
Products(client)
¶
Bases: Base
Product catalog management.
Provides CRUD operations and search for products in the Katana catalog.
Example
async with KatanaClient() as client: ... # Search products ... products = await client.products.search("widget") ... ... # CRUD operations ... products = await client.products.list(is_sellable=True) ... product = await client.products.get(123) ... new_product = await client.products.create({"name": "Widget"})
Source code in katana_public_api_client/helpers/base.py
Functions¶
create(product_data)
async
¶
Create a new product.
Parameters:
-
product_data(CreateProductRequest) –CreateProductRequest model with product details.
Returns:
-
KatanaProduct–Created KatanaProduct domain model object.
Example
from katana_public_api_client.models import CreateProductRequest new_product = await client.products.create( ... CreateProductRequest( ... name="New Widget", ... sku="WIDGET-NEW", ... is_sellable=True, ... variants=[], ... ) ... )
Source code in katana_public_api_client/helpers/products.py
delete(product_id)
async
¶
Delete a product.
Parameters:
-
product_id(int) –The product ID to delete.
Example
await client.products.delete(123)
Source code in katana_public_api_client/helpers/products.py
get(product_id)
async
¶
Get a specific product by ID.
Parameters:
-
product_id(int) –The product ID.
Returns:
-
KatanaProduct–KatanaProduct domain model object.
Example
product = await client.products.get(123)
Source code in katana_public_api_client/helpers/products.py
list(**filters)
async
¶
List all products with optional filters.
Parameters:
-
**filters(Any, default:{}) –Filtering parameters (e.g., is_sellable, is_producible, include_deleted).
Returns:
-
list[KatanaProduct]–List of KatanaProduct domain model objects.
Example
products = await client.products.list(is_sellable=True, limit=100)
Source code in katana_public_api_client/helpers/products.py
search(query, limit=50)
async
¶
Search products by name and category (case-insensitive substring search).
Used by: MCP tool search_products
Note: The Katana API 'name' parameter only does exact matches, so we fetch all products and perform client-side substring searching against product names and categories.
Parameters:
-
query(str) –Search query to match against product names (case-insensitive).
-
limit(int, default:50) –Maximum number of results to return.
Returns:
-
list[KatanaProduct]–List of matching KatanaProduct domain model objects, sorted by relevance.
Example
products = await client.products.search("fox", limit=10) for product in products: ... print(f"{product.id}: {product.name}")
Source code in katana_public_api_client/helpers/products.py
update(product_id, product_data)
async
¶
Update an existing product.
Parameters:
-
product_id(int) –The product ID to update.
-
product_data(UpdateProductRequest) –UpdateProductRequest model with fields to update.
Returns:
-
KatanaProduct–Updated KatanaProduct domain model object.
Example
from katana_public_api_client.models import UpdateProductRequest updated = await client.products.update( ... 123, UpdateProductRequest(name="Updated Name") ... )
Source code in katana_public_api_client/helpers/products.py
Services(client)
¶
Bases: Base
Service catalog management.
Provides CRUD operations for services in the Katana catalog.
Example
async with KatanaClient() as client: ... # CRUD operations ... services = await client.services.list() ... service = await client.services.get(123) ... new_service = await client.services.create({"name": "Assembly"})
Source code in katana_public_api_client/helpers/base.py
Functions¶
create(service_data)
async
¶
Create a new service.
Parameters:
-
service_data(CreateServiceRequest) –CreateServiceRequest model with service details.
Returns:
-
KatanaService–Created KatanaService domain model object.
Example
from katana_public_api_client.models import CreateServiceRequest new_service = await client.services.create( ... CreateServiceRequest(name="Assembly") ... )
Source code in katana_public_api_client/helpers/services.py
delete(service_id)
async
¶
Delete a service.
Parameters:
-
service_id(int) –The service ID to delete.
Example
await client.services.delete(123)
Source code in katana_public_api_client/helpers/services.py
get(service_id)
async
¶
Get a specific service by ID.
Parameters:
-
service_id(int) –The service ID.
Returns:
-
KatanaService–KatanaService domain model object.
Example
service = await client.services.get(123)
Source code in katana_public_api_client/helpers/services.py
list(**filters)
async
¶
List all services with optional filters.
Parameters:
-
**filters(Any, default:{}) –Filtering parameters.
Returns:
-
list[KatanaService]–List of KatanaService domain model objects.
Example
services = await client.services.list(limit=100)
Source code in katana_public_api_client/helpers/services.py
update(service_id, service_data)
async
¶
Update an existing service.
Parameters:
-
service_id(int) –The service ID to update.
-
service_data(UpdateServiceRequest) –UpdateServiceRequest model with fields to update.
Returns:
-
KatanaService–Updated KatanaService domain model object.
Example
from katana_public_api_client.models import UpdateServiceRequest updated = await client.services.update( ... 123, UpdateServiceRequest(name="QA Testing") ... )
Source code in katana_public_api_client/helpers/services.py
Variants(*args, **kwargs)
¶
Bases: Base
Variant catalog management.
Provides CRUD operations for product variants in the Katana catalog. Includes caching for improved search performance.
Example
async with KatanaClient() as client: ... # CRUD operations ... variants = await client.variants.list() ... variant = await client.variants.get(123) ... new_variant = await client.variants.create({"name": "Large"}) ... ... # Fast repeated searches (uses cache) ... results1 = await client.variants.search("fox") ... results2 = await client.variants.search( ... "fork" ... ) # Instant - uses cached data
Source code in katana_public_api_client/helpers/variants.py
Functions¶
create(variant_data)
async
¶
Create a new variant.
Note: Clears the variant cache after creation.
Parameters:
-
variant_data(CreateVariantRequest) –CreateVariantRequest model with variant details.
Returns:
-
KatanaVariant–Created Variant object.
Example
from katana_public_api_client.models import CreateVariantRequest new_variant = await client.variants.create( ... CreateVariantRequest(name="Large", product_id=123) ... )
Source code in katana_public_api_client/helpers/variants.py
delete(variant_id)
async
¶
Delete a variant.
Note: Clears the variant cache after deletion.
Parameters:
-
variant_id(int) –The variant ID to delete.
Example
await client.variants.delete(123)
Source code in katana_public_api_client/helpers/variants.py
get(variant_id)
async
¶
Get a specific variant by ID.
Parameters:
-
variant_id(int) –The variant ID.
Returns:
-
KatanaVariant–KatanaVariant object.
Example
variant = await client.variants.get(123) print(variant.get_display_name()) print(f"Profit margin: {variant.profit_margin}%")
Source code in katana_public_api_client/helpers/variants.py
list(**filters)
async
¶
List all variants with optional filters.
Parameters:
-
**filters(Any, default:{}) –Filtering parameters.
Returns:
-
list[KatanaVariant]–List of KatanaVariant objects.
Example
variants = await client.variants.list(limit=100) for v in variants: ... print(f"{v.get_display_name()}: {v.profit_margin}%")
Source code in katana_public_api_client/helpers/variants.py
search(query, limit=50)
async
¶
Search variants by SKU or parent product/material name with relevance ranking.
Used by: MCP tool search_products
Features: - Fetches all variants with parent product/material info (cached for 5 min) - Multi-token matching (all tokens must match) - Relevance-based ranking (exact matches first) - Case-insensitive substring matching
Parameters:
-
query(str) –Search query (e.g., "fox fork 160")
-
limit(int, default:50) –Maximum number of results to return
Returns:
-
list[KatanaVariant]–List of matching Variant objects, sorted by relevance
Example
First search: fetches from API (~1-2s)¶
variants = await client.variants.search("fox fork", limit=10)
Subsequent searches: instant (<10ms, uses cache)¶
variants = await client.variants.search("fox 160", limit=10)
for variant in variants: ... print(f"{variant.sku}: {variant.product_or_material_name}")
Source code in katana_public_api_client/helpers/variants.py
update(variant_id, variant_data)
async
¶
Update an existing variant.
Note: Clears the variant cache after update.
Parameters:
-
variant_id(int) –The variant ID to update.
-
variant_data(UpdateVariantRequest) –UpdateVariantRequest model with fields to update.
Returns:
-
KatanaVariant–Updated Variant object.
Example
from katana_public_api_client.models import UpdateVariantRequest updated = await client.variants.update( ... 123, UpdateVariantRequest(name="XL") ... )