Calculate API Endpoint
Calculate electricity costs based on specific consumption data
The /calculate/
endpoint processes consumption data to provide detailed cost calculations based on specified tariffs and time periods. This endpoint is ideal for applications that need to determine costs for actual or estimated electricity usage, such as EV charging cost calculations or energy usage analysis.
Endpoint Overview
This endpoint accepts consumption data with timestamps and usage amounts, calculates costs using the specified tariffs, and returns detailed or summarized cost information.
Data Flow Diagram
Key Parameters
Country code (e.g., DK
, SE
) for the location.
Array of tariff IDs to apply for cost calculations. Each tariff ID must include the tar_
prefix (e.g., tar_123
).
Array of consumption entries, each with a timestamp and consumed amount:
Location address to determine applicable pricing. Required if coordinates are not provided.
Latitude coordinate of the location. Required if address is not provided.
Longitude coordinate of the location. Required if address is not provided.
Time resolution for calculations. Options: 60min
, 30min
, or 15min
. All consumption timestamps must align with the chosen interval.
Types of price components to include in the calculation (e.g., PER_KWH
, FIXED
, TAX
).
Level of detail in the response:
summarized
: Only total costsemi
: Costs aggregated by organization typefull
: Complete breakdown of all price components
How to handle VAT in the response:
excluded
: Prices exclude VATincluded
: VAT included in each price componentseparated
: VAT shown as separate components
Location Specification
The Calculate endpoint follows the same location specification pattern as other Prezio endpoints:
- You must provide either an
address
or thelatitude
/longitude
coordinates, but not both. - The provided location is used to determine which tariffs are applicable in that geographic area.
- For improved accuracy, prefer using an address with postal code when possible.
- The endpoint will return a confidence score (1-10) for the location resolution.
Time Window Constraint
The time window between the earliest and latest intervals in the kwh_consumed
array must not exceed 48 hours. Requests violating this constraint will return an error.
Example Requests
Response Structure
The response returns both total cost and interval-by-interval breakdown of electricity costs:
Detail Levels
Full Detail
Returns all price components individually with metadata about each component, ideal for detailed cost analysis.
Semi Detail
Aggregates costs by organization type (DSO, Retailer, etc.), providing a simplified but still informative breakdown.
Summarized
Returns only the total cost for the entire consumption period, useful when only the bottom line matters.
VAT Handling
Control how Value Added Tax is represented in the response:
Best Practices
Provide consumption data aligned with the specified time_span
. For example, if time_span
is 60min
, ensure timestamps are on the hour (e.g., 14:00:00
). Misaligned timestamps will result in errors.
Ensure the total time window for consumption data does not exceed 48 hours between the earliest and latest timestamps. Exceeding this limit will trigger a validation error.
Use the detail
parameter to control response size. If you only need total costs, use detail=summarized
to minimize response payload size.
Common Use Cases
EV Charging Cost Calculation
Calculate the exact cost of charging sessions for electric vehicles based on actual consumption data.
Home Energy Billing
Determine costs for home energy usage over specific periods for billing or reimbursement purposes.
Energy Usage Analysis
Analyze cost breakdowns by component to understand the impact of different tariff elements on total expenses.
Fleet Management
Compute aggregated costs for EV fleets, supporting expense tracking and optimization.
Error Handling
The Calculate endpoint may return specific errors for invalid inputs:
- 400 Bad Request: Invalid or misaligned timestamps, missing required fields, or time window exceeding 48 hours.
- 401 Unauthorized: Missing or invalid API key.
- 404 Not Found: Specified tariffs are not applicable for the given location.
- 422 Validation Error: Consumption data format issues or unsupported
time_span
values.
Ensure your application handles these errors gracefully and provides meaningful feedback to users.