# Autocomplete

The Google Maps Autocomplete API provides automatic query predictions as users type. Helps users find places, addresses, and points of interest quickly. Accepts both "q" and "query" parameters for consistency with other autocomplete endpoints.

- **Documentation:** [https://scrappa.co/docs/google-maps-api/autocomplete](https://scrappa.co/docs/google-maps-api/autocomplete)
- **API group:** Google Maps API
- **Endpoint:** `GET https://scrappa.co/api/maps/autocomplete`

## Authentication

Send your Scrappa API key in the `X-API-KEY` request header. Paid endpoints also support accountless x402 payments when called without an API key.

## Parameters

| Parameter | Type | Required | Description |
| --- | --- | --- | --- |
| `q` | string | Yes | The partial search term to get autocomplete suggestions for. Accepts both "q" (consistent with Google Hotels) and "query". |
| `hl` | string | No | Language code for results. Default: en. Examples: en, de, fr, es. Format: ISO 639-1 two-letter language code. |
| `gl` | string | No | Country/region code for geo-filtering results. Examples: us, de, uk, jp. Format: ISO 3166-1 alpha-2 country code. |
| `ll` | string | No | Latitude and longitude to bias results toward a specific location. Format: "latitude,longitude" (e.g., 40.7128,-74.0060 for New York City). |
| `google_domain` | string | No | Google domain to use for the search. Examples: google.com, google.de, google.com.br, google.co.uk. |

## Example request

```bash
#!/bin/bash

curl -X GET \
    -H "x-api-key: YOUR_API_KEY_HERE" \
    "https://scrappa.co/api/maps/autocomplete?q=bakery"
```

## Example response

```json
{
    "search_parameters": {
        "engine": "google_maps_autocomplete",
        "q": "bakery",
        "hl": "en",
        "gl": null,
        "google_domain": null
    },
    "suggestions": [
        {
            "type": "place",
            "place_id": "ChIJo5WzdY-4QIYRSL3AEsOhcYc",
            "google_id": "0x8640b88f75b395a3:0x8771a1c312c0bd48",
            "main_text": "Bakery near me",
            "subtext": "Houston, TX",
            "main_text_highlights": [
                {
                    "offset": 0,
                    "length": 6
                }
            ],
            "latitude": 29.7604,
            "longitude": -95.3698,
            "country": "US"
        }
    ],
    "response_time_ms": 587
}
```

## Errors

| Status | Error | Description |
| --- | --- | --- |
| 422 | Validation Error | The q/query, locale, domain, or ll parameters failed validation before the Google Maps autocomplete request ran. |
| 503 | Autocomplete Temporarily Unavailable | The upstream service is temporarily unavailable. Please retry shortly. |

## More Scrappa resources

- [API documentation](https://scrappa.co/docs)
- [Full LLM-readable API reference](https://scrappa.co/llms-full.txt)
- [OpenAPI specification](https://scrappa.co/docs/api.json)
- [Pricing](https://scrappa.co/pricing)
