# Avito.ma API scraper — Morocco's largest classifieds marketplace: keyword and category search across second-hand goods, cars, real estate, jobs and services, filtered by city, district, price range, private-vs-professional seller and Avito's own ad flags; full ad detail with the vertical's own attributes and the public seller profile, plus live category and city resolvers — French/Arabic listings, prices in dirham, no key required

> Search Avito.ma by keyword and/or category, narrowed by city, district, price range, seller type and Avito's own ad flags. Covers every vertical on the site — phones, cars, apartments, furniture, jobs, services — and returns Avito's own result page (about 35-38 rows) with the total, the price both as a number and as the string the card prints, the seller's profile and phone number as the card publishes them and that vertical's own attribute rows. Every filter is verified against Avito's own parse of the request, so a value Avito does not understand is reported instead of quietly returning the whole catalogue. `ad_type` picks the sale, rent, holiday-rent or flat-share tree of a category (1010 + rent = apartments to let) and every row is checked to be of that type. Avito's new-development project cards (no ad id, not bound by the district filter) come back separately in `projects[]`, never mixed into `listings[]`. Give at least one of `q` or `category`.
> ReefAPI engine `avito-ma` · 4 endpoints · clean JSON, no scraping or browsers to manage.

## How to call
- **Endpoint:** `POST https://api.reefapi.com/avito-ma/v1/<action>` with a JSON body.
- **Auth:** header `x-api-key: <YOUR_REEFAPI_KEY>` — create one free (1,000 credits, no card): https://reefapi.com/signup
- **Response (every call):** `{ ok: boolean, data: ..., meta: { record_count, credits, ... }, error: { code, message } }` — branch on `ok`. Failed calls are free.
- **One key + one shared credit pool** across every ReefAPI API. Per-call credits are listed on each endpoint below.
- **Use it from an AI agent (MCP):** connect `https://api.reefapi.com/mcp` (remote streamable-http). Clients that add connectors by URL, such as ChatGPT and the Claude app, connect with OAuth 2.1 (the user pastes their key once on a ReefAPI page; discovery at `/.well-known/oauth-protected-resource/mcp`). Config files send the key as `Authorization: Bearer <key>`. `?key=<key>` in the URL also works as a last-resort fallback.

## Endpoints

### POST https://api.reefapi.com/avito-ma/v1/search — 1 credit
Search Avito.ma by keyword and/or category, narrowed by city, district, price range, seller type and Avito's own ad flags. Covers every vertical on the site — phones, cars, apartments, furniture, jobs, services — and returns Avito's own result page (about 35-38 rows) with the total, the price both as a number and as the string the card prints, the seller's profile and phone number as the card publishes them and that vertical's own attribute rows. Every filter is verified against Avito's own parse of the request, so a value Avito does not understand is reported instead of quietly returning the whole catalogue. `ad_type` picks the sale, rent, holiday-rent or flat-share tree of a category (1010 + rent = apartments to let) and every row is checked to be of that type. Avito's new-development project cards (no ad id, not bound by the district filter) come back separately in `projects[]`, never mixed into `listings[]`. Give at least one of `q` or `category`.

