Zum Inhalt

Einführung

Die rastr API bietet programmatischen Zugriff auf deutsche Geokodierungs- und Demografiedaten. Verwende sie, um Adressen in Koordinaten umzuwandeln, Bevölkerungsstatistiken von Destatis abzurufen und API-Schlüssel für deine Anwendungen zu verwalten.

API-Endpunkte

4

Geokodierung mit integrierten Demografiedaten

Regionale Abdeckung

Germany

Nur Deutschland

Protokoll

REST

JSON über HTTPS

Authentifizierung

Alle API-Endpunkte erfordern eine Authentifizierung. Du kannst dich entweder mit einem Bearer-JWT-Token (über Login erhalten) oder mit einem API-Schlüssel authentifizieren, der im X-Api-Key-Header übergeben wird. API-Schlüssel werden für den programmatischen Zugriff und serverseitige Integrationen empfohlen.

API-Schlüssel-Authentifizierung

Füge deinen API-Schlüssel in den X-Api-Key-Header jeder Anfrage ein. Du kannst API-Schlüssel in deinem Dashboard erstellen und verwalten.

cURL-Beispiel

Bash
curl -X GET "https://api.locationreport.com/geocode/location/52.524705,13.3932623" \
  -H "X-Api-Key: your_api_key_here"

JavaScript-Beispiel

JavaScript
const response = await fetch(
  "https://api.locationreport.com/geocode/location/52.524705,13.3932623",
  {
    headers: {
      "X-Api-Key": "your_api_key_here",
    },
  }
);
const data = await response.json();

Halte deine API-Schlüssel sicher. Gib diese niemals in clientseitigem Code oder öffentlichen Repositorys preis. Rotiere Schlüssel regelmäßig, wenn du vermutest, dass sie kompromittiert wurden.

Geokodierung

GET/geocode/address/{address}
GeocodingBoth

Accepts a text address in the path and returns coordinates with formatted address. Returns best match only. DE region only. Optional 'year' and 'quarter' query params select a specific dataset period. When 'fields=census' is set, the response includes a 'fields.census' object with population, age bands, marital status, average household size, and the resolved grid cell's corner coordinates, sourced from Destatis. 'dataSource' is 'census' or 'estimated' and 'effectiveQuarter' is 0-4 (both null when no dataset version resolves for the requested period). 'granularity' is a string: unknown, rooftop, rangeInterpolated, geometricCenter, approximate.

Parameters

NameTypeInRequiredDescription
addressstringpathRequiredFull address text (e.g. "71 Oranienburger Straße, 10117 Berlin")
fieldsstringqueryOptionalComma-separated list of enrichment fields (e.g. "census")
yearintegerqueryOptionalDataset year to query (default: latest available).
quarterintegerqueryOptionalDataset quarter: 0 for the annual/census snapshot, 1-4 for a specific quarter (default: latest available for the given year).
languagestringqueryOptionalLanguage of the returned address text: "de" or "en". Defaults to "de".

Response

JSON
{
  "results": [
    {
      "location": {
        "latitude": 52.524705,
        "longitude": 13.3932623
      },
      "granularity": "rooftop",
      "formattedAddress": "Oranienburger Str. 71, 10117 Berlin, Germany",
      "addressComponents": [
        {
          "types": [
            "street_number"
          ],
          "longText": "71",
          "shortText": "71",
          "languageCode": "de"
        },
        {
          "types": [
            "route"
          ],
          "longText": "Oranienburger Straße",
          "shortText": "Oranienburger Str.",
          "languageCode": "de"
        },
        {
          "types": [
            "postal_code"
          ],
          "longText": "10117",
          "shortText": "10117",
          "languageCode": "de"
        },
        {
          "types": [
            "locality"
          ],
          "longText": "Berlin",
          "shortText": "Berlin",
          "languageCode": "de"
        },
        {
          "types": [
            "country"
          ],
          "longText": "Germany",
          "shortText": "DE",
          "languageCode": "de"
        }
      ],
      "types": [
        "street_address"
      ],
      "fields": {
        "census": {
          "population": 3421,
          "datasetYear": 2022,
          "dataSource": "census",
          "effectiveQuarter": 0,
          "ageUnder10": 210,
          "age10To19": 260,
          "age20To29": 480,
          "age30To39": 610,
          "age40To49": 540,
          "age50To59": 470,
          "age60To69": 390,
          "age70To79": 300,
          "age80AndOver": 161,
          "single": 1850,
          "married": 1120,
          "widowed": 240,
          "divorced": 211,
          "averageHouseholdSize": 1.8,
          "cellBounds": {
            "southWest": {
              "latitude": 52.5241,
              "longitude": 13.3925
            },
            "southEast": {
              "latitude": 52.5241,
              "longitude": 13.3941
            },
            "northEast": {
              "latitude": 52.5253,
              "longitude": 13.3941
            },
            "northWest": {
              "latitude": 52.5253,
              "longitude": 13.3925
            }
          }
        }
      }
    }
  ]
}

cURL Example

Bash
curl -X GET "https://api.locationreport.com/geocode/address/71%20Oranienburger%20Stra%C3%9Fe%2C%2010117%20Berlin?fields=census" \
  -H "X-Api-Key: your_api_key"
GET/geocode/address
GeocodingBoth

Accepts a text address or structured fields in the query and returns coordinates. Returns best match only. DE region only. Optional 'year' and 'quarter' query params select a specific dataset period. When 'fields=census' is set, the response includes a 'fields.census' object with population, age bands, marital status, average household size, and the resolved grid cell's corner coordinates, sourced from Destatis. 'dataSource' is 'census' or 'estimated' and 'effectiveQuarter' is 0-4 (both null when no dataset version resolves for the requested period). 'granularity' is a string: unknown, rooftop, rangeInterpolated, geometricCenter, approximate.

Parameters

NameTypeInRequiredDescription
streetstringqueryOptionalStreet name
houseNumberstringqueryOptionalHouse / building number
postalCodestringqueryOptionalPostal code (PLZ)
citystringqueryOptionalCity name
countrystringqueryOptionalCountry name or code (default: DE)
fieldsstringqueryOptionalComma-separated enrichment fields (e.g. "census")
yearintegerqueryOptionalDataset year to query (default: latest available).
quarterintegerqueryOptionalDataset quarter: 0 for the annual/census snapshot, 1-4 for a specific quarter (default: latest available for the given year).
languagestringqueryOptionalLanguage of the returned address text: "de" or "en". Defaults to "de".

Response

JSON
{
  "results": [
    {
      "location": {
        "latitude": 52.524705,
        "longitude": 13.3932623
      },
      "granularity": "rooftop",
      "formattedAddress": "Oranienburger Str. 71, 10117 Berlin, Germany",
      "addressComponents": [],
      "types": [
        "street_address"
      ],
      "fields": {
        "census": {
          "population": 3421,
          "datasetYear": 2022,
          "dataSource": "census",
          "effectiveQuarter": 0,
          "ageUnder10": 210,
          "age10To19": 260,
          "age20To29": 480,
          "age30To39": 610,
          "age40To49": 540,
          "age50To59": 470,
          "age60To69": 390,
          "age70To79": 300,
          "age80AndOver": 161,
          "single": 1850,
          "married": 1120,
          "widowed": 240,
          "divorced": 211,
          "averageHouseholdSize": 1.8,
          "cellBounds": {
            "southWest": {
              "latitude": 52.5241,
              "longitude": 13.3925
            },
            "southEast": {
              "latitude": 52.5241,
              "longitude": 13.3941
            },
            "northEast": {
              "latitude": 52.5253,
              "longitude": 13.3941
            },
            "northWest": {
              "latitude": 52.5253,
              "longitude": 13.3925
            }
          }
        }
      }
    }
  ]
}

cURL Example

Bash
curl -X GET "https://api.locationreport.com/geocode/address?street=Oranienburger%20Stra%C3%9Fe&houseNumber=71&postalCode=10117&city=Berlin&fields=census" \
  -H "X-Api-Key: your_api_key"
GET/geocode/location/{latitude},{longitude}
GeocodingBoth

Accepts latitude/longitude in the path and returns formatted address with structured breakdown. DE region only. Optional 'year' and 'quarter' query params select a specific dataset period. When 'fields=census' is set, the response includes a 'fields.census' object with population, age bands, marital status, average household size, and the resolved grid cell's corner coordinates, sourced from Destatis. 'dataSource' is 'census' or 'estimated' and 'effectiveQuarter' is 0-4 (both null when no dataset version resolves for the requested period). 'granularity' is a string: unknown, rooftop, rangeInterpolated, geometricCenter, approximate.

