Installation
Quick Start
Configuration
Get your API key from Settings → API Keys in your Metrifox dashboard.
Customer Management
Create a Customer
Type-Safe Dataclasses
For better type safety and IDE support:Update a Customer
The
customer_key cannot be changed after creation.Get Customer Data
Delete a Customer
Archive / Unarchive a Customer
Bulk CSV Upload
Usage Tracking & Access Control
Check Feature Access
Type-Safe Access Checks
Record Usage Events
Type-Safe Usage Events
List Usage Events
Retrieve usage events with optional filters and pagination:Compute Quantity Price
Compute the price for a given quantity of a feature for a customer, based on their plan. Useful for previewing upgrade costs or showing customers the cost of additional usage before they commit.Only available to tenants whose plan includes the finance API feature.
Complete Usage Example
Checkout & Billing
Generate Checkout URL
Type-Safe Checkout
Card Collection URL
Generate a hosted URL for collecting a payment method against an existing subscription or order. Useful for trial-to-paid conversions and re-collecting card details after expiry.Wallets & Credit Allocations
Error Handling
Framework Integration
Django
Flask
FastAPI
API Reference
Client Methods
Initialization:MetrifoxClient(api_key, base_url, web_app_base_url, meter_service_base_url)- Initialize the clientinit(config)- Convenience function to initialize the client
client.customers):
create(request)- Create a customerupdate(customer_key, request)- Update a customerget(customer_key)- Get a customerget_details(customer_key)- Get detailed customer informationlist(params)- List customers with pagination and filtersdelete(customer_key)- Delete a customerarchive(customer_key)- Archive a customerunarchive(customer_key)- Restore an archived customerhas_active_subscription(customer_key)- Check for active subscriptionupload_csv(file_path)- Upload customers via CSVbulk_create(customers)- Create multiple customers in one call
client.usages):
check_access(request)- Check feature accessrecord_usage(request)- Record a usage eventlist_events(customer_key, feature_key, page, per_page)- List recorded usage eventsquantity_price(customer_key, feature_key, quantity)- Compute the price of a usage quantity (requires finance API feature)
client.checkout):
url(config)- Generate a checkout URLcard_collection_url(subscription_id, order_id)- Generate a hosted card-collection URL
client.wallets):
list(customer_key)- List a customer’s credit walletslist_credit_allocations(wallet_id, status)- List credit allocations for a walletget_credit_allocation(allocation_id)- Get a single allocation with transaction history
Type Definitions
All type definitions are available for import:Configuration
Environment Variables
METRIFOX_API_KEY- Your Metrifox API keyMETRIFOX_METER_SERVICE_BASE_URL- Optional override for the meter service URL
Custom URLs
Default URLs
- Production API:
https://api.metrifox.com/api/v1/ - Meter Service:
https://api-meter.metrifox.com/ - Web App:
https://app.metrifox.com
Requirements
- Python 3.8+
- requests >= 2.31.0
Support
- Email: support@metrifox.com
- Documentation: https://docs.metrifox.com
- GitHub: https://github.com/metrifox/metrifox-python
- Discord https://discord.gg/GGMHDDBdw
The Python SDK follows Pythonic patterns with type hints, dataclasses, and comprehensive error handling for a great developer experience.

