---
url: https://docs.geo.admin.ch/access-data/search.md
---
# Search

Search for locations, layers or features using text or a bounding box.

::: tip The search service is separated in 3 categories or types:

* The **location search** which is composed of the following geocoded
  locations:
  * Cantons, Cities and communes
  * All names as printed on the national map
    ([SwissNames](https://www.swisstopo.admin.ch/en/geodata/landscape/names3d.html))
  * The districts
  * The ZIP codes
  * The addresses
  * The cadastral parcels
* The **layer search** wich enables the search of layers belonging to
  the GeoAdmin API.
* The **feature search** which is used to search through features
  descriptions. Note: you can also specify a bounding box to filter
  the features.

:::

## Request Details

To interact with the search service, you need to provide specific parameters in your request.
This endpoint only has query parameters that modify the behavior of the request, some are required and some are optional.

### Query Parameters

#### Location Search

| Parameters                         | Description                                                                                                                                                                                                                                                                                       |
| ---------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **searchText (required/optional)** | Must be provided if the `bbox` is not. The text to search for. Maximum of 10 words.                                                                                                                                                                                                               |
| **type (required)**                | The type of performed search. Specify `locations` to perform a location search.                                                                                                                                                                                                                   |
| **bbox (required/optional)**       | Must be provided if the `searchText` is not. A comma separated list of 4 coordinates representing the bounding box on which features should be filtered (SRID: 21781 or 2056).                                                                                                                    |
| **sortbbox (optional)**            | When `bbox` is specified and this parameter is "true", then the ranking of the results is performed according to the distance between the locations and the center of the bounding box. Default to "true".                                                                                        |
| **returnGeometry (optional)**      | This parameter defines whether the geometry is returned or not. Default to "true".                                                                                                                                                                                                                |
| **origins (optional)**             | A comma separated list of origins. Possible origins are: zipcode,gg25,district,kantone,gazetteer,address,parcel A description of the origins can be found hereunder. Per default all origins are used.                                                                                            |
| **limit (optional)**               | The maximum number of results to retrive per request (Max and default limit=50)                                                                                                                                                                                                                   |
| **sr (optional)**                  | The spatial reference. Supported values: 21781 (LV03), 2056 (LV95), 4326 (WGS84) and 3857 (Web Pseudo-Mercator). Defaults to "21781". When a *returnGeometry* is set, its coordiantes will be returned in this *sr*. When setting a *bbox*, its coordinates have to be in the corresponding *sr*. |
| **geometryFormat (optional)**      | Set to *geojson* if you want the service to return a GeoJSON `FeatureCollection`. Geometries will be returned in the *sr* projection.                                                                                                                                                             |
| **callback (optional)**            | The name of the callback function.                                                                                                                                                                                                                                                                |

#### Layer Search

| Parameters                    | Description                                                                                                                                                                                                                               |
| ----------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **searchText (required)**     | The text to search for. Maximum of 10 words allowed.                                                                                                                                                                                      |
| **type (required)**           | The type of performed search. Specify `layers` to perform a layer search.                                                                                                                                                                 |
| **lang (optional)**           | The language metadata. Supported values: de (default), fr, it, rm, en.                                                                                                                                                                    |
| **limit (optional)**          | The maximum number of results to retrive per request (Max and default limit=30)                                                                                                                                                           |
| **sr (optional)**             | The spatial reference. Supported values: 21781 (LV03), 2056 (LV95), 4326 (WGS84) and 3857 (Web Pseudo-Mercator). Defaults to "21781". When setting *geometryFormat* to *geosjon*, the coordinates are returned in the corresponding *sr*. |
| **geometryFormat (optional)** | Set to *geojson* if you want the service to return a GeoJSON `FeatureCollection`. Geometries will be returned in the *sr* projection.                                                                                                     |
| **callback (optional)**       | The name of the callback function.                                                                                                                                                                                                        |

#### Feature Search

| Parameters                    | Description                                                                                                                                                                                                |
| ----------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **searchText (required)**     | The text to search for (in features detail field). Maximum of 10 words allowed.                                                                                                                            |
| **type (required)**           | The type of performed search. Specify `featuresearch` to perform a feature search.                                                                                                                         |
| **bbox (optional)**           | A comma separated list of 4 coordinates representing the bounding box according to which features should be ordered (SRID: 21781 or 2056).                                                                 |
| **sortbbox (optional)**       | When `bbox` is specified and this parameter is "true", then the ranking of the results is performed according to the distance between the locations and the center of the bounding box. Default to "true". |
| **features (required)**       | A comma separated list of technical layer names.                                                                                                                                                           |
| **limit (optional)**          | The maximum number of results to retrive per request (Max and default limit=20)                                                                                                                            |
| **sr (optional)**             | The spatial reference. Supported values: 21781 (LV03) and 2056 (LV95) Defaults to "21781".                                                                                                                 |
| **geometryFormat (optional)** | Set to *geojson* if you want the service to return a GeoJSON `FeatureCollection`. Geometries will be returned in the *sr* projection.                                                                      |
| **callback (optional)**       | The name of the callback function.                                                                                                                                                                         |

## Response Details

The results are presented as a list of object literals.
Here is a description of the response's data.

| **Field** | **Description**                                                                                                                                                                                                                                                                                                                                                                                                                                                             |
| --------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `id`      | This is an internal value and therefore shouldn't be used.                                                                                                                                                                                                                                                                                                                                                                                                                  |
| `weight`  | The `weight` attribute represents the similarity between the search query and the index. **For location search**: `weight = 100` typically indicates exact matches, `weight < 100` indicates partial/wildcard matches, `weight > 1000` indicates fuzzy search results. Since the search engine combines multiple ranking methods, weight values should be used as general guidelines only. **Important**: Absolute weight values may change without backward compatibility. |

**Attributes:**

| **Field**       | **Description**                                                                                                                                                   |
| --------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `origin`        | This attribute refers to the type of data an entry stands for.                                                                                                    |
| `layerBodId`    | The ID of the associated layer (if any).                                                                                                                          |
| `featureId`     | If available, the object's ID can be combined with the `layerBodId` to collect more information about a feature.                                                  |
| `detail`        | The search field.                                                                                                                                                 |
| `rank`          | A different `rank` is associated to each origin. Results are always ordered in ascending ranks.                                                                   |
| `geom_st_box2d` | This attribute is in CH1903 / LV03 (EPSG:21781) reference system and represents the bounding box of the associated geometry.                                      |
| `num`           | This attribute is only valid for locations with `address` `origin`. It refers to the street number.                                                               |
| `x` and `y`     | These attributes represent the coordinates of an entry. If an object's entry is a line or a polygon, those coordinates will always be on the underlying geometry. |
| `label`         | The HTML label for an entry.                                                                                                                                      |

**Links (for address results):**

| **Field** | **Description**                                                                                                                       |
| --------- | ------------------------------------------------------------------------------------------------------------------------------------- |
| `links`   | An array of related resources for address search results. Each link contains:                                                         |
| `rel`     | The relationship type, typically "related".                                                                                           |
| `title`   | The layer ID of the related resource (e.g., "ch.swisstopo.amtliches-gebaeudeadressverzeichnis", "ch.bfs.gebaeude_wohnungs_register"). |
| `href`    | The URL path to access the related feature resource. The `<featureid>` placeholder contains the actual feature ID.                    |

::: tip
For address search results, it is recommended to use the `links` provided in the response to get additional feature information instead of constructing feature URLs manually. The links point to related resources such as the official building address directory and building/dwelling register.
:::

Here is a list of possible origins sorted in ascending ranking order:

* **zipcode** (ch.swisstopo-vd.ortschaftenverzeichnis_plz)
* **gg25** (ch.swisstopo.swissboundaries3d-gemeinde-flaeche.fill)
* **district** (ch.swisstopo.swissboundaries3d-bezirk-flaeche.fill)
* **kantone** (ch.swisstopo.swissboundaries3d-kanton-flaeche.fill)
* **gazetteer** (ch.swisstopo.swissnames3d, ch.bav.haltestellen-oev)
* **address** (ch.swisstopo.amtliches-gebaeudeadressverzeichnis with EGID or use prefix 'addresse', 'adresse', 'indirizzo', 'address' without EGID)
* **parcel** (use prefix "parcel", "parzelle", "parcelle" or "parcella" in your requests to filter out other origins)

Prefix filtering cannot be combined with parameter origins.

## Examples

Search for locations matching the word “wabern”:

Search for an address (note the `links` section containing related resources):

Search for locations of type "parcel" and "district" (the origins):

Search for locations within a given map extent the `bbox`:

* Search for layers in French matching the word “géoïde” in their description:

Search for features matching word "433" in their description:

Get a GeoJSON for locations matching the word “wabern”:

Get a Webmercator GeoJSON:

Input `bbox` may also be in `LV95`:

### Example of feature search usage with other services

First: search for addresses using the feature search service:

Then: use "feature_id" found in "attrs" to get detailed information about a feature:
