Google Maps -> Autocomplete API
Readonly
Action summary
Google Maps -> Autocomplete API
Xano Action Documentation: Google Maps → Autocomplete API
Overview
This Xano action integrates with the Google Maps Places Autocomplete API to provide location-based suggestions as users type. It is designed to enhance user experience by offering predictive search results for addresses and places, using various optional parameters to refine the results.
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
google_api_key |
text | Yes | Your Google Maps API key (from settings registry). |
input |
text | Yes | The text string for which to return place predictions. |
session_token |
text | No | A unique token for grouping Autocomplete requests (improves billing & usage). |
field_mask |
text | No | Comma-separated list of fields to include in the response. |
latitude |
text | No | Latitude for location biasing. |
longitude |
text | No | Longitude for location biasing. |
radius |
integer | No | Radius (in meters) for location biasing. |
region_code |
text | No | Region code to bias results (e.g., "us", "in"). |
Function Stack
1. Prepare Parameters
- Prepare
field_maskParameter: Sets thefield_maskvariable to "*" if not provided, or uses the input value. - Prepare
session_token: Uses the providedsession_tokenor generates a new UUID if not supplied.
2. API Request
- API Request:
Sends a GET request to
https://places.googleapis.com/v1/places:autocompletewith the relevant parameters (input,session_token,field_mask,latitude,longitude,radius,region_code, andgoogle_api_key).
3. Precondition
- Checks that the API response status is
200and that a result is present.
4. Response
- Returns the API response result and the
session_token.
Example Usage
Request
{
"google_api_key": "AIzaSyD...",
"input": "221B Baker Street",
"latitude": "51.5237",
"longitude": "-0.1585",
"radius": 500,
"region_code": "gb"
}
Response
{
"api_response": [
{
"place_id": "ChIJd8BlQ2BZwokRAFUEcm_qrcA",
"description": "221B Baker St, Marylebone, London NW1 6XE, UK",
// ... other fields as specified by field_mask
}
// ... additional predictions
],
"session_token": "d7b6fbb8-4a1d-4c7a-8b8e-9d2d7a6c1e2f"
}
Notes
- The
google_api_keymust have Places API enabled. - Using a
session_tokenis recommended for grouping user sessions and optimizing billing. - The
field_maskparameter controls which fields are returned; use "*" to return all available fields. - Location and region parameters help bias results to a specific area or country.
Troubleshooting
REQUEST_DENIED: Ensure your API key is correct and has Places API access enabled.INVALID_REQUEST: Check that the requiredinputparameter is provided.ZERO_RESULTS: No predictions found for the input; try adjusting the input or location bias.- Other Errors: Refer to the Google Maps Places API documentation for detailed error handling.
References
Version notes
2025-05-28 21:19:15
Current