Skip to content

Search

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

https://api3.geo.admin.ch/rest/services/ech/SearchServer

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)
    • 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

ParametersDescription
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.
ParametersDescription
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.
ParametersDescription
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.

FieldDescription
idThis is an internal value and therefore shouldn't be used.
weightThe 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:

FieldDescription
originThis attribute refers to the type of data an entry stands for.
layerBodIdThe ID of the associated layer (if any).
featureIdIf available, the object's ID can be combined with the layerBodId to collect more information about a feature.
detailThe search field.
rankA different rank is associated to each origin. Results are always ordered in ascending ranks.
geom_st_box2dThis attribute is in CH1903 / LV03 (EPSG:21781) reference system and represents the bounding box of the associated geometry.
numThis attribute is only valid for locations with address origin. It refers to the street number.
x and yThese 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.
labelThe HTML label for an entry.

Links (for address results):

FieldDescription
linksAn array of related resources for address search results. Each link contains:
relThe relationship type, typically "related".
titleThe layer ID of the related resource (e.g., "ch.swisstopo.amtliches-gebaeudeadressverzeichnis", "ch.bfs.gebaeude_wohnungs_register").
hrefThe 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”:

Request
Response
sh
$ curl https://api3.geo.admin.ch/rest/services/ech/SearchServer?searchText=wabern&type=locations

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

Request
Response
sh
$ curl https://api3.geo.admin.ch/rest/services/ech/SearchServer?searchText=Landstrasse%208595%20Altnau&type=locations

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

Request
Response
sh
$ curl https://api3.geo.admin.ch/rest/services/ech/SearchServer?searchText=bern&origins=parcel,district&type=locations

Search for locations within a given map extent the bbox:

Request
Response
sh
$ curl https://api3.geo.admin.ch/rest/services/ech/SearchServer?bbox=551306.5625,167918.328125,551754.125,168514.625&type=locations
  • Search for layers in French matching the word “géoïde” in their description:
Request
Response
sh
$ curl https://api3.geo.admin.ch/rest/services/ech/SearchServer?searchText=géoïde&type=layers&lang=fr

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

Request
Response
sh
$ curl https://api3.geo.admin.ch/rest/services/ech/SearchServer?features=ch.bafu.hydrologie-gewaesserzustandsmessstationen&type=featuresearch&searchText=433

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

Request
Response
sh
$ curl https://api3.geo.admin.ch/rest/services/ech/SearchServer?searchText=wabern&type=locations&geometryFormat=geojson

Get a Webmercator GeoJSON:

Request
Response
sh
$ curl https://api3.geo.admin.ch/rest/services/ech/SearchServer?searchText=wabern&type=locations&geometryFormat=geojson

Input bbox may also be in LV95:

Request
Response
sh
$ curl https://api3.geo.admin.ch/rest/services/ech/SearchServer?bbox=2551306.5625,1167918.328125,2551754.125,1168514.625&type=locations&sr=2056

Example of feature search usage with other services

First: search for addresses using the feature search service:

Request
Response
sh
$ curl https://api3.geo.admin.ch/rest/services/ech/SearchServer?features=ch.bfs.gebaeude_wohnungs_register&type=featuresearch&searchText=isabelle

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

Request
Response
sh
$ curl https://api3.geo.admin.ch/rest/services/ech/MapServer/ch.bfs.gebaeude_wohnungs_register/880711_0?returnGeometry=false