Country filter

The /autocomplete endpoint allows limiting results to one or several countries. This is useful to avoid ambiguity and unexpected results when you know that all the addresses are located in a specific country.

For example, one highly relevant result for a global query Paris would be the capital of France. But if the end-user is only interested in address suggestions from Germany, your application can limit the results to Germany by specifying the parameter in=countryCode:DEU

Formulate the query like this:

GET https://autocomplete.search.hereapi.com/v1/
    autocomplete
    ?q=Paris
    &in=countryCode%3ADEU
    &limit=2

Authorization: Bearer [your token]

Note that this query includes the parameter limit=2 to limit number of the suggestions. The default limit for /autocomplete is 5. The maximum value for the limit parameter supported by /autocomplete is 20.

Since Paris is a city in France, it does not meet the country filter criteria. Instead the /autocomplete responds with address suggestions from Germany that contain token Paris for example in the street name or district name. One relevant suggestion may be Pariser Platz in Berlin:

{
  "items": [
    {
      "title": "Deutschland, Berlin, Pariser Platz",
      "id": "here:af:street:blZMmLnwtsYaXawaeHWfzC",
      "resultType": "street",
      "address": {
        "label": "Pariser Platz, 10117 Berlin, Deutschland",
        "countryCode": "DEU",
        "countryName": "Deutschland",
        "stateCode": "BE",
        "state": "Berlin",
        "countyCode": "B",
        "county": "Berlin",
        "city": "Berlin",
        "district": "Mitte",
        "street": "Pariser Platz",
        "postalCode": "10117"
      },
      "highlights": {
        "title": [
          {
            "start": 21,
            "end": 26
          }
        ],
        "address": {
          "label": [
            {
              "start": 0,
              "end": 5
            }
          ],
          "street": [
            {
              "start": 0,
              "end": 5
            }
          ]
        }
      }
    },
    {
      "title": "Deutschland, Berlin, Straße der Pariser Kommune",
      "id": "here:af:street:AfkQXa0XADEPA-WZxLPzmB",
      "resultType": "street",
      "address": {
        "label": "Straße der Pariser Kommune, 10243 Berlin, Deutschland",
        "countryCode": "DEU",
        "countryName": "Deutschland",
        "stateCode": "BE",
        "state": "Berlin",
        "countyCode": "B",
        "county": "Berlin",
        "city": "Berlin",
        "district": "Friedrichshain",
        "street": "Straße der Pariser Kommune",
        "postalCode": "10243"
      },
      "highlights": {
        "title": [
          {
            "start": 32,
            "end": 37
          }
        ],
        "address": {
          "label": [
            {
              "start": 11,
              "end": 16
            }
          ],
          "street": [
            {
              "start": 11,
              "end": 16
            }
          ]
        }
      }
    }
  ]
}

More details about /autocomplete parameters can be found in the API Reference.

results matching ""

    No results matching ""