Geocoding API
Geocoding handles full addresses, places, coordinates, approximate IP locations, and timezones. Use the Address API for country and administrative-area pickers. Use these endpoints when a consumer needs street or building suggestions or coordinates.
All routes require x-app-id and x-api-key application credentials. For forward, reverse, and full-address autocomplete, the default route queries the self-hosted OSM dataset first and falls back to Photon when the local dataset is unavailable, not seeded yet, or its query fails. A successful local search against an imported dataset with no matches returns an empty data.results array. Photon requests can take up to 10 seconds before timing out. The x-provider-key header can select self-hosted, photon-komoot, maplibre, or geoapify; it selects a provider and is not a BYOK secret. maplibre is an alias for Photon. The old spelling x-provide-key is still accepted. IP and timezone continue to use Geoapify by default.
Forward, reverse, and full-address autocomplete share a default quota of 60 requests per consuming app per rolling minute. IP and timezone each have a separate default of 30 requests per minute. See the rate-limiting guide for optional overrides and deployment behavior.
Postman setup
Create environment variables for baseUrl (http://localhost:8000), appId (registered application slug), and apiKey (application credential). Add x-app-id: {{appId}} and x-api-key: {{apiKey}} to each protected request. Requests without x-provider-key use the default provider routing. To force one provider, use x-provider-key: self-hosted, x-provider-key: photon-komoot, x-provider-key: maplibre, or x-provider-key: geoapify. Server-side Geoapify calls require the existing GEOAPIFY_API_KEY setting; x-provider-key never contains that secret. Set PHOTON_BASE_URL only when pointing to another Photon endpoint.
Endpoints
| Method and path | Query parameters | Purpose |
|---|---|---|
GET /geocoding/forward |
q, optional countryCode, limit |
Address/place to coordinates |
GET /geocoding/reverse |
lat, lon, optional limit |
Coordinates to nearby addresses/places |
GET /geocoding/address-autocomplete |
q, optional countryCode, limit |
Full street/building suggestions |
GET /geocoding/ip |
Required ip |
Approximate IPv4/IPv6 location |
GET /geocoding/timezone |
lat, lon, optional at |
Timezone, local time, offset, next change |
All success responses use { "provider": "...", "data": ..., "raw_response_provider": ... }. data is the normalized result. raw_response_provider contains the selected provider’s parsed source data for transparency. Forward, reverse, and autocomplete return data.results; missing scalar values are null, and a successful search with no matches returns []. Forward and autocomplete accept 2–200 and 3–200 characters respectively. Search limits are 1–10, default 5. Reverse limit defaults to 1 and searches within 250 meters in the self-hosted provider. Coordinates must be in their geographic ranges. The timezone at value must be RFC 3339 with an explicit offset or Z, within 2025-01-01 to 2031-12-31 UTC as supported by Geoapify.
The self-hosted provider searches imported names, address tags, and supported OSM features. It preserves the original OSM geometry and tags in PostGIS, ranks text matches with PostgreSQL pg_trgm, and uses imported country boundaries to resolve country codes when available. Its coordinates are source points or a representative point on the feature geometry; it does not invent house-number interpolation.
cURL examples
Default routing: self-hosted first, Photon fallback if local data is unavailable.
curl --get 'http://localhost:8000/geocoding/forward' \
--header 'x-app-id: postman' --header 'x-api-key: <credential-id>.<secret>' \
--data-urlencode 'q=38 Upper Montagu Street, Westminster, London' \
--data-urlencode 'countryCode=GB' --data-urlencode 'limit=5'
curl --get 'http://localhost:8000/geocoding/reverse' \
--header 'x-app-id: postman' --header 'x-api-key: <credential-id>.<secret>' \
--data-urlencode 'lat=51.5138' --data-urlencode 'lon=-0.1436'
curl --get 'http://localhost:8000/geocoding/address-autocomplete' \
--header 'x-app-id: postman' --header 'x-api-key: <credential-id>.<secret>' \
--data-urlencode 'q=38 Upper Montagu' --data-urlencode 'countryCode=GB'
To force the self-hosted dataset and avoid the online fallback, add:
--header 'x-provider-key: self-hosted'
Explicit Photon example:
curl --get 'http://localhost:8000/geocoding/forward' \
--header 'x-app-id: postman' --header 'x-api-key: <credential-id>.<secret>' \
--header 'x-provider-key: photon-komoot' \
--data-urlencode 'q=Quezon City' --data-urlencode 'countryCode=PH'
curl --get 'http://localhost:8000/geocoding/ip' \
--header 'x-app-id: postman' --header 'x-api-key: <credential-id>.<secret>' \
--header 'x-provider-key: geoapify' \
--data-urlencode 'ip=129.6.15.28'
curl --get 'http://localhost:8000/geocoding/timezone' \
--header 'x-app-id: postman' --header 'x-api-key: <credential-id>.<secret>' \
--header 'x-provider-key: geoapify' \
--data-urlencode 'lat=40.758' --data-urlencode 'lon=-73.9855' \
--data-urlencode 'at=2027-01-15T14:00:00Z'
Standard response shape
{
"provider": "self-hosted",
"raw_response_provider": {
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"id": "N/123456789",
"geometry": { "type": "Point", "coordinates": [120.9842, 14.5995] },
"properties": {
"osm_type": "N",
"osm_id": "123456789",
"name": "Example Place",
"class": "poi",
"type": "cafe",
"tags": { "name": "Example Place", "amenity": "cafe" },
"source_import": { "sha256": "<file-sha256>", "file_name": "philippines-latest.osm.pbf", "imported_at": "2026-12-03T00:00:00Z" }
}
}
]
},
"data": {
"results": [
{
"name": "Example Place",
"formattedAddress": "Example Place, Manila, Philippines",
"latitude": 14.5995,
"longitude": 120.9842,
"address": {
"houseNumber": null,
"street": null,
"district": null,
"city": "Manila",
"county": null,
"state": null,
"postcode": null,
"country": "Philippines",
"countryCode": "PH"
},
"match": { "rank": 1, "confidence": 1, "level": "cafe", "coordinateMethod": "exact" }
}
]
}
}
match.confidence is null when a provider supplies no score. Self-hosted text matches use PostgreSQL trigram similarity as a ranking score. match.coordinateMethod is exact for an OSM point and null for non-point geometries. The engine does not currently interpolate missing house numbers.
IP responses include nullable ip, country, countryCode, region, city, latitude, and longitude. IP location is approximate and fields can be absent. Timezone responses include latitude, longitude, at, nullable tzdbVersion, and a timezones array. Each timezone has nullable offset and local-time fields and a nullable nextTransition. Transition offsets are expressed in seconds and may change by other than one hour.
Self-hosted dataset setup
For the Windows PostgreSQL, PostGIS, and osm2pgsql setup, import commands, and additive import behavior, see the self-hosted geocoding guide or open its /self-hosting page in the web app.
The seed command imports PBF files from imports/ with osm2pgsql Flex. Existing (osm_type, osm_id) rows are kept as-is; overlapping extracts only add unseen OSM objects. A new snapshot does not update or delete existing objects. An exact file checksum is skipped on rerun.
Provider fallback and errors
For address operations without a provider header, a usable local query is always returned, including an empty result. Photon is called only when the local dataset is unconfigured, unavailable, or a local query fails. Explicit x-provider-key: self-hosted uses local PostGIS only. An explicit Geoapify address request keeps the existing transient-error fallback to Photon; a missing or rejected Geoapify key is returned directly. IP and timezone require a working Geoapify key. Photon is a public fair-use demo service and may throttle requests or be unavailable. Photon public API terms
The main stable errors are GEOCODING_UNAVAILABLE (no configured provider answered), GEOCODING_TIMEOUT (a provider did not respond in time), PROVIDER_KEY_MISSING, PROVIDER_KEY_INVALID, UNKNOWN_PROVIDER, PROVIDER_DEFERRED, PROVIDER_FEATURE_UNAVAILABLE, PROVIDER_RATE_LIMITED, and PROVIDER_INVALID_RESPONSE. Technical details are logged by the service and are not returned to API consumers.
Consumer workflow and attribution
Use /address/countries, country area types, area browsing, and the existing Address autocomplete for the administrative picker. When the user wants to complete a street/building address, call /geocoding/address-autocomplete. Save the selected formatted address and coordinates returned in the standard result.
Display the required provider and OpenStreetMap attribution where geocoding results are presented. Geoapify usage also requires Geoapify attribution. OpenStreetMap attribution · Geoapify terms