Parameters

NameTypeInRequiredDescription
latitudenumberpathRequiredWGS84 latitude (e.g. 52.524705)
longitudenumberpathRequiredWGS84 longitude (e.g. 13.3932623)
fieldsstringqueryOptionalComma-separated enrichment fields (e.g. "census")
yearintegerqueryOptionalDataset year to query (default: latest available).
quarterintegerqueryOptionalDataset quarter: 0 for the annual/census snapshot, 1-4 for a specific quarter (default: latest available for the given year).
languagestringqueryOptionalLanguage of the returned address text: "de" or "en". Defaults to "de".

Response

JSON
{
  "results": [
    {
      "location": {
        "latitude": 52.524705,
        "longitude": 13.3932623
      },
      "granularity": "rooftop",
      "formattedAddress": "Oranienburger Str. 71, 10117 Berlin, Germany",
      "addressComponents": [],
      "types": [
        "street_address"
      ],
      "fields": {
        "census": {
          "population": 3421,
          "datasetYear": 2022,
          "dataSource": "census",
          "effectiveQuarter": 0,
          "ageUnder10": 210,
          "age10To19": 260,
          "age20To29": 480,
          "age30To39": 610,
          "age40To49": 540,
          "age50To59": 470,
          "age60To69": 390,
          "age70To79": 300,
          "age80AndOver": 161,
          "single": 1850,
          "married": 1120,
          "widowed": 240,
          "divorced": 211,
          "averageHouseholdSize": 1.8,
          "cellBounds": {
            "southWest": {
              "latitude": 52.5241,
              "longitude": 13.3925
            },
            "southEast": {
              "latitude": 52.5241,
              "longitude": 13.3941
            },
            "northEast": {
              "latitude": 52.5253,
              "longitude": 13.3941
            },
            "northWest": {
              "latitude": 52.5253,
              "longitude": 13.3925
            }
          }
        }
      }
    }
  ]
}

cURL Example

Bash
curl -X GET "https://api.locationreport.com/geocode/location/52.524705,13.3932623?fields=census" \
  -H "X-Api-Key: your_api_key"
GET/geocode/location
GeocodingBoth

Accepts latitude/longitude as query parameters and returns formatted address with structured breakdown. DE region only. Optional 'year' and 'quarter' query params select a specific dataset period. When 'fields=census' is set, the response includes a 'fields.census' object with population, age bands, marital status, average household size, and the resolved grid cell's corner coordinates, sourced from Destatis. 'dataSource' is 'census' or 'estimated' and 'effectiveQuarter' is 0-4 (both null when no dataset version resolves for the requested period). 'granularity' is a string: unknown, rooftop, rangeInterpolated, geometricCenter, approximate.

Parameters

NameTypeInRequiredDescription
latitudenumberqueryRequiredWGS84 latitude
longitudenumberqueryRequiredWGS84 longitude
fieldsstringqueryOptionalComma-separated enrichment fields (e.g. "census")
yearintegerqueryOptionalDataset year to query (default: latest available).
quarterintegerqueryOptionalDataset quarter: 0 for the annual/census snapshot, 1-4 for a specific quarter (default: latest available for the given year).
languagestringqueryOptionalLanguage of the returned address text: "de" or "en". Defaults to "de".

Response

JSON
{
  "results": [
    {
      "location": {
        "latitude": 52.524705,
        "longitude": 13.3932623
      },
      "granularity": "rooftop",
      "formattedAddress": "Oranienburger Str. 71, 10117 Berlin, Germany",
      "addressComponents": [],
      "types": [
        "street_address"
      ],
      "fields": {
        "census": {
          "population": 3421,
          "datasetYear": 2022,
          "dataSource": "census",
          "effectiveQuarter": 0,
          "ageUnder10": 210,
          "age10To19": 260,
          "age20To29": 480,
          "age30To39": 610,
          "age40To49": 540,
          "age50To59": 470,
          "age60To69": 390,
          "age70To79": 300,
          "age80AndOver": 161,
          "single": 1850,
          "married": 1120,
          "widowed": 240,
          "divorced": 211,
          "averageHouseholdSize": 1.8,
          "cellBounds": {
            "southWest": {
              "latitude": 52.5241,
              "longitude": 13.3925
            },
            "southEast": {
              "latitude": 52.5241,
              "longitude": 13.3941
            },
            "northEast": {
              "latitude": 52.5253,
              "longitude": 13.3941
            },
            "northWest": {
              "latitude": 52.5253,
              "longitude": 13.3925
            }
          }
        }
      }
    }
  ]
}

