Searches for keywords and returns a list of relevant places.
Endpoint
https://maps.track-asia.com/api/v2/place/textsearch/{outputFormat}
outputFormat
outputFormat | Description |
---|---|
json (recommended) | indicates output in JavaScript Object Notation (JSON) |
xml | indicates output in XML |
Parameters
Parameter | Values | Short Description | Example |
---|---|---|---|
query | String (required) | Must be a place name, address, or category (e.g., cafe, hospital, ATM...) | Landmark 81, 720A Dien Bien Phu, Thanh My Tay Ward, Ho Chi Minh City |
radius | Number | Search radius (meters) to limit the result area | 5000 |
key | String (required) | API key | public_key |
new_admin | Boolean | Return address according to new administrative boundaries | true |
include_old_admin | Boolean | (Use with new_admin) Return both new and old addresses | true |
Example Usage
Example 1: Return new administrative address
https://maps.track-asia.com/api/v2/place/textsearch/json?language=en&key=public_key&query=Landmark 81, 720A Dien Bien Phu, Thanh My Tay Ward, Ho Chi Minh City&new_admin=true
Example 2: Return both new and old addresses
https://maps.track-asia.com/api/v2/place/textsearch/json?language=en&key=public_key&query=Landmark 81, 720A Dien Bien Phu, Thanh My Tay Ward, Ho Chi Minh City&new_admin=true&include_old_admin=true
curl -G "https://maps.track-asia.com/api/v2/place/textsearch/json" \
--data-urlencode "language=en" \
--data-urlencode "key=public_key" \
--data-urlencode "query=Landmark 81, 720A Dien Bien Phu, Thanh My Tay Ward, Ho Chi Minh City" \
--data-urlencode "new_admin=true" \
--data-urlencode "include_old_admin=true"
Response
JSON Response
The response is a JSON object with the following structure:
plus_code
: Object withglobal_code
(and possiblycompound_code
).status
: Status string (e.g., "OK").results
: Array of result objects. Each object includes:place_id
: Unique identifier for the place.name
: Name of the place.formatted_address
: Full formatted address.address_components
: Array of objects with:long_name
: Full name of the address component.short_name
: Abbreviated or short name.types
: Array of types, e.g.,street_number
,route
,administrative_area_level_1
, etc.
geometry
: Object describing location info, including:location
: Geographic coordinates withlat
andlng
.location_type
: Type of location (e.g., "ROOFTOP").viewport
: Suggested viewport bounds, withnortheast
andsouthwest
.
plus_code
: Object withcompound_code
andglobal_code
(may repeat in each result).adr_address
: Address string with HTML tags (e.g.,<span class=\"...\">
) for UI formatting.partial_match
: Boolean indicating if the result is a partial match.icon
: Icon code representing the place type.icon_background_color
: Icon background color (HEX code).types
: Array of place types, e.g.,point_of_interest
,establishment
, etc.old_address_components
: (Only present wheninclude_old_admin=true
) Array of address components according to the old boundaries, same structure asaddress_components
.old_formatted_address
: (Only present wheninclude_old_admin=true
) Full formatted address according to the old boundaries.
XML Response
The XML response has a similar structure, with elements corresponding to the JSON fields above. Notable differences:
- XML results are wrapped in a root
<GeocodeResponse>
element. - Arrays in JSON (like
results
,address_components
,types
) become repeated elements in XML (like<result>
,<address_component>
,<type>
). - Blank elements are indicated by empty arrays in JSON, but by the absence of such elements in XML.
Status
Status | Description |
---|---|
OK | Indicates no errors occurred; the address was successfully parsed and at least one geocode was returned. |
ZERO_RESULTS | Indicates the geocode was successful but returned no results. This may occur if the geocoder was passed a non-existent address. |
Error messages
When the service returns a status code other than OK
, there may be an additional error_message
field within the response object. This field provides more detailed information about the reasons behind the given status code. This field is not always returned, and its content is subject to change.
Next steps
- Try API playground