# Autocomplete

Suggest airports, cities, and stations for a partial location query, the same suggestions the "Where from?" box of Google Flights shows. Results follow the requested language (hl) and country (gl).

- **Documentation:** [https://scrappa.co/docs/google-flights-api/google_flights_autocomplete](https://scrappa.co/docs/google-flights-api/google_flights_autocomplete)
- **API group:** Google Flights API
- **Endpoint:** `GET https://scrappa.co/api/flights/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 | Partial location text, for example Berl (required) |
| `hl` | string | No | Language code, 2 characters or language-country (e.g., en, de). Default: en |
| `gl` | string | No | Country/region code, 2 characters (e.g., us, de). Default: us |

## Example request

```bash
#!/bin/bash

curl -X GET \
    -H "x-api-key: YOUR_API_KEY_HERE" \
    "https://scrappa.co/api/flights/autocomplete?q=Berl&hl=en&gl=us"
```

## Example response

```json
{
    "query": "Berl",
    "suggestions": [
        {
            "type": "city",
            "name": "Berlin, Germany",
            "short_name": "Berlin",
            "description": "Capital of Germany",
            "id": "/m/0156q",
            "code": null,
            "score": 0.9897102117538452,
            "airports": [
                {
                    "name": "Berlin Brandenburg Airport",
                    "id": "BER",
                    "city": "Berlin",
                    "distance": "11 mi"
                },
                {
                    "name": "Berlin Hauptbahnhof",
                    "id": "QPP",
                    "city": "Berlin",
                    "distance": null
                }
            ]
        },
        {
            "type": "airport",
            "name": "Berlevag Airport",
            "short_name": "Berlev\u00e5g",
            "description": "Airport in Berlev\u00e5g, Norway",
            "id": "/m/026qcp3",
            "code": "BVG",
            "score": 0.4950000047683716,
            "airports": []
        }
    ]
}
```

## Errors

| Status | Error | Description |
| --- | --- | --- |
| 422 | Validation Error | q is required and must be 1 to 255 characters; hl and gl must be valid language and country codes when provided. |
| 402 | Insufficient Credits | Your API key is valid, but the account has no free, subscription, or package credits available. |
| 429 | Rate Limited | The request could not be completed because a temporary request limit was reached. |
| 503 | Google Flights Temporarily Unavailable | The Google Flights search could not be completed because its upstream provider was temporarily unavailable. |
| 500 | Google Flights Search Error | Scrappa could not complete the Google Flights search after validation passed. |

## 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)
