Skip to main content

Autocomplete + Place Detail per Session

Reduce costs and improve user experience by providing place details per session with autocomplete.

In this guide, we will explore how to implement an autocomplete feature that provides place details per session. By utilizing the power of the autocomplete API, users will be able to search for places and retrieve detailed information about each result. Stay tuned for step-by-step instructions on how to integrate this functionality into your application!

tip

When using that, just use our Enterprise Dashboard or guild API Key to create your API Key try for free!

note

This feature requires a sessiontoken to be generated and passed along with each request.

Base URL

The base URL for all API requests is:
https://mapapis.openmap.vn/v1

Endpoint

GET /autocomplete

Example

Generate a UUID v4 session token: 576e6543-fbc8-422c-9aad-9884c97df128, keep it in your application's session.

You can generate a UUID v4 session token using UUID v4 Generator

Request:

GET /autocomplete?input=Lotte Mall Tây Hồ&sessiontoken=576e6543-fbc8-422c-9aad-9884c97df128

Response:

{
"predictions": [
{
"description": "Lotte Mall Tây Hồ, 272 Đường Võ Chí Công, phường Phú Thượng, quận Tây Hồ, thành phố Hà Nội",
"distance_meters": null,
"matched_substrings": [

],
"place_id": "aQA0KHmLGXVtbpFgpMqFfA0OjpRAAVFgTGaOYDTSgKXVbpiV-A6xZXkuPZgc",
"structured_formatting": {
"main_text": "Lotte Mall Tây Hồ",
"main_text_matched_substrings": [

],
"secondary_text": "272 Đường Võ Chí Công, phường Phú Thượng, quận Tây Hồ, thành phố Hà Nội",
"secondary_text_matched_substrings": [

]
},
"terms": [
{
"offset": 0,
"value": "Lotte Mall Tây Hồ"
},
{
"offset": 21,
"value": "272 Đường Võ Chí Công"
},
{
"offset": 51,
"value": "phường Phú Thượng"
},
{
"offset": 77,
"value": "quận Tây Hồ"
},
{
"offset": 95,
"value": "thành phố Hà Nội"
}
],
"types": [
"business_center"
]
}
],
"status": "OK"
}

Then, you can use the id field along with the sessiontoken parameter to get more details about the place (phone, website, opening hours..),

Request:

GET /place?ids=aQA0KHmLGXVtbpFgpMqFfA0OjpRAAVFgTGaOYDTSgKXVbpiV-A6xZXkuPZgc&sessiontoken=576e6543-fbc8-422c-9aad-9884c97df128&format=google

Response

{
"result": {
"address_components": [
{
"long_name": "Lotte Mall Tây Hồ",
"short_name": "Lotte Mall Tây Hồ"
},
{
"long_name": "272 Đường Võ Chí Công",
"short_name": "272 Đường Võ Chí Công"
},
{
"long_name": "phường Phú Thượng",
"short_name": "Phú Thượng"
},
{
"long_name": "quận Tây Hồ",
"short_name": "Tây Hồ"
},
{
"long_name": "thành phố Hà Nội",
"short_name": "Hà Nội"
}
],
"formatted_address": "Lotte Mall Tây Hồ, 272 Đường Võ Chí Công, phường Phú Thượng, quận Tây Hồ, thành phố Hà Nội",
"geometry": {
"location": {
"lat": 21.075951,
"lng": 105.812662
},
"viewport": null
},
"name": "Lotte Mall Tây Hồ",
"place_id": "aQA0KHmLGXVtbpFgpMqFfA0OjpRAAVFgTGaOYDTSgKXVbpiV-A6xZXkuPZgc",
"types": [
"business_center"
],
"url": "https://openmap.vn/place/aQA0KHmLGXVtbpFgpMqFfA0OjpRAAVFgTGaOYDTSgKXVbpiV-A6xZXkuPZgc"
},
"status": "OK"
}