GuidesAPI Reference
Guides

Get suggestions for a place using an incomplete category query

This tutorial demonstrates how to search for a place using an incomplete category query.

Procedure

A user searching for restaurants using an embedded application (in his car or on his cellphone) starts entering the text "restaurant." The application submits /autosuggest endpoint queries starting with the 3rd key stroke. For suggestions to a "res" partial query somewhere in Berlin, the call would appear as follows:

GET https://autosuggest.search.hereapi.com/v1/
    autosuggest
    ?at=39.31974,-76.56721
    &limit=5
    &q=rest
    &apiKey={YOUR_API_KEY}

The following parameters are used:

  • at - Specify the center of the search context expressed as coordinates.
  • limit - Maximum number of results to be returned.
  • lang - Select the language to be used for result rendering from a list of BCP 47 compliant language codes.
  • q - Enter a free-text query.
  • apiKey - Your API key.
📘

Note

This request uses API key authentication. For more information about authentication options on the HERE platform, see the Identity & Access Management Guide.

The response to the above request appears as follows:

{
  "items": [
    {
      "title": "Restaurant",
      "id": "here:cm:ontology:restaurant",
      "resultType": "categoryQuery",
      "href": "https://autosuggest.search.hereapi.com/v1/discover?at=39.31974%2C-76.56721&limit=5&q=Restaurant&_ontology=restaurant",
      "highlights": { "title": [{ "start": 0, "end": 4 }] }
    },
    {
      "title": "Rest stop",
      "id": "here:cm:ontology:rest_area",
      "resultType": "categoryQuery",
      "href": "https://autosuggest.search.hereapi.com/v1/discover?at=39.31974%2C-76.56721&limit=5&q=Rest+stop&_ontology=rest_area",
      "highlights": { "title": [{ "start": 0, "end": 4 }] }
    },
    {
      "title": "Restoration East",
      "id": "here:pds:place:840dqcx9-2f1561a4501b4cc0a49aa6611838b448",
      "resultType": "place",
      "address": { "label": "Restoration East, 4209 E Chase St, Baltimore, MD 21205-3020, United States" },
      "position": { "lat": 39.30398, "lng": -76.56193 },
      "access": [{ "lat": 39.30435, "lng": -76.56264 }],
      "distance": 1810,
      "categories": [{ "id": "700-7400-0000", "name": "Consumer Services", "primary": true }, { "id": "700-7200-0277", "name": "Specialty Trade Contractors" }],
      "highlights": { "title": [{ "start": 0, "end": 4 }], "address": { "label": [{ "start": 0, "end": 4 }] } }
    },
    {
      "title": "Rent Now (Rest for the Wicke)",
      "id": "here:pds:place:8403fv6k-b6fd543c49df01f3ae3981be17ed3412",
      "resultType": "place",
      "address": { "label": "Rent Now, 5229 Harford Rd, Baltimore, MD 21214-2622, United States" },
      "position": { "lat": 39.34978, "lng": -76.56321 },
      "access": [{ "lat": 39.34991, "lng": -76.56347 }],
      "distance": 3358,
      "categories": [{ "id": "700-7400-0145", "name": "Real Estate Services", "primary": true }, { "id": "600-6950-0000", "name": "Hair & Beauty" }, { "id": "700-7400-0000", "name": "Consumer Services" }],
      "highlights": { "title": [{ "start": 10, "end": 14 }], "address": { "label": [ ] } }
    },
    {
      "title": "Prorest Pest (Pro Rest Pest)",
      "id": "here:pds:place:840dqcxd-2a86850c1c34418f8023280a5f7baf62",
      "resultType": "place",
      "address": { "label": "Prorest Pest, 6600 Frankford Ave, Baltimore, MD 21206-4901, United States" },
      "position": { "lat": 39.31265, "lng": -76.54259 },
      "access": [{ "lat": 39.31285, "lng": -76.54273 }],
      "distance": 2260,
      "categories": [{ "id": "700-7200-0277", "name": "Specialty Trade Contractors", "primary": true }, { "id": "550-5520-0210", "name": "Wildlife Refuge" }, { "id": "700-7400-0000", "name": "Consumer Services" }],
      "references": [{ "supplier": { "id": "yelp" }, "id": "BY3MjxFzBwCl_OemyfJBKQ" }],
      "highlights": { "title": [{ "start": 3, "end": 7 }, { "start": 18, "end": 22 }], "address": { "label": [{ "start": 3, "end": 7 }] } }
    }
  ],
  "queryTerms": [ ]
}

The Autosuggest engine returns the category suggestion "Restaurants", along with a follow-up URI for the application to use if the user chooses the query suggestion.

This follow-up query will return restaurant places at the same user location.

Additionally, the suggestion engine returns a set of relevant restaurants.

Additional information

For more information about the /autosuggest endpoint parameters, see the API Reference.