# Gratka Location Autocomplete API Documentation

Scrappa's `GET /api/gratka/location-autocomplete` finds Polish places by the start of a name and returns what the search endpoint needs.

## What you get

Each location has `id`, `name`, `description`, `kind` (for example `miasto` for a city or `dzielnica` for a district), `region`, `city` and `slug`. For cities and districts, `search_params` holds the exact `location` and `district` values to send to the search endpoint. Other kinds, such as counties, have `slug` and `search_params` as `null`.

## Notes

At least 2 characters are needed. Results are cached for ten minutes.

- **Documentation:** [https://scrappa.co/docs/gratka-api/gratka_location_autocomplete](https://scrappa.co/docs/gratka-api/gratka_location_autocomplete)
- **API group:** Gratka API
- **Endpoint:** `GET https://scrappa.co/api/gratka/location-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 |
| --- | --- | --- | --- |
| `query` | string | Yes | Start of a place name, at least 2 characters, for example Krak. |

## Example request

```bash
#!/bin/bash

curl -X GET \
    -H "x-api-key: YOUR_API_KEY_HERE" \
    "https://scrappa.co/api/gratka/location-autocomplete?query=Krak"
```

## Example response

```json
{
    "success": true,
    "query": "Krak",
    "locations": [
        {
            "id": "311510",
            "name": "Krak\u00f3w",
            "description": "miasto, ma\u0142opolskie",
            "kind": "miasto",
            "region": "ma\u0142opolskie",
            "city": "Krak\u00f3w",
            "slug": "krakow",
            "search_params": {
                "location": "krakow"
            }
        },
        {
            "id": "1900000311510",
            "name": "Podg\u00f3rze",
            "description": "dzielnica, Krak\u00f3w, ma\u0142opolskie",
            "kind": "dzielnica",
            "region": "ma\u0142opolskie",
            "city": "Krak\u00f3w",
            "slug": "podgorze",
            "search_params": {
                "location": "krakow",
                "district": "podgorze"
            }
        }
    ],
    "meta": {
        "endpoint_family": "location",
        "billable": true,
        "attempts": 1
    }
}
```

## Errors

| Status | Error | Description |
| --- | --- | --- |
| 422 | Validation Error | A query parameter is missing, unknown or unusable. Unknown parameters are rejected, never ignored. Non-billable. |
| 503 | Upstream Unavailable | Gratka could not be reached after retries, answered with an error, or returned a page without the expected data (`upstream_unavailable`, `upstream_blocked`, `upstream_rejected`, `parser_drift`). Retryable and never billed. Clients are never rate limited. |

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