# Green-Acres Location Autocomplete API Documentation

Scrappa's `GET /api/green-acres/autocomplete` finds the Green-Acres locations that the search accepts.

## What you get

Departments, cities, city groups and districts that match a term. Each location has `id`, `label`, `category`, `area_id`, `area_type`, `code`, `postal_code`, `latitude` and `longitude`. Departments and city groups have no coordinates, so those fields are null.

## How to use it

Pass the `id` of a result to `GET /api/green-acres/search` as `location`, for example `dp_07` for the department Ardeche or `city_36662` for Paris 10eme.

- **Documentation:** [https://scrappa.co/docs/green-acres-api/green_acres_autocomplete](https://scrappa.co/docs/green-acres-api/green_acres_autocomplete)
- **API group:** Green-Acres API
- **Endpoint:** `GET https://scrappa.co/api/green-acres/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 | Part of a location name, at least 2 characters, for example Paris or Ardeche. |

## Example request

```bash
#!/bin/bash

curl -X GET \
    -H "x-api-key: YOUR_API_KEY_HERE" \
    "https://scrappa.co/api/green-acres/autocomplete?query=paris"
```

## Example response

```json
{
    "success": true,
    "data": {
        "query": "paris",
        "locations": [
            {
                "id": "dp_75",
                "label": "Paris",
                "category": "D\u00e9partement",
                "area_id": 4365,
                "area_type": "department",
                "code": "75",
                "postal_code": null,
                "latitude": null,
                "longitude": null,
                "url": null
            },
            {
                "id": "city_36662",
                "label": "Paris 10\u00e8me (75010)",
                "category": "Arrondissements",
                "area_id": 36662,
                "area_type": "city",
                "code": null,
                "postal_code": "75010",
                "latitude": 48.87174,
                "longitude": 2.35713,
                "url": null
            }
        ]
    },
    "meta": {
        "endpoint_family": "autocomplete",
        "billable": true,
        "attempts": 1
    }
}
```

## Errors

| Status | Error | Description |
| --- | --- | --- |
| 422 | Validation Error | A query parameter is missing, unknown or unusable. Unknown parameters and unknown values are rejected, never ignored. Non-billable. |
| 503 | Upstream Unavailable | Green-Acres could not be reached, refused the request or answered with a page this API could not read (`UPSTREAM_UNAVAILABLE`). 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)
