# Habitaclia Locations API Documentation

Resolve a place name to the code and layer_id that /search expects. Returns a JSON array of matches, each with the place code, name, layer_id (11 province, 14 zone, 20 municipality, 26 street) and the live listing count. property_type is required upstream and the call answers a 400 without it. An unknown place name returns an empty array, which is a successful, billable response.

- **Documentation:** [https://scrappa.co/docs/habitaclia-api/habitaclia_locations](https://scrappa.co/docs/habitaclia-api/habitaclia_locations)
- **API group:** Habitaclia API
- **Endpoint:** `GET https://scrappa.co/api/habitaclia/locations`

## 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 | Place name to resolve, for example Valencia. |
| `property_type` | string | Yes | flat, house, office, garage, building or land. |
| `transaction_type` | string | No | buy or rent. Refines the listing counts. |

## Example request

```bash
#!/bin/bash

curl -X GET \
    -H "x-api-key: YOUR_API_KEY_HERE" \
    "https://scrappa.co/api/habitaclia/locations?query=Valencia&transaction_type=buy&property_type=flat"
```

## Example response

```json
{
    "success": true,
    "data": [
        {
            "code": "46250",
            "name": "Valencia, Valencia",
            "layer_id": 20,
            "count": 3588
        },
        {
            "code": "46",
            "name": "Valencia",
            "layer_id": 11,
            "count": 17064
        },
        {
            "code": "358",
            "name": "Valencia, Zona de, Valencia",
            "layer_id": 14,
            "count": 3588
        }
    ],
    "meta": {
        "endpoint_family": "locations",
        "billable": true
    }
}
```

## Errors

| Status | Error | Description |
| --- | --- | --- |
| 404 | Not Found | The requested listing was not found. This response is not billable. |
| 422 | Validation Error | A public parameter is invalid, including an unknown transaction_type, property_type or sort_by. This response is not billable. |
| 503 | Service Unavailable | The service could not obtain a complete result from Habitaclia. This response is not billable. |

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