> ## Documentation Index
> Fetch the complete documentation index at: https://developer.plugchoice.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Get transaction energy

Returns what one charging session cost the location, with every quarter hour of the session. The cost comes from the energy contract in the location's [energy profile](https://developer.plugchoice.com/api-reference/site-energy-profile/get-energy-profile.md), always including delivery costs and VAT. Plugchoice calculates it once the session is final, and again when the session is corrected.

You need access to the location's charging data and Plugchoice Plus. Without Plus the answer is `403` with `reason` `plus_required`.

**transaction** `integer` *required*

The ID of the transaction.

## How the cost is calculated

* **Energy per quarter hour**: the energy the session was billed for, split over its quarter hours by the charger's meter readings. Without readings the energy is split evenly and `estimated` is `true`.
* **Fixed or variable contract**: the price per kWh, or the off-peak price within the off-peak hours, in the location's own time.
* **Dynamic contract in the Netherlands**: the day-ahead price including energy tax and VAT, plus the supplier's markup.
* **Dynamic contract elsewhere**: (day-ahead price + energy tax) x (1 + VAT), plus the supplier's markup. This needs the energy tax of the country; without it there is no cost.
* **Solar energy** counts at the feed-in price of the contract, or 0 without one. Grid energy counts at the quarter hour's price.

## Solar share and CO2

* **Solar share**: `solar_kwh` is the solar energy of the session, from the charger's solar samples, and at most `kwh`. When that is not known, `solar_share` is null with `not_available`. A home battery does not change that.
* **Quarter hours**: that solar energy is split by the solar power in the session's samples in each quarter hour, scaled so the quarters add up to `solar_kwh`. Without samples, or when those samples cannot be read, it is split in proportion to the energy of each quarter hour. The rest of each quarter hour is grid energy.
* **CO2**: the grid energy of each quarter hour times the CO2 per kWh of the country's electricity in that hour, from the ENTSO-E generation mix and life cycle emission factors per fuel.
* **CO2 avoided**: the distance the energy covers (at `consumption_kwh_per_km` of the [energy summary](https://developer.plugchoice.com/api-reference/energy/get-site-energy-summary.md)) times what an average petrol car emits per km, including producing its fuel, minus `co2_g`.

A session keeps the contract it was first priced with, so changing the contract later does not change it.

## Response

**data** `object`

**data**

**transaction\_id** `integer`

The ID of the transaction.

**status** `string`

`computed`, or `pending` when there is no calculation yet. A pending answer only has `transaction_id`, `status` and `decided`.

**decided** `boolean`

Only when `status` is `pending`: whether the session is final. A final session gets its calculation within a few minutes.

**started\_at** `string`

When the session started, as an ISO 8601 UTC timestamp.

**stopped\_at** `string`

When the session stopped, as an ISO 8601 UTC timestamp.

**kwh** `number`

The energy of the session in kWh.

**grid\_kwh** `number`

The part from the grid, in kWh.

**solar\_kwh** `number`

The part from solar panels, in kWh.

**cost** `number`

What the session cost, in `currency`, or `null` with the reason in `null_reason`.

**currency** `string`

`EUR`, `GBP` for a location in the United Kingdom, or `null` without a cost.

**solar\_share** `number`

The part of the energy from solar panels, from 0 to 1, or `null` with the reason in `solar_share_null_reason`.

**co2\_g** `number`

The CO2 of the grid energy in grams, or `null` with the reason in `co2_null_reason`.

**co2\_avoided\_g** `number`

The CO2 in grams a petrol car would have emitted over the same distance, minus `co2_g`, or `null`.

**null\_reason** `string`

Why `cost` is `null`: `contract_incomplete` (ask the user to finish the energy contract), `tax_rates_missing`, `prices_missing` or `no_location`. `null` when there is a cost.

**solar\_share\_null\_reason** `string`

Why `solar_share` is `null`: `not_available` (the solar energy of the session is not known) or `no_location`. A summary from before this calculation may still say `home_battery` until it is recalculated.

**co2\_null\_reason** `string`

Why `co2_g` is `null`: `intensity_missing` (no grid mix for the country and one of the session's hours; the United Kingdom has none) or `no_location`. A summary from before this calculation may still say `not_available` until it is recalculated.

**estimated** `boolean`

Whether the split over the quarter hours is an estimate because the charger sent no meter readings.

**method\_version** `integer`

The version of the calculation. A new version recalculates every session.

**computed\_at** `string`

When the session was calculated, as an ISO 8601 UTC timestamp.

**intervals** `array`

The quarter hours of the session, oldest first.

**interval object**

**start** `string`

The start of the quarter hour, as an ISO 8601 UTC timestamp.

**kwh** `number`

The energy in the quarter hour, in kWh.

**grid\_kwh** `number`

The part from the grid, in kWh.

**solar\_kwh** `number`

The part from solar panels, in kWh.

**price\_per\_kwh** `number`

The grid price per kWh, or `null` without a cost.

**cost** `number`

The cost of the quarter hour, or `null` without a cost.

**co2\_g** `number`

The CO2 of the grid energy in grams, or `null`.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.