ACTIONS
  • Home
  • My Actions
  • My Projects
  • My Packages
Google Maps -> Autocomplete API
Readonly
Xano Action Documentation: Google Maps → Autocomplete API

Action summary

Google Maps -> Autocomplete API

Xano / Google Maps

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_mask Parameter: Sets the field_mask variable to "*" if not provided, or uses the input value.
  • Prepare session_token: Uses the provided session_token or generates a new UUID if not supplied.

2. API Request

  • API Request: Sends a GET request to https://places.googleapis.com/v1/places:autocomplete with the relevant parameters (input, session_token, field_mask, latitude, longitude, radius, region_code, and google_api_key).

3. Precondition

  • Checks that the API response status is 200 and 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_key must have Places API enabled.
  • Using a session_token is recommended for grouping user sessions and optimizing billing.
  • The field_mask parameter 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 required input parameter 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

  • Google Maps Places Autocomplete API Documentation
  • Google Maps API Error Messages

Version notes

2025-05-28 21:19:15
Current
2025-06-30T11:08:46.000+00:00