# Baixar NFes em Lote: XML + DANFE em ZIP (`brasildados/baixar-nfes-lote-api`) Actor

Consulta chaves NFe (modelo 55) em paralelo e gera um .zip com XMLs + DANFEs (PDF). Retorna URL de download, contagens e erros. / Query NF-e access keys in parallel and generate a .zip with XMLs and DANFEs. Returns download URL, counts and errors.

- **URL**: https://apify.com/brasildados/baixar-nfes-lote-api.md
- **Developed by:** [BrasilDados.org](https://apify.com/brasildados) (community)
- **Categories:** Automation, E-commerce, AI
- **Stats:** 1 total users, 1 monthly users, 0.0% runs succeeded, NaN bookmarks
- **User rating**: No ratings yet

## Pricing

from $100.00 / 1,000 por nfe encontrada com sucesso / per invoice correctly founds

This Actor is paid per event and usage. You are charged both the fixed price for specific events and for Apify platform usage.
Since this Actor supports Apify Store discounts, the price gets lower the higher subscription plan you have.

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

## What's an Apify Actor?

Actors are a software tools running on the Apify platform, for all kinds of web data extraction and automation use cases.
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.
Actors are written with capital "A".

## 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.
The best way to integrate Actors is as follows.

In JavaScript/TypeScript projects, use official [JavaScript/TypeScript client](https://docs.apify.com/api/client/js.md):

```bash
npm install apify-client
```

In Python projects, use official [Python client library](https://docs.apify.com/api/client/python.md):

```bash
pip install apify-client
```

In shell scripts, use [Apify CLI](https://docs.apify.com/cli/docs.md):

````bash
# MacOS / Linux
curl -fsSL https://apify.com/install-cli.sh | bash
# Windows
irm https://apify.com/install-cli.ps1 | iex
```bash

In AI frameworks, you might use the [Apify MCP server](https://docs.apify.com/platform/integrations/mcp.md).

If your project is in a different language, use the [REST API](https://docs.apify.com/api/v2.md).

For usage examples, see the [API](#api) section below.

For more details, see Apify documentation as [Markdown index](https://docs.apify.com/llms.txt) and [Markdown full-text](https://docs.apify.com/llms-full.txt).


# README

## 📦 Baixar NF-e em Lote: XML e DANFE em ZIP

Consulte uma ou mais chaves de acesso NF-e (modelo 55), **sem necessidade de certificado digital**, e receba um único arquivo `.zip` com os XMLs e os DANFEs (PDF) de todas as notas. Ideal para contadores, ERPs e rotinas de arquivo fiscal que precisam de vários documentos de uma vez sem fazer uma requisição por nota.

> 🎯 **Diferencial:** uma única chamada para até 50 chaves; o actor consulta em paralelo, monta o `.zip` com XMLs + DANFEs e devolve a URL pronta para download - sem precisar gerenciar cada nota individualmente.

---

### O que retorna

| | Campo | Descrição |
|---|---|---|
| 📦 | `zipUrl` | Link público para download do `.zip` (válido pela duração do run) |
| ✅ | `totalEncontradas` | Notas localizadas e incluídas no ZIP |
| ❌ | `totalNaoEncontradas` | Chaves válidas sem nota no banco |
| ⚠️ | `totalInvalidas` | Chaves com dígito verificador incorreto |
| 🗂️ | `resultados[]` | Status por chave: `encontrado`, `temXml`, `temDanfe`, `erro` |

**Estrutura interna do ZIP:**

````

nfe-lote.zip
├── xmls/
│   └── 35260444...xml    ← XML completo da NF-e
├── danfes/
│   └── 35260444...pdf    ← DANFE em PDF
└── manifest.json         ← array com todos os resultados

````

---

### Por que usar

- 🔄 **Lote sem código extra** - envie até 50 chaves numa única chamada; sem loop de requisições
- ⚡ **8 consultas em paralelo** - todas as notas são buscadas ao mesmo tempo
- 📁 **ZIP organizado** - XMLs em `xmls/`, DANFEs em `danfes/`, manifesto incluso
- 💰 **Cobrança justa** - paga somente por nota encontrada; inválidas e não encontradas não cobram
- 🔗 **Integração via API ou Standby** - lote assíncrono ou endpoint HTTP síncrono

---

### Como usar

**1. Cole as chaves de acesso**

No campo "Chaves de Acesso NF-e", informe uma ou mais chaves de 44 dígitos (pontuação é ignorada):

```json
{
  "chaves": [
    "35260444823938000187551090000002691092067649",
    "35260444823938000187551090000002691092067650"
  ]
}
````

**2. Execute o actor**

Clique em "Save & Start". O actor consulta cada nota em paralelo e gera o arquivo `.zip`.

**3. Baixe o ZIP**

Na aba **Output**, clique em **Arquivo ZIP (XMLs e DANFEs)** para baixar. Ou use a `zipUrl` retornada para integrar no seu sistema.

***

### Precificação

Cobrado por nota **encontrada** - `$0.10` por NF-e localizada (evento `consulta-nfe-lote`).

- Chaves inválidas (dígito verificador errado): **sem cobrança**
- Notas não encontradas no banco: **sem cobrança**
- 50 notas encontradas: `$0.10 × 50 = $5.00`

***

### Exemplo de saída

```json
{
  "zipUrl": "https://api.apify.com/v2/key-value-stores/abc.../records/nfe-lote.zip?signature=...",
  "totalChaves": 2,
  "totalEncontradas": 1,
  "totalNaoEncontradas": 1,
  "totalInvalidas": 0,
  "erros": [
    { "chave": "35260444823938000187551090000002691092067650", "erro": "Nota não encontrada." }
  ],
  "geradoEm": "2026-06-09T10:20:54.324Z",
  "resultados": [
    {
      "chave": "35260444823938000187551090000002691092067649",
      "encontrado": true,
      "consultadoEm": "2026-06-09T10:20:52.955Z",
      "referenciaConsulta": "bd-af03c0f94e82",
      "temXml": true,
      "temDanfe": true,
      "erro": null
    },
    {
      "chave": "35260444823938000187551090000002691092067650",
      "encontrado": false,
      "consultadoEm": "2026-06-09T10:20:53.100Z",
      "referenciaConsulta": "bd-c1d2e3f4a5b6",
      "temXml": false,
      "temDanfe": false,
      "erro": "Nota não encontrada."
    }
  ]
}
```

***

### Perguntas frequentes

**Quais NF-es são suportadas?**
NF-e modelo 55 (nota eletrônica de mercadoria). Não inclui NFS-e (serviços) nem CT-e (conhecimento de transporte). Para CT-e, use o actor [Consulta CT-e por Chave](https://apify.com/brasildados/api-consulta-cte-por-chave?fpr=t5lwzq).

**Qual o limite de chaves por execução?**
50 chaves por run. Para volumes maiores, divida em lotes e execute sequencialmente.

**E se o DANFE não estiver disponível?**
Algumas notas têm XML mas não têm DANFE disponível no banco. Nesse caso `temXml: true` e `temDanfe: false` - o ZIP terá o XML mas não o PDF para aquela chave.

**O link do ZIP expira?**
Sim. O link `zipUrl` fica ativo pelo tempo de retenção do run (padrão Apify: 7 dias em planos pagos). Para arquivo permanente, baixe e guarde o ZIP no seu sistema.

**Posso chamar em tempo real (Standby)?**
Sim. O endpoint `POST /export` responde de forma síncrona. Veja os exemplos curl abaixo.

***

#### 🔌 Integração via API

**Execução em lote:**

```bash
curl -X POST "https://api.apify.com/v2/acts/brasildados~baixar-nfes-lote-api/run-sync-get-dataset-items?token=SEU_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"chaves":["35260444823938000187551090000002691092067649"]}'
```

**Standby (`POST /export`):**

```bash
curl -X POST "https://brasildados--baixar-nfes-lote-api.apify.actor/export" \
  -H "Authorization: Bearer SEU_APIFY_TOKEN" \
  -H "Content-Type: application/json" \
  --compressed \
  -d '{"chaves":["35260444823938000187551090000002691092067649"]}'
```

***

### Actors relacionados

| Actor | Descrição |
|---|---|
| [Consulta NF-e por Chave](https://apify.com/brasildados/api-consulta-nfe-por-chave?fpr=t5lwzq) | Consulta individual com dados estruturados (emitente, itens, impostos, pagamento) |
| [Consulta CT-e por Chave](https://apify.com/brasildados/api-consulta-cte-por-chave?fpr=t5lwzq) | Download de XML e DACTE de CT-e (conhecimento de transporte) |
| [CNPJ Enrichment](https://apify.com/brasildados/brazil-enrich-data-lead-by-cnpj?fpr=t5lwzq) | Dados cadastrais completos por CNPJ (Simples, IE, Suframa, portais) |

***

### Legal

Este actor acessa informações de NF-e por meio de chave de acesso (dado público por design da SEFAZ para o portador da chave). O usuário é responsável por garantir que possui autorização para acessar as notas consultadas.

***

### 🇬🇧 English

Query NF-e access keys (Brazilian electronic invoices, model 55) in parallel and receive a single `.zip` file with all XMLs and DANFEs (PDFs). Maximum 50 keys per run — no need to fetch each invoice individually.

**How to use:**

```json
{
  "chaves": ["35260444823938000187551090000002691092067649"]
}
```

**Batch run:**

```bash
curl -X POST "https://api.apify.com/v2/acts/brasildados~baixar-nfes-lote-api/run-sync-get-dataset-items?token=YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"chaves":["35260444823938000187551090000002691092067649"]}'
```

**Standby (`POST /export`):**

```bash
curl -X POST "https://brasildados--baixar-nfes-lote-api.apify.actor/export" \
  -H "Authorization: Bearer YOUR_APIFY_TOKEN" \
  -H "Content-Type: application/json" \
  --compressed \
  -d '{"chaves":["35260444823938000187551090000002691092067649"]}'
```

**Pricing:** $0.10 per found invoice (event `consulta-nfe-lote`). Invalid keys and not-found invoices are not charged.

**Related:** [Individual NF-e lookup](https://apify.com/brasildados/api-consulta-nfe-por-chave?fpr=t5lwzq) (structured data: issuer, items, taxes, payment).

***

*Dúvidas ou problemas? <contato@brasildados.org> | [brasildados.org](https://brasildados.org)*

# Actor input Schema

## `chaves` (type: `array`):

Chaves de acesso NF-e com 44 dígitos (modelo 55). Pontuação e espaços são ignorados automaticamente. Máximo 50 chaves por execução - envie em lotes maiores via chamadas sequenciais. / NF-e access keys (44 digits, model 55). Punctuation and spaces are stripped automatically. Maximum 50 keys per run.

## Actor input object example

```json
{
  "chaves": [
    "35260444823938000187551090000002691092067649",
    "35260444823938000187551090000002691092067650"
  ]
}
```

# Actor output Schema

## `arquivoZip` (type: `string`):

Arquivo .zip com todos os XMLs e DANFEs (PDF) das notas consultadas.

## `resultadosPorChave` (type: `string`):

Dataset com um item por chave consultada: status, temXml, temDanfe, erros.

# 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 = {
    "chaves": [
        "35260444823938000187551090000002691092067649",
        "35260444823938000187551090000002691092067650"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("brasildados/baixar-nfes-lote-api").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 = { "chaves": [
        "35260444823938000187551090000002691092067649",
        "35260444823938000187551090000002691092067650",
    ] }

# Run the Actor and wait for it to finish
run = client.actor("brasildados/baixar-nfes-lote-api").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print("💾 Check your data here: https://console.apify.com/storage/datasets/" + run["defaultDatasetId"])
for item in client.dataset(run["defaultDatasetId"]).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "chaves": [
    "35260444823938000187551090000002691092067649",
    "35260444823938000187551090000002691092067650"
  ]
}' |
apify call brasildados/baixar-nfes-lote-api --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "command": "npx",
            "args": [
                "mcp-remote",
                "https://mcp.apify.com/?tools=brasildados/baixar-nfes-lote-api",
                "--header",
                "Authorization: Bearer <YOUR_API_TOKEN>"
            ]
        }
    }
}

```

## OpenAPI specification

```json
{
    "openapi": "3.0.1",
    "info": {
        "title": "Baixar NFes em Lote: XML + DANFE em ZIP",
        "description": "Consulta chaves NFe (modelo 55) em paralelo e gera um .zip com XMLs + DANFEs (PDF). Retorna URL de download, contagens e erros. / Query NF-e access keys in parallel and generate a .zip with XMLs and DANFEs. Returns download URL, counts and errors.",
        "version": "1.0",
        "x-build-id": "AJHT8e7HFzzpPN1ix"
    },
    "servers": [
        {
            "url": "https://api.apify.com/v2"
        }
    ],
    "paths": {
        "/acts/brasildados~baixar-nfes-lote-api/run-sync-get-dataset-items": {
            "post": {
                "operationId": "run-sync-get-dataset-items-brasildados-baixar-nfes-lote-api",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor, waits for its completion, and returns Actor's dataset items in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK"
                    }
                }
            }
        },
        "/acts/brasildados~baixar-nfes-lote-api/runs": {
            "post": {
                "operationId": "runs-sync-brasildados-baixar-nfes-lote-api",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor and returns information about the initiated run in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/runsResponseSchema"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/acts/brasildados~baixar-nfes-lote-api/run-sync": {
            "post": {
                "operationId": "run-sync-brasildados-baixar-nfes-lote-api",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor, waits for completion, and returns the OUTPUT from Key-value store in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK"
                    }
                }
            }
        }
    },
    "components": {
        "schemas": {
            "inputSchema": {
                "type": "object",
                "required": [
                    "chaves"
                ],
                "properties": {
                    "chaves": {
                        "title": "Chaves de Acesso NFe / NF-e Access Keys",
                        "minItems": 1,
                        "maxItems": 50,
                        "type": "array",
                        "description": "Chaves de acesso NF-e com 44 dígitos (modelo 55). Pontuação e espaços são ignorados automaticamente. Máximo 50 chaves por execução - envie em lotes maiores via chamadas sequenciais. / NF-e access keys (44 digits, model 55). Punctuation and spaces are stripped automatically. Maximum 50 keys per run.",
                        "items": {
                            "type": "string"
                        }
                    }
                }
            },
            "runsResponseSchema": {
                "type": "object",
                "properties": {
                    "data": {
                        "type": "object",
                        "properties": {
                            "id": {
                                "type": "string"
                            },
                            "actId": {
                                "type": "string"
                            },
                            "userId": {
                                "type": "string"
                            },
                            "startedAt": {
                                "type": "string",
                                "format": "date-time",
                                "example": "2025-01-08T00:00:00.000Z"
                            },
                            "finishedAt": {
                                "type": "string",
                                "format": "date-time",
                                "example": "2025-01-08T00:00:00.000Z"
                            },
                            "status": {
                                "type": "string",
                                "example": "READY"
                            },
                            "meta": {
                                "type": "object",
                                "properties": {
                                    "origin": {
                                        "type": "string",
                                        "example": "API"
                                    },
                                    "userAgent": {
                                        "type": "string"
                                    }
                                }
                            },
                            "stats": {
                                "type": "object",
                                "properties": {
                                    "inputBodyLen": {
                                        "type": "integer",
                                        "example": 2000
                                    },
                                    "rebootCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "restartCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "resurrectCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "computeUnits": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            },
                            "options": {
                                "type": "object",
                                "properties": {
                                    "build": {
                                        "type": "string",
                                        "example": "latest"
                                    },
                                    "timeoutSecs": {
                                        "type": "integer",
                                        "example": 300
                                    },
                                    "memoryMbytes": {
                                        "type": "integer",
                                        "example": 1024
                                    },
                                    "diskMbytes": {
                                        "type": "integer",
                                        "example": 2048
                                    }
                                }
                            },
                            "buildId": {
                                "type": "string"
                            },
                            "defaultKeyValueStoreId": {
                                "type": "string"
                            },
                            "defaultDatasetId": {
                                "type": "string"
                            },
                            "defaultRequestQueueId": {
                                "type": "string"
                            },
                            "buildNumber": {
                                "type": "string",
                                "example": "1.0.0"
                            },
                            "containerUrl": {
                                "type": "string"
                            },
                            "usage": {
                                "type": "object",
                                "properties": {
                                    "ACTOR_COMPUTE_UNITS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_WRITES": {
                                        "type": "integer",
                                        "example": 1
                                    },
                                    "KEY_VALUE_STORE_LISTS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_INTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_EXTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_SERPS": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            },
                            "usageTotalUsd": {
                                "type": "number",
                                "example": 0.00005
                            },
                            "usageUsd": {
                                "type": "object",
                                "properties": {
                                    "ACTOR_COMPUTE_UNITS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_WRITES": {
                                        "type": "number",
                                        "example": 0.00005
                                    },
                                    "KEY_VALUE_STORE_LISTS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_INTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_EXTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_SERPS": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
```
