# CFDI (XML) a Excel, CSV o JSON (México) (`andressm2001/cfdi-a-excel`) Actor

Convierte facturas CFDI 4.0 y 3.3 (XML sueltos, ZIP de la descarga masiva del SAT o texto pegado) en una tabla: folio fiscal, emisor, receptor, impuestos, totales y si cuadran. Pago por factura leída.

- **URL**: https://apify.com/andressm2001/cfdi-a-excel.md
- **Developed by:** [Andrés Sa](https://apify.com/andressm2001) (community)
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $3.00 / 1,000 cfdi leidos

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

## CFDI (XML) a Excel, CSV o JSON

Convierte tus facturas electrónicas mexicanas (**CFDI 4.0 y 3.3**) en una tabla lista para conciliar o capturar:
una fila por factura (o por concepto) con folio fiscal, fechas, emisor, receptor, tipo, método y forma de pago,
moneda, subtotal, descuento, impuestos trasladados y retenidos (federales y locales), total y **si los importes
cuadran**.

- Acepta enlaces a XML, enlaces a **ZIP** (como los de la descarga masiva del SAT) y XML pegados, todo mezclado.
- Lee por espacio de nombres del SAT, no por prefijo. Los importes conservan el valor exacto del XML; no se
  redondea ni se convierte moneda.
- Lo que no se puede leer sale como fila `rechazado` con el motivo en palabras (sin timbre, no es CFDI, mal
  formado, enlace caído, etc.) y no se cobra.
- Descarga el resultado en Excel, CSV o JSON desde la pestaña del dataset.

### Entrada

```json
{
  "enlaces": ["https://ejemplo.com/descarga-masiva.zip"],
  "xmls": ["<?xml version=\"1.0\" ...>"],
  "filaPorConcepto": false
}
```

Hasta 5,000 entradas por ejecución; 50 MB por archivo y 500 MB por ZIP expandido.

### Salida

`estado`, `origen`, `uuid`, `version`, `serie`, `folio`, `fecha`, `fecha_timbrado`, `tipo_comprobante`,
`metodo_pago`, `forma_pago`, `uso_cfdi`, `lugar_expedicion`, `moneda`, `tipo_cambio`, `emisor_rfc`,
`emisor_nombre`, `emisor_regimen`, `receptor_rfc`, `receptor_nombre`, `receptor_regimen`, `subtotal`,
`descuento`, `impuestos_trasladados`, `impuestos_retenidos`, `impuestos_locales_trasladados`,
`impuestos_locales_retenidos`, `total`, `conceptos`, `cuadra`, `diferencia`. Con `filaPorConcepto` se agregan
`concepto_numero`, `concepto_clave_prod_serv`, `concepto_descripcion`, `concepto_cantidad`,
`concepto_clave_unidad`, `concepto_valor_unitario`, `concepto_importe`, `concepto_descuento`.

"Cuadra" = suma de conceptos − descuento + trasladados − retenidos (más impuestos locales) contra el total, con
tolerancia de un centavo.

### Precio

**US$0.003 por factura leída.** No se cobran rechazos, folios fiscales repetidos ni facturas que no caben en tu
tope de gasto (salen como `fuera_del_tope`). Con una fila por concepto se cobra igual: una vez por factura.

### Privacidad

Tus facturas sólo viven en tu ejecución: no se guardan en otro lado ni se escriben en el registro.

***

## Mexican CFDI invoices (XML) to Excel, CSV or JSON

Turns Mexican e-invoices (CFDI 4.0 and 3.3) into a flat table: one row per invoice (or per line item) with UUID,
dates, issuer, receiver, payment fields, currency, subtotal, discount, transferred and withheld taxes (federal
and local), total, and whether the amounts add up. Accepts XML links, ZIP links (e.g. SAT bulk downloads) and
pasted XML. Unreadable files become `rechazado` rows with a reason and are never charged. Price: **US$0.003 per
invoice read**. Export the dataset to Excel, CSV or JSON.

# Actor input Schema

## `enlaces` (type: `array`):

Enlaces http(s) a archivos XML o ZIP (por ejemplo, la descarga masiva del SAT). Máximo 50 MB por archivo y 500 MB por ZIP expandido. / Links to CFDI XML files or ZIP archives.

## `xmls` (type: `array`):

Texto completo de cada CFDI. Entre enlaces y XML, máximo 5,000 entradas. / Raw CFDI XML strings.

## `filaPorConcepto` (type: `boolean`):

Una fila por concepto con los datos de la factura repetidos. Se cobra igual: una vez por factura. / One row per line item; still charged once per invoice.

## Actor input object example

```json
{
  "enlaces": [],
  "xmls": [
    "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<cfdi:Comprobante xmlns:cfdi=\"http://www.sat.gob.mx/cfd/4\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" Version=\"4.0\" Serie=\"A\" Folio=\"8\" Fecha=\"2026-09-21T09:30:00\" FormaPago=\"03\" SubTotal=\"1000.00\" Moneda=\"USD\" TipoCambio=\"18.5000\" Total=\"1160.00\" TipoDeComprobante=\"I\" Exportacion=\"01\" MetodoPago=\"PUE\" LugarExpedicion=\"64000\" Sello=\"s\" NoCertificado=\"30001000000500003416\" Certificado=\"c\">\n  <cfdi:Emisor Rfc=\"EKU9003173C9\" Nombre=\"ESCUELA KEMPER URGATE\" RegimenFiscal=\"601\"/>\n  <cfdi:Receptor Rfc=\"URE180429TM6\" Nombre=\"UNIVERSIDAD ROBOTICA ESPAÑOLA\" DomicilioFiscalReceptor=\"65000\" RegimenFiscalReceptor=\"601\" UsoCFDI=\"G03\"/>\n  <cfdi:Conceptos><cfdi:Concepto ClaveProdServ=\"81112100\" Cantidad=\"1\" ClaveUnidad=\"E48\" Descripcion=\"Hosting anual\" ValorUnitario=\"1000.00\" Importe=\"1000.00\" ObjetoImp=\"02\"/></cfdi:Conceptos>\n  <cfdi:Impuestos TotalImpuestosTrasladados=\"160.00\"><cfdi:Traslados><cfdi:Traslado Base=\"1000.00\" Impuesto=\"002\" TipoFactor=\"Tasa\" TasaOCuota=\"0.160000\" Importe=\"160.00\"/></cfdi:Traslados></cfdi:Impuestos>\n  <cfdi:Complemento><tfd:TimbreFiscalDigital xmlns:tfd=\"http://www.sat.gob.mx/TimbreFiscalDigital\" Version=\"1.1\" UUID=\"11111111-AAAA-4AAA-8AAA-000000000004\" FechaTimbrado=\"2026-09-21T12:00:00\" RfcProvCertif=\"SAT970701NN3\" SelloCFD=\"x\" NoCertificadoSAT=\"00001000000500000000\" SelloSAT=\"y\"/></cfdi:Complemento>\n</cfdi:Comprobante>\n"
  ],
  "filaPorConcepto": false
}
```

# Actor output Schema

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

Una fila por factura (o por concepto): emisor, receptor, importes, impuestos y UUID.

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

Conteos de la ejecución (recibidos, procesados, cobrados); sin RFC ni nombres.

# 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 = {
    "enlaces": [],
    "xmls": [
        "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<cfdi:Comprobante xmlns:cfdi=\"http://www.sat.gob.mx/cfd/4\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" Version=\"4.0\" Serie=\"A\" Folio=\"8\" Fecha=\"2026-09-21T09:30:00\" FormaPago=\"03\" SubTotal=\"1000.00\" Moneda=\"USD\" TipoCambio=\"18.5000\" Total=\"1160.00\" TipoDeComprobante=\"I\" Exportacion=\"01\" MetodoPago=\"PUE\" LugarExpedicion=\"64000\" Sello=\"s\" NoCertificado=\"30001000000500003416\" Certificado=\"c\">\n  <cfdi:Emisor Rfc=\"EKU9003173C9\" Nombre=\"ESCUELA KEMPER URGATE\" RegimenFiscal=\"601\"/>\n  <cfdi:Receptor Rfc=\"URE180429TM6\" Nombre=\"UNIVERSIDAD ROBOTICA ESPAÑOLA\" DomicilioFiscalReceptor=\"65000\" RegimenFiscalReceptor=\"601\" UsoCFDI=\"G03\"/>\n  <cfdi:Conceptos><cfdi:Concepto ClaveProdServ=\"81112100\" Cantidad=\"1\" ClaveUnidad=\"E48\" Descripcion=\"Hosting anual\" ValorUnitario=\"1000.00\" Importe=\"1000.00\" ObjetoImp=\"02\"/></cfdi:Conceptos>\n  <cfdi:Impuestos TotalImpuestosTrasladados=\"160.00\"><cfdi:Traslados><cfdi:Traslado Base=\"1000.00\" Impuesto=\"002\" TipoFactor=\"Tasa\" TasaOCuota=\"0.160000\" Importe=\"160.00\"/></cfdi:Traslados></cfdi:Impuestos>\n  <cfdi:Complemento><tfd:TimbreFiscalDigital xmlns:tfd=\"http://www.sat.gob.mx/TimbreFiscalDigital\" Version=\"1.1\" UUID=\"11111111-AAAA-4AAA-8AAA-000000000004\" FechaTimbrado=\"2026-09-21T12:00:00\" RfcProvCertif=\"SAT970701NN3\" SelloCFD=\"x\" NoCertificadoSAT=\"00001000000500000000\" SelloSAT=\"y\"/></cfdi:Complemento>\n</cfdi:Comprobante>\n"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("andressm2001/cfdi-a-excel").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 = {
    "enlaces": [],
    "xmls": ["""<?xml version=\"1.0\" encoding=\"UTF-8\"?>
<cfdi:Comprobante xmlns:cfdi=\"http://www.sat.gob.mx/cfd/4\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" Version=\"4.0\" Serie=\"A\" Folio=\"8\" Fecha=\"2026-09-21T09:30:00\" FormaPago=\"03\" SubTotal=\"1000.00\" Moneda=\"USD\" TipoCambio=\"18.5000\" Total=\"1160.00\" TipoDeComprobante=\"I\" Exportacion=\"01\" MetodoPago=\"PUE\" LugarExpedicion=\"64000\" Sello=\"s\" NoCertificado=\"30001000000500003416\" Certificado=\"c\">
  <cfdi:Emisor Rfc=\"EKU9003173C9\" Nombre=\"ESCUELA KEMPER URGATE\" RegimenFiscal=\"601\"/>
  <cfdi:Receptor Rfc=\"URE180429TM6\" Nombre=\"UNIVERSIDAD ROBOTICA ESPAÑOLA\" DomicilioFiscalReceptor=\"65000\" RegimenFiscalReceptor=\"601\" UsoCFDI=\"G03\"/>
  <cfdi:Conceptos><cfdi:Concepto ClaveProdServ=\"81112100\" Cantidad=\"1\" ClaveUnidad=\"E48\" Descripcion=\"Hosting anual\" ValorUnitario=\"1000.00\" Importe=\"1000.00\" ObjetoImp=\"02\"/></cfdi:Conceptos>
  <cfdi:Impuestos TotalImpuestosTrasladados=\"160.00\"><cfdi:Traslados><cfdi:Traslado Base=\"1000.00\" Impuesto=\"002\" TipoFactor=\"Tasa\" TasaOCuota=\"0.160000\" Importe=\"160.00\"/></cfdi:Traslados></cfdi:Impuestos>
  <cfdi:Complemento><tfd:TimbreFiscalDigital xmlns:tfd=\"http://www.sat.gob.mx/TimbreFiscalDigital\" Version=\"1.1\" UUID=\"11111111-AAAA-4AAA-8AAA-000000000004\" FechaTimbrado=\"2026-09-21T12:00:00\" RfcProvCertif=\"SAT970701NN3\" SelloCFD=\"x\" NoCertificadoSAT=\"00001000000500000000\" SelloSAT=\"y\"/></cfdi:Complemento>
</cfdi:Comprobante>
"""],
}

# Run the Actor and wait for it to finish
run = client.actor("andressm2001/cfdi-a-excel").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 '{
  "enlaces": [],
  "xmls": [
    "<?xml version=\\"1.0\\" encoding=\\"UTF-8\\"?>\\n<cfdi:Comprobante xmlns:cfdi=\\"http://www.sat.gob.mx/cfd/4\\" xmlns:xsi=\\"http://www.w3.org/2001/XMLSchema-instance\\" Version=\\"4.0\\" Serie=\\"A\\" Folio=\\"8\\" Fecha=\\"2026-09-21T09:30:00\\" FormaPago=\\"03\\" SubTotal=\\"1000.00\\" Moneda=\\"USD\\" TipoCambio=\\"18.5000\\" Total=\\"1160.00\\" TipoDeComprobante=\\"I\\" Exportacion=\\"01\\" MetodoPago=\\"PUE\\" LugarExpedicion=\\"64000\\" Sello=\\"s\\" NoCertificado=\\"30001000000500003416\\" Certificado=\\"c\\">\\n  <cfdi:Emisor Rfc=\\"EKU9003173C9\\" Nombre=\\"ESCUELA KEMPER URGATE\\" RegimenFiscal=\\"601\\"/>\\n  <cfdi:Receptor Rfc=\\"URE180429TM6\\" Nombre=\\"UNIVERSIDAD ROBOTICA ESPAÑOLA\\" DomicilioFiscalReceptor=\\"65000\\" RegimenFiscalReceptor=\\"601\\" UsoCFDI=\\"G03\\"/>\\n  <cfdi:Conceptos><cfdi:Concepto ClaveProdServ=\\"81112100\\" Cantidad=\\"1\\" ClaveUnidad=\\"E48\\" Descripcion=\\"Hosting anual\\" ValorUnitario=\\"1000.00\\" Importe=\\"1000.00\\" ObjetoImp=\\"02\\"/></cfdi:Conceptos>\\n  <cfdi:Impuestos TotalImpuestosTrasladados=\\"160.00\\"><cfdi:Traslados><cfdi:Traslado Base=\\"1000.00\\" Impuesto=\\"002\\" TipoFactor=\\"Tasa\\" TasaOCuota=\\"0.160000\\" Importe=\\"160.00\\"/></cfdi:Traslados></cfdi:Impuestos>\\n  <cfdi:Complemento><tfd:TimbreFiscalDigital xmlns:tfd=\\"http://www.sat.gob.mx/TimbreFiscalDigital\\" Version=\\"1.1\\" UUID=\\"11111111-AAAA-4AAA-8AAA-000000000004\\" FechaTimbrado=\\"2026-09-21T12:00:00\\" RfcProvCertif=\\"SAT970701NN3\\" SelloCFD=\\"x\\" NoCertificadoSAT=\\"00001000000500000000\\" SelloSAT=\\"y\\"/></cfdi:Complemento>\\n</cfdi:Comprobante>\\n"
  ]
}' |
apify call andressm2001/cfdi-a-excel --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,andressm2001/cfdi-a-excel"
        }
    }
}
```

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/FKoVLmPR0MApiSgCt/builds/uLVJwYYz551gU5mtY/openapi.json
