# MarocAnnonces Real Estate Scraper (`dadhalfdev/marocannonces-real-estate-scraper`) Actor

Scrape apartments, villas, land, and offices for sale or rent on marocannonces.com, with rooms, bathrooms, and surface.

- **URL**: https://apify.com/dadhalfdev/marocannonces-real-estate-scraper.md
- **Developed by:** [Marco Rodrigues](https://apify.com/dadhalfdev) (community)
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $1.50 / 1,000 results

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/running/actors-in-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

## 🏠 MarocAnnonces Real Estate Scraper

Want property ads from [MarocAnnonces](https://www.marocannonces.com/categorie/315/Vente-immobilier/Appartements.html) in a spreadsheet? This scraper makes it easy.

Use **structured filters** — better for AI agents — **or** paste an **`input_url`**. When `input_url` is set it overrides the filters.

This actor stays on sale and rent shelves that share the same columns (offer, rooms, bathrooms, surface): apartments, villas, studios, shops, offices, land, farms, and pharmacies. It returns up to 2000 rows per run.

Cars, goods, jobs, and services live in separate actors, because those shelves use different filters and different columns.

### 💡 Perfect for...

- **Agencies:** Export MarocAnnonces sale and rent ads with rooms and surface.
- **Dashboards:** Track asking prices in Casablanca, Rabat, and Marrakech.
- **Market research:** Slice listings by city, rooms, surface, or price.
- **Data analysts:** Export structured rows with seller, phone, photos, and the public ad text.
- **🤖 AI Agents:** Power Claude, Cursor, Codex, the Hermes Agent, and OpenClaw workflows with live MarocAnnonces property ads.
- **📚 RAG Systems:** Feed titles, cities, and specs into retrieval pipelines.
- **🔗 AI Workflows:** Plug into LangChain, AutoGPT, CrewAI, and similar stacks.

### ✨ Why you'll love this scraper

- 🔗 **Input URL or Filters:** Paste any MarocAnnonces property URL, or pick sale or rent, a shelf, and a city. `input_url` always wins when set.
- 🎯 **Website-Matched Filters:** Offer, shelf, city, keyword, price, surface, rooms, and bathrooms.
- 🌐 **Full property ads:** Rooms, bathrooms, surface, photos, seller, phone, and description.

### 📦 What's inside the data?

`id`, `url`, `title`, `category`, `offer_type`, `price`, `price_text`, `currency`, `city`, `country`, `posted`, `views`, `image`, `images`, `description`, `seller`, `phone`, `rooms`, `bathrooms`, `area_m2`

### 🚀 Quick start

**Option A:** paste `https://www.marocannonces.com/categorie/315/Vente-immobilier/Appartements.html`.
**Option B:** pick sale or rent, a shelf, and a city, then set `max_results`.

**Input Example (filters):**

```json
{
  "offer": "vente",
  "category": "appartements",
  "city": "Marrakech",
  "rooms": 2,
  "max_results": 100
}
```

**Input Example (URL):**

```json
{
  "input_url": "https://www.marocannonces.com/categorie/321/Location-immobilier/Appartements.html",
  "max_results": 100
}
```

**Output Example:**

```json
{
  "id": "10474037",
  "url": "https://www.marocannonces.com/categorie/315/Appartements/annonce/10474037/Appartement-à-vendre-résidence-Coralia-Marrakech.html",
  "title": "Appartement à vendre résidence Coralia Marrakech",
  "category": "Appartements",
  "offer_type": "Sale",
  "price": 2200000,
  "price_text": "2 200 000 DH",
  "currency": "MAD",
  "city": "Marrakech",
  "country": "Morocco",
  "posted": "15 Oct-23:01",
  "views": 5,
  "rooms": 2,
  "bathrooms": 2,
  "area_m2": 94,
  "seller": "Othmane El Qasah",
  "phone": "061-857-9487",
  "description": "Appartement à vendre dans une résidence fermée et sécurisée avec piscine",
  "image": "https://www.marocannonces.com/user_images/315/2171558.jpg"
}
```

**Output fields:**

| Field | Description |
|-------|-------------|
| `id` | MarocAnnonces ad id. |
| `url` | Public ad page. |
| `title` | Ad title. |
| `category` | Property shelf, such as Appartements or Villas et Riads. |
| `offer_type` | `Sale` or `Rent`. |
| `price` | Numeric price in dirhams when stated. |
| `price_text` | Formatted price string from the card. |
| `currency` | `MAD` when a price is shown. |
| `city` / `country` | City, and Morocco. |
| `posted` | Date and time shown on the ad. The site prints the day and time without a year. |
| `views` | View count on the ad page. |
| `image` / `images` | Cover photo, and the photo gallery. |
| `description` | Ad text. |
| `seller` / `phone` | Seller name and phone number shown on the ad. |
| `rooms` | Number of rooms. |
| `bathrooms` | Number of bathrooms. |
| `area_m2` | Surface in square metres. |

### 📋 Input reference

| Parameter | Type | Required | Default | Description |
|-----------|------|----------|---------|-------------|
| `input_url` | string | No | — | MarocAnnonces property category, search, or ad URL. Overrides every filter. |
| `offer` | dropdown | No | vente | For sale or for rent. |
| `category` | dropdown | No | appartements | Apartments, villas, studios, shops, offices, land, farms, pharmacies, holiday rentals, or shared housing. |
| `city` | string | No | — | City, such as Marrakech. |
| `query` | string | No | — | Search keyword. |
| `price_min` / `price_max` | integer | No | — | Price range in Moroccan dirhams. |
| `surface_min` / `surface_max` | integer | No | — | Surface in square metres. |
| `rooms` | integer | No | — | Number of rooms. 6 or more matches +5. |
| `bathrooms` | integer | No | — | Number of bathrooms. 5 or more matches +4. |
| `max_results` | integer | No | `50` | Maximum rows (`1`–`2000`). |

# Actor input Schema

## `input_url` (type: `string`):

Paste a MarocAnnonces category, search, or ad URL (e.g. https://www.marocannonces.com/categorie/315/Vente-immobilier/Appartements.html). Overrides every filter when set.

## `offer` (type: `string`):

For sale or for rent.

## `category` (type: `string`):

Property shelf. Land and pharmacies are sale only. Holiday rentals and shared housing are rent only.

## `city` (type: `string`):

City name, such as Casablanca, Rabat, Marrakech, Tanger, Fès, or Agadir.

## `query` (type: `string`):

Search keyword.

## `price_min` (type: `integer`):

Price range in Moroccan dirhams.

## `price_max` (type: `integer`):

Price range in Moroccan dirhams.

## `surface_min` (type: `integer`):

Smallest surface in square metres.

## `surface_max` (type: `integer`):

Largest surface in square metres.

## `rooms` (type: `integer`):

Number of rooms. 6 or more matches the site's +5 choice.

## `bathrooms` (type: `integer`):

Number of bathrooms. 5 or more matches the site's +4 choice.

## `max_results` (type: `integer`):

How many ads to return (1-2000).

## Actor input object example

```json
{
  "offer": "vente",
  "category": "appartements",
  "max_results": 50
}
```

# Actor output Schema

## `overview` (type: `string`):

Table view of scraped property ads using the dataset overview.

## `results` (type: `string`):

All scraped property ads from the 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 = {};

// Run the Actor and wait for it to finish
const run = await client.actor("dadhalfdev/marocannonces-real-estate-scraper").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 = {}

# Run the Actor and wait for it to finish
run = client.actor("dadhalfdev/marocannonces-real-estate-scraper").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 '{}' |
apify call dadhalfdev/marocannonces-real-estate-scraper --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,dadhalfdev/marocannonces-real-estate-scraper"
        }
    }
}
```

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/luQbcpIl5tdtTDEsw/builds/7IC4gQeK84a8V1paZ/openapi.json
