# OMPIC Morocco Business Registry Scraper (`scraper_guru/ompic-scraper`) Actor

Scrape company data from Morocco's official business registry (OMPIC / directinfo.ma). Extract company name, RC number, city, legal form, activity sector, creation date, and capital.

- **URL**: https://apify.com/scraper\_guru/ompic-scraper.md
- **Developed by:** [LIAICHI MUSTAPHA](https://apify.com/scraper_guru) (community)
- **Categories:** AI, Lead generation, MCP servers
- **Stats:** 3 total users, 1 monthly users, 100.0% runs succeeded, NaN bookmarks
- **User rating**: No ratings yet

## Pricing

from $10.00 / 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.

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

## What's an Apify Actor?

Actors are a software tools running on the Apify platform, for all kinds of web data extraction and automation use cases.
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.

In JavaScript/TypeScript projects, use official [JavaScript/TypeScript client](https://docs.apify.com/api/client/js.md):

```bash
npm install apify-client
```

In Python projects, use official [Python client library](https://docs.apify.com/api/client/python.md):

```bash
pip install apify-client
```

In shell scripts, use [Apify CLI](https://docs.apify.com/cli/docs.md):

````bash
# MacOS / Linux
curl -fsSL https://apify.com/install-cli.sh | bash
# Windows
irm https://apify.com/install-cli.ps1 | iex
```bash

In AI frameworks, you might use the [Apify MCP server](https://docs.apify.com/platform/integrations/mcp.md).

If your project is in a different language, use 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

## OMPIC Business Registry Scraper: The Ultimate Moroccan B2B Lead Engine 🇲🇦📈

[![Apify Actor](https://img.shields.io/badge/Apify-Actor-brightgreen)](https://apify.com) https://apify.com/scraper_guru

Unlock the entire corporate landscape of Morocco with the most robust, high-performance scraper built for the official **OMPIC Business Registry (directinfo.ma)**. This tool pierces through complex anti-bot measures to deliver structured, high-fidelity corporate intelligence directly into your data pipelines.

---

### 💎 The Value Proposition: Why OMPIC Data is Pure Gold

In the world of B2B sales, investment, and market research, **accurate firmographic data is the ultimate competitive advantage**. 

However, extracting data from official government registries like OMPIC is notoriously difficult. The platform sits behind dynamic XSRF-TOKEN protections, session validations, and strict 403 firewalls that block standard scraping attempts. 

**We solved it.** This scraper acts as a stealthy, authenticated browser session, extracting raw, clean JSON data directly from the registry's backend APIs. By using this tool, you gain immediate access to:

- **Hyper-Targeted Lead Generation:** Build massive lists of verified Moroccan companies filtered by city (e.g., Casablanca), legal form (e.g., SARL), or specific keywords.
- **Market Intelligence & Sizing:** Understand exactly how many businesses operate in specific sectors or regions to size the Moroccan market accurately.
- **Due Diligence & Compliance:** Instantly verify the legal existence, exact registration number (RC), and creation date of partners, suppliers, or competitors.
- **AI Agent Tooling:** Provide your AI sales agents or legal research agents with direct access to official Moroccan corporate data.

---

### 🌍 The "MENA Data Mine" Vision

We are on a mission to build the **ultimate Data Mine for the Middle East and North Africa (MENA) region.**

Historically, the MENA region has been a massive blind spot for global data providers. B2B platforms like ZoomInfo or Apollo.io have notoriously weak coverage in North Africa. **The OMPIC Business Registry Scraper is a foundational pillar of our vision to fix this.**

By bridging the data gap, we empower developers, B2B agencies, and enterprises to:
1. **Execute hyper-localized B2B outreach** without relying on outdated, expensive lead databases.
2. **Train smarter AI models** on the actual economic landscape of Morocco.
3. **Automate financial and legal workflows** across the African continent.

This isn't just a scraper; it's the missing infrastructure layer for Moroccan B2B tech.

---

### ⚡ Technical Superiority

Scraping OMPIC manually or with basic scripts results in instant IP bans and 403 Forbidden errors. We engineered this actor to be flawless:

- **API Interception Engine:** It doesn't rely on fragile HTML parsing. It securely establishes a browser session, handles the XSRF security handshakes, and extracts the raw JSON payloads directly from OMPIC's backend APIs.
- **Smart Pagination & Anti-Cap Sweeping:** OMPIC limits searches to 200 results. Our actor features a proprietary **Bigram Expansion Algorithm**. If a search hits the 200-company limit, it automatically splits the search into granular two-letter combinations (e.g., "tech-a", "tech-b") to bypass the cap and scrape *everything*.
- **Ultra-Fast & Cost-Efficient:** By doing API-level extraction inside a single reused Playwright session, it pulls thousands of records in seconds while keeping your Apify compute costs near zero.

---

### 🛠️ Extracted Data Schema

For every company scraped, you receive a perfectly structured JSON object ready for your CRM, database, or LLM:

```json
{
  "name": "MENA TECH SOLUTIONS SARL",
  "rc": "723165",
  "city": "CASABLANCA",
  "legalForm": "SOCIETE A RESPONSABILITE LIMITEE",
  "activity": "DEVELOPPEMENT INFORMATIQUE ET SERVICES",
  "creationDate": "2021-03-15T00:00:00.000Z",
  "capital": "100000",
  "address": "123 Bd Mohammed V, Casablanca",
  "status": "EN ACTIVITE",
  "ice": "003917968000057",
  "source": "directinfo.ma / OMPIC",
  "keyword": "tech",
  "scrapedAt": "2026-04-26T02:15:00.000Z"
}
````

***

### ⚙️ Input Configuration

Easily control exactly what leads you want to extract:

| Parameter | Type | Description |
|-----------|------|-------------|
| **Search Keywords** | `Array` | Add sectors or names (e.g., `["immobilier", "consulting"]`). Leave as `[""]` for a massive A-Z alphabet sweep. |
| **Max Items** | `Integer` | Set a hard limit to control your budget (e.g., `5000` companies). |
| **City Filter** | `String` | *(Optional)* Only return companies registered in a specific city (e.g., `Rabat`). |
| **Legal Form Filter** | `String` | *(Optional)* Only return specific legal structures (e.g., `SARL`, `SA`). |
| **Proxy Configuration** | `Object` | *Crucial:* Always enable Apify Proxies. **Residential IPs** are highly recommended if doing massive A-Z sweeps to prevent IP blacklisting. |

***

### 💰 Monetization & ROI

At a **Pay-Per-Event** pricing model, this actor costs a fraction of a cent per highly-qualified, verified B2B lead. Whether you need 100 competitors for a report or 50,000 SMEs for a cold email campaign, you only pay for exactly what you extract.

***

### 🔗 Discover the MENA Data Mine Ecosystem

OMPIC is just the beginning. Power your entire Moroccan and MENA regional strategy with our suite of specialized scrapers:

- 🏠 **[Avito.ma Scraper](https://apify.com/scraper_guru/avito-scraper)** - Extract real estate, vehicles, and classifieds data across Morocco.
- 🏢 **[Mubawab Scraper](https://apify.com/scraper_guru/mubawab-scraper)** - The premier source for Moroccan real estate market intelligence.
- 💼 **[Rekrute.com Scraper](https://apify.com/scraper_guru/rekrute-scraper)** - Mine professional job listings and corporate hiring trends.
- 📰 **[Hespress Scraper](https://apify.com/scraper_guru/hespress-scraper)** - Monitor news, sentiment, and current events in Morocco.

***

*Unlock the B2B data of tomorrow, today. Welcome to the MENA Data Mine.*

**Built by Mustapha LIAICHI** | [Mustapha LIAICHI](https://mustaphaliaichi.com)

# Actor input Schema

## `searchKeywords` (type: `array`):

Keywords to search in OMPIC registry. Leave empty for full A-Z alphabetic sweep (slower but more complete).

## `maxItems` (type: `integer`):

Maximum number of companies to extract.

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

Filter results by city (e.g. Casablanca, Rabat, Marrakech). Leave empty for all cities.

## `legalForm` (type: `string`):

Filter by legal form: SA, SARL, SNC, SCS, GIE, Auto-entrepreneur. Leave empty for all.

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

Use Apify residential proxies to avoid blocks.

## Actor input object example

```json
{
  "searchKeywords": [
    ""
  ],
  "maxItems": 500,
  "city": "",
  "legalForm": "",
  "proxyConfiguration": {
    "useApifyProxy": true,
    "apifyProxyGroups": [
      "RESIDENTIAL"
    ]
  }
}
```

# Actor output Schema

## `companies` (type: `string`):

The structured companies data including name, RC, city, legal form, activity, capital, and date of creation.

# 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("scraper_guru/ompic-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("scraper_guru/ompic-scraper").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print("💾 Check your data here: https://console.apify.com/storage/datasets/" + run["defaultDatasetId"])
for item in client.dataset(run["defaultDatasetId"]).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 scraper_guru/ompic-scraper --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "command": "npx",
            "args": [
                "mcp-remote",
                "https://mcp.apify.com/?tools=scraper_guru/ompic-scraper",
                "--header",
                "Authorization: Bearer <YOUR_API_TOKEN>"
            ]
        }
    }
}

```

## OpenAPI specification

```json
{
    "openapi": "3.0.1",
    "info": {
        "title": "OMPIC Morocco Business Registry Scraper",
        "description": "Scrape company data from Morocco's official business registry (OMPIC / directinfo.ma). Extract company name, RC number, city, legal form, activity sector, creation date, and capital.",
        "version": "1.0",
        "x-build-id": "gtmrfHnDDkPH8P1AQ"
    },
    "servers": [
        {
            "url": "https://api.apify.com/v2"
        }
    ],
    "paths": {
        "/acts/scraper_guru~ompic-scraper/run-sync-get-dataset-items": {
            "post": {
                "operationId": "run-sync-get-dataset-items-scraper_guru-ompic-scraper",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor, waits for its completion, and returns Actor's dataset items in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK"
                    }
                }
            }
        },
        "/acts/scraper_guru~ompic-scraper/runs": {
            "post": {
                "operationId": "runs-sync-scraper_guru-ompic-scraper",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor and returns information about the initiated run in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/runsResponseSchema"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/acts/scraper_guru~ompic-scraper/run-sync": {
            "post": {
                "operationId": "run-sync-scraper_guru-ompic-scraper",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor, waits for completion, and returns the OUTPUT from Key-value store in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK"
                    }
                }
            }
        }
    },
    "components": {
        "schemas": {
            "inputSchema": {
                "type": "object",
                "properties": {
                    "searchKeywords": {
                        "title": "Search Keywords",
                        "type": "array",
                        "description": "Keywords to search in OMPIC registry. Leave empty for full A-Z alphabetic sweep (slower but more complete).",
                        "default": [
                            ""
                        ],
                        "items": {
                            "type": "string"
                        }
                    },
                    "maxItems": {
                        "title": "Max Companies",
                        "minimum": 1,
                        "maximum": 50000,
                        "type": "integer",
                        "description": "Maximum number of companies to extract.",
                        "default": 500
                    },
                    "city": {
                        "title": "Filter by City",
                        "type": "string",
                        "description": "Filter results by city (e.g. Casablanca, Rabat, Marrakech). Leave empty for all cities.",
                        "default": ""
                    },
                    "legalForm": {
                        "title": "Filter by Legal Form",
                        "enum": [
                            "",
                            "SA",
                            "SARL",
                            "SNC",
                            "SCS",
                            "GIE",
                            "Auto-entrepreneur"
                        ],
                        "type": "string",
                        "description": "Filter by legal form: SA, SARL, SNC, SCS, GIE, Auto-entrepreneur. Leave empty for all.",
                        "default": ""
                    },
                    "proxyConfiguration": {
                        "title": "Proxy Configuration",
                        "type": "object",
                        "description": "Use Apify residential proxies to avoid blocks.",
                        "default": {
                            "useApifyProxy": true,
                            "apifyProxyGroups": [
                                "RESIDENTIAL"
                            ]
                        }
                    }
                }
            },
            "runsResponseSchema": {
                "type": "object",
                "properties": {
                    "data": {
                        "type": "object",
                        "properties": {
                            "id": {
                                "type": "string"
                            },
                            "actId": {
                                "type": "string"
                            },
                            "userId": {
                                "type": "string"
                            },
                            "startedAt": {
                                "type": "string",
                                "format": "date-time",
                                "example": "2025-01-08T00:00:00.000Z"
                            },
                            "finishedAt": {
                                "type": "string",
                                "format": "date-time",
                                "example": "2025-01-08T00:00:00.000Z"
                            },
                            "status": {
                                "type": "string",
                                "example": "READY"
                            },
                            "meta": {
                                "type": "object",
                                "properties": {
                                    "origin": {
                                        "type": "string",
                                        "example": "API"
                                    },
                                    "userAgent": {
                                        "type": "string"
                                    }
                                }
                            },
                            "stats": {
                                "type": "object",
                                "properties": {
                                    "inputBodyLen": {
                                        "type": "integer",
                                        "example": 2000
                                    },
                                    "rebootCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "restartCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "resurrectCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "computeUnits": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            },
                            "options": {
                                "type": "object",
                                "properties": {
                                    "build": {
                                        "type": "string",
                                        "example": "latest"
                                    },
                                    "timeoutSecs": {
                                        "type": "integer",
                                        "example": 300
                                    },
                                    "memoryMbytes": {
                                        "type": "integer",
                                        "example": 1024
                                    },
                                    "diskMbytes": {
                                        "type": "integer",
                                        "example": 2048
                                    }
                                }
                            },
                            "buildId": {
                                "type": "string"
                            },
                            "defaultKeyValueStoreId": {
                                "type": "string"
                            },
                            "defaultDatasetId": {
                                "type": "string"
                            },
                            "defaultRequestQueueId": {
                                "type": "string"
                            },
                            "buildNumber": {
                                "type": "string",
                                "example": "1.0.0"
                            },
                            "containerUrl": {
                                "type": "string"
                            },
                            "usage": {
                                "type": "object",
                                "properties": {
                                    "ACTOR_COMPUTE_UNITS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_WRITES": {
                                        "type": "integer",
                                        "example": 1
                                    },
                                    "KEY_VALUE_STORE_LISTS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_INTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_EXTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_SERPS": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            },
                            "usageTotalUsd": {
                                "type": "number",
                                "example": 0.00005
                            },
                            "usageUsd": {
                                "type": "object",
                                "properties": {
                                    "ACTOR_COMPUTE_UNITS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_WRITES": {
                                        "type": "number",
                                        "example": 0.00005
                                    },
                                    "KEY_VALUE_STORE_LISTS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_INTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_EXTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_SERPS": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
```
