# Swiss open data sources

Besides companies and geodata, Cormorant follows named public Swiss
sources: the approved health-insurance premiums and their rules from the
Federal Office of Public Health (BAG), the cantons' offices for premium
subsidies, the Federal Roads Office's open vehicle data and the geodata of
swisstopo and the federal offices. Each source has a stable id, its
publisher, how often it is checked and, for files, an edition per year.

These sources are in beta. Each keeps its publisher's terms of use, which
travel with every answer; Cormorant reports them and does not judge
whether your use is covered.

## The catalogue

```sh
curl -s -H "Authorization: Bearer $KEY" "https://api.cormorant.ch/v1/sources"
curl -s -H "Authorization: Bearer $KEY" "https://api.cormorant.ch/v1/sources/bag.okp.premiums"
```

Listing the catalogue and reading a source download nothing and are not
charged. `latest` in a source is the newest edition Cormorant holds.

## Editions

An edition is a source's file for one year:

```sh
curl -s -H "Authorization: Bearer $KEY" \
  "https://api.cormorant.ch/v1/sources/bag.okp.premiums/editions/2027"
# {"year": 2027, "sha256": "957fef82…", "bytes": 25832930,
#  "body_url": "https://api.cormorant.ch/v1/bodies/957fef82…", "terms": {…}, …}
```

Download the file from `body_url` with your key. The kept version answers
(`cached: true`) while it is current, so asking again is cheap; otherwise
the file is downloaded once and kept beside earlier versions. Earlier years
come from the publisher's yearly archive when it has one (`archive` names
it). A year that is not out yet answers `404 edition_not_published`.

When a publisher's site refuses the download, the kept version is returned
with `stale: true` and the site is left alone for a while
(`blocked_until`). Data already retrieved is never removed.

## Health insurance (BAG and priminfo)

The premiums, tariffs, premium regions and rules of the compulsory health
insurance, from the BAG's dataset on opendata.swiss and from
priminfo.admin.ch:

<!-- generated: sources-health -->
| `source_id` | What it is | Format | Checked |
| --- | --- | --- | --- |
| `bag.okp.dataset` | Dataset health-insurance-premiums with all its resources | CKAN | daily 15 Sept to 31 Dec, weekly otherwise |
| `bag.okp.premiums` | Approved premiums of the compulsory health insurance | CSV | with bag.okp.dataset |
| `bag.okp.tariffs` | Insurance models and child discount groups | CSV | with bag.okp.dataset |
| `bag.okp.areas` | Where each insurance model is offered | CSV | with bag.okp.dataset |
| `bag.okp.restricted_areas` | Insurers with a restricted area of activity | CSV | with bag.okp.dataset |
| `bag.okp.dictionary` | Data dictionary of the premium files | XLSX | with bag.okp.dataset |
| `bag.okp.change_notice` | Notice of new codes and changes to the file structure | PDF | with bag.okp.dataset |
| `priminfo.regions` | Municipality and postcode to premium region | XLSX | yearly, probed daily from 1 Sept |
| `priminfo.report_ch` | Full premium report, Switzerland | PDF | yearly |
| `priminfo.report_eu` | Premiums for insured persons living in the EU, EFTA or UK | PDF | yearly |
| `priminfo.posted_workers` | Guide for posted workers | PDF | yearly |
| `priminfo.mutations` | Mergers and changes of health insurers | PDF | yearly, weekly Sept to Dec |
| `priminfo.mean_premium` | Mean premiums | HTML | yearly |
| `bag.insurer_register` | Admitted health insurers with their BAG number | HTML with XLSX and PDF | monthly |
| `bag.model_categories` | Insurance model categories from 2027 | HTML | monthly |
| `bag.cost_sharing` | Premiums and cost sharing | HTML | monthly |
| `bag.subsidies` | Premium subsidies, federal overview | HTML | monthly |
| `bag.bonus` | Bonus insurance | HTML | monthly |
| `bag.daily_allowance` | Voluntary daily allowance insurance | HTML | yearly |
| `priminfo.faq` | Questions and answers | HTML | monthly |
| `priminfo.saving` | Ways to save | HTML | monthly |
<!-- /generated -->

## Premium subsidies of the cantons

One source per canton for the office in charge of the premium subsidy, with
the `canton` and the `language` of its address. Several addresses are the
office's home page: watch it for changes, or let a discovery find its
documents (see [Tables, versions and watches](/docs/tables-and-watches.md)).

