Searches for keywords and returns a list of relevant places. API search is commonly used when the input is a full address.
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) | It is recommended to use a full address for the most accurate results; you can also use a specific place name or place category. | 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 (use your own key; public_key is limited and for testing only) | 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
Tham số query: Landmark 81, 720A Điện Biên Phủ, Phường Thạnh Mỹ Tây, Thành phố Hồ Chí Minh
Output: 21.0137443130001,105.798346108
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.
Important Notes
- The fields in the response follow the Google Maps Places API standard - Text Search (Legacy).
- The response does not include all possible details for each place. To get the most complete information, use the Place Detail API.
- Unlike the autocomplete API, which only requires a short keyword (e.g., "landmark81") to receive a list of suggested addresses.
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
- To understand the differences and choose the appropriate API, you can view TrackAsia's Guide to Choosing Search and Autocomplete API Services
- Try API playground