# Pisos.com Location Autocomplete API Documentation

Scrappa's `GET /api/pisos/autocomplete` finds the Pisos.com locations that the search accepts.

## What you get

Provinces, municipalities, districts and neighbourhoods that match the start of a name. Each location has `name`, `short_name`, `location`, `short_id`, `latitude`, `longitude`, `listing_count` and `level`.

## How to use it

Pass `location` of a result to `GET /api/pisos/search` as `location`. The `operation` parameter picks the sale or the rent counts.

- **Documentation:** [https://scrappa.co/docs/pisos-api/pisos_autocomplete](https://scrappa.co/docs/pisos-api/pisos_autocomplete)
- **API group:** Pisos.com API
- **Endpoint:** `GET https://scrappa.co/api/pisos/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 location name, at least 2 characters, for example Madrid or Alcal. |
| `operation` | string | No | sale (default) or rent. Picks which listing counts are returned. |

## Example request

```bash
#!/bin/bash

curl -X GET \
    -H "x-api-key: YOUR_API_KEY_HERE" \
    "https://scrappa.co/api/pisos/autocomplete?query=madrid&operation=sale"
```

## Example response

```json
{
    "success": true,
    "data": {
        "query": "madrid",
        "operation": "sale",
        "locations": [
            {
                "name": "Madrid",
                "short_name": "Madrid",
                "location": "madrid",
                "short_id": "P00000000000028",
                "latitude": 40.4168,
                "longitude": -3.7038,
                "listing_count": 16499,
                "level": 1,
                "type": 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 | Pisos.com 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)