cURL Example

Bash
curl -X GET "https://api.locationreport.com/geocode/location?latitude=52.524705&longitude=13.3932623&fields=census" \
  -H "X-Api-Key: your_api_key"

Migration von der Google Maps Geocoding API

Wenn du derzeit die Google Maps Geocoding API verwendest, ist die Migration zur rastr API unkompliziert. Nachfolgend findest du einen direkten Vergleich, der dir hilft, die Unterschiede zu verstehen und deine Migration zu planen.

DimensionGoogle Maps Geocoding APIrastr API
Endpunkt-StrukturRESTful-Endpunkt mit Query-Parametern (address=, key=, language=, usw.)RESTful-Endpunkt mit Pfadparametern (/geocode/address/{address}) und X-Api-Key-Header
AuthentifizierungURL-Parameter (key=IHR_API_SCHLÜSSEL)HTTP-Header (X-Api-Key: IHR_API_SCHLÜSSEL)
AntwortformatVerschachteltes JSON mit geometry.bounds, geometry.location, address_components-ArraysFlaches JSON mit latitude, longitude, formattedAddress sowie Demografiedaten
PreismodellNutzungsbasierte Abrechnung (5 $ pro 1.000 Anfragen), Volumenrabatte verfügbarPrepaid-Guthaben oder Abo-Pläne mit planbaren monatlichen Kosten
RatenbegrenzungenVariabel nach Tarif (50 QPS Standard, 100+ QPS Premium)Tarifbasierte Ratenbegrenzungen mit Burst-Toleranz
Regionale AbdeckungWeltweite Abdeckung, ~200 LänderAusschließlich Deutschland mit zensus-genauen Destatis-Daten
DemografiedatenKeine integrierten Demografiedaten — separate API oder Datenquelle erforderlichIntegrierte Bevölkerungs-, Altersverteilungs- und Haushaltsdaten aus Destatis Zensus 2022 und Schätzungen bis 2026

Code-Migrationsbeispiel

Das folgende Beispiel zeigt, wie du eine einfache Forward-Geokodierungsanfrage von Google Maps zu rastr migrierst. Die Hauptunterschiede liegen in der URL-Struktur, dem Authentifizierungs-Header und dem flacheren Antwortformat.

VorherGoogle Maps Geocoding API
JavaScript
const API_KEY = "YOUR_GOOGLE_API_KEY";
const address = "Oranienburger Straße 71, Berlin";

const response = await fetch(
  `https://maps.googleapis.com/maps/api/geocode/json?` +
  `address=${encodeURIComponent(address)}&key=${API_KEY}`
);
const data = await response.json();

// Extract coordinates from nested response
const lat = data.results[0].geometry.location.lat;
const lng = data.results[0].geometry.location.lng;
Nachherrastr API
JavaScript
const API_KEY = "YOUR_LR_API_KEY";
const address = "Oranienburger Straße 71, Berlin";

const response = await fetch(
  `https://api.locationreport.com/geocode/address/` +
  `${encodeURIComponent(address)}`,
  {
    headers: { "X-Api-Key": API_KEY }
  }
);
const data = await response.json();

// Flat response with coordinates + demographics
const { latitude, longitude } = data;

Wesentliche Unterschiede

  • Authentifizierung über HTTP-Header statt URL-Parameter — dein API-Schlüssel wird niemals in Server-Logs oder Browserverlauf sichtbar.
  • Flache Antwortstruktur — kein Navigieren durch verschachtelte geometry.location-Objekte nötig.
  • Demografische Daten - Bevölkerungsstatistiken, Altersverteilung und Haushaltsdaten - können bei jeder Geokodierungsanfrage hinzugefügt werden.
  • Deutschland-optimierte Ergebnisse — höhere Genauigkeit für deutsche Adressen mit Destatis-Datenanreicherung, die nirgendwo anders verfügbar ist.

Fehlt ein Endpunkt oder Feld, das hier nicht steht?

Sag uns, was fehlt — wir lesen jede Anfrage.

Anfordern