# Tipo de Cambio Oficial USD/MXN — DOF y FIX Banxico (`nahua/tipo-de-cambio-oficial`) Actor

Tipo de cambio oficial dólar/peso por día: el publicado en el Diario Oficial de la Federación (para efectos fiscales) y el FIX de Banco de México. Official USD/MXN exchange rate per day from the DOF and Banxico FIX.

- **URL**: https://apify.com/nahua/tipo-de-cambio-oficial.md
- **Developed by:** [Miguel Najera](https://apify.com/nahua) (community)
- **Categories:** Business, Developer tools, Automation
- **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

## Tipo de Cambio Oficial USD/MXN — DOF y FIX Banxico · 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 ni con el Banco de México; 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 or Banco de México; the official DOF prevails.

**ES** · Devuelve, **por día**, el tipo de cambio oficial dólar/peso:

- **DOF** — el publicado ese día en el *Diario Oficial de la Federación* («Tipo de cambio para solventar obligaciones denominadas en moneda extranjera pagaderas en la República Mexicana»).
- **FIX** — el determinado ese día por el **Banco de México** (se publica en el DOF el siguiente día hábil bancario).

Qué fecha aplicar a una operación depende de la regla fiscal de tu caso: consúltala con tu contador. Este Actor te dice qué se publicó y cuándo, no cuál te corresponde.

**EN** · Returns the official USD/MXN exchange rate **per day**: the rate **published in the Official Gazette (DOF)** on that date and/or the **Banxico FIX** determined on that date. Which date applies to a transaction depends on the tax rule for your case; ask your accountant.

***

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

| Serie | Fuente principal | Respaldo |
|---|---|---|
| `DOF` | Servicio oficial del DOF (SIDOF), indicador 158 «DÓLAR». **No requiere token.** | Sin respaldo: si SIDOF no responde, el Actor lo avisa y no entrega valor. |
| `FIX` | Banxico SIE serie `SF43718` («Pesos por dólar, FIX») si se proporciona `banxicoToken` (gratuito). | Sin token: lee el **texto de cada nota oficial del DOF** («…el tipo de cambio obtenido el día de hoy fue de $18.7592 M.N. … Ciudad de México, a 3 de noviembre de 2026») y asigna el valor a su **fecha de determinación**. Es exacto, pero hace una petición por día (≈ 300 ms entre cada una). |

Verificado (nov-2026): nota publicada en el DOF el 04-11-2026 con $18.7592 fechada el 03-11-2026 → `fix` del 2026-11-03 = 18.7592 = `dof` del 2026-11-04.

### Entrada / Input

```json
{
  "from": "2026-10-26",
  "to": "2026-11-05",
  "series": ["FIX", "DOF"],
  "banxicoToken": "<opcional, secreto>",
  "includeEmptyDays": false
}
```

| Campo / Field | Tipo | Descripción |
|---|---|---|
| `from`, `to` | `YYYY-MM-DD` | Rango (máx. 400 días). Por defecto: últimos 7 días. / Range (max 400 days); default last 7 days. |
| `series` | `["FIX","DOF"]` | Series a devolver. / Series to return. |
| `banxicoToken` | `string` (secreto) | Token gratuito del SIE: https://www.banxico.org.mx/SieAPIRest/service/v1/token. Nunca se registra en logs. |
| `includeEmptyDays` | `boolean` | Emitir fines de semana/días inhábiles con `null`. |

### Salida / Output (un registro por día)

```json
{
  "fecha": "2026-11-04",
  "dof": 18.7592,
  "fix": 18.6285,
  "moneda": "USD/MXN",
  "dofDetalle": {
    "valor": 18.7592,
    "fechaPublicacion": "2026-11-04",
    "fechaDeterminacion": "2026-11-03",
    "fuente": "sidof-api",
    "serieId": "DOF-158",
    "codigoNota": 5802953,
    "url": "https://dof.gob.mx/nota_detalle.php?codigo=5802953&fecha=04/11/2026",
    "cita": "Tipo de cambio para solventar obligaciones denominadas en moneda extranjera pagaderas en la República Mexicana, Banco de México; 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"
  },
  "fixDetalle": {
    "valor": 18.6285,
    "fechaDeterminacion": "2026-11-04",
    "fechaPublicacionDof": "2026-11-05",
    "fuente": "dof-nota",
    "serieId": "DOF-158",
    "estimado": false,
    "codigoNota": 5803034,
    "url": "https://dof.gob.mx/nota_detalle.php?codigo=5803034&fecha=05/11/2026",
    "cita": "Tipo de cambio para solventar obligaciones denominadas en moneda extranjera pagaderas en la República Mexicana, Banco de México; Estados Unidos Mexicanos; DOF 05/11/2026; [citado 06-11-2026]; disponible en versión HTML en internet: https://dof.gob.mx/nota_detalle.php?codigo=5803034&fecha=05/11/2026"
  },
  "consultadoEn": "2026-11-05T21:30:00.000Z"
}
```

- `dof` = valor **publicado** en el DOF en `fecha`. `fix` = valor **determinado** por Banxico en `fecha`.
- `url` es la nota oficial o, si no se leyó la nota, la página de indicadores del DOF. `cita` sigue el formato que pide el [aviso legal del DOF](https://sidof.segob.gob.mx/avisoLegal). Un FIX tomado de Banxico trae `cita: null` y su `url` apunta a Banxico.
- `fuente` ∈ `sidof-api` (DOF oficial) · `banxico-sie` (con token) · `dof-nota` (FIX extraído del texto oficial de la nota). `estimado: true` solo si no se pudo leer la fecha en la nota y se asumió el día hábil anterior.
- Días sin publicación (fines de semana, festivos) se omiten salvo `includeEmptyDays`.
- `SUMMARY` en el key-value store: fuentes usadas, días con cada serie, advertencias.

### 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/tipo-de-cambio-oficial",
      "headers": { "Authorization": "Bearer <APIFY_TOKEN>" }
    }
  }
}
```

Prompt de ejemplo: *«¿Qué tipo de cambio se publicó en el DOF el 4 de noviembre de 2026? Dame la liga a la nota.»*

API REST:

```bash
curl -X POST "https://api.apify.com/v2/acts/nahua~tipo-de-cambio-oficial/run-sync-get-dataset-items?token=<APIFY_TOKEN>" \
  -H "Content-Type: application/json" \
  -d '{"from":"2026-11-01","to":"2026-11-05","series":["DOF"]}'
