Skip to content

GET /autocomplete API

  • Geocoding

Provide type-ahead suggestions for user-entered text.

Optimised for low-latency, prefix-matching queries. Supports the same geographic focus and filtering controls as `/search`.
Parameters
NameInTypeRequiredDescription
textquerystringYesFree-form text to geocode.
sizequeryintegerNoNumber of results to return. Values above 40 are coerced to 40.
focus.point.latquerynumberNoLatitude used to bias results toward a focus point.
focus.point.lonquerynumberNoLongitude used to bias results toward a focus point.
boundary.rect.min_latquerynumberNoSouthern latitude of the rectangular bounding box.
boundary.rect.min_lonquerynumberNoWestern longitude of the rectangular bounding box.
boundary.rect.max_latquerynumberNoNorthern latitude of the rectangular bounding box.
boundary.rect.max_lonquerynumberNoEastern longitude of the rectangular bounding box.
boundary.circle.latquerynumberNoLatitude for the center of the circular boundary filter.
boundary.circle.lonquerynumberNoLongitude for the center of the circular boundary filter.
boundary.circle.radiusquerynumberNoRadius in kilometers for circular boundary filtering. Defaults to 50 for search and autocomplete, and 1 for reverse. Reverse queries cap the value at 5 km.
boundary.countryquerystringNoRestrict results to ISO-3166 alpha-2 or alpha-3 country codes. Provide a comma separated list for multiple countries.
boundary.gidquerystringNoPelias global identifier used to restrict results to a parent geography.
sourcesqueryarrayNoComma separated list of data sources to include.
layersqueryarrayNoComma separated list of record layers to include in the response.
  • textqueryRequired
    Typestring

    Free-form text to geocode.

  • sizequeryOptional
    Typeinteger

    Number of results to return. Values above 40 are coerced to 40.

  • focus.point.latqueryOptional
    Typenumber

    Latitude used to bias results toward a focus point.

  • focus.point.lonqueryOptional
    Typenumber

    Longitude used to bias results toward a focus point.

  • boundary.rect.min_latqueryOptional
    Typenumber

    Southern latitude of the rectangular bounding box.

  • boundary.rect.min_lonqueryOptional
    Typenumber

    Western longitude of the rectangular bounding box.

  • boundary.rect.max_latqueryOptional
    Typenumber

    Northern latitude of the rectangular bounding box.

  • boundary.rect.max_lonqueryOptional
    Typenumber

    Eastern longitude of the rectangular bounding box.

  • boundary.circle.latqueryOptional
    Typenumber

    Latitude for the center of the circular boundary filter.

  • boundary.circle.lonqueryOptional
    Typenumber

    Longitude for the center of the circular boundary filter.

  • boundary.circle.radiusqueryOptional
    Typenumber

    Radius in kilometers for circular boundary filtering. Defaults to 50 for search and autocomplete, and 1 for reverse. Reverse queries cap the value at 5 km.

  • boundary.countryqueryOptional
    Typestring

    Restrict results to ISO-3166 alpha-2 or alpha-3 country codes. Provide a comma separated list for multiple countries.

  • boundary.gidqueryOptional
    Typestring

    Pelias global identifier used to restrict results to a parent geography.

  • sourcesqueryOptional
    Typearray

    Comma separated list of data sources to include.

  • layersqueryOptional
    Typearray

    Comma separated list of record layers to include in the response.

