# Avito Scraper (`worshipful_knife/avito-scraper`) Actor

Fast & reliable scraper for Avito.ma listings. Extract titles, prices, descriptions,
seller info, images & attributes. Supports 50+ categories or custom search URLs.
Concurrent scraping with anti-detection.

- **URL**: https://apify.com/worshipful\_knife/avito-scraper.md
- **Developed by:** [kata Kuri](https://apify.com/worshipful_knife) (community)
- **Categories:** Automation, Developer tools, E-commerce
- **Stats:** 10 total users, 1 monthly users, 97.1% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $0.70 / 1,000 results

This Actor is paid per event and usage. You are charged both the fixed price for specific events and for Apify platform usage.
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?

Actors are web data automations that power AI and operations. They run on the Apify platform to scrape websites, process data, connect APIs, and automate workflows.
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.
Actors are written with capital "A".

## 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.
The best way to integrate Actors is as follows.

- **AI agents and MCP clients** — the [Apify MCP server](https://docs.apify.com/integrations/mcp.md) at `https://mcp.apify.com` (remote, streamable HTTP, OAuth on first use).
- **Agentic workflows and local Actor development** — [Agent Skills](https://apify.com/.well-known/agent-skills/index.json) with the [Apify CLI](https://docs.apify.com/cli/docs.md): `npm install -g apify-cli`, then `apify login`.
- **JavaScript/TypeScript projects** — the official [JS/TS client](https://docs.apify.com/api/client/js/docs.md): `npm install apify-client`.
- **Python projects** — the official [Python client](https://docs.apify.com/api/client/python/docs.md): `pip install apify-client`.
- **Any other language** — the [REST API](https://docs.apify.com/api/v2.md).

For usage examples, see the [API](#api) section below.

For more details, see Apify documentation as [Markdown index](https://docs.apify.com/llms.txt) and [Markdown full-text](https://docs.apify.com/llms-full.txt).

# README

## Avito.ma Scraper

Fast and reliable Apify actor that scrapes listings from [Avito.ma](https://www.avito.ma) — Morocco's largest classifieds marketplace.

### Features

- **Two input modes**: choose from 50+ predefined categories OR paste custom Avito.ma URLs
- **Search filters**: keyword, city, sort order, min/max price
- **Full detail scraping**: description, HD images, seller info, phone, attributes
- **Smart limits**: `maxResults` stops scraping immediately when reached — no wasted requests
- **Anti-detection**: user-agent rotation, viewport randomization, stealth mode, resource blocking
- **Proxy support**: residential proxies recommended
- **Fast**: blocks images/css/fonts, concurrent browser pages
- **Structured JSON** output ready for analysis

### Pricing

**$0.01 USD per result** — you only pay for the listings extracted.

### Input

#### Categories & URLs

| Parameter | Type | Default | Description |
|-----------|------|---------|-------------|
| `categories` | string\[] | — | Select from 50+ predefined Avito.ma categories |
| `categoryUrls` | string\[] | — | Paste any Avito.ma category/search URLs directly |

At least one of `categories` or `categoryUrls` is required. You can use both together.

#### Search Filters

| Parameter | Type | Default | Description |
|-----------|------|---------|-------------|
| `searchKeyword` | string | — | Filter by keyword (e.g. "iPhone 15", "Mercedes") |
| `city` | string | — | Filter by city (e.g. "Casablanca", "Rabat") |
| `sortBy` | string | — | Sort: `newest`, `oldest`, `price-low`, `price-high` |
| `minPrice` | integer | — | Minimum price in MAD |
| `maxPrice` | integer | — | Maximum price in MAD |

#### Scraping Limits

| Parameter | Type | Default | Description |
|-----------|------|---------|-------------|
| `maxResults` | integer | unlimited | Stop after this many results (across all URLs) |
| `maxPages` | integer | 5 | Max pages per category (~38 listings/page) |
| `scrapeDetails` | boolean | true | Visit detail pages for full data |
| `maxConcurrency` | integer | 5 | Parallel browser tabs (1-20) |
| `proxyConfiguration` | object | — | Apify proxy settings |

#### Example Input

```json
{
    "categories": ["smartphones", "ordinateurs-portables"],
    "searchKeyword": "iPhone 15",
    "city": "Casablanca",
    "sortBy": "newest",
    "minPrice": 5000,
    "maxPrice": 15000,
    "maxResults": 50,
    "maxPages": 10,
    "scrapeDetails": true,
    "proxyConfiguration": {
        "useApifyProxy": true,
        "apifyProxyGroups": ["RESIDENTIAL"]
    }
}
```

### Output

Each result contains:

| Field | Type | Description |
|-------|------|-------------|
| `avitoId` | string | Unique Avito listing ID |
| `title` | string | Listing title |
| `price` | number | Price value |
| `currency` | string | Currency (MAD) |
| `city` | string | City name |
| `location` | string | Full location |
| `category` | string | Category name |
| `description` | string | Full description |
| `images` | string\[] | Image URLs (HD when available) |
| `details` | object | Category-specific attributes |
| `sellerName` | string | Seller display name |
| `sellerPhone` | string | Seller phone number |
| `sellerId` | string | Seller Avito ID |
| `sellerProfileUrl` | string | Seller profile URL |
| `sellerMemberSince` | string | Year seller joined |
| `sellerLocation` | string | Seller location |
| `sellerTotalListings` | number | Seller's total active ads |
| `listingUrl` | string | Direct link to listing |
| `publishedAt` | string | Publication date |
| `scrapedAt` | string | Scrape timestamp (ISO 8601) |
| `_completeness` | string | `basic` (category only) or `full` (detail page visited) |

#### Example Output

```json
{
    "avitoId": "12345678",
    "title": "MacBook Pro M2 2023 - Comme neuf",
    "price": 15000,
    "currency": "MAD",
    "city": "Casablanca",
    "location": "Casablanca",
    "category": "Ordinateurs Portables",
    "description": "MacBook Pro M2 en excellent état...",
    "images": [
        "https://content.avito.ma/classifieds/images/..."
    ],
    "details": {
        "Marque": "Apple",
        "Modèle": "MacBook Pro",
        "RAM": "16 Go"
    },
    "sellerName": "TechShop",
    "sellerPhone": "0612345678",
    "sellerId": "987654",
    "sellerProfileUrl": "/profil/techshop",
    "sellerMemberSince": "2019",
    "sellerLocation": "Casablanca",
    "sellerTotalListings": 42,
    "listingUrl": "https://www.avito.ma/fr/casablanca/macbook_pro_m2-12345678.htm",
    "publishedAt": "2024-01-15T10:30:00.000Z",
    "scrapedAt": "2024-01-20T14:22:33.000Z",
    "_completeness": "full"
}
```

### How It Works

1. Resolves category slugs to Avito.ma URLs and applies search filters (keyword, city, sort, price)
2. Navigates using a stealth Playwright browser with randomized fingerprints
3. Extracts listing data from Next.js `__NEXT_DATA__` (no HTML parsing — fast & reliable)
4. Paginates through pages up to `maxPages`, stopping early if `maxResults` is reached
5. Optionally visits each detail page for full description, HD images, seller info, and attributes
6. Outputs structured JSON to the Apify dataset

### Tips

- Use **residential proxies** for best reliability
- Set `scrapeDetails: false` for faster runs when you only need basic listing info
- Use `maxResults` to control costs — the scraper stops immediately when the limit is hit
- Increase `maxConcurrency` for faster runs (monitor memory usage)
- Each category page has ~38 listings, so `maxPages=10` gives ~380 results per URL
- Combine `categories` with `searchKeyword` and price filters for precise targeting

# Actor input Schema

## `categories` (type: `array`):

Select one or more Avito.ma categories to scrape. You can combine this with custom URLs below. At least one of 'categories' or 'categoryUrls' is required.

## `categoryUrls` (type: `array`):

Paste any Avito.ma category, search, or filtered URL directly. Use this for specific search queries or filtered results. At least one of 'categories' or 'categoryUrls' is required.

## `searchKeyword` (type: `string`):

Filter listings by keyword (e.g. 'iPhone 15', 'Mercedes'). Applied as a search query parameter to all category URLs.

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

Filter by city name (e.g. 'Casablanca', 'Rabat', 'Marrakech').

## `sortBy` (type: `string`):

Sort order for results.

## `minPrice` (type: `integer`):

Minimum price filter in MAD (Moroccan Dirham).

## `maxPrice` (type: `integer`):

Maximum price filter in MAD (Moroccan Dirham).

## `maxResults` (type: `integer`):

Maximum number of listings to scrape across all categories/URLs. The scraper will stop when this limit is reached. Leave empty for unlimited.

## `maxPages` (type: `integer`):

Maximum pages to scrape per category URL. Each page has ~38 listings. This is a per-category limit, not a global limit.

## `scrapeDetails` (type: `boolean`):

Visit each listing page for full description, HD images, seller info, phone, and attributes. Disable for faster basic scraping. Detail pages take ~3-5 seconds each.

## `maxConcurrency` (type: `integer`):

Number of parallel browser pages. Higher = faster but uses more memory. Recommended: 3-5 for stability.

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

Apify proxy settings. Residential proxies recommended for best reliability and to avoid blocking.

## Actor input object example

```json
{
  "categories": [
    "smartphones"
  ],
  "maxResults": 5,
  "maxPages": 5,
  "scrapeDetails": true,
  "maxConcurrency": 5
}
```

# Actor output Schema

## `avitoId` (type: `string`):

Unique Avito listing identifier

## `title` (type: `string`):

Listing title

## `price` (type: `string`):

Price value

## `currency` (type: `string`):

No description

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

No description

## `location` (type: `string`):

No description

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

No description

## `description` (type: `string`):

No description

## `images` (type: `string`):

Image URLs (JSON array)

## `details` (type: `string`):

Category attributes (JSON object)

## `sellerName` (type: `string`):

No description

## `sellerPhone` (type: `string`):

No description

## `sellerId` (type: `string`):

No description

## `sellerProfileUrl` (type: `string`):

No description

## `sellerMemberSince` (type: `string`):

No description

## `sellerLocation` (type: `string`):

No description

## `sellerTotalListings` (type: `string`):

No description

## `listingUrl` (type: `string`):

No description

## `publishedAt` (type: `string`):

No description

## `scrapedAt` (type: `string`):

No description

## `_completeness` (type: `string`):

Data completeness level: 'basic' (category page only) or 'full' (detail page visited)

# 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 = {
    "categories": [
        "smartphones"
    ],
    "maxResults": 5,
    "scrapeDetails": false
};

// Run the Actor and wait for it to finish
const run = await client.actor("worshipful_knife/avito-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 = {
    "categories": ["smartphones"],
    "maxResults": 5,
    "scrapeDetails": False,
}

# Run the Actor and wait for it to finish
run = client.actor("worshipful_knife/avito-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 '{
  "categories": [
    "smartphones"
  ],
  "maxResults": 5,
  "scrapeDetails": false
}' |
apify call worshipful_knife/avito-scraper --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,worshipful_knife/avito-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/6eSlXsr4NAVzDUrPw/builds/dNIOAdfCQS5L1GVij/openapi.json
