> ## Documentation Index
> Fetch the complete documentation index at: https://docs.tariffs.nlead.ch/llms.txt
> Use this file to discover all available pages before exploring further.

# Take the whole dataset

> One request for every tariff, in CSV or newline-delimited JSON.

If you want more than a handful of operators, do not loop over
`/api/v1/dsos/{dso_id}/tariffs`. There is a bulk endpoint, it is not paginated,
and it streams.

```bash theme={null}
curl "$TARIFF_API/api/v1/tariffs/export?format=jsonl&period=2026&feedin=false" \
  -o tariffs-2026.jsonl
```

12,910 rows for 2026 consumption tariffs, one JSON object per line.

| Parameter | | |
| - | - | - |
| `format` | `csv` (default) or `jsonl` | |
| `period` | optional | Tariff year. Omit for every year. |
| `feedin` | optional | `true` for feed-in only, `false` for consumption only. Omit for both. |

## Columns

```
id, vse_number, dso_name, stage, period, voltage_level, tariff_name,
tariff_type, tariff_form, start_date, end_date, customer_type, is_feedin,
base_chf_m, energy_min, energy_max, n_energy_windows, power_chf_kw_m,
has_dynamic, valid_kwh_min, valid_kwh_max, is_eco, comment, source_file
```

> [!WARNING]
>
> The export contains **every stage**, unfiltered. That is the point of a bulk
> export, but it means the same tariff can appear more than once — a machine-read
> version and a reviewer-validated one. Deduplicate before you aggregate, or your
> averages will be wrong.

## Deduplicating properly

Reduce to one row per tariff identity, keeping the highest stage:

```python theme={null}
import json

STAGE_RANK = {"tarif_validiert": 5, "pipeline_korrigiert": 4,
              "API_validiert": 3, "pipeline": 2, "ungeprüft": 1, "ki": 0}

best = {}
for line in open("tariffs-2026.jsonl"):
    t = json.loads(line)
    key = (t["vse_number"], t["period"], t["voltage_level"],
           t["tariff_type"], t["tariff_name"])
    cur = best.get(key)
    if cur is None or STAGE_RANK.get(t["stage"], -1) > STAGE_RANK.get(cur["stage"], -1):
        best[key] = t

tariffs = list(best.values())
```

> [!NOTE]
>
> Key on the **tariff**, not on the operator. Taking one best stage per operator
> drops an operator's machine-read NE3 tariff because its NE7 tariffs happen to be
> validated — a mistake that is easy to make and hard to notice.

## Joining to operators and geometry

The export carries `vse_number`. To get ElCom operator ids, names and the
operators' own source URLs:

```bash theme={null}
curl "$TARIFF_API/api/v1/dsos" -o dsos.json
```

`elcom_operator_id` is the join key to the GeoJSON in
`/api/geo/dso_areas`, whose features carry `operator_id`.

> [!WARNING]
>
> Not every VSE-registered operator has an ElCom operator id, so not every tariff
> can be placed on the map. Filter on a non-null `elcom_operator_id` rather than
> assuming the join is total — 502 of 553 operators had both for 2026.

## Other whole-dataset endpoints

| Endpoint | |
| - | - |
| `/api/v1/feedin?period=2026` | Every feed-in tariff, with the full structured matrix where the operator publishes one. |
| `/api/v1/national-charges?period=2026` | The federal charges, identical for every operator. |
| `/api/v1/elcom/{dso_id}` | ElCom's own published series from 2011, for cross-checking. |
| `/api/v1/dsos/{dso_id}/tariffsheet` | One operator's sheet reconstructed in the official VSE submission format. |
| `/api/v1/qa/pdf-crosscheck` | Where a PDF and the machine-readable file disagree, per operator. |

## Please cache it

The export is regenerated only when the collection pipeline runs — daily at
most, and for a closed tariff year, effectively never. Pulling it hourly costs
you nothing and everyone else something.

> [!NOTE]
>
> This endpoint streams and is therefore the one public read **without** an
> `ETag` — holding the whole dataset in memory to hash it would defeat the reason
> it streams. Cache it on your side by tariff year. Everywhere else, send the
> `ETag` back as `If-None-Match` and get a `304` with no body. See [Caching and
> limits](https://docs.tariffs.nlead.ch/limits.md).


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