**Parameters:**
- `q` (string, optional) — Free-text keyword. Avito.ma's own search is French/Arabic and matches the ad title and body ('iphone', 'appartement', 'voiture occasion', 'شقة'). Optional: give `category` instead to browse a whole section. At least one of `q` or `category` is required.
- `category` (integer, optional) — Avito.ma category id — a root (7100 Market, 1000 Immobilier, 2000 Véhicules, 6000 Entreprise) or a leaf (5010 phones, 2010 used cars, 2040 vehicle parts, 1010 apartments). Property leaf ids are shared by the sale, rent, holiday-rent and flat-share trees (1010 = apartments in all four): add `ad_type` to pick the tree, otherwise the sale tree is used. Call the `categories` action for the live tree with every id.
- `city` (string, optional) — One Moroccan city, as its Avito slug or its name — 'casablanca', 'Marrakech', 'fes' (Avito strips the accents: Fès → fes, Béni Mellal → beni_mellal). Common English/French spellings are mapped: Fez, Marrakesh, Tangier, Casa, Tetuan, El Aaiun, Al Hoceima, Chaouen, Mazagan. The `locations` action lists every one Avito publishes with its slug and its live ad count. A city Avito does not know is rejected, never silently widened to the whole country.
- `area` (string, optional) — A district inside the chosen city ('maarif', 'medina_de_rabat'). Requires `city`. Take it from the `locations` action, which lists every city's districts.
- `ad_type` (enum, optional, default "sell") — Which tree of a `category` to search: for sale, long-term rent, holiday rent or flat-share. With category 1010 (apartments), 'rent' returns apartments to let (tree 1300), 'holiday_rent' holiday lets (1500), 'shared_rent' flat-shares (1400). Also works on cars (2100 + rent = car rental) and trucks. Needs a `category`: Avito's keyword search across all categories does not filter by ad type, so a rent type without a category is rejected. A category that does not exist in that ad type (5010 phones + rent) is rejected too — never answered with the wrong ad type. Each row echoes its own `ad_type` (SELL, LET, VAC_RENT, CO_RENT). [one of: sell, rent, holiday_rent, shared_rent]
- `price_min` (integer, optional) — Lowest price, in the currency the ads publish (Moroccan dirham, printed 'DH'). Either bound may be given alone.
- `price_max` (integer, optional) — Highest price, in the currency the ads publish.
- `seller_type` (enum, optional) — Restrict to private individuals or to professional sellers/shops. Each returned row echoes its own `seller_type`. [one of: private, professional]
- `ad_options` (enum, optional) — One of Avito's own ad flags: only ads with a price, only ads with a photo, only promotions, only urgent ads. [one of: has_price, has_image, hotdeal, urgent]
- `page` (integer, optional, default 1) — 1-based page number. Avito serves about 35-38 rows a page and the page size is not adjustable. Page forward with meta.next_page; consecutive pages of a live feed overlap by a row or two.
- `lang` (enum, optional, default "fr") — Interface language for the category and location names Avito prints. Ad titles and bodies are whatever the seller wrote, in French or Arabic, either way. [one of: fr, ar]

**Returns:** listings[]{ad_id, list_id, url, title, description, price, price_display, currency, price_matches_display, old_price, old_price_display, monthly_payment, ad_type, ad_type_label, category_id, category_name, category_path[]{id,name}, city_id, city, area_id, area, address, latitude, longitude, posted_at, seller_type, seller{seller_id, name, is_verified, is_ecommerce, registered_since, active_listings_count, logo, phone_verified, phone_contact_type, address, website}, phone, image, images[], image_count, is_premium, is_highlighted, is_urgent, is_hot_deal, is_promoted, offers_shipping, attributes[]{id,label,value,display,unit,section,code}} + projects[]{kind, title, url, city, area, price, price_display, currency, rooms, bathrooms, size, image} + meta{total, page, has_more, next_page, promoted_count, project_count, filters_applied[], resolved{city, area, category_id, keyword, ad_type}}

**Example request body:**
```json
{
  "q": "iphone",
  "category": 5010
}
```

### POST https://api.reefapi.com/avito-ma/v1/detail — 1 credit
One Avito.ma ad in full, by its `list_id` or by its address: title, the whole body text, price with the currency the ad publishes, category path, city and district, posting time, the complete photo gallery, the seller profile with its store id and listing count, the phone number the page publishes, and the ad's own attribute rows — storage and condition for a phone, year, mileage, gearbox and fuel for a car, rooms, surface and floor for an apartment. A removed or expired ad answers NOT_FOUND (Avito redirects it to a search page with HTTP 200, which this engine detects).

**Parameters:**
- `list_id` (string, optional) — The ad's `list_id` from a search result — the number that ends an avito.ma ad address. Give this or `url`.
- `url` (string, optional) — Full avito.ma ad address, either the short /vi/<id>.htm form or the long friendly one. Use `list_id` when you already have the number.
- `lang` (enum, optional, default "fr") — Interface language for the category and location names Avito prints. Ad titles and bodies are whatever the seller wrote, in French or Arabic, either way. [one of: fr, ar]

**Returns:** listing{ad_id, list_id, url, title, description, price, price_display, currency, price_matches_display, old_price, old_price_display, ad_type (SELL|LET|VAC_RENT|CO_RENT, as in search), ad_type_code (the page's own s|u|v|w), ad_type_label, category_id, category_name, category_path[], vertical, city_id, city, area_id, area, address, latitude, longitude, posted_at, seller_type (STORE|PRIVATE, as in search), seller_type_code (the page's own shop|private), seller{...}, phone (as the page publishes it; null when Avito hides it), image, images[], videos[], is_premium, is_urgent, is_hot_deal, offers_shipping, has_hidden_phone, attributes[]{id,label,value,display,unit,section,code}}

**Example request body:**
```json
{
  "url": "https://www.avito.ma/vi/56251043.htm"
}
```

### POST https://api.reefapi.com/avito-ma/v1/categories — 1 credit
The live Avito.ma category tree — an all-categories root plus the four sections (Avito Market, Immobilier, Véhicules, Entreprise) with every branch and leaf below them — 153 nodes, 140 distinct ids on 2026-11-03 (property leaves such as 1010 appear once in each of the sale, rent, flat-share and holiday-rent trees) — each with its id, its French name, its ad type (sell, let, vac_rent, co_rent), the `ad_type` value `search` needs to reach that exact node, and the url slug Avito uses for it. Use it to get the `category` id that `search` takes.

**Parameters:**
- `lang` (enum, optional, default "fr") — Interface language for the category and location names Avito prints. Ad titles and bodies are whatever the seller wrote, in French or Arabic, either way. [one of: fr, ar]

**Returns:** categories[]{category_id, name, ad_type, search_ad_type, url_slug, children[]…} + meta{total, node_count, distinct_category_ids}

**Example request body:**
```json
{
  "lang": "fr"
}
```

### POST https://api.reefapi.com/avito-ma/v1/locations — 1 credit
Every city and town Avito.ma publishes — about 600 (595 on 2026-11-03) — with its id, the slug `search` takes, the live number of ads in it, and the districts inside it. This is the live filter block Avito builds its own city picker from, so the ad counts are current.

**Parameters:**
- `city` (string, optional) — Return only this city (by slug, name or id) and its districts. Omit for all of them.
- `lang` (enum, optional, default "fr") — Interface language for the category and location names Avito prints. Ad titles and bodies are whatever the seller wrote, in French or Arabic, either way. [one of: fr, ar]

**Returns:** cities[]{city_id, name, slug, ad_count, areas[]{area_id, name, slug}} + meta{total}

**Example request body:**
```json
{
  "city": "casablanca"
}
```

## At scale
- **Volume:** 5M+ requests a day, measured at 60 requests a second across the fleet with no
  central bottleneck. Per-key limits are raised for high-volume accounts; volume pricing on request.
- **Missing a source:** tell us a site we do not cover and it becomes an engine. A customer asked
  for bestprice.gr on 21 Sep 2026 and it was in the catalog on 22 Sep.
- **Support:** 2 minute median time from a question in the live chat to the first answer. Setup
  help included, no support tier to buy.
- **One key, one credit pool** across every API. No per-site plans, no separate subscriptions.

## More
- Try it live, no code: https://reefapi.com/playground?engine=avito-ma
- Human docs page: https://reefapi.com/docs/avito-ma
- Overview page: https://reefapi.com/avito-ma-api
- Every ReefAPI API in one file (for your AI): https://reefapi.com/llms-full.txt

## Questions developers ask about Avito.ma data

### Is there an official Avito.ma API for listings and prices?

Not a public one. Scraper vendors on Apify state that Avito.ma publishes no public data API, and an open-source Avito.ma MCP server on GitHub says it relies on private endpoints found by analysing the Android app, which Avito may change at any time.

ReefAPI's Avito.ma API returns the site's public listings as JSON: `search` covers every section (phones, cars, apartments, jobs) with city, district, price and seller-type filters, and `detail` returns one ad in full. `categories` and `locations` give the live category ids and city slugs.

```
curl -X POST https://api.reefapi.com/avito-ma/v1/search \
  -H "x-api-key: $REEF_KEY" -H "content-type: application/json" \
  -d '{"q":"iphone 15","category":5010,"city":"casablanca","price_min":3000,"price_max":8000}'
```

Real response, 2 Nov 2026: total 396 · page 1: 35 ads from 3,005 to 8,000 DH, median 6,700 · "iPhone 15 Pro Max 256G importé d'Europe non recyclé" 7,500 DH · 256 GB · Bon état · Aïn Chock · seller_type STORE

### My Playwright scraper for Avito.ma works locally but gets a Cloudflare 403 ("Un instant…") on AWS Lambda. Why?

A developer on Stack Overflow describes exactly this: the same Playwright code loads Avito.ma on a laptop, but from AWS Lambda it gets HTTP 403 and Cloudflare's Turnstile page ("Vérification de sécurité en cours"), even with a French locale and the Africa/Casablanca timezone. The answer there points at the Lambda network and the browser's signals together, not at Playwright itself.

If the function only needs the data, call ReefAPI's Avito.ma API instead: it is one HTTPS POST, so there is no Chromium to ship in the Lambda, and `detail` takes the same avito.ma ad URL you were opening.

```
import json, os, urllib.request

def handler(event, context):
    req = urllib.request.Request(
        "https://api.reefapi.com/avito-ma/v1/detail",
        data=json.dumps({"url": event["url"]}).encode(),
        headers={"x-api-key": os.environ["REEF_KEY"], "content-type": "application/json"},
    )
    ad = json.load(urllib.request.urlopen(req, timeout=60))["data"]["listing"]
    return {"title": ad["title"], "price": ad["price"], "city": ad["city"],
            "attributes": {a["id"]: a["value"] for a in ad["attributes"]}}
```

Real response, 2 Nov 2026: "Skoda Octavia" · 209000 DH · Casablanca, Sidi Moumen · brand Skoda · model Octavia · regdate 2022 · mileage_exact 77800 · Manuelle · Diesel · 8 CV · 12 photos · verified store with 180 active ads

### Why does Avito.ma ignore my keyword, city or district filter and return ads from all of Morocco?

The author of an open-source Avito.ma search tool on GitHub documents it: `?keyword=` is silently ignored, a single-value `?cities=` is dropped, `?areas=` does nothing and there is no sort parameter at all, yet the page still loads with ads from the whole country.

ReefAPI's Avito.ma API takes `city` and `area` as Avito slugs or names, accents optional (`Fès` resolves to `fes`), lists what Avito actually applied in `meta.filters_applied` and `meta.resolved`, and answers `INVALID_PARAM` at no charge when Avito does not know a value. English names such as `Fez`, `Marrakesh`, `Tangier` or `Casa` resolve too; take the accepted slugs and every city's districts from `locations`.

```
curl -X POST https://api.reefapi.com/avito-ma/v1/search \
  -H "x-api-key: $REEF_KEY" -H "content-type: application/json" \
  -d '{"category":2010,"city":"Fès","seller_type":"private","ad_options":"has_price"}'
```

Real response, 2 Nov 2026: resolved.city "fes" · filters_applied city, category, seller_type, ad_options · total 5,789 · 38 of 38 rows in Fès

### How do I get apartment prices per m² by neighbourhood in Casablanca, Rabat or Marrakech?

Moroccan real-estate projects on GitHub, such as AvitoTrackr ("prix moyen par m2 des appartements dans différentes villes"), scrape Avito.ma apartment ads and divide the price by the surface.

With ReefAPI, search category `1010` with `city`, `area` and `ad_options: has_price`; each row carries `price` in dirham and the surface as the `size` attribute. New-development project cards that Avito mixes into the page come back separately in `projects`, so `listings` holds only ads; take the median, because sellers sometimes post a monthly rental in the sale section.

```
import requests, statistics

ppm2 = []
for page in (1, 2):
    r = requests.post(
        "https://api.reefapi.com/avito-ma/v1/search",
        headers={"x-api-key": REEF_KEY},
        json={"category": 1010, "city": "casablanca", "area": "maarif",
              "ad_options": "has_price", "page": page},
    )
    for ad in r.json()["data"]["listings"]:
        size = next((a["value"] for a in ad["attributes"] if a["id"] == "size"), None)
        if ad["list_id"] and ad["price"] and size:
            ppm2.append(ad["price"] / size)
print(len(ppm2), round(statistics.median(ppm2)))
```

Real response, 2 Nov 2026: Maarif, Casablanca: 755 ads, median 14,545 DH/m² over 67 priced ads on pages 1–2 · Agdal, Rabat: 171 ads, 17,940 DH/m² (52) · Guéliz, Marrakech: 853 ads, 19,819 DH/m² (44)

### How do I build a used-car price dataset from Avito.ma for a price-prediction model?

It is a common Moroccan ML project: one CarPrice AI repository on GitHub trained on 99,506 cars scraped from 500 Avito.ma pages, and when an r/Morocco poster shared an analysis of 1,815 Avito.ma used-car listings, the first question was how he scraped them; only 1,158 of his 1,815 had a usable asking price.

With ReefAPI, page through category `2010` (Voitures d'occasion) with `ad_options: has_price`: each row already carries the model year (`regdate`), `mileage_exact`, gearbox and fuel, and `detail` adds brand, model, fiscal horsepower and first-owner status. Mileage is whatever the seller typed, so clean it before training.

```
import requests

rows, seen = [], set()
for page in range(1, 6):
    r = requests.post(
        "https://api.reefapi.com/avito-ma/v1/search",
        headers={"x-api-key": REEF_KEY},
        json={"category": 2010, "ad_options": "has_price", "page": page},
    )
    data = r.json()
    for ad in data["data"]["listings"]:
        if ad["list_id"] in seen:
            continue
        seen.add(ad["list_id"])
        attrs = {a["id"]: a["value"] for a in ad["attributes"]}
        rows.append({"list_id": ad["list_id"], "title": ad["title"], "price": ad["price"],
                     "city": ad["city"], "year": attrs.get("regdate"),
                     "km": attrs.get("mileage_exact"), "gearbox": attrs.get("bv"),
                     "fuel": attrs.get("fuel")})
    if not data["meta"]["has_more"]:
        break
```

Real response, 2 Nov 2026: category 2010: 141,620 ads, 111,758 with a price · "Skoda Octavia" 209000 DH, regdate 2022, mileage_exact 77800, Manuelle, Diesel → detail: brand Skoda, model Octavia, 8 CV, first_owner Non · a 1995 Renault 19 lists 99 km

### How do I get an alert when a new Avito.ma rental appears in Rabat under my budget?

Developers build this as a small bot: one open-source Avito.ma bot on GitHub polls new apartment ads, filters them by price and location and sends each match to Telegram once, keeping the ids it has already sent in SQLite, because "the best opportunities are often gone within minutes".

With ReefAPI, poll page 1 of `search` with category `1300` (Locations Immobilières; `1500` is holiday rentals by the night), `city` and `price_max`, and alert on any `list_id` you have not stored. Dedupe on `list_id` rather than on the date: rows come roughly newest first, and an older ad can come back near the top with a fresh `posted_at`.

```
import requests

seen = set()  # load from your database
r = requests.post(
    "https://api.reefapi.com/avito-ma/v1/search",
    headers={"x-api-key": REEF_KEY},
    json={"category": 1300, "city": "rabat", "price_max": 6000},
)
for ad in r.json()["data"]["listings"]:
    if ad["category_id"] == "1010" and ad["list_id"] not in seen:
        seen.add(ad["list_id"])
        print(ad["price"], ad["area"], ad["title"], ad["url"])  # send to Telegram here
```

Real response, 2 Nov 2026: Rabat, up to 6,000 DH a month: total 1,614 · newest "APPARTEMENT MEUBLÉ CENTRE-VILLE PRÈS BAB AL HAD" 5000 DH, 40 m², Hassan, posted_at 22:17 UTC · page 1: 27 apartments, 5 shops, 3 offices