# Facturas argentinas (ARCA/AFIP) a JSON validado (`lif_manager/facturas-arca-json`) Actor

Lee facturas electrónicas argentinas en PDF o foto (OCR en español) y devuelve JSON con CUIT, punto de venta, número, IVA, total y CAE. Decodifica el QR de ARCA y valida que coincida con lo impreso. Permisos mínimos, nada se guarda y solo pagás los comprobantes leídos.

- **URL**: https://apify.com/lif_manager/facturas-arca-json.md
- **Developed by:** [LIF](https://apify.com/lif_manager) (community)
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $10.00 / 1,000 comprobante procesados

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

## Facturas argentinas (ARCA/AFIP) a JSON validado

Convertí facturas y comprobantes electrónicos argentinos, en PDF o foto, en datos estructurados y **controlados**. Para apps de gastos y rendiciones, estudios contables, agentes de IA que cargan comprobantes y cualquier integración con facturas de proveedores.

*English: reads Argentine electronic invoices (ARCA/AFIP) from PDF or images, decodes the official QR code and returns validated JSON (tax IDs, amounts, VAT, CAE).*

### Qué devuelve

Un ítem por comprobante con:

- **Campos:** tipo (Factura A/B/C/E/M/T, notas de crédito y débito, FCE MiPyMEs y el resto de la tabla de ARCA), punto de venta, número, fecha, CUIT emisor y receptor, neto gravado, IVA por alícuota, otros tributos, total, moneda, cotización, CAE o CAEA y su vencimiento.
- **Validaciones** (`ok`, `error`, `no_disponible` o `no_aplica`, por ejemplo el CUIT del receptor en una factura a consumidor final):
  - dígito verificador de los CUIT;
  - formato del CAE (14 dígitos) y vencimiento posterior a la fecha del comprobante;
  - neto + IVA + otros tributos = total (incluye el *IVA contenido* de las Factura B del Régimen de Transparencia Fiscal);
  - **el QR oficial coincide con lo impreso** (CUIT, punto de venta, número, fecha, CAE, total).
- **Confianza** (0 a 1) y **advertencias** en lenguaje claro: un QR que no coincide con el texto o que apunta a un dominio que no es de ARCA es una señal de comprobante adulterado.

```json
{
  "estado": "procesado",
  "campos": {"tipo_cmp_nombre": "Factura A", "punto_venta": 10, "numero": 94, "fecha": "2020-10-13",
             "cuit_emisor": "30000000007", "cuit_receptor": "20000000001", "total": "12100",
             "neto_gravado": "10000.00", "iva": {"21": "2100.00"}, "cae": "70417054367476", "vto_cae": "2020-10-23"},
  "validaciones": {"cuit_emisor": "ok", "cuit_receptor": "ok", "cae_formato": "ok", "vto_cae_posterior": "ok",
                   "suma_importes": "ok", "qr_coincide_con_texto": "ok"},
  "confianza": 1.0,
  "advertencias": []
}
```

*(Datos ficticios del ejemplo de la especificación de ARCA.)*

### Cómo se usa

1. Subí los archivos o pegá URLs en **Comprobantes**.
2. Si subiste archivos, elegí en **Almacén de archivos subidos** el almacén donde quedaron. El actor corre con permisos limitados y solo puede leer ese almacén.
3. Dejá **OCR** en *Automático* (pasa OCR en español solo si la página es una imagen escaneada).
4. Corré. Los resultados quedan en el dataset de la corrida, con dos vistas: *Resumen* y *Validaciones*.

Desde agentes de IA: el actor está disponible como herramienta MCP a través del servidor MCP de Apify.

### Precio

**USD 0,01 por comprobante electrónico leído** (evento `comprobante-procesado`: con CAE/CAEA o QR de ARCA), más un cargo de inicio de USD 0,00005 por corrida. El cómputo está incluido. Los archivos que no se pueden leer, los documentos no fiscales, los que solo mencionan CUITs y la demostración **no se cobran**. Podés fijar un tope de gasto por corrida.

### Privacidad y permisos

- **Nada se guarda:** los archivos se procesan en memoria y en temporales que se borran al terminar. El resultado queda solo en el dataset de tu cuenta.
- **Red:** el actor solo descarga los archivos que vos le pasás. Tu token de Apify se usa únicamente para leer archivos subidos a tu propio almacenamiento en `api.apify.com`.
- **Sin IA generativa:** el proceso es determinístico (extracción de texto, lectura del QR, OCR con Tesseract y reglas). No se manda nada a terceros.
- **Dependencias fijadas** (licencias permisivas: MIT, Apache 2.0, BSD): `apify`, `pdfplumber`, `pypdfium2`, `opencv-python-headless`, `numpy`, Tesseract.

### Límites

- No consulta a ARCA: constatar un comprobante contra los servicios de ARCA requiere el certificado del titular.
- Probado con facturas reales de facturadores grandes (Mercado Libre, PedidosYa). Facturadores con formatos poco comunes pueden dejar algunos campos como `no_disponible`; las validaciones lo informan en vez de inventar datos.
- Hasta 20 MB por archivo y 20 páginas por PDF.
- Es una ayuda para cargar y controlar comprobantes, no asesoramiento contable.

# Actor input Schema

## `comprobantes` (type: `array`):

Subí los archivos o pegá URLs públicas. Formatos: PDF, PNG, JPG, WEBP, TIFF, BMP. Hasta 20 MB por archivo. Si los subís desde acá, elegí también abajo el almacén donde quedaron. Lo que no se puede leer se informa en el resultado.

## `almacen` (type: `string`):

El almacén (key-value store) donde quedaron los archivos que subiste. El actor corre con permisos limitados y solo puede leer el almacén que elijas acá. Si no pegás URLs arriba, se procesan todos los PDF e imágenes de este almacén.

## `ocr` (type: `string`):

auto: pasa OCR en español solo a las páginas escaneadas (sin texto). nunca: más rápido, en escaneos lee solo el QR.

## `max_paginas` (type: `integer`):

Se leen las primeras N páginas de cada PDF (el comprobante suele estar en la 1).

## Actor input object example

```json
{
  "ocr": "auto",
  "max_paginas": 5
}
```

# Actor output Schema

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

// Run the Actor and wait for it to finish
const run = await client.actor("lif_manager/facturas-arca-json").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("lif_manager/facturas-arca-json").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 lif_manager/facturas-arca-json --silent --output-dataset

```

## MCP server setup

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

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/i9vO4n2KuP0XEPmzH/builds/oEBiJDJ3U6cjQAOE5/openapi.json