```

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

- **DOF / SIDOF:** `https://sidofqa.segob.gob.mx/dof/sidof/indicadores/158/{dd-mm-yyyy}/{dd-mm-yyyy}` (respaldo `sidof.segob.gob.mx`). Actualizado cada día hábil al publicarse el DOF (edición matutina).
- **Banxico SIE:** `https://www.banxico.org.mx/SieAPIRest/service/v1/series/SF43718/datos/{from}/{to}` con header `Bmx-Token`. Límites oficiales: 200 consultas / 5 min y 10,000 / día por token. El FIX se determina cada día hábil bancario alrededor de las 12:00 h.
- Cortesía: peticiones secuenciales con ≥ 300 ms de espera, reintentos con backoff y `User-Agent: nahua-apify-actor/1.0`.

### Limitaciones / Limitations

- Máximo 400 días por ejecución. Sin token, el FIX requiere una petición por día hábil (un año ≈ 2–3 minutos).
- El valor del día de hoy aparece cuando el DOF lo publica (normalmente por la mañana, hora de la Ciudad de México); el FIX de hoy sin token solo estará disponible mañana, cuando se publique en el DOF.
- Solo USD/MXN. Otras divisas se calculan en México a partir del dólar (ver nota del DOF).

### Privacidad / Privacy

No se procesan datos personales. El token de Banxico se marca como secreto en el esquema de entrada y no se escribe en logs ni en la salida.

### Ejecución local / Local run

```bash
npm install
npx apify-cli run -i '{"from":"2026-10-26","to":"2026-11-05"}'
npx apify-cli run -i '{"from":"2026-10-26","to":"2026-11-05","banxicoToken":"<token>"}'
npm test
```

***

# Actor input Schema

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

Primer día del rango. Por defecto: 7 días antes de "to". Máximo 400 días por ejecución. / First day; default 7 days before "to"; max 400 days per run.

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

Último día del rango. Por defecto: hoy (hora de la Ciudad de México). / Last day; default today (Mexico City time).

## `series` (type: `array`):

DOF = tipo de cambio publicado en el DOF ese día (el que se usa para impuestos y CFDI). FIX = tipo de cambio FIX determinado por Banxico ese día. / DOF = rate published in the Official Gazette that day (tax purposes). FIX = Banxico FIX determined that day.

## `banxicoToken` (type: `string`):

Token gratuito de https://www.banxico.org.mx/SieAPIRest/service/v1/token. Con token, el FIX se obtiene directamente de la serie SF43718 en una sola petición; sin token, el Actor lo extrae del texto de las notas oficiales del DOF (más lento). / Free token; without it, FIX is extracted from the official DOF notes (slower).

## `includeEmptyDays` (type: `boolean`):

Emitir también fines de semana y días inhábiles con valores nulos. / Also emit weekends and holidays with null values.

## Actor input object example

```json
{
  "series": [
    "FIX",
    "DOF"
  ],
  "includeEmptyDays": false
}
```

# Actor output Schema

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

Un registro por día con la tasa DOF y el FIX. / One item per day with the DOF rate and FIX.

## `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 = {};

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

```

## MCP server setup

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

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/bXzP3LmAf3Dq14bEs/builds/KceQ2Pc8HdgqQQv7d/openapi.json
