# Morocco Public Tenders Scraper (`scraper_guru/morocco-public-tenders-scraper`) Actor

Scrape Morocco public tenders from the official procurement portal. Extract buyers, categories, locations, deadlines, references, submission rules, and documents.

- **URL**: https://apify.com/scraper\_guru/morocco-public-tenders-scraper.md
- **Developed by:** [LIAICHI MUSTAPHA](https://apify.com/scraper_guru) (community)
- **Categories:** Lead generation, Automation
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

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

## Morocco Public Tenders Scraper

Scrape active public tenders from **Morocco's official public procurement portal** at MarchesPublics.gov.ma. Collect contract opportunities, public buyers, tender objects, categories, locations, publication dates, submission deadlines, electronic-response rules, and public documents.

### Features

- Extracts active Moroccan government tenders and procurement notices
- Captures full tender objects, references, procedures, and public buyers
- Collects works, supplies, and services categories
- Normalizes publication and submission dates to `YYYY-MM-DD`
- Extracts execution cities, provinces, and regions
- Identifies mandatory, optional, or unavailable electronic submission
- Detects electronic-signature requirements, simplified contracts, and environmental provisions
- Collects public withdrawal, question, submission, and message counts
- Optionally visits detail pages for tender dossier links
- Handles stateful WebForms pagination, duplicates, filtering, retries, and proxy sessions

### Use Cases

- **Sales intelligence:** find public-sector contract opportunities for Moroccan suppliers
- **Tender alerts:** monitor keywords, buyers, cities, and approaching deadlines
- **Procurement research:** analyze demand by administration, category, and region
- **Competitive intelligence:** track public interest through withdrawals and submissions
- **Lead generation:** identify administrations buying specific products or services
- **Automation:** schedule searches and send new opportunities to email, Slack, Sheets, or a CRM

### Input

| Field | Type | Default | Description |
|---|---|---:|---|
| `startUrls` | array | empty | Optional official search-result URLs |
| `searchQuery` | string | empty | Keyword such as `informatique`, `nettoyage`, or `construction` |
| `currentOnly` | boolean | `true` | Limit the portal search to current consultations |
| `category` | string | `all` | Works, supplies, services, or all categories |
| `buyer` | string | empty | Public buyer name contains this text |
| `location` | string | empty | Execution location contains this text |
| `publishedAfter` | string | empty | Inclusive publication filter in `YYYY-MM-DD` |
| `deadlineBefore` | string | empty | Inclusive deadline filter in `YYYY-MM-DD` |
| `maxItems` | integer | `100` | Maximum unique tenders to save |
| `maxPages` | integer | `10` | Maximum stateful result pages to process |
| `resultsPerPage` | integer | `100` | Portal page size; 500 requires 2 GB memory |
| `includeDetails` | boolean | `false` | Visit detail pages for public document URLs |
| `paginationDelayMs` | integer | `2000` | Polite delay before each next result page |
| `proxyConfiguration` | object | Apify Proxy | Proxy configuration; residential IPs may be needed |

```json
{
  "searchQuery": "informatique",
  "currentOnly": true,
  "category": "Services",
  "location": "Rabat",
  "maxItems": 100,
  "maxPages": 10,
  "includeDetails": false,
  "proxyConfiguration": {
    "useApifyProxy": true,
    "apifyProxyGroups": ["RESIDENTIAL"]
  }
}
```

### Output

Each dataset item represents one official tender notice:

```json
{
  "tenderId": "1023594",
  "organization": "g3h",
  "reference": "15/SAP/2026",
  "subject": "Travaux de pré-câblage réseaux informatiques et électriques...",
  "buyer": "CHEF DE LA SURETE PROVINCIAL DE KENITRA",
  "procedureCode": "AOO",
  "procedure": "Appel d'offres ouvert",
  "category": "Travaux",
  "publicationDate": "2026-08-28",
  "deadlineDate": "2026-11-03",
  "deadlineTime": "11:00",
  "locations": ["KENITRA"],
  "electronicSubmission": "required",
  "signatureRequired": true,
  "simplifiedMarket": false,
  "environmentalProvisions": false,
  "withdrawals": 0,
  "questions": 0,
  "submissions": 0,
  "messages": 0,
  "documents": [],
  "detailUrl": "https://www.marchespublics.gov.ma/index.php5?page=entreprise.EntrepriseDetailConsultation&refConsultation=1023594&orgAcronyme=g3h",
  "source": "MARCHES_PUBLICS_GOV_MA",
  "scrapedAt": "2026-08-30T12:00:00.000Z"
}
```

The Actor also writes a `STATS` record to the default key-value store with page, result, filter, duplicate, detail, failure, and duration counts.

### How to Use

1. Open the Actor in Apify Console.
2. Enter a product, service, industry, buyer, or location keyword.
3. Keep the default 20-result prefill for a quick first run.
4. Enable residential proxies if the portal rejects datacenter traffic.
5. Enable `includeDetails` only when tender dossier links are required.
6. Run the Actor and inspect the **Output** table.
7. Export the dataset as JSON, CSV, Excel, or consume it through the API.

```python
from apify_client import ApifyClient

client = ApifyClient("YOUR_API_TOKEN")
run = client.actor("scraper_guru/morocco-public-tenders-scraper").call(run_input={
    "searchQuery": "informatique",
    "category": "Services",
    "maxItems": 100,
    "includeDetails": False,
})

for tender in client.dataset(run["defaultDatasetId"]).iterate_items():
    print(tender["reference"], tender["buyer"], tender["deadlineDate"])
```

### Pricing

The intended pricing is **$0.005 per saved tender**, or **$5 per 1,000 results**, plus the small Actor-start charge shown by Apify. Filtered rows, duplicates, and failed requests do not create dataset-result charges.

Proxy traffic and compute usage depend on the selected Apify plan. Start with a small result limit before enabling detail enrichment.

### Data Notes

- The source portal uses a web application firewall. Browser automation and an Apify residential proxy may be necessary.
- The Actor collects public procurement notices without authentication and does not submit bids.
- `includeDetails` collects public links; it does not download or parse tender PDF/ZIP contents.
- Missing source fields remain `null` or empty arrays rather than being guessed.
- Use reasonable schedules and limits to avoid unnecessary load on the official portal.

### FAQ

**Which Moroccan tenders can I collect?**\
The Actor targets public consultations visible on MarchesPublics.gov.ma, including works, supplies, and services.

**Can I monitor one ministry, public company, or municipality?**\
Yes. Use `searchQuery` for source-side search and `buyer` for an exact contains filter.

**Can I filter by city or region?**\
Yes. Enter a city, province, or region in `location`.

**Why does the Actor use Playwright?**\
The portal uses browser sessions, a web application firewall, and stateful WebForms pagination that plain HTTP requests do not reliably handle.

**Are tender documents included?**\
Enable `includeDetails` to collect public dossier links and published file sizes where available. The files themselves are not downloaded.

**Can I schedule tender alerts?**\
Yes. Save the input as an Apify Task, run it daily, and connect the dataset to email, Slack, Google Sheets, a webhook, or your CRM.

This Actor is not affiliated with the Moroccan government. Use public procurement data lawfully and respect the source website's terms and capacity.

# Actor input Schema

## `startUrls` (type: `array`):

Optional marchespublics.gov.ma search-result URLs. When supplied, these URLs override the search keyword and current-only setting.

## `searchQuery` (type: `string`):

Search tender references, objects, and related portal fields, for example informatique, nettoyage, construction, or audit.

## `currentOnly` (type: `boolean`):

Collect active consultations that still accept submissions. Disable to use the portal's broader consultation search.

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

Filter results by the official procurement category after each result page is loaded.

## `buyer` (type: `string`):

Keep tenders whose public buyer contains this text, for example MINISTERE, COMMUNE, ONEE, or ONCF.

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

Keep tenders matching a city, province, or region such as Casablanca, Rabat, Tanger, or Agadir.

## `publishedAfter` (type: `string`):

Optional inclusive publication-date filter in YYYY-MM-DD format.

## `deadlineBefore` (type: `string`):

Optional inclusive submission-deadline filter in YYYY-MM-DD format.

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

Maximum number of unique tender records to save.

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

Safety limit for the portal's stateful search-result pagination.

## `resultsPerPage` (type: `string`):

Use 100 with the default 1 GB memory. The 500-row option is faster for bulk runs but requires 2 GB memory.

## `includeDetails` (type: `boolean`):

Visit each tender detail page to collect public dossier and notice links. This is slower and should be enabled only when needed.

## `paginationDelayMs` (type: `integer`):

Polite delay in milliseconds before loading the next result page. Increase this for large collections if the portal rate-limits the session.

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

The portal uses a web application firewall. Apify residential proxies are recommended if datacenter traffic is blocked.

## Actor input object example

```json
{
  "startUrls": [],
  "searchQuery": "informatique",
  "currentOnly": true,
  "category": "all",
  "buyer": "",
  "location": "",
  "publishedAfter": "",
  "deadlineBefore": "",
  "maxItems": 20,
  "maxPages": 2,
  "resultsPerPage": "20",
  "includeDetails": false,
  "paginationDelayMs": 2000,
  "proxyConfiguration": {
    "useApifyProxy": true
  }
}
```

# Actor output Schema

## `tenders` (type: `string`):

Tender notices collected from marchespublics.gov.ma.

## `runStats` (type: `string`):

Search pages, tenders found, saved records, duplicates, filters, and failures.

# 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 = {
    "searchQuery": "informatique",
    "currentOnly": true,
    "maxItems": 20,
    "maxPages": 2,
    "resultsPerPage": "20",
    "includeDetails": false,
    "paginationDelayMs": 2000
};

// Run the Actor and wait for it to finish
const run = await client.actor("scraper_guru/morocco-public-tenders-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 = {
    "searchQuery": "informatique",
    "currentOnly": True,
    "maxItems": 20,
    "maxPages": 2,
    "resultsPerPage": "20",
    "includeDetails": False,
    "paginationDelayMs": 2000,
}

# Run the Actor and wait for it to finish
run = client.actor("scraper_guru/morocco-public-tenders-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 '{
  "searchQuery": "informatique",
  "currentOnly": true,
  "maxItems": 20,
  "maxPages": 2,
  "resultsPerPage": "20",
  "includeDetails": false,
  "paginationDelayMs": 2000
}' |
apify call scraper_guru/morocco-public-tenders-scraper --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,scraper_guru/morocco-public-tenders-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/UvbFU2WotRtLAuouz/builds/T8GgrVOFJH6eGJtQV/openapi.json