<!-- generated: sources-subsidies -->
| `source_id` | What it is | Format | Checked |
| --- | --- | --- | --- |
| `canton.ag.subsidies` | Premium subsidy, canton AG | HTML | monthly |
| `canton.ai.subsidies` | Premium subsidy, canton AI | HTML | monthly |
| `canton.ar.subsidies` | Premium subsidy, canton AR | HTML | monthly |
| `canton.be.subsidies` | Premium subsidy, canton BE | HTML | monthly |
| `canton.bl.subsidies` | Premium subsidy, canton BL | HTML | monthly |
| `canton.bs.subsidies` | Premium subsidy, canton BS | HTML | monthly |
| `canton.fr.subsidies` | Premium subsidy, canton FR | HTML | monthly |
| `canton.ge.subsidies` | Premium subsidy, canton GE | HTML | monthly |
| `canton.gl.subsidies` | Premium subsidy, canton GL | HTML | monthly |
| `canton.gr.subsidies` | Premium subsidy, canton GR | HTML | monthly |
| `canton.ju.subsidies` | Premium subsidy, canton JU | HTML | monthly |
| `canton.lu.subsidies` | Premium subsidy, canton LU | HTML | monthly |
| `canton.ne.subsidies` | Premium subsidy, canton NE | HTML | monthly |
| `canton.nw.subsidies` | Premium subsidy, canton NW | HTML | monthly |
| `canton.ow.subsidies` | Premium subsidy, canton OW | HTML | monthly |
| `canton.sg.subsidies` | Premium subsidy, canton SG | HTML | monthly |
| `canton.sh.subsidies` | Premium subsidy, canton SH | HTML | monthly |
| `canton.so.subsidies` | Premium subsidy, canton SO | HTML | monthly |
| `canton.sz.subsidies` | Premium subsidy, canton SZ | HTML | monthly |
| `canton.tg.subsidies` | Premium subsidy, canton TG | HTML | monthly |
| `canton.ti.subsidies` | Premium subsidy, canton TI | HTML | monthly |
| `canton.ur.subsidies` | Premium subsidy, canton UR | HTML | monthly |
| `canton.vd.subsidies` | Premium subsidy, canton VD | HTML | monthly |
| `canton.vs.subsidies` | Premium subsidy, canton VS | HTML | monthly |
| `canton.zg.subsidies` | Premium subsidy, canton ZG | HTML | monthly |
| `canton.zh.subsidies` | Premium subsidy, canton ZH | HTML | monthly |
<!-- /generated -->

## Vehicles (ASTRA)

The Federal Roads Office's open vehicle data (type approvals, the vehicle
stock, new registrations) is a plain file directory. Read it folder by
folder:

<!-- generated: sources-vehicles -->
| `source_id` | What it is | Format | Checked |
| --- | --- | --- | --- |
| `astra.ivz` | Open vehicle data: type approvals, vehicle stock, new registrations | File directory | monthly |
<!-- /generated -->

```sh
curl -s -H "Authorization: Bearer $KEY" \
  "https://api.cormorant.ch/v1/catalogs/astra-ivz/files?path=3000-eDatenblatt/"
```

Each entry has its `url`; pass it to `POST /v1/fetch` with `mode: "raw"`
to download it. Sizes in the listing are rounded (`831M`): the download's
`bytes` is exact.

## opendata.swiss datasets

Any dataset of opendata.swiss resolves into its files, with the terms the
catalogue states for each file:

```sh
curl -s -H "Authorization: Bearer $KEY" \
  "https://api.cormorant.ch/v1/catalogs/opendata-swiss/datasets/health-insurance-premiums"
```

Terms differ per file, and the catalogue's `bytes_declared` is often wrong:
use the `sha256` and `bytes` of your download, and `modified` as the sign
that a file changed. Each call is one fetch, cached for five minutes.

## Geodata

The geodata sources (terrain, aerial photos, buildings, the landscape
model, noise, solar, the building register, OpenStreetMap) are in the same
catalogue. They have their own index of files per tile and their own
guide: [Swiss geodata](/docs/geodata.md). swisstopo's STAC API can also be read
directly with
`GET /v1/catalogs/geoadmin-stac/collections/{collection_id}/items`, one
fetch per call, for a collection the index does not hold.

## Before you build on a source

`GET /v1/sources/{source_id}/access` reports every address the source is
read from: what its robots.txt says for Cormorant, which routes may be
used, and the terms of use known for it. `GET /v1/access?url=…` does the
same for any address.

## Follow a source

A watch checks a source on a schedule and tells you when it changes, by
webhook or on a feed; versions and diffs say what changed. See
[Tables, versions and watches](/docs/tables-and-watches.md). Every field is in
the [API contract](/docs/api.md#source-catalogue-get-v1sources).
