Python SDK
from metrifox_sdk import MetrifoxClient
client = MetrifoxClient(api_key="your_api_key")
# Compute the price of 500 units of a feature for a customer
price = client.usages.quantity_price(
customer_key="cust-6d11ca90",
feature_key="feature_interview_booking",
quantity=500,
)
print(f"{price['data']['price']} {price['data']['unit']}")
# For tiered pricing, inspect the per-tier breakdown
for tier in price['data'].get('applied_tiers', []):
print(
f" Tier {tier['first_unit']}-{tier['last_unit']}: "
f"{tier['units_consumed']} units -> {tier['tier_price']}"
)import { init } from "metrifox-js";
const metrifoxClient = init({
apiKey: process.env.METRIFOX_API_KEY
});
const price = await metrifoxClient.usages.quantityPrice({
customerKey: "cust-6d11ca90",
featureKey: "feature_interview_booking",
quantity: 500,
});
console.log(`${price.data.price} ${price.data.unit}`);
price.data.applied_tiers.forEach((tier) => {
console.log(
` Tier ${tier.first_unit}-${tier.last_unit}: ` +
`${tier.units_consumed} units -> ${tier.tier_price}`
);
});
require 'metrifox-sdk'
METRIFOX_SDK = MetrifoxSDK.init({ api_key: "your-api-key" })
response = METRIFOX_SDK.usages.quantity_price(
customer_key: "cust-6d11ca90",
feature_key: "feature_interview_booking",
quantity: 500
)
puts "#{response['data']['price']} #{response['data']['unit']}"
response["data"]["applied_tiers"].each do |tier|
puts " Tier #{tier['first_unit']}-#{tier['last_unit']}: #{tier['units_consumed']} units -> #{tier['tier_price']}"
end
curl --request GET \
--url https://{defaultHost}/api/v1/usage/quantity-price \
--header 'x-api-key: <api-key>'<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://{defaultHost}/api/v1/usage/quantity-price",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"x-api-key: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://{defaultHost}/api/v1/usage/quantity-price"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("x-api-key", "<api-key>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://{defaultHost}/api/v1/usage/quantity-price")
.header("x-api-key", "<api-key>")
.asString();{
"message": "Quantity price fetched",
"data": {
"customer_key": "cust-6d11ca90",
"feature_key": "feature_interview_booking",
"quantity": 500,
"price": 3000,
"unit": "USD",
"applied_tiers": [
{
"first_unit": 0,
"last_unit": 100,
"pricing_model": "per_unit",
"unit_price": 10,
"package_price": null,
"package_size": null,
"flat_fee": null,
"min_price": null,
"max_price": null,
"percentage": null,
"total_unit_quantity": null,
"units_consumed": 100,
"tier_price": "1000.0"
},
{
"first_unit": 101,
"last_unit": 1000,
"pricing_model": "per_unit",
"unit_price": 5,
"package_price": null,
"package_size": null,
"flat_fee": null,
"min_price": null,
"max_price": null,
"percentage": null,
"total_unit_quantity": null,
"units_consumed": 400,
"tier_price": "2000.0"
}
]
}
}{
"message": "Validation failed",
"errors": {
"customer_key": [
"is required"
],
"feature_key": [
"is required"
],
"quantity": [
"must be a non-negative number"
]
}
}{
"message": "Unauthorized"
}{
"message": "Not found"
}Finance
Get Quantity Price
Computes the price of a feature quantity for a customer based on their plan. This endpoint is only available to users with the finance api feature on their plan.
GET
/
api
/
v1
/
usage
/
quantity-price
Python SDK
from metrifox_sdk import MetrifoxClient
client = MetrifoxClient(api_key="your_api_key")
# Compute the price of 500 units of a feature for a customer
price = client.usages.quantity_price(
customer_key="cust-6d11ca90",
feature_key="feature_interview_booking",
quantity=500,
)
print(f"{price['data']['price']} {price['data']['unit']}")
# For tiered pricing, inspect the per-tier breakdown
for tier in price['data'].get('applied_tiers', []):
print(
f" Tier {tier['first_unit']}-{tier['last_unit']}: "
f"{tier['units_consumed']} units -> {tier['tier_price']}"
)import { init } from "metrifox-js";
const metrifoxClient = init({
apiKey: process.env.METRIFOX_API_KEY
});
const price = await metrifoxClient.usages.quantityPrice({
customerKey: "cust-6d11ca90",
featureKey: "feature_interview_booking",
quantity: 500,
});
console.log(`${price.data.price} ${price.data.unit}`);
price.data.applied_tiers.forEach((tier) => {
console.log(
` Tier ${tier.first_unit}-${tier.last_unit}: ` +
`${tier.units_consumed} units -> ${tier.tier_price}`
);
});
require 'metrifox-sdk'
METRIFOX_SDK = MetrifoxSDK.init({ api_key: "your-api-key" })
response = METRIFOX_SDK.usages.quantity_price(
customer_key: "cust-6d11ca90",
feature_key: "feature_interview_booking",
quantity: 500
)
puts "#{response['data']['price']} #{response['data']['unit']}"
response["data"]["applied_tiers"].each do |tier|
puts " Tier #{tier['first_unit']}-#{tier['last_unit']}: #{tier['units_consumed']} units -> #{tier['tier_price']}"
end
curl --request GET \
--url https://{defaultHost}/api/v1/usage/quantity-price \
--header 'x-api-key: <api-key>'<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://{defaultHost}/api/v1/usage/quantity-price",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"x-api-key: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://{defaultHost}/api/v1/usage/quantity-price"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("x-api-key", "<api-key>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://{defaultHost}/api/v1/usage/quantity-price")
.header("x-api-key", "<api-key>")
.asString();{
"message": "Quantity price fetched",
"data": {
"customer_key": "cust-6d11ca90",
"feature_key": "feature_interview_booking",
"quantity": 500,
"price": 3000,
"unit": "USD",
"applied_tiers": [
{
"first_unit": 0,
"last_unit": 100,
"pricing_model": "per_unit",
"unit_price": 10,
"package_price": null,
"package_size": null,
"flat_fee": null,
"min_price": null,
"max_price": null,
"percentage": null,
"total_unit_quantity": null,
"units_consumed": 100,
"tier_price": "1000.0"
},
{
"first_unit": 101,
"last_unit": 1000,
"pricing_model": "per_unit",
"unit_price": 5,
"package_price": null,
"package_size": null,
"flat_fee": null,
"min_price": null,
"max_price": null,
"percentage": null,
"total_unit_quantity": null,
"units_consumed": 400,
"tier_price": "2000.0"
}
]
}
}{
"message": "Validation failed",
"errors": {
"customer_key": [
"is required"
],
"feature_key": [
"is required"
],
"quantity": [
"must be a non-negative number"
]
}
}{
"message": "Unauthorized"
}{
"message": "Not found"
}Authorizations
Query Parameters
The customer key to compute the price for
The feature key to compute the price for
The quantity you want to price
Required range:
x >= 0⌘I

