Python SDK
from metrifox_sdk import MetrifoxClient
client = MetrifoxClient(api_key="your_api_key")
# Get a single credit allocation with transactions
allocation = client.wallets.get_credit_allocation("a3f2b8e0-4d11-4f9a-8c2d-7e1b3a9f0c12")
data = allocation['data']
print(f"{data['amount']} granted, {data['consumed']} consumed")
for txn in data['transactions']:
print(f" {txn['amount']} via {txn.get('event_name')} at {txn['created_at']}")
import { init } from "metrifox-js";
const metrifoxClient = init({
apiKey: process.env.METRIFOX_API_KEY
});
const allocation = await metrifoxClient.wallets.getCreditAllocation(
"a3f2b8e0-4d11-4f9a-8c2d-7e1b3a9f0c12"
);
console.log(`${allocation.data.amount} granted, ${allocation.data.consumed} consumed`);
allocation.data.transactions.forEach((t) => {
console.log(` ${t.amount} via ${t.event_name} at ${t.created_at}`);
});
require 'metrifox-sdk'
METRIFOX_SDK = MetrifoxSDK.init({ api_key: "your-api-key" })
# Get a single credit allocation with transactions
response = METRIFOX_SDK.wallets.get_credit_allocation("a3f2b8e0-4d11-4f9a-8c2d-7e1b3a9f0c12")
data = response["data"]
puts "#{data['amount']} granted, #{data['consumed']} consumed"
data["transactions"].each do |txn|
puts " #{txn['amount']} via #{txn['event_name']} at #{txn['created_at']}"
end
curl --request GET \
--url https://{defaultHost}/api/v1/credit_systems/v2/credit-allocations/{id} \
--header 'x-api-key: <api-key>'<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://{defaultHost}/api/v1/credit_systems/v2/credit-allocations/{id}",
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/credit_systems/v2/credit-allocations/{id}"
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/credit_systems/v2/credit-allocations/{id}")
.header("x-api-key", "<api-key>")
.asString();{
"statusCode": 200,
"message": "Credit transactions fetched successfully",
"meta": {},
"data": {
"id": "a3f2b8e0-4d11-4f9a-8c2d-7e1b3a9f0c12",
"amount": 100,
"consumed": 35,
"allocation_type": "subscription",
"invoice_id": "0d9e5a0e-7de4-48c6-b01a-b1759394578b",
"order_id": null,
"order_number": null,
"valid_until": "2026-04-12T16:55:21.847Z",
"created_at": "2026-03-12T16:55:22.014Z",
"transactions": [
{
"id": "2e8c1a4f-9b73-4f1a-bd64-58a9d7c83ef0",
"amount": 10,
"quantity": 2,
"event_name": "image_generated",
"usage_event_id": "ue_01HXYZ123ABC",
"created_at": "2026-03-15T09:22:03.114Z"
},
{
"id": "9af2e7b1-8c3d-4d52-9b1a-23c7e4f60d21",
"amount": 25,
"quantity": 5,
"event_name": "image_generated",
"usage_event_id": "ue_01HXYZ456DEF",
"created_at": "2026-03-18T14:08:47.802Z"
}
]
},
"errors": {}
}{
"message": "<string>",
"errors": {}
}{
"message": "<string>",
"errors": {}
}Wallets
Get a credit allocation
Retrieve a single credit allocation by ID, including its full transaction history.
GET
/
api
/
v1
/
credit_systems
/
v2
/
credit-allocations
/
{id}
Python SDK
from metrifox_sdk import MetrifoxClient
client = MetrifoxClient(api_key="your_api_key")
# Get a single credit allocation with transactions
allocation = client.wallets.get_credit_allocation("a3f2b8e0-4d11-4f9a-8c2d-7e1b3a9f0c12")
data = allocation['data']
print(f"{data['amount']} granted, {data['consumed']} consumed")
for txn in data['transactions']:
print(f" {txn['amount']} via {txn.get('event_name')} at {txn['created_at']}")
import { init } from "metrifox-js";
const metrifoxClient = init({
apiKey: process.env.METRIFOX_API_KEY
});
const allocation = await metrifoxClient.wallets.getCreditAllocation(
"a3f2b8e0-4d11-4f9a-8c2d-7e1b3a9f0c12"
);
console.log(`${allocation.data.amount} granted, ${allocation.data.consumed} consumed`);
allocation.data.transactions.forEach((t) => {
console.log(` ${t.amount} via ${t.event_name} at ${t.created_at}`);
});
require 'metrifox-sdk'
METRIFOX_SDK = MetrifoxSDK.init({ api_key: "your-api-key" })
# Get a single credit allocation with transactions
response = METRIFOX_SDK.wallets.get_credit_allocation("a3f2b8e0-4d11-4f9a-8c2d-7e1b3a9f0c12")
data = response["data"]
puts "#{data['amount']} granted, #{data['consumed']} consumed"
data["transactions"].each do |txn|
puts " #{txn['amount']} via #{txn['event_name']} at #{txn['created_at']}"
end
curl --request GET \
--url https://{defaultHost}/api/v1/credit_systems/v2/credit-allocations/{id} \
--header 'x-api-key: <api-key>'<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://{defaultHost}/api/v1/credit_systems/v2/credit-allocations/{id}",
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/credit_systems/v2/credit-allocations/{id}"
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/credit_systems/v2/credit-allocations/{id}")
.header("x-api-key", "<api-key>")
.asString();{
"statusCode": 200,
"message": "Credit transactions fetched successfully",
"meta": {},
"data": {
"id": "a3f2b8e0-4d11-4f9a-8c2d-7e1b3a9f0c12",
"amount": 100,
"consumed": 35,
"allocation_type": "subscription",
"invoice_id": "0d9e5a0e-7de4-48c6-b01a-b1759394578b",
"order_id": null,
"order_number": null,
"valid_until": "2026-04-12T16:55:21.847Z",
"created_at": "2026-03-12T16:55:22.014Z",
"transactions": [
{
"id": "2e8c1a4f-9b73-4f1a-bd64-58a9d7c83ef0",
"amount": 10,
"quantity": 2,
"event_name": "image_generated",
"usage_event_id": "ue_01HXYZ123ABC",
"created_at": "2026-03-15T09:22:03.114Z"
},
{
"id": "9af2e7b1-8c3d-4d52-9b1a-23c7e4f60d21",
"amount": 25,
"quantity": 5,
"event_name": "image_generated",
"usage_event_id": "ue_01HXYZ456DEF",
"created_at": "2026-03-18T14:08:47.802Z"
}
]
},
"errors": {}
}{
"message": "<string>",
"errors": {}
}{
"message": "<string>",
"errors": {}
}Authorizations
Path Parameters
The unique credit allocation identifier
Response
Credit allocation fetched successfully
Example:
200
Example:
"Credit transactions fetched successfully"
A single credit allocation together with its full transaction history. Returned by
GET /api/v1/credit_systems/v2/credit-allocations/{id}. The allocation listing endpoint
does not embed transactions — fetch them via the wallet transactions endpoints instead.
Show child attributes
Show child attributes
⌘I

