# Response format

> Search and reverse return the same flat format. Every result is a Place with a ready-made label, address parts and coordinates.

Source: https://findort.ch/en/docs/response/

## Envelope

```json
  "results": [ { "id": "…", "label": "…" } ],
  "attribution": "© OpenStreetMap contributors, ODbL"
}
```

| Field | Type | Description |
|---|---|---|
| `results` | list of Place | Matches, best first. May be empty. |
| `attribution` | text | Data source notice. Show it wherever you show results, see [attribution](#attribution). |

## Place

| Field | Type | Description |
|---|---|---|
| `id` | text | OpenStreetMap type and ID: `N` for node, `W` for way, `R` for relation, for example `W254958900`. Usually stable, but it can change when someone remodels the data. Official Swiss addresses have `CHA` or `LIA` plus the federal address ID (EGAID), for example `CHA101002312`; this ID is permanent. |
| `label` | text | Ready-made one-line label for display, like `Bundesplatz 3, 3011 Bern` |
| `name` | text | Name of the place. For addresses without a name, "street housenumber". |
| `type` | text | One of the [types](#types) |
| `category` | text | OpenStreetMap feature as `key:value`, see [category](#category) |
| `address` | object | Address parts, see [address](#address) |
| `location` | object | `{ "lat": 46.94649, "lon": 7.44433 }`, rounded to six decimals (about 10 cm) |
| `bbox` | list, optional | Extent as `[minLon, minLat, maxLon, maxLat]`. Only for places with an area, such as buildings, streets or cities. |

Fields without a value are left out instead of being `null`. Check for presence.

## Address

| Field | Example | Description |
|---|---|---|
| `street` | `Bundesplatz` | Street |
| `housenumber` | `3` | House number, as text (there are `12a` and `3-5`) |
| `postcode` | `3011` | Postal code, as text |
| `locality` | `Wankdorf` | Neighbourhood, hamlet or named area |
| `district` | `Stadtteil I` | City district |
| `city` | `Bern` | City, town or municipality |
| `county` | `Verwaltungskreis Bern-Mittelland` | County, administrative district |
| `state` | `Bern` | Canton, state, region |
| `country` | `Switzerland` | Country, in the language from `lang` |
| `countryCode` | `CH` | ISO 3166 code, always upper case |

## Types

`type` has exactly one of these values. The `types` parameter takes the same values.

| Type | What | How `label` is built |
|---|---|---|
| `address` | Building or entrance with a house number and no name of its own | Street No, Postcode City |
| `poi` | Named place: shop, restaurant, stop, named building | Name, Street No, Postcode City |
| `street` | Street, path, square | Name, Postcode City |
| `locality` | Neighbourhood, hamlet, named area | Name, City, State |
| `district` | City district | Name, City, State |
| `city` | City, town, village | Name, State, Country |
| `county` | County, district | Name, Country |
| `state` | Canton, state | Name, Country |
| `country` | Country | Name |

Missing parts are left out of the label. Repeated parts (such as the city and canton of Bern) appear only once.

## Category

`category` is the place's main OpenStreetMap feature in the form `key:value`. Examples:

| Category | Meaning |
|---|---|
| `place:house` | Address without further details |
| `building:yes` | Building |
| `amenity:restaurant` | Restaurant |
| `shop:bakery` | Bakery |
| `tourism:attraction` | Attraction |
| `highway:residential` | Residential street |
| `public_transport:station` | Station, stop |
| `place:city` | City |
| `boundary:administrative` | Administrative boundary (municipality, canton, country) |

The list is open, there are hundreds of values. Their meaning is documented in the [OpenStreetMap wiki](https://wiki.openstreetmap.org/wiki/Map_features). If Findort knows nothing more specific, the value is `place:yes`.

## Coordinates and bbox

- `location` is a point in the WGS 84 coordinate system, as used by GPS and every web map.
- Mind the order: `location` is an object with `lat` and `lon`. `bbox` is a list and starts with the longitude: `[minLon, minLat, maxLon, maxLat]`. That is the same order as the `bbox` parameter and GeoJSON.
- Many map libraries want bounds as `[[minLat, minLon], [maxLat, maxLon]]`. Swap the values accordingly.

## Attribution

The data comes from OpenStreetMap and is licensed under the [Open Database License (ODbL)](https://www.openstreetmap.org/copyright). Wherever you show results, the notice "© OpenStreetMap contributors" must be visible, ideally as a link to `https://www.openstreetmap.org/copyright`.

Addresses in Switzerland and Liechtenstein come from the official building address register by swisstopo. When such an address is included, `attribution` also contains «Gebäudeadressen © swisstopo».

The Web Component already shows the notice in its suggestion list. If you build your own interface, use the text from `attribution`. More in [limits](https://findort.ch/en/docs/limits/#attribution).
