Search
GET /v1/search finds addresses, streets and places for a search text. Built for autocomplete, so half words and typos are fine.
Request
HTTP
GET https://api.findort.ch/v1/search?q=Bundesplatz 3 Bern&country=ch&lang=en&limit=2
Authorization: Bearer pk_…Encode values in the URL (spaces as %20). The libraries do that for you.
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
q | text, required | Search text, at most 250 characters. Half words like Bahnhofstr 1 Zür are fine. | |
limit | number | 5 | Number of results, 1 to 20. Decimals are rounded. |
lang | text | local language | de, fr, it or en. Only the first two characters count, so en-GB works too. Other languages are ignored and names come in the local language. |
country | list | all countries | Two-letter ISO 3166 codes, comma separated: ch or ch,li. Case does not matter. |
near | lat,lon | Prefers results near this coordinate without excluding others. Latitude -90 to 90, longitude -180 to 180. | |
bbox | minLon,minLat,maxLon,maxLat | Strictly limits results to this rectangle. Longitude first, then latitude. | |
types | list | all types | Only these types, comma separated: address, street, poi, locality, city, district, county, state, country. See types. |
key | text | API key, if you cannot send an Authorization header. |
An invalid value leads to 400 invalid_request with a message naming the parameter, for example limit must be a number between 1 and 20.
Example
Shell
curl "https://api.findort.ch/v1/search?q=Bundesplatz%203%20Bern&country=ch&lang=en&limit=2" \
-H "Authorization: Bearer sk_…"JSON
{
"results": [
{
"id": "W254958900",
"label": "Bundeshaus - Parlamentsgebäude, Bundesplatz 3, 3011 Bern",
"name": "Bundeshaus - Parlamentsgebäude",
"type": "poi",
"category": "office:government",
"address": {
"street": "Bundesplatz",
"housenumber": "3",
"postcode": "3011",
"district": "Stadtteil I",
"city": "Bern",
"state": "Bern",
"country": "Switzerland",
"countryCode": "CH"
},
"location": { "lat": 46.94649, "lon": 7.44433 },
"bbox": [7.44366, 46.94618, 7.44477, 46.94682]
},
{
"id": "W26990913",
"label": "Bundesplatz, 3011 Bern",
"name": "Bundesplatz",
"type": "street",
"category": "highway:pedestrian",
"address": {
"street": "Bundesplatz",
"postcode": "3011",
"city": "Bern",
"state": "Bern",
"country": "Switzerland",
"countryCode": "CH"
},
"location": { "lat": 46.94677, "lon": 7.44409 },
"bbox": [7.44343, 46.94651, 7.44482, 46.94702]
}
],
"attribution": "© OpenStreetMap contributors, ODbL"
}The values are an example, IDs and coordinates change with the data. Every field is explained in response format. If nothing matches, results is an empty list and the status is still 200.
Narrowing down results
- One country only:
country=ch. For Switzerland and Liechtensteincountry=ch,li. - Addresses only, for a delivery form:
types=address. Buildings with a name of their own (like "Bundeshaus") arepoi, even with a house number. To get both, usetypes=address,poi. - Towns only, for a "city" field:
types=city,locality. - Nearby first:
near=46.95,7.44, for example with the location of your shop. - One region only:
bbox=7.29,46.90,7.50,47.00cuts off everything outside.
Behaviour
- Results are ordered by relevance, best first.
- Streets that consist of several pieces in OpenStreetMap appear only once.
- Findort answers identical requests from its cache. Responses carry
Cache-Control: private, max-age=60, so the browser may reuse them for a minute. - If the search index does not answer within 8 seconds, you get
502 upstream_error.