# Habitaclia Scraper with Rental Yield & Deal Score – Spain (`data-nest/habitaclia-rental-yield`) Actor

Gross rental yield by district and bedrooms in 11 Spanish cities, plus a deal score, estimated rent and yield for every flat for sale on Habitaclia. Whole-city market, prices in EUR.

- **URL**: https://apify.com/data-nest/habitaclia-rental-yield.md
- **Developed by:** [Datanest](https://apify.com/data-nest) (community)
- **Features:** Limited permissions
- **Stats:** 1 total users, 0 monthly users, 0.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $0.85 / 1,000 listings

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.
Since this Actor supports Apify Store discounts, the price gets lower the higher subscription plan you have.

Learn more: https://docs.apify.com/actors/store.md#pay-per-event

## What's an Apify Actor?

An Actor is a serverless cloud program that runs on the Apify platform. It has two run modes.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.

Apify vocabulary and the platform model are defined once, in the agent quickstart at https://apify.com/agents.md.

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.

Do not guess an integration path. Every one of them is in the agent quickstart at https://apify.com/agents.md: the Apify MCP server, Agent Skills with the Apify CLI, the JavaScript and Python clients, the REST API, and the account-free path for an agent with no human to sign in. It also carries the rule on stating cost before the first paid run.

For examples already wired to this Actor's own input schema, see the [API](#api) section below.

Each client library has reference documentation the quickstart does not restate: [JavaScript/TypeScript](https://docs.apify.com/api/client/js/docs.md) (`npm install apify-client`) and [Python](https://docs.apify.com/api/client/python/docs.md) (`pip install apify-client`).

# README

## Habitaclia Scraper with Rental Yield & Deal Score – Spain

This Actor calculates the price per m² by district and the gross rental yield by district and bedroom count, and gives every flat for sale a deal score, using Habitaclia listings for 11 Spanish cities: Madrid, Barcelona, Valencia, Zaragoza, Sevilla, Málaga, Murcia, Palma, Las Palmas de Gran Canaria, Alicante and Vigo. All prices are in EUR. Use it for rental yield in Spain, price per m² by district and spotting flats priced below their neighbourhood, whether you are a buy-to-let investor, an analyst or an AI agent. One run reads the flats for sale and for long-term rent and returns:

- **Gross rental yield per district and bedroom count**, with medians, quartiles and sample sizes.
- **A 0–100 deal score for every listing for sale**, against the median price per m² of comparable flats.
- **Every listing with our analytics** (mode `listings`): deal score, estimated monthly rent and estimated gross yield for flats for sale, rent per m² for flats for rent.
- **Everything in EUR.** The portal lists Spain only, so there is no currency conversion.

Asking prices and advertised rents, honestly labelled. Gross, not net.

### Example output

City-level results of runs on the Apify platform on 27 November 2026 (mode `yieldReport`, whole market, Spanish residential proxy), highest gross yield first:

| City | Gross yield | Median asking price €/m² | Median asking rent €/m²/month | Listings used sale/rent | Temporary rentals excluded |
|---|---|---|---|---|---|
| Valencia | 7.12% | 3,406 | 20.2 | 2,646/1,374 | 25% |
| Barcelona | 6.86% | 5,465 | 31.2 | 7,140/1,051 | 53% |
| Zaragoza | 6.64% | 2,502 | 13.8 | 656/95 | 10% |
| Sevilla | 6.51% | 2,667 | 14.5 | 1,690/334 | 29% |
| Alicante | 6.45% | 2,712 | 14.6 | 2,443/258 | 24% |
| Murcia | 6.41% | 1,933 | 10.3 | 1,489/284 | 9% |
| Madrid | 5.79% | 6,216 | 30.0 | 8,428/3,800 | 31% |
| Las Palmas de Gran Canaria | 5.51% | 3,079 | 14.1 | 651/105 | 26% |
| Málaga | 5.45% | 4,037 | 18.3 | 2,574/264 | 44% |
| Vigo | 5.15% | 3,000 | 12.9 | 621/89 | 14% |
| Palma | 4.90% | 5,246 | 21.4 | 1,479/167 | 34% |

Snapshot of asking prices and rents on 27 November 2026; figures change month to month.

### How to use it without code

1. Open the Actor in Apify Console.
2. Choose the cities and the mode: `listings`, `yieldReport`, `scoreListings` or `both`.
3. Click **Start**.
4. Download the results as Excel, CSV or JSON from the Output tab. Yield groups are in the `yields` dataset, except in `yieldReport` mode, where they are in the default dataset.

The first run with the default example (prefill: Vigo, the whole market) makes about 35 requests and takes under a minute.

### What you get

- **Listings** (`listing` records, `mode: "listings"`): every flat for sale and for rent, one row each, with our analytics on the sale rows. The cheapest way to use the Actor (see *Listings mode*).
- **Yield by district** (`areaYield` records): for every district × bedroom group, the median sale price per m², the median monthly rent per m², quartiles, the number of listings behind each number, and the gross yield with a range. Groups with too few listings fall back to the city level and say so (`groupLevel`, `confidence`).
- **Scored listings** (`scoredListing` records): for every flat for sale, a 0–100 deal score, its discount against comparable flats, an estimated monthly rent and gross yield, and a link to the listing. Sorted best deal first.
- **Sample transparency**: every yield record reports how recent its sample is (median age, oldest listing) and what share of the portal's listings it covers (`sample`).
- **Two datasets**: scored listings in the default dataset, yield groups in a second dataset called `yields` (see *Where the results are*).
- **Two reports in the key-value store**: `YIELD_REPORT` (yield groups per city: the delivered ones in `yieldReport` and `both`, only the free low-confidence ones in `scoreListings`, none in `listings`) and `RUN_SUMMARY` (what was fetched, rejected and charged, per city and market side).

### Cities and coverage

Madrid, Barcelona, Valencia, Zaragoza, Sevilla, Málaga, Murcia, Palma, Las Palmas de Gran Canaria, Alicante, Vigo. The portal serves at most 10,000 results per list. A city with a longer list (Madrid, Barcelona) is read district by district, and a district that is still too long barrio by barrio; `RUN_SUMMARY` reports how much of the portal's total this reached (`districtCoverage`, `share`).

The portal's coverage is strongest in Barcelona and Madrid. In smaller cities there are fewer listings per district, so many groups are compared at the city level (`groupLevel: "city_bedrooms"` or `"city"`), which lowers `confidence`.

In the runs of 27 November 2026 every list of all 11 cities was read to its last page, with 0 blocked requests. Madrid and Barcelona were read through their districts (21 and 10); in both, the district totals added up to the city's number of listings.

### Quick start

Open the Actor and press **Start**: the form opens with Vigo, the smallest city, for a quick first run (whole market, mode `both`). A run without any input, for example from the API or an AI agent, uses Vigo too. To analyse other cities, choose them in the **Cities** field. Every input field has a short description in the form.

Main settings:

- `cities` – one or more of the 11 cities.
- `mode` – `listings`, `yieldReport`, `scoreListings` or `both`.
- `bedrooms` – `"0"` (studio), `"1"`, `"2"`, `"3"`, `"4+"`.
- `areaMin`, `areaMax` – flat size in m².
- `maxListingsPerSide` – listings for sale and, separately, for rent per city; `0` is the whole market.
- `minScore`, `maxScoredListings` – keep only the best deals.
- `minSalePrice`, `maxSalePrice`, `minMonthlyRent`, `maxMonthlyRent` – return only listings in your price range (see *Price filter*).
- `onlyNewOrChanged`, `watchlistName` – monitoring.

### Listings mode

`mode: "listings"` returns one row per listing, for sale and for rent, with `recordType: "listing"` and a `transaction` field (`sale` or `rent`).

- **Sale rows** carry `dealScore`, `discountVsMedianPct`, `estimatedMonthlyRentEur`, `estimatedGrossYieldPct` and `comparable`, which names the groups the numbers come from. A flat with no comparable group (a city with too few listings) is still returned, with these fields `null` and the reason in `estimateNote`; if you narrowed the selection (area, bedrooms or a higher minimum sample; the price filter does not count, as it leaves comparisons unchanged), that note refers to the selected filters instead of the city.
- **Rent rows** carry `monthlyRentPerM2Eur`; the sale fields are `null`.
- Flats the portal itself excludes from price comparisons (see *Limitations*) are returned with `null` analytics, a flag and a note.
- Rows follow the portal's relevance order, with sales and rents interleaved. No yield groups are written and `maxScoredListings` is ignored; the number of rows follows from `maxListingsPerSide` and the exclusions.

Example sale row (values are illustrative):

```json
{
  "recordType": "listing",
  "transaction": "sale",
  "source": "habitaclia",
  "listingId": "00000000-0000-0000-0000-000000000000",
  "url": "<link to the listing on the portal>",
  "country": "ES",
  "city": "Vigo",
  "district": "Centro Urbano",
  "bedrooms": 2,
  "areaM2": 78.0,
  "isPrimaryMarket": false,
  "priceEur": 210000,
  "pricePerM2Eur": 2692,
  "groupMedianPricePerM2Eur": 3268,
  "dealScore": 81,
  "discountVsMedianPct": 17.6,
  "estimatedMonthlyRentEur": 960,
  "estimatedGrossYieldPct": 5.49,
  "saleGroupLevel": "district",
  "rentGroupLevel": "district",
  "confidence": "high",
  "updatedAt": "2026-11-20",
  "flags": [],
  "estimateNote": null,
  "monthlyRentPerM2Eur": null,
  "comparable": {
    "sale": {"groupLevel": "district", "district": "Centro Urbano", "bedrooms": "2", "saleCount": 88, "confidence": "high"},
    "rent": {"groupLevel": "district", "district": "Centro Urbano", "bedrooms": "2", "rentCount": 28}
  }
}
```

### Price filter

Four optional inputs, whole EUR, bounds included: `minSalePrice` and `maxSalePrice` for listings for sale, `minMonthlyRent` and `maxMonthlyRent` for rentals. Leave a field empty for no limit.

```json
{"cities": ["valencia"], "mode": "listings", "maxSalePrice": 300000, "maxMonthlyRent": 1500}
```

- **Only the returned rows change.** Medians, comparable groups, deal scores and rent and yield estimates are still computed from the whole market of the city (or your `maxListingsPerSide` sample), including the listings the filter leaves out.
- **The filter does not shorten a run:** the Actor still reads the whole market of each city (unless `maxListingsPerSide` limits it), so that the comparisons stay fair.
- **Where it works:** `mode: "listings"` (sale and rent rows, temporary rentals included) and `scoreListings` (sale rows; the rent fields are ignored with a warning in the log). In `both` it narrows the scored listings in the same way and leaves the yield groups unchanged. `yieldReport` ignores all four with a warning.
- **Filtered rows** are not returned, not charged and not recorded by monitoring. The filter applies after the outlier exclusion and `minScore`, and before `maxScoredListings`.
- **Nothing matches:** the run succeeds with no listing rows, its status message names the price filter, and no listing rows are charged. In `both`, the yield groups are still delivered and charged.
- A minimum greater than its maximum is an input error: the run stops before its first request.
- `RUN_SUMMARY.cities.*.priceFiltered` counts the rows left out per side (`sale`, `rent`).

A measured example of a filtered run is in *What a report costs*.

### Example inputs

Whole market of one city, every listing with analytics:

```json
{"cities": ["vigo"], "mode": "listings"}
```

Yield report for two cities:

```json
{"cities": ["valencia", "malaga"], "mode": "yieldReport"}
```

Underpriced two-bedroom flats in Barcelona:

```json
{"cities": ["barcelona"], "mode": "scoreListings", "bedrooms": ["2"], "minScore": 80, "maxScoredListings": 200}
```

### Where the results are

- **Default dataset**: `scoredListing` records (modes `scoreListings` and `both`), `listing` records (mode `listings`), or the yield groups themselves in mode `yieldReport`. The API call that returns the default dataset directly would otherwise be empty in that mode.
- **`yields` dataset**: `areaYield` records. In mode `yieldReport` a copy is kept here too, because the **Rental yield by district** view of the Output tab reads this dataset.
- **Key-value store**: `YIELD_REPORT` and `RUN_SUMMARY`.

### For AI agents

Call the Actor `data-nest/habitaclia-rental-yield` from an agent or over MCP with a small input, for example one city in yield-report mode:

```json
{"cities": ["vigo"], "mode": "yieldReport"}
```

The result is a list of `areaYield` records in the default dataset, one per district and bedroom group, with `city`, `district`, `bedrooms`, `groupLevel`, `confidence`, `saleCount`, `rentCount`, `salePricePerM2Eur.median`, `rentPerM2MonthlyEur.median` and `grossYieldPct`. Set a maximum charge per run to cap the cost.

### Output

**`areaYield`** – one record per district and bedroom group (`bedrooms` is `"0"`, `"1"`, `"2"`, `"3"`, `"4+"`, or `"all"` for the whole district or city):

```json
{
  "recordType": "areaYield",
  "country": "ES",
  "city": "Vigo",
  "district": "Centro Urbano",
  "bedrooms": "2",
  "groupLevel": "district",
  "confidence": "high",
  "saleCount": 88,
  "rentCount": 28,
  "salePricePerM2Eur": {"median": 3268, "p25": 2900, "p75": 3700},
  "rentPerM2MonthlyEur": {"median": 14.4, "p25": 12.9, "p75": 16.0},
  "grossYieldPct": 5.29,
  "grossYieldRangePct": [4.2, 6.6],
  "priceBasis": "asking",
  "sample": {
    "sale": {"medianDaysSinceUpdate": 28.0, "maxDaysSinceUpdate": 113, "share": 1.0, "fetched": 780, "totalItems": 799, "typologyTiles": 19, "reachableItems": 780},
    "rent": {"medianDaysSinceUpdate": 15.0, "maxDaysSinceUpdate": 113, "share": 1.0, "fetched": 117, "totalItems": 117, "typologyTiles": 0, "reachableItems": 117}
  },
  "sources": ["habitaclia"],
  "computedAt": "2026-11-27T11:09:13Z"
}
```

**`scoredListing`** – one record per flat for sale:

```json
{
  "recordType": "scoredListing",
  "source": "habitaclia",
  "listingId": "00000000-0000-0000-0000-000000000000",
  "url": "<link to the listing on the portal>",
  "country": "ES",
  "city": "Vigo",
  "district": "Centro Urbano",
  "bedrooms": 2,
  "areaM2": 78.0,
  "isPrimaryMarket": false,
  "priceEur": 210000,
  "pricePerM2Eur": 2692,
  "groupMedianPricePerM2Eur": 3268,
  "dealScore": 81,
  "discountVsMedianPct": 17.6,
  "estimatedRentMonthlyEur": 960,
  "grossYieldPct": 5.49,
  "saleGroupLevel": "district",
  "rentGroupLevel": "district",
  "confidence": "high",
  "updatedAt": "2026-11-20",
  "flags": [],
  "estimateNote": null,
  "changeType": null,
  "priceCutPct": null
}
```

`updatedAt` is the date the portal last modified the listing, not the date it was published: the portal exposes no publication date. `flags` can contain `large_discount` (more than 30% below the group median), `needsRenovation`, `suspectBedrooms`, and the portal's exclusions `bareOwnership`, `occupied` and `auction`. In mode `listings`, a rent row flagged `temporary_rent` is a temporary (seasonal) rental: it is returned and charged like any other row, its `estimateNote` says so, and its rent is not used in any median or estimate. `identicalListingIds` lists listings merged into this one because price, area, bedrooms, district and property type are identical.

### How the numbers are computed

- **Groups.** Listings are grouped by city, district and bedroom count (0 for a studio, 1, 2, 3, 4+). Sale prices and rents fall back to the city level independently: a listing's price is compared with at least 15 comparable flats for sale, and its rent is estimated from at least 10 comparable rentals. Each record says which level it used.
- **Gross yield** = 12 × median monthly rent per m² ÷ median sale price per m². The range uses the quartiles (low rent against high price, and the reverse).
- **Deal score.** A listing's price per m² is compared with the median of its group on a log scale, divided by the group's typical spread (median absolute deviation). 50 means priced at the median; about 84 is one typical deviation cheaper; about 98 is two.
- **Estimated rent** for a listing = median rent per m² of its group × the flat's area.
- **Prices** are asking prices and advertised rents in EUR, and rents are long-term rentals only: temporary (seasonal) rentals, marked by a flag of the portal, are excluded from the rent medians and marked `temporary_rent`. Community fees are not counted as rent.
- **Asking-price yields** are typically higher than yields based on signed contracts.
- **Bedrooms, not rooms.** The portal counts bedrooms; 0 is a studio.

### Why the numbers can be trusted

- **Sample sizes are shown.** Every group carries its listing counts and a confidence level; thin groups fall back to the city level instead of producing noisy numbers.
- **Cleaning is explicit.** Duplicates, hidden prices, unknown bedroom counts and implausible sizes are removed and counted in `RUN_SUMMARY`. Repeated rent listings for the same flat are counted once, and identical sale listings (same district, property type, bedrooms, area and price) are merged into one. The cheapest 1% and the most expensive 1% of each city's listings by price per m² are dropped before scoring. Separately, flat listings priced more than 40% below their group's median are not returned and not charged; their number is `scoredExcludedOutliers` in `RUN_SUMMARY`.
- **Portal exclusions stay out of the medians.** Occupied flats, bare ownership and auctions are priced differently from normal sales, so the portal excludes them from its own price comparisons and so do we.
- **No personal data.** Contact details, advertiser names, descriptions and photos are dropped when a listing is read; results contain our numbers and a link.
- **Proxy.** By default every request, from the first one, goes through Apify Proxy's residential group with addresses in Spain, in one proxy session for the whole run. You can change this in the proxy configuration.
- **Loud failures.** All retries stay in the same proxy session. If the portal answers with HTTP 403, the Actor repeats the request up to 3 times, after 15, 30 and 60 seconds (about 2 minutes in total). After HTTP 429 it repeats it up to 5 times, with growing pauses (about 8 minutes in total; longer if the answer asks for it with `Retry-After`, at most 5 minutes per pause). Then the run stops. A captcha or another challenge page, or a page without the expected listing data, stops the run at once. Network and proxy errors are retried up to 3 times; if they persist, that city is reported as failed (if this happens while reading robots.txt, the run fails). The Actor never switches proxy sessions, solves captchas or works around blocks. A stop is reported with a clear message (`blockedMessage` in `RUN_SUMMARY`; `blockedAt` says where). Cities completed before the stop are delivered and charged; the rest are marked `skipped`. If nothing was completed, the run fails and none of the Actor's result events are charged; Apify charges only its standard start fee of $0.00005.

### Monitoring

Set `onlyNewOrChanged: true` and schedule the Actor (for example daily). Each run returns only listings that are new, or at least 1% cheaper, since the last run with the same `watchlistName`, marked `changeType: "new"` or `"priceCut"` with `priceCutPct`. Use one schedule per watchlist name. Unchanged listings are neither returned nor charged.

The monitoring memory is a named key-value store (`habitaclia-rental-yield-state`) in your account. If it cannot be opened or written, the run does not fail: it returns the listings without change detection (`changeType` is `null`), and `RUN_SUMMARY.monitoring.warning` says what happened.

For schedules we recommend `mode: "scoreListings"`: with `both`, every scheduled run also returns (and charges) the full set of yield groups. Because the portal does not show when a listing was first published, `firstSeenAt` is set by the first run that sees it.

### Pricing

Pay per result. Prices are for the Free plan; they are lower on higher Apify plans, and Platinum and Diamond pay the Gold price.

| Event | Free | Bronze | Silver | Gold | When |
|---|---|---|---|---|---|
| Yield group (`area-yield`) | $0.03 | $0.0285 | $0.027 | $0.0255 | per `areaYield` record with high or medium confidence |
| Listing or scored listing (`scored-listing`) | $0.001 | $0.00095 | $0.0009 | $0.00085 | per `listing` record (mode `listings`) or `scoredListing` record |

That is $1 per 1,000 listings on the Free plan. City-level context records (low confidence) are free. Apify adds its own start event of $0.00005 per run.

Measured on the Apify platform on 27 November 2026: the whole market of Vigo in mode `listings`, 695 rows, cost $0.70 (Free plan price, platform usage included).

To spend less: `mode: "yieldReport"` returns only the yield groups; `maxScoredListings`, `minScore`, `bedrooms` and the price filter reduce the number of scored listings; and you can set a maximum charge per run. When that maximum is close, the run stops cleanly, staying below it, after delivering free city-level context, the yield groups and the best-scored listings first.

**Very low maximum charge.** The Actor collects the whole sample before it returns any result. If your maximum charge per run is too low to justify that, the run uses a smaller sample instead: the first city in your list and 360 listings per side. The run still succeeds, never charges an event type you did not ask for, and `RUN_SUMMARY` shows `budgetReduced: true`. With an active price filter the sample is never reduced: the run reads the requested scope and stops writing rows at your maximum charge.

### What a report costs

A report (`mode: "yieldReport"`) is charged only for yield groups: $0.03 per `area-yield` event at the Free plan price. No `scored-listing` events are charged in this mode, and city-level context groups (low confidence) are free.

Measured on the Apify platform on 27 November 2026, whole market, mode `yieldReport`, Free plan price, platform usage included:

| Run | Paid yield groups | Cost | Duration |
|---|---|---|---|
| Barcelona | 29 | $0.87 | about 11 minutes |
| Madrid | 61 | $1.83 | about 12 minutes |
| The 9 other cities in one run | 135 | $4.05 | about 16 minutes |

Vigo, mode `listings` with `maxSalePrice` 200000 and `maxMonthlyRent` 900 (run on 29 November 2026): 159 rows (108 sale + 51 rent) = 159 `scored-listing` events = $0.16 at the Free plan price. Deal scores and rent estimates were still computed from the whole Vigo market.

### Limitations

- **Asking prices, not transaction prices.** Gross yield, not net (no taxes, vacancy, maintenance).
- **Resale flats only.** The portal's development tiles ("obra nueva") are projects, not listings: they have no single price or area, so they are counted in `RUN_SUMMARY` (`typologyTiles`) and left out of medians and results. The numbers describe individually listed flats; new builds are often more expensive per m², so the yield of the whole market may be somewhat lower.
- **Portal order, not newest first.** The portal lists results by its own relevance and offers no sort by date that this Actor may use. A limited sample (`maxListingsPerSide`) is therefore not the newest listings; `updatedAt` and the `sample` block show how recent it is.
- **Bedrooms instead of rooms.** Groups use the portal's bedroom count (0 = studio), which differs from the room counts of other markets.
- **Coverage differs by city.** The portal is strongest in Barcelona and Madrid. In smaller cities many groups are compared at the city level and carry a lower confidence.
- **Portal exclusions.** Flats with bare ownership, occupied flats and auctions are left out of the medians and returned (mode `listings`) only with a flag and without analytics.
- **No information about the flat's condition** beyond the portal's status: a cheap listing may need renovation (`needsRenovation`).
- **Identical listings are merged.** Different flats in one building with the same property type, price, area and bedrooms can be merged into one record; the merged IDs are listed in `identicalListingIds`.
- **Spain only, one portal.**

### FAQ

**What does `confidence` mean?** `high`: compared within the district with at least 40 sale listings; a city × bedroom count or whole-city comparison is also `high` when at least 80% of the city's listings were fetched and both sides have enough listings. `medium`: district with fewer listings, or city × bedroom count. `low`: whole-city comparison.

**Why does a listing score 100 or 0?** Its price per m² is far below or above its group's median. Check the listing: very low prices often mean a renovation case, a share of a flat or a data error.

**Why is `firstSeenAt` empty?** It is filled only in monitoring runs.

**Can I get the newest listings only?** Use monitoring (`onlyNewOrChanged`) on a schedule: the portal does not allow sorting by date.

### Data sources and responsible use

- Data comes from Habitaclia search-result pages only, which the portal's robots.txt allows; the Actor checks it at the start of every run and stops if a needed path is forbidden. Listing detail pages are never opened.
- At most one request per second.
- No personal data is collected or stored; each result links to the original listing instead of copying it.
- This Actor is independent and not affiliated with or endorsed by Habitaclia.

# Actor input Schema

## `cities` (type: `array`):

Cities to analyse. Each city fetches the apartments for sale and for long-term rent of the whole city.

## `mode` (type: `string`):

listings: every listing for sale and for rent with our analytics (deal score, estimated rent and yield for sales), one row each, no yield rows; the number of rows follows from maxListingsPerSide and the exclusions, maxScoredListings is ignored. yieldReport: gross rental yield per district and bedroom count. scoreListings: a 0–100 deal score for every listing for sale. both: yield report and scored listings. bedrooms and areaMin/areaMax apply to listings rows too, minScore only to sale rows.

## `bedrooms` (type: `array`):

Bedroom counts to include in the results. "0" is a studio, "4+" means four or more bedrooms.

## `areaMin` (type: `integer`):

Smallest flat size to include, in m².

## `areaMax` (type: `integer`):

Largest flat size to include, in m².

## `minScore` (type: `integer`):

Return only listings with a deal score at or above this value (50 = priced at the median of comparable flats).

## `maxScoredListings` (type: `integer`):

Return at most this many listings, best deals first. 0 = all. Ignored in mode listings.

## `maxListingsPerSide` (type: `integer`):

Listings for sale and, separately, for rent per city. 0 = the whole market of the city (all pages the portal serves).

## `minSaleSample` (type: `integer`):

Listings for sale needed to compare with. If a district and bedroom group has fewer, a flat is compared with the same bedroom count across the city, then with the whole city; if the city has fewer too, it gets no deal score. A yield group below this number is not reported.

## `minRentSample` (type: `integer`):

Listings for rent needed for a rent estimate. If a district and bedroom group has fewer, the estimate uses the same bedroom count across the city, then the whole city; if the city has fewer too, there is no rent or yield estimate. A yield group below this number is not reported. Mode listings gives no estimate for low-confidence whole-city comparisons.

## `onlyNewOrChanged` (type: `boolean`):

Return only listings that are new or at least 1% cheaper since the last run with the same watchlist name.

## `watchlistName` (type: `string`):

Name of the monitoring memory. Use a different name for each watchlist; letters, digits, '.', '\_' and '-'.

## `proxyConfiguration` (type: `object`):

Proxy used to reach the listing portal. The default is Apify Proxy's residential group with addresses in Spain. You can pass your own proxyConfiguration instead.

## `minSalePrice` (type: `integer`):

Return only listings for sale asking at least this much. Filters returned rows only; scores compare with the whole market. Modes listings, scoreListings and both.

## `maxSalePrice` (type: `integer`):

Return only listings for sale asking at most this much. Filters returned rows only; scores compare with the whole market. Modes listings, scoreListings and both.

## `minMonthlyRent` (type: `integer`):

Return only rentals asking at least this much per month. Filters returned rows only; estimates use the whole market. Mode listings only.

## `maxMonthlyRent` (type: `integer`):

Return only rentals asking at most this much per month. Filters returned rows only; estimates use the whole market. Mode listings only.

## Actor input object example

```json
{
  "cities": [
    "vigo"
  ],
  "mode": "both",
  "bedrooms": [
    "0",
    "1",
    "2",
    "3",
    "4+"
  ],
  "areaMin": 15,
  "areaMax": 250,
  "minScore": 0,
  "maxScoredListings": 1000,
  "maxListingsPerSide": 0,
  "minSaleSample": 15,
  "minRentSample": 10,
  "onlyNewOrChanged": false,
  "watchlistName": "default",
  "proxyConfiguration": {
    "useApifyProxy": true,
    "apifyProxyGroups": [
      "RESIDENTIAL"
    ],
    "apifyProxyCountry": "ES"
  }
}
```

# Actor output Schema

## `rentalYield` (type: `string`):

Gross rental yield per district and bedroom count (areaYield records; in mode yieldReport they are in the default dataset).

## `scoredListings` (type: `string`):

Apartments for sale with deal score, best deals first (default dataset).

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "cities": [
        "vigo"
    ],
    "proxyConfiguration": {
        "useApifyProxy": true,
        "apifyProxyGroups": [
            "RESIDENTIAL"
        ],
        "apifyProxyCountry": "ES"
    }
};

// Run the Actor and wait for it to finish
const run = await client.actor("data-nest/habitaclia-rental-yield").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = {
    "cities": ["vigo"],
    "proxyConfiguration": {
        "useApifyProxy": True,
        "apifyProxyGroups": ["RESIDENTIAL"],
        "apifyProxyCountry": "ES",
    },
}

# Run the Actor and wait for it to finish
run = client.actor("data-nest/habitaclia-rental-yield").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "cities": [
    "vigo"
  ],
  "proxyConfiguration": {
    "useApifyProxy": true,
    "apifyProxyGroups": [
      "RESIDENTIAL"
    ],
    "apifyProxyCountry": "ES"
  }
}' |
apify call data-nest/habitaclia-rental-yield --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,data-nest/habitaclia-rental-yield"
        }
    }
}
```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/j6rJanfHH2PCmAZ0w/builds/0DxQ0pdy47unJehXu/openapi.json
