# Habitaclia Search API Documentation

Search the live Habitaclia catalogue for Spain. Pass a place code and layer_id from /locations to scope the search, for example code 46250 with layer_id 20 (municipality) or layer_id 11 (province). Paginate with page and page_size; total_count and has_more come from the same response, so they always agree with the page you fetched. An unknown place code returns an empty data array, which is a successful, billable response. Prices are in EUR.

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

## 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 |
| --- | --- | --- | --- |
| `transaction_type` | string | Yes | buy or rent. |
| `property_type` | string | Yes | flat, house, office, garage, building or land. |
| `code` | string | Yes | Numeric place code from /locations, for example 46250. |
| `layer_id` | integer | Yes | Place level from /locations: 11 province, 14 zone, 20 municipality, 26 street. |
| `page` | integer | No | 1-based page number. Defaults to 1. |
| `page_size` | integer | No | Items per page, 1 to 1000. Defaults to 20. |
| `sort_by` | string | No | relevance, price_asc, price_desc or newest. Defaults to relevance. |
| `min_price` | integer | No | Minimum price in EUR. |
| `max_price` | integer | No | Maximum price in EUR. |
| `min_rooms` | integer | No | Minimum number of rooms. |
| `min_bathrooms` | integer | No | Minimum number of bathrooms. |
| `features` | array | No | Repeatable feature filter, for example features=pool&features=terrace. Allowed: pool, terrace, elevator, furnished, unfurnished, private_parking, private_garden, nearby_public_transport. |
| `is_private` | boolean | No | Only private-owner listings when true. |

## Example request

```bash
#!/bin/bash

curl -X GET \
    -H "x-api-key: YOUR_API_KEY_HERE" \
    "https://scrappa.co/api/habitaclia/search?transaction_type=buy&property_type=flat&code=46250&layer_id=20&page=1&page_size=5&sort_by=price_asc"
```

## Example response

```json
{
    "success": true,
    "data": [
        {
            "ad_id": "5f6a57a2-f588-47e8-8182-588957475340",
            "legacy_id": "i41124000089339",
            "url": "https://www.habitaclia.com/i41124000089339.htm",
            "reference": "CL-00729-0001",
            "title": "Solvia Inmobiliaria Piso Valencia",
            "property_type": "flat",
            "property_subtype": "flat",
            "transaction_type": "buy",
            "price": 24600,
            "currency": "EUR",
            "rooms": 2,
            "bathrooms": 1,
            "built_surface": 76,
            "state": "PUBLISHED",
            "coordinates": {
                "lat": 39.497327652217486,
                "lon": -0.37446511845189434
            }
        }
    ],
    "meta": {
        "endpoint_family": "search",
        "billable": true,
        "page": 1,
        "page_size": 5,
        "total_count": 3634,
        "has_more": 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)
