Usage Based Pricing API Reference
This page documents the API for the business KPIs module in Pypulate.
Usage Pricing Module
This module provides functions for calculating usage-based pricing.
calculate_usage_price(usage_metrics, metric_rates, minimum_charge=0.0, maximum_charge=None)
Calculate price based on usage metrics.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
usage_metrics
|
dict
|
Dictionary of metric names and their usage values |
required |
metric_rates
|
dict
|
Dictionary of metric names and their per-unit rates |
required |
minimum_charge
|
float
|
Minimum charge to apply |
0.0
|
maximum_charge
|
float
|
Maximum charge cap |
None
|
Returns:
Type | Description |
---|---|
float
|
Total usage-based price |
Examples:
calculate_volume_discount(base_price, volume, discount_tiers)
Calculate price with volume-based discounts.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
base_price
|
float
|
Base price per unit |
required |
volume
|
int
|
Number of units |
required |
discount_tiers
|
dict
|
Dictionary of volume thresholds and discount rates Format: {100: 0.05, 500: 0.10, 1000: 0.15} |
required |
Returns:
Type | Description |
---|---|
float
|
Total price after volume discount |
Examples: