Blog ·API guides ·

Swiss address autocomplete and validation with an API

Add autocomplete of Switzerland's 3.3 million official addresses to your forms and check that an address exists, with two API calls.

Altius Group · EN FR DE IT

Picturesque residential street scene in Aarau, Switzerland featuring historic architecture under a clear sky.
Thomas P / Pexels

A mistyped address is expensive: returned parcels, invoices that never arrive, duplicate customers in the CRM. In Switzerland the reference is the official directory of building addresses published by swisstopo: 3.3 million addresses, each with a federal identifier. The raw file is 470 MB and uses Swiss coordinates (LV95). Our API makes it usable in a single request.

1. Get a key

Create a free OpenData | Altius Group account: your API key is shown in your dashboard. Each request sends it in the Authorization header.

2. Autocomplete while typing

From 3 characters, the API returns up to 10 addresses. Every word typed must appear in the street, number, postcode or locality, in any order.

curl -H "Authorization: Token YOUR_KEY" \
  "https://opendata.altius-group.ch/geodata/addresses/api/v1/addresses/autocomplete/?q=echallens 6 froideville"
{"results": [{"full_address": "Route d'Echallens 6, 1055 Froideville",
              "zip_code": "1055", "locality": "Froideville", "canton": "VD",
              "latitude": 46.6003595, "longitude": 6.6735308}]}

Call the URL from your server (so the key is not exposed in the browser) and wait 200 ms between keystrokes.

3. Validate an entered address

For a completed form, the validate call tells you whether the address exists and otherwise suggests the closest ones in the same postcode:

curl -H "Authorization: Token YOUR_KEY" \
  "https://opendata.altius-group.ch/geodata/addresses/api/v1/addresses/validate/?street=Route de Echallens&number=6&zip_code=1055"

The answer contains "valid": false and, first, the suggestion Route d'Echallens 6, 1055 Froideville. Offer the correction instead of rejecting the form.

4. What you also get

  • The building ID (EGID), linking the address to the Federal Register of Buildings and Dwellings.
  • GPS coordinates, for a map or a distance calculation.
  • The building category (residential or not).

Quotas

The free plan allows 100 requests per day, enough to test and prototype. For a form in production, a paid plan lifts these limits. The data is updated weekly from swisstopo.

Addresses on the website · Plans and pricing

All articles
Buy us a coffee Explore the data