# DENUE Mexico Business Directory Scraper (INEGI) (`automatic/mexico-denue-scraper`) Actor

Search Mexico's official DENUE business directory (INEGI) by keyword or activity and state: establishment name, SCIAN activity, address, GPS, phone, website, CLEE and incorporation date. Fresh directory answers every run. JSON, CSV or Excel.

- **URL**: https://apify.com/automatic/mexico-denue-scraper.md
- **Developed by:** [Philip Kirkbride](https://apify.com/automatic) (community)
- **Categories:** Lead generation
- **Features:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $2.00 / 1,000 business records

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?

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

## Mexico DENUE Business Directory Scraper

Search Mexico's official business directory, DENUE (INEGI), and export
establishments as clean records: name, economic activity, SCIAN code, size
category, full address, GPS coordinates, phone, e-mail, website, CLEE and
incorporation date. Every run reads the live directory, so results are current.

**Typical uses**

- **B2B lead lists:** find tortillerías, pharmacies, hotels or hardware stores
  in one state or nationwide, with phone and address to qualify them.
- **Market and location research:** count and map establishments of one
  activity in a city, municipality or state before opening a branch.
- **Record enrichment:** append official activity codes, coordinates and
  identifiers to a CRM or supplier list using `idee`/`clee` as join keys.
- **Store and route planning:** use the coordinates and colonia to plan
  coverage areas for field teams.

### How it works

1. Enter a keyword or economic activity (Spanish works best, e.g.
   `tortilleria`, `hotel boutique`, `farmacias similares`).
2. Optionally scope it to one or more states by CVE_ENT code, official name or
   alias (`09`, `Ciudad de México`, `CDMX`).
3. Each hit is enriched with its DENUE record (address, contact, CLEE,
   incorporation date) unless `includeDetails` is off.
4. Export the dataset as JSON, CSV or Excel from the run page.

### Quick start

```json
{"search": "tortilleria", "states": ["09"], "maxResults": 100}
```

An empty run (no search and no maximum) returns a small 10-record sample for
`tortilleria` so you can see the fields before choosing your own search; it is
flagged `usedExample: true` in the run summary and status message. A search
left empty on purpose (`{"search": ""}`) stops at once with a message asking
for a keyword.

### Input

| Field | Type | Default | What it does |
|---|---|---:|---|
| `search` | string | required | Keyword or economic activity. Punctuation the source cannot handle is stripped automatically. |
| `states` | array | `[]` | State codes, names or aliases; empty means nationwide. |
| `maxResults` | integer | `50` | Maximum establishments returned, 1–1,000. |
| `includeDetails` | boolean | `true` | Include address and contact details (one extra request per record). |
| `requestDelaySecs` | number | `1` | Pause between requests, 0.5–10 seconds. |

### Output

One row per establishment. Fields: `idee`, `companyKey`, `name`, `razonSocial`,
`scianCode`, `activity`, `sizeCategory`, `unitType`, `address`, `colonia`,
`postalCode`, `locality`, `municipality`, `state`, `latitude`, `longitude`,
`phone`, `email`, `website`, `clee`, `incorporatedAt`, `url`, `sourceState`,
`sourceQuery`, `source`, `scrapedAt`.

`companyKey` is `inegi.org.mx:denue:<idee>` so records can be deduplicated
across runs. Fields the directory does not publish for an establishment are
`null`, never invented.

```json
{
  "idee": "0100000001",
  "companyKey": "inegi.org.mx:denue:0100000001",
  "name": "TORTILLERIA EJEMPLO",
  "activity": "Elaboración de tortillas de maíz y molienda de nixtamal",
  "scianCode": "311830",
  "sizeCategory": "Micro",
  "address": "AV. EJEMPLO 123",
  "colonia": "CENTRO",
  "municipality": "Aguascalientes",
  "state": "Aguascalientes",
  "latitude": 21.8853,
  "longitude": -102.2916,
  "phone": "4491234567",
  "website": null,
  "clee": "0100000001",
  "url": "https://www.inegi.org.mx/app/mapa/denue/default.aspx?idee=0100000001",
  "sourceQuery": "tortilleria",
  "source": "inegi.org.mx",
  "scrapedAt": "2026-11-10T04:12:03.114Z"
}
```

### Pricing

Pricing:

- **$0.005** actor start (one start event per GB of memory; the default
  512 MB run is one start event).
- **$0.002** per delivered business record.

Worked costs: a 10-record sample is about **$0.025**; a 50-record run about
**$0.105**; a 1,000-record run about **$2.005**. Free-plan users get the
monthly Apify credits first, so small runs are usually free.

### Limits and reliability

- The cap is 1–1,000 records per run; each state scope is paginated 50 records
  at a time.
- `includeDetails` costs one extra request per record and slows a run down;
  turn it off for a fast name/activity/location scan.
- If INEGI refuses a request the run reports a source access error; an
  establishment is never reported as missing because a page was refused.
- A search that matches nothing says so in the status message instead of
  failing silently.

### FAQ

**How fresh is the data?** Results are read from the official directory
service when the run starts; nothing is cached between runs.

**Is the directory free to use?** DENUE is INEGI's public directory. Respect
INEGI's terms, and use the data for lawful purposes with your own legal basis.

**Can I search by activity code instead of a keyword?** Yes — the keyword is
matched against establishment names and economic activity names; enter the
SCIAN activity wording (e.g. `elaboración de tortillas`) or part of it.

**Why are some phone or website fields empty?** INEGI publishes what each
establishment reports; absent fields stay `null`.

**How do I keep only new businesses between runs?** Deduplicate on `idee` (or
`companyKey`) between datasets; the identifiers are stable.

**Can I schedule it?** Yes — run it on a daily or weekly schedule and export
the dataset; only delivered records are charged.

### Support

For questions or issues, use the **Issues** tab on the Actor page or contact
Apify support and include the run ID.

# Actor input Schema

## `search` (type: `string`):

Free-text keyword matched against establishment name and economic activity (SCIAN), e.g. "tortilleria", "hotel boutique", "farmacias similares". Punctuation the INEGI search chokes on is stripped automatically.

## `states` (type: `array`):

Optional list of Mexican states to scope the search. Accepts CVE_ENT codes — "01" Aguascalientes, "02" Baja California, "03" Baja California Sur, "04" Campeche, "05" Coahuila, "06" Colima, "07" Chiapas, "08" Chihuahua, "09" Ciudad de México, "10" Durango, "11" Guanajuato, "12" Guerrero, "13" Hidalgo, "14" Jalisco, "15" México, "16" Michoacán, "17" Morelos, "18" Nayarit, "19" Nuevo León, "20" Oaxaca, "21" Puebla, "22" Querétaro, "23" Quintana Roo, "24" San Luis Potosí, "25" Sinaloa, "26" Sonora, "27" Tabasco, "28" Tamaulipas, "29" Tlaxcala, "30" Veracruz, "31" Yucatán, "32" Zacatecas — official names (accents optional) or aliases ("CDMX", "EDOMEX"). Empty = national search. One scoped search runs per state; maxResults is a global cap.

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

Stop after this many records (across all states). The endpoint serves 50 records per page. An empty run (no search and no maximum) returns a 10-record sample instead of failing.

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

When true (default), each hit is enriched with its DENUE ficha: full street address, phone, e-mail, website, CLEE and incorporation date. When false, only the search-row fields (name, activity, SCIAN, municipality, state, GPS).

## `requestDelaySecs` (type: `number`):

Pause between search pages and detail fetches. Minimum 0.5 seconds.

## Actor input object example

```json
{
  "search": "tortilleria",
  "states": [],
  "maxResults": 10,
  "includeDetails": true,
  "requestDelaySecs": 1
}
```

# Actor output Schema

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

No description

# 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 = {
    "search": "tortilleria",
    "states": [],
    "maxResults": 10
};

// Run the Actor and wait for it to finish
const run = await client.actor("automatic/mexico-denue-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 = {
    "search": "tortilleria",
    "states": [],
    "maxResults": 10,
}

# Run the Actor and wait for it to finish
run = client.actor("automatic/mexico-denue-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 '{
  "search": "tortilleria",
  "states": [],
  "maxResults": 10
}' |
apify call automatic/mexico-denue-scraper --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,automatic/mexico-denue-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/jCBvGaQWaVyPwwBnS/builds/78dp8i90jycrNb7bX/openapi.json
