# DOF Search — Diario Oficial de la Federación (México) (`nahua/dof-search`) Actor

Busca publicaciones del Diario Oficial de la Federación por texto y rango de fechas vía el servicio oficial SIDOF: fecha, título, dependencia, código de nota, URL oficial y extracto. Search Mexico's Official Gazette (DOF) by text and date range.

- **URL**: https://apify.com/nahua/dof-search.md
- **Developed by:** [Miguel Najera](https://apify.com/nahua) (community)
- **Categories:** Business, News, Developer tools
- **Security:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

Pay per usage

This Actor is paid per platform usage. The Actor is free to use, and you only pay for the Apify platform usage, which gets cheaper the higher subscription plan you have.

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

## 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

## DOF Search — Buscador del Diario Oficial de la Federación (México) · by Nahua

> **Gratis y no oficial.** Este Actor es gratuito: el autor no cobra nada por usarlo. Apify puede cobrarte el uso de su plataforma según tu plan. Los datos provienen del Diario Oficial de la Federación y cada resultado cita la fuente. No es un servicio oficial ni tiene relación con la Secretaría de Gobernación; el DOF oficial prevalece.
>
> **Free and unofficial.** This Actor is free: the author charges nothing for it. Apify may bill you for platform usage under your plan. The data comes from the Diario Oficial de la Federación and every result cites the source. It is not an official service and is not affiliated with the Secretaría de Gobernación; the official DOF prevails.

**ES** · Busca publicaciones del **Diario Oficial de la Federación (DOF)** por texto y rango de fechas y devuelve, por cada nota: fecha, título, dependencia/poder, edición y sección, código de nota, **URL oficial en dof.gob.mx**, un extracto literal corto y la **cita de la fuente**. Usa el servicio JSON del DOF (SIDOF) con respaldo en la búsqueda pública del sitio.

**EN** · Searches **Mexico's Official Gazette (DOF)** by text and date range. For each entry it returns the date, title, issuing agency, edition/section, note code, the **official dof.gob.mx URL**, a short verbatim excerpt and the **source citation**. Powered by the DOF's JSON service (SIDOF) with a polite fallback to the public website search.

***

### ¿Qué hace? / What it does

- **Modo `diario`** (automático para rangos ≤ 31 días): recorre cada día del rango con `notas/{fecha}` y filtra localmente los títulos que contienen **todas** las palabras de `query` (sin distinguir acentos ni mayúsculas). Es el modo más completo.
- **Modo `titulo`** (automático para rangos largos): usa el buscador por frase del DOF (`buscarNotas/titulo`) y filtra por fechas.
- Con `includeSnippet` descarga el texto de cada nota (`notas/nota/{código}`) y devuelve un extracto centrado en la consulta, además de completar edición, sección y página.
- Si el servicio SIDOF no responde, cae a la búsqueda pública de `dof.gob.mx` (solo título, fecha, dependencia y enlace; sin extracto, porque `robots.txt` prohíbe rastrear `nota_detalle.php`).

### Entrada / Input

```json
{
  "query": "tipo de cambio",
  "from": "2026-10-26",
  "to": "2026-11-05",
  "maxResults": 50,
  "includeSnippet": true,
  "searchMode": "auto",
  "organismo": "Banco de México",
  "order": "desc"
}
```

| Campo / Field | Tipo | Descripción |
|---|---|---|
| `query` | `string` | Palabras que deben aparecer en el título. Vacío = todo lo publicado en el rango (máx. 93 días). / Words that must appear in the title; empty = everything in range. |
| `from`, `to` | `YYYY-MM-DD` | Rango de fechas de publicación. Por defecto: últimos 30 días (hora de la Ciudad de México). |
| `maxResults` | `1–500` (default 50) | Máximo de publicaciones devueltas. |
| `includeSnippet` | `boolean` (default `true`) | Descargar el texto de cada nota para el extracto (una petición extra por resultado). |
| `searchMode` | `auto` · `diario` · `titulo` | Ver arriba. |
| `organismo` | `string` | Filtro por dependencia/poder (substring). |
| `order` | `desc` · `asc` | Más recientes primero por defecto. |

### Salida / Output (una publicación por registro)

```json
{
  "codigoNota": 5802953,
  "fecha": "2026-11-04",
  "titulo": "Tipo de cambio para solventar obligaciones denominadas en moneda extranjera pagaderas en la República Mexicana.",
  "edicion": "Matutina",
  "seccion": "UNICA",
  "poder": "ORGANISMOS AUTONOMOS",
  "organismo": "BANCO DE MEXICO",
  "pagina": 149,
  "codigoDiario": 330605,
  "url": "https://dof.gob.mx/nota_detalle.php?codigo=5802953&fecha=04/11/2026",
  "urlSidof": "https://sidof.segob.gob.mx/notas/5802953",
  "snippet": "…informa que el tipo de cambio obtenido el día de hoy fue de $18.7592 M.N. (dieciocho pesos con siete mil quinientos noventa y dos diezmilésimos moneda nacional) por un dólar de los EE.UU.A.…",
  "fuente": "sidof-api",
  "cita": "Tipo de cambio para solventar obligaciones denominadas en moneda extranjera pagaderas en la República Mexicana, BANCO DE MEXICO; Estados Unidos Mexicanos; DOF 04/11/2026; [citado 06-11-2026]; disponible en versión HTML en internet: https://dof.gob.mx/nota_detalle.php?codigo=5802953&fecha=04/11/2026",
  "query": "tipo de cambio"
}
```

- `url` es la nota oficial. `cita` sigue el formato que pide el [aviso legal del DOF](https://sidof.segob.gob.mx/avisoLegal).
- `titulo` y `snippet` son texto del DOF sin reescribir. `snippet` es un recorte, no sustituye al documento.
- Un resumen (`SUMMARY`) con modo usado, fuente, total de coincidencias y si el resultado quedó truncado se guarda en el key-value store de la ejecución.

### Precio / Pricing

**Gratis.** El autor no cobra por este Actor. Apify puede cobrarte el uso de su plataforma (cómputo y almacenamiento) según tu plan.

**Free.** The author charges nothing for this Actor. Apify may bill you for platform usage (compute and storage) under your plan.

### Uso de los datos / Use of the data

El [aviso legal del DOF](https://sidof.segob.gob.mx/avisoLegal) permite reproducir su contenido sin fines de lucro citando la fuente, prohíbe alterar la integridad de los textos y exige consentimiento previo por escrito de la Secretaría de Gobernación para reproducirlo con fines de lucro. Si reutilizas estos resultados, cumplir esas condiciones te corresponde a ti.

The DOF legal notice allows non-profit reproduction with the source cited, forbids altering the integrity of the texts, and requires prior written consent from the Secretaría de Gobernación for for-profit reproduction. If you reuse these results, meeting those conditions is your responsibility.

### Uso desde un agente de IA (MCP) / MCP usage

```json
{
  "mcpServers": {
    "apify": {
      "url": "https://mcp.apify.com?tools=nahua/dof-search",
      "headers": { "Authorization": "Bearer <APIFY_TOKEN>" }
    }
  }
}
```

Prompt de ejemplo: *«Busca en el DOF las publicaciones de la Secretaría de Hacienda sobre "estímulos fiscales" de octubre de 2026 y dame título, fecha y enlace oficial.»*

API REST:

```bash
curl -X POST "https://api.apify.com/v2/acts/nahua~dof-search/run-sync-get-dataset-items?token=<APIFY_TOKEN>" \
  -H "Content-Type: application/json" \
  -d '{"query":"estímulos fiscales","from":"2026-10-01","to":"2026-10-31","maxResults":20}'
```

### Fuente de datos y frecuencia / Data source & update frequency

- **SIDOF** (`https://sidofqa.segob.gob.mx/dof/sidof/…`, con respaldo en `https://sidof.segob.gob.mx/dof/sidof/…`): servicio JSON del DOF. Endpoints usados: `buscarNotas/titulo/{texto}/{página}/{tamaño}/fecha/{asc|desc}`, `notas/{dd-mm-yyyy}`, `notas/nota/{código}`.
- **Respaldo:** `https://dof.gob.mx/busqueda_detalle.php` (búsqueda pública del sitio).
- El DOF se publica de lunes a viernes (ediciones matutina, vespertina y extraordinarias). Los datos aparecen en SIDOF el mismo día de la publicación.
- Cortesía: una petición a la vez, ≥ 250 ms entre peticiones, reintentos con backoff, `User-Agent: nahua-apify-actor/1.0`.

### Limitaciones / Limitations

- La búsqueda es **sobre el título** de la nota (modo `diario`: todas las palabras; modo `titulo`: frase tal como la indexa el DOF). No es búsqueda de texto completo, aunque el extracto sí proviene del contenido.
- Sin `query`, el rango máximo es de 93 días. En modo `titulo` se revisan hasta 3,000 coincidencias (30 páginas); si el rango queda fuera, `SUMMARY.truncado = true`.
- El respaldo web devuelve solo la primera página de resultados y sin extracto.
- Máximo 500 resultados por ejecución.

### Privacidad / Privacy

El DOF es información pública por mandato constitucional. El Actor no recopila datos personales ni perfila a personas; solo devuelve metadatos y extractos de publicaciones oficiales con enlace a la fuente.

### Ejecución local / Local run

```bash
npm install
npx apify-cli run -i '{"query":"tipo de cambio","from":"2026-11-01","to":"2026-11-05","maxResults":5}'
npm test
```

***

# Actor input Schema

## `query` (type: `string`):

Palabras que deben aparecer en el título de la publicación (sin distinguir acentos ni mayúsculas). Vacío = listar todo lo publicado en el rango (máx. 93 días). / Words that must appear in the publication title. Empty = list everything published in the range (max 93 days).

## `from` (type: `string`):

Fecha inicial de publicación. Por defecto: 30 días antes de "to". / Start publication date. Default: 30 days before "to".

## `to` (type: `string`):

Fecha final de publicación. Por defecto: hoy (hora de la Ciudad de México). / End publication date. Default: today (Mexico City time).

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

Máximo de publicaciones devueltas. / Maximum number of entries returned.

## `includeSnippet` (type: `boolean`):

Descarga el texto de cada nota (una petición extra por resultado) para devolver un extracto corto centrado en la consulta. / Fetches each note's text (one extra request per result) to return a short snippet.

## `searchMode` (type: `string`):

auto: por día si el rango es ≤ 31 días, por título si es mayor. diario: recorre cada día del rango y filtra títulos localmente (más completo). titulo: usa el buscador por frase del DOF (rangos largos). / auto, per-day listing, or title search.

## `organismo` (type: `string`):

Texto que debe aparecer en la dependencia u organismo (p. ej. "Banco de México", "Hacienda"). / Text that must appear in the issuing agency.

## `order` (type: `string`):

desc = más recientes primero. / desc = newest first.

## Actor input object example

```json
{
  "query": "tipo de cambio",
  "maxResults": 50,
  "includeSnippet": true,
  "searchMode": "auto",
  "order": "desc"
}
```

# Actor output Schema

## `resultados` (type: `string`):

Una entrada por publicación del DOF encontrada. / One item per DOF publication found.

## `resumen` (type: `string`):

Conteos, fuentes y advertencias de la ejecución. / Counts, sources and warnings for the run.

# 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 = {
    "query": "tipo de cambio"
};

// Run the Actor and wait for it to finish
const run = await client.actor("nahua/dof-search").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 = { "query": "tipo de cambio" }

# Run the Actor and wait for it to finish
run = client.actor("nahua/dof-search").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 '{
  "query": "tipo de cambio"
}' |
apify call nahua/dof-search --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,nahua/dof-search"
        }
    }
}
```

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/UV0s29Dv7TQSVQIlk/builds/a7hVIIeS4WOJGFUqA/openapi.json