Sample responses
  • 200 Success — Successful autocomplete response.

    application/jsonGeoJSONFeatureCollection

    {
    "type": "FeatureCollection",
    "geocoding": {
    "version": "1.0.0",
    "timestamp": "2024-03-18T12:36:02Z",
    "engine": {
    "name": "pelias",
    "author": "geobridge",
    "version": "2.14.0"
    },
    "query": {
    "text": "hard rock",
    "size": 5,
    "focus.point.lat": 52.5,
    "focus.point.lon": 13.3
    }
    },
    "features": [
    {
    "type": "Feature",
    "geometry": {
    "type": "Point",
    "coordinates": [
    13.32787,
    52.50641
    ]
    },
    "properties": {
    "id": "8735031043",
    "gid": "openstreetmap:venue:node/8735031043",
    "layer": "venue",
    "source": "openstreetmap",
    "source_id": "node/8735031043",
    "name": "Hard Rock Cafe Berlin",
    "label": "Hard Rock Cafe Berlin, Charlottenburg-Wilmersdorf, Berlin, Germany",
    "confidence": 0.87,
    "accuracy": "point",
    "continent": "Europe",
    "country": "Germany",
    "country_a": "DEU",
    "region": "Berlin",
    "locality": "Berlin",
    "neighbourhood": "Charlottenburg"
    }
    }
    ]
    }

    Prefix suggestions around Berlin.

  • 400 Client error — Invalid input parameters supplied.

    application/jsonGeoJSONFeatureCollection

    {
    "type": "FeatureCollection",
    "geocoding": {
    "version": "1.0.0",
    "timestamp": "2024-03-18T12:36:02Z",
    "query": {},
    "errors": [
    {
    "code": "MISSING_QUERY",
    "message": "text parameter is required for autocomplete."
    }
    ]
    },
    "features": []
    }

    Missing `text` parameter for autocomplete.

  • 408 Client error — Upstream search engine timeout.

    application/jsonGeoJSONFeatureCollection

    {
    "type": "FeatureCollection",
    "geocoding": {
    "version": "1.0.0",
    "query": {
    "text": "hard rock",
    "size": 5
    },
    "errors": [
    {
    "code": "TIMEOUT",
    "message": "Autocomplete request exceeded the 750 ms timeout."
    }
    ],
    "warnings": [
    {
    "code": "RETRY_REQUEST",
    "message": "Retry shortly or reduce the requested size."
    }
    ]
    },
    "features": []
    }

    Autocomplete timeout due to high load.

  • 500 Server error — Unexpected server error.

    application/jsonGeoJSONFeatureCollection

    {
    "type": "FeatureCollection",
    "geocoding": {
    "version": "1.0.0",
    "query": {
    "text": "hard rock"
    },
    "errors": [
    {
    "code": "INTERNAL_SERVER_ERROR",
    "message": "Unexpected error while generating suggestions."
    }
    ]
    },
    "features": []
    }

    Example payload for an autocomplete failure.

Code samples

200 OK

Terminal window
# 200 OK — Type-ahead query biased around Berlin.
curl -s -G 'https://api-na.geobridge.io/v1/autocomplete' \
-H 'Accept: application/json' \
-H 'X-API-Key: YOUR_API_KEY' \
--data-urlencode 'text=hard rock' \
--data-urlencode 'focus.point.lat=52.5' \
--data-urlencode 'focus.point.lon=13.3' \
--data-urlencode 'size=5'

400 Bad Request

Terminal window
# 400 Bad Request — Missing text parameter triggers validation error.
curl -s -G 'https://api-na.geobridge.io/v1/autocomplete' \
-H 'Accept: application/json' \
-H 'X-API-Key: YOUR_API_KEY' \
--data-urlencode 'size=5'

408 Request Timeout

Terminal window
# 408 Request Timeout — Illustrates timeout handling for autocomplete.
curl -s -G 'https://api-na.geobridge.io/v1/autocomplete' \
-H 'Accept: application/json' \
-H 'X-API-Key: YOUR_API_KEY' \
--data-urlencode 'text=union' \
--data-urlencode 'size=5'

500 Internal Server Error

Terminal window
# 500 Internal Server Error — Handles unexpected server error responses for autocomplete.
curl -s -G 'https://api-na.geobridge.io/v1/autocomplete' \
-H 'Accept: application/json' \
-H 'X-API-Key: YOUR_API_KEY' \
--data-urlencode 'text=union' \
--data-urlencode 'size=5'
Try it live

Save your API key once and reuse it across endpoints. Configure the request below and send it directly from the docs.

Stored locally in your browser. Removing it clears access for this device.

Query parameters

Free-form text to geocode.

Number of results to return. Values above 40 are coerced to 40.

Latitude used to bias results toward a focus point.

Longitude used to bias results toward a focus point.

Southern latitude of the rectangular bounding box.

Western longitude of the rectangular bounding box.

Northern latitude of the rectangular bounding box.

Eastern longitude of the rectangular bounding box.

Latitude for the center of the circular boundary filter.

Longitude for the center of the circular boundary filter.

Radius in kilometers for circular boundary filtering. Defaults to 50 for search and autocomplete, and 1 for reverse. Reverse queries cap the value at 5 km.

Restrict results to ISO-3166 alpha-2 or alpha-3 country codes. Provide a comma separated list for multiple countries.

Pelias global identifier used to restrict results to a parent geography.

Comma separated list of data sources to include.

Comma separated list of record layers to include in the response.

Configure the request and select “Send request” to preview the response.