Fetch Consumptions
Retrieve monthly and yearly consumption totals for the authenticated user. Returns aggregated billing data from all transactions and data transfers.
POST
https://api-v3.sweeppea.com/billing/consumptions
Description
This endpoint retrieves all historical consumption data for the authenticated user, aggregated by year and month. It calculates the total amount charged from both billing transactions and data transfer logs, providing a comprehensive view of account spending over time.
Authentication
This endpoint requires Bearer token authentication via the Authorization header.
Code Examples
curl -X POST "https://api-v3.sweeppea.com/billing/consumptions" \
-H "Authorization: Bearer uuid-v4-string" \
-H "Content-Type: application/json"
const response = await fetch('https://api-v3.sweeppea.com/billing/consumptions', {
method: 'POST',
headers: {
'Authorization': 'Bearer uuid-v4-string',
'Content-Type': 'application/json'
}
});
const data = await response.json();
console.log(data);
import requests
url = "https://api-v3.sweeppea.com/billing/consumptions"
headers = {
"Authorization": "Bearer uuid-v4-string",
"Content-Type": "application/json"
}
response = requests.post(url, headers=headers)
print(response.json())
Response
{
"Response": true,
"Data": {
"GrandTotal": 115776.91,
"Consumptions": [
{
"Year": 2026,
"Total": 813.69,
"Months": [
{
"Month": 1,
"Total": 813.69
}
]
},
{
"Year": 2025,
"Total": 47585.10,
"Months": [
{
"Month": 1,
"Total": 2543.00
},
{
"Month": 2,
"Total": 599.00
}
]
}
]
}
}
Response Fields
| Field | Type | Description |
|---|---|---|
GrandTotal |
Number | Total amount charged across all years and months |
Consumptions |
Array | Array of yearly consumption data |
Year |
Number | Calendar year |
Total |
Number | Total amount for the year or month |
Months |
Array | Array of monthly consumption data within the year |
Month |
Number | Month number (1-12) |
Error Responses
{
"Response": false,
"Message": "Missing or invalid Bearer token. Send your API token in the Authorization header as: Authorization: Bearer YOUR_API_TOKEN",
"Code": 401
}
{
"Response": false,
"Message": "Invalid API token. It does not match any account.",
"Code": 403
}
{
"Response": false,
"Message": "Internal server error. Please try again; if it persists, contact support with the time of this request.",
"Code": 500
}