keyban_api_client
Keyban API Client
A Python client library for interacting with the Keyban API Product management. This library provides a simple and intuitive interface for managing products in your applications.
keyban_api_client.client
Keyban API Product Python Client
A Python client for interacting with the Keyban API Product API. This client provides methods for CRUD operations on products.
DynamicFieldDef Objects
class DynamicFieldDef(BaseModel)
Dynamic field definition model.
Supported types:
- 'number': Numeric values with optional min/max constraints
- 'string': Text with optional minLength/maxLength constraints
- 'url': URL string
- 'image': Image URL string
- 'text': Multi-line text
- 'boolean': True/false value
- 'date': ISO date string with optional min/max constraints
- 'enum': Selection from predefined variants
- 'json': Arbitrary JSON value
- 'array': List of items with recursive itemsType definition
- 'object': Nested object with recursive fields definition
type
'number', 'string', 'url', 'image', 'text', 'boolean', 'date', 'enum', 'json', 'array', 'object'
min
str for date type (ISO date)
max
str for date type (ISO date)
ProductFields Objects
class ProductFields(BaseModel)
Dynamic product fields based on field definitions
model_config
Use model_config for Pydantic v2
__init__
def __init__(**data)
Initialize ProductFields with dynamic data
create_encrypted
@classmethod
def create_encrypted(cls,
confidential_paths: Optional[List[str]] = None,
enc_algorithm: str = "sha256",
enc_key: Optional[str] = None,
**data) -> "ProductFields"
Create ProductFields with optional encryption/hashing of confidential fields.
Arguments:
confidential_paths- List of field paths to protectenc_algorithm- Protection algorithm:- "sha256": One-way hash (irreversible, for integrity verification)
- "aes-256-gcm": Symmetric encryption (reversible with key)
enc_key- Base64-encoded 32-byte key (required for aes-256-gcm, ignored for sha256)**data- Product data fields
Returns:
ProductFields instance with protected fields
WARNING- SHA256 produces a one-way hash - the original value CANNOT be recovered. Use "aes-256-gcm" if you need to decrypt the values later.
model_dump
def model_dump(**kwargs)
Custom serialization to exclude null values
encryption_key
@property
def encryption_key() -> Optional[str]
Get the encryption key used (if any)
Application Objects
class Application(BaseModel)
Application model
Product Objects
class Product(BaseModel)
Keyban API DPP Product model
application
Handle both object and UUID formats
network
Network enum value
status
DppProductStatus enum value
name
Product name
shopify_id
Shopify product ID (if linked)
fields
Dynamic product fields
productFields
Product field definitions
passportsFields
Passport field definitions
parse_application
@field_validator('application', mode='before')
@classmethod
def parse_application(cls, v)
Handle both Application object and UUID string formats
CreateProductRequest Objects
class CreateProductRequest(BaseModel)
Request model for creating a DPP product
validate_network
@field_validator('network')
@classmethod
def validate_network(cls, v)
Only StarknetSepolia network is currently supported
validate_status
@field_validator('status')
@classmethod
def validate_status(cls, v)
Validate product status
UpdateProductRequest Objects
class UpdateProductRequest(BaseModel)
Request model for updating a DPP product
validate_network
@field_validator('network')
@classmethod
def validate_network(cls, v)
Only StarknetSepolia network is currently supported
validate_status
@field_validator('status')
@classmethod
def validate_status(cls, v)
Validate product status
ProductListResponse Objects
class ProductListResponse(BaseModel)
Response model for listing products
FilterOperator Objects
class FilterOperator(BaseModel)
Filter operator for querying
operator
'eq', 'contains', 'gt', 'lt'
QueryParams Objects
class QueryParams(BaseModel)
Query parameters for listing products
ProductClient Objects
class ProductClient()
Python client for interacting with Keyban API DPP Product endpoints.
Supports the following operations:
- List products with filtering and pagination
- Get a specific product by ID
- Create a new product
- Update an existing product
- Delete an existing product
The list_products() method supports filtering using FilterOperator objects. Supported filter fields: application.id (eq only), name (eq, contains) Supported network: StarknetSepolia (default)
__init__
def __init__(base_url: str,
api_key: str,
api_version: str = "v1",
timeout: int = 30)
Initialize the Keyban API DPP Product client.
Arguments:
base_url- Base URL of the API (e.g., "https://api.keyban.io")api_key- API key for authentication (required)api_version- API version (default: "v1")timeout- Request timeout in seconds (default: 30)
list_products
def list_products(filters: Optional[List[FilterOperator]] = None,
current_page: int = 1,
page_size: int = 10) -> ProductListResponse
List DPP products with filtering and pagination.
Arguments:
filters- List of FilterOperator objects for filtering (optional)current_page- Page number (1-based, default: 1)page_size- Number of items per page (default: 10, max: 100)
Returns:
ProductListResponse containing the list of products and total count
Supported filter fields and operators:
- application.id: Application UUID (eq only)
- name: Product name (eq for exact match, contains for substring search)
Examples:
List all products (no filters)
all_products = client.list_products()
Filter by application ID (exact match only)
app_filter = FilterOperator(field="application.id", operator="eq", value=str(app_id)) products = client.list_products(filters=[app_filter])
Filter by product name (exact match)
name_filter = FilterOperator(field="name", operator="eq", value="My Product") products = client.list_products(filters=[name_filter])
Filter by product name (substring search, case-insensitive)
name_filter = FilterOperator(field="name", operator="contains", value="Nike") products = client.list_products(filters=[name_filter])
Combine filters
filters = [ FilterOperator(field="application.id", operator="eq", value=str(app_id)), FilterOperator(field="name", operator="contains", value="Product") ] products = client.list_products(filters=filters)
get_product
def get_product(product_id: UUID) -> Product
Get a specific product by its ID.
This endpoint is public and doesn't require authentication.
Arguments:
product_id- The UUID of the product
Returns:
Product object
Raises:
requests.HTTPError- If the product is not found (404) or other HTTP errors
create_product
def create_product(product_data: CreateProductRequest) -> Product
Create a new DPP product.
Requires authentication and organization-level access.
Arguments:
product_data- The product data to create
Returns:
Created Product object
Raises:
requests.HTTPError- If the application is not found (404) or other HTTP errors
update_product
def update_product(product_id: UUID,
update_data: UpdateProductRequest) -> Product
Update an existing DPP product.
Requires authentication and organization-level access. Only products belonging to the authenticated organization can be updated.
Arguments:
product_id- The UUID of the product to updateupdate_data- The updated product data
Returns:
Updated Product object
Raises:
requests.HTTPError- If the product is not found (404) or other HTTP errors
delete_product
def delete_product(product_id: UUID) -> bool
Delete an existing DPP product.
Requires authentication and organization-level access. Only products belonging to the authenticated organization can be deleted.
Arguments:
product_id- The UUID of the product to delete
Returns:
bool- True if deletion was successful
Raises:
requests.HTTPError- If the product is not found (404) or other HTTP errors
close
def close()
Close the HTTP session
create_filter
def create_filter(field: str, operator: str, value: Any) -> FilterOperator
Create a FilterOperator for use with list_products.
Arguments:
field- Field to filter on ("application.id" or "name")operator- Filter operator ("eq" or "contains")value- Value to filter by
Returns:
FilterOperator object
Supported fields and operators:
- application.id: eq only
- name: eq (exact match) or contains (substring search)
Examples:
Filter by application ID
app_filter = create_filter("application.id", "eq", str(app_id))
Filter by name (exact match)
name_filter = create_filter("name", "eq", "My Product")
Filter by name (substring search)
name_filter = create_filter("name", "contains", "Nike")
Multiple filters example
filters = [ create_filter("application.id", "eq", str(app_id)), create_filter("name", "contains", "Product") ] products = client.list_products(filters=filters)
search_products_by_application_id
def search_products_by_application_id(client: ProductClient,
application_id: UUID,
page_size: int = 100) -> List[Product]
Convenience function to search for DPP products by application ID.
Arguments:
client- ProductClient instanceapplication_id- Application ID to filter bypage_size- Number of results to return (default: 100)
Returns:
List of matching Product objects
keyban_api_client._version
Version information for keyban-api-client.