# Consulta CNPJ em Lote — Brazil CNPJ Bulk Lookup, QSA & CNAE (`tidydata/brazil-cnpj-lookup`) Actor

Look up thousands of Brazilian CNPJs in one run: razão social, status, CNAE, address, e-mail, phone, porte, capital social, Simples/MEI and partners (QSA) from Receita Federal open data. 3 free sources with automatic fallback. $0.80 per 1,000.

- **URL**: https://apify.com/tidydata/brazil-cnpj-lookup.md
- **Developed by:** [tidydata](https://apify.com/tidydata) (community)
- **Categories:** Lead generation, Business, Automation
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $0.64 / 1,000 company founds

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

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

## Consulta CNPJ em Lote — Brazil CNPJ Bulk Lookup, QSA & CNAE

![A list of CNPJs turned into Receita Federal records with razão social, status, CNAE, city and number of partners (real output)](https://raw.githubusercontent.com/tidydata-dev/tidydata-dev/main/assets/apify/brazil-cnpj-lookup.png)

Paste a list of **CNPJs** and get one clean row per company from the **Receita Federal open CNPJ data**: razão social, nome fantasia, situação cadastral, opening date, main and secondary **CNAE**, full address, **e-mail and phone**, porte, capital social, natureza jurídica, **Simples Nacional / MEI** and the partners and administrators (**QSA**).

Three free public mirrors of the Receita data are used with **automatic fallback** (OpenCNPJ → Minha Receita → BrasilAPI): if one is slow, rate-limited or down, the next one answers, so big lists finish instead of failing halfway. No scraping of commercial sites, no captchas, no proxies.

### Why use it

- **Bulk** — up to 100,000 CNPJs per run, about 8-10 per second.
- **Reliable** — three sources with retries and fallback; every CNPJ ends as a company row or a clear, free error row.
- **Any format** — `33.000.167/0001-01`, `33000167000101`, numbers that lost their leading zeros in Excel, 8-digit roots (looked up as the head office) and the **new alphanumeric CNPJ** (letters in the first 12 characters, IN RFB 2.229/2024). Check digits are validated before any request; duplicates are removed.
- **Complete row** — status and reason, special situation (e.g. recuperação judicial), CNAE codes with descriptions, IBGE city code, Simples and MEI dates, latest tax regime (Lucro Real / Presumido), share capital and QSA with roles, entry dates and age ranges.
- **Cheap** — $0.80 per 1,000 companies found. Invalid and not-found CNPJs are free.

### Use cases

Enriching CRM and lead lists, KYC / KYB and supplier onboarding, checking that customers and suppliers are still ATIVA, Simples Nacional checks before invoicing, credit and risk analysis, cleaning ERP databases, market research by CNAE.

### Input

```json
{
  "cnpjs": ["33.000.167/0001-01", "00.000.000/0001-91", "60.701.190/0001-04"],
  "includePartners": true,
  "onlyActive": false
}
```

Paste the CNPJs one per line, or a whole column from a spreadsheet (commas, semicolons and line breaks all split).

### Output (real row, trimmed; partner names hidden here)

```json
{
  "cnpj": "33000167000101", "cnpjFormatted": "33.000.167/0001-01", "cnpjRoot": "33000167", "branchNumber": "0001",
  "companyName": "PETROLEO BRASILEIRO S A PETROBRAS", "tradeName": "PETROBRAS - EDISE", "isHeadOffice": true,
  "status": "ATIVA", "isActive": true, "statusDate": "2005-11-03", "statusReason": "SEM MOTIVO", "openingDate": "1966-09-28",
  "legalNatureCode": "2038", "legalNature": "Sociedade de Economia Mista", "companySize": "DEMAIS",
  "shareCapital": 205431960490.52,
  "mainCnae": "0600001", "mainCnaeFormatted": "0600-0/01", "mainCnaeDescription": "Extração de petróleo e gás natural",
  "secondaryCnaesText": "1921-7/00 Fabricação de produtos do refino de petróleo; 3520-4/01 Produção de gás; processamento de gás natural; …",
  "address": "AVENIDA REPUBLICA DO CHILE, 65, CENTRO", "zipCode": "20031170", "city": "RIO DE JANEIRO", "state": "RJ",
  "email": "CC-RFISC@PETROBRAS.COM.BR", "phone": "+55 21 21660000",
  "simplesOptant": null, "meiOptant": null, "partnersCount": 8,
  "partners": [{ "name": "«NAME»", "qualification": "Presidente", "entryDate": "2024-06-07", "ageRange": "61 a 70 anos", "document": "***612937**", "type": "person" }],
  "source": "OpenCNPJ (Receita Federal open data)", "sourceUpdatedAt": "2026-11-01T21:47:27.1957841Z"
}
```

Three table views in the Output tab: **Companies**, **Tax & size** and **Partners (QSA)**. Export to CSV, Excel, JSON or Google Sheets.

### Pricing

**$0.80 per 1,000 companies** returned. Invalid CNPJs, CNPJs not found, companies left out by *Only active companies* and input errors are **free**. Apify store discounts apply on paid plans.

### Sources

| Source | What it adds | Notes |
|---|---|---|
| **OpenCNPJ** (default first) | e-mail, exact share capital, phones with DDD | Open-source project, Receita data republished monthly |
| **Minha Receita** | tax regime history, IBGE code | Open-source project by Eduardo Cuducos |
| **BrasilAPI** | same layout as Minha Receita | Community API, used as last fallback |

All three republish the **Cadastro Nacional da Pessoa Jurídica** open data that the Receita Federal publishes every month (dados abertos, public by law). This actor is not affiliated with the Receita Federal or with these projects. Change the order in *Sources* if you prefer one of them.

### Privacy (LGPD)

CNPJ registration data and the QSA are public by law. Partners' CPFs come masked exactly as the Receita publishes them (`***123456**`). Use the e-mails and partner names in line with the LGPD and the purpose of your processing.

### FAQ

**How fresh is the data?** As fresh as the Receita Federal open data, which is published monthly; `sourceUpdatedAt` shows when the mirror refreshed the record. A company opened in the last few weeks may not be in the open data yet: it comes back as a free "not found" row.

**Can I search companies by CNAE, city or state?** Not in this actor: it enriches CNPJs you already have. The free public sources only allow lookups by CNPJ.

**What happens if a source is down or rate-limited?** The actor waits and retries, then asks the next source. Only if all three fail does the CNPJ come back as a free error row saying "run again later".

**Why is the e-mail empty?** Many companies do not register an e-mail with the Receita, and Minha Receita / BrasilAPI do not publish it: keep OpenCNPJ first in *Sources* to get e-mails.

**Does it accept the new alphanumeric CNPJ?** Yes. The check digits are validated with the Receita rule (letters count as ASCII − 48). Whether a given alphanumeric CNPJ is found depends on the sources having published it.

**Can I check thousands of suppliers every month?** Yes: schedule it in Apify with *Only active companies* off and compare `status` with the previous run, or chain it with our [Merge, Filter, Deduplicate & Transform Datasets](https://apify.com/tidydata/merge-dedupe-datasets) actor to keep only changes.

**Does it need an API key?** No key, account or proxy.

### Related Actors

- [French Company Search](https://apify.com/tidydata/french-company-search) — every French company from the official Sirene register.
- [Company Registry Lookup](https://apify.com/tidydata/company-registry-lookup) — LEI (GLEIF), Norway and Finland official registries.
- [Merge, Filter, Deduplicate & Transform Datasets](https://apify.com/tidydata/merge-dedupe-datasets) — merge runs and keep only new or changed rows.

# Actor input Schema

## `cnpjs` (type: `array`):

Paste CNPJs with or without punctuation (33.000.167/0001-01 or 33000167000101), one per line; commas and semicolons also split. An 8-digit root (33000167) looks up the head office. Numbers that lost their leading zeros in Excel are fixed. Invalid or unknown CNPJs come back as free error rows. Up to 100,000 per run.

## `includePartners` (type: `boolean`):

Partners and administrators from the Receita Federal QSA: name, role, entry date, age range and the masked CPF/CNPJ exactly as the Receita publishes it.

## `includeSecondaryCnaes` (type: `boolean`):

All secondary activity codes with descriptions.

## `onlyActive` (type: `boolean`):

Leave out CNPJs whose status is not ATIVA (BAIXADA, INAPTA, SUSPENSA, NULA). Left-out companies are free.

## `sources` (type: `array`):

Free public mirrors of the Receita Federal open CNPJ data. The actor asks the first one and moves to the next if it fails or is rate-limited. OpenCNPJ has e-mails and exact share capital; Minha Receita and BrasilAPI add the tax regime (Lucro Real / Presumido) and the IBGE city code.

## Actor input object example

```json
{
  "cnpjs": [
    "33.000.167/0001-01",
    "00.000.000/0001-91",
    "60.701.190/0001-04"
  ],
  "includePartners": true,
  "includeSecondaryCnaes": true,
  "onlyActive": false,
  "sources": [
    "opencnpj",
    "minhareceita",
    "brasilapi"
  ]
}
```

# Actor output Schema

## `results` (type: `string`):

One row per CNPJ.

# 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 = {
    "cnpjs": [
        "33.000.167/0001-01",
        "00.000.000/0001-91",
        "60.701.190/0001-04"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("tidydata/brazil-cnpj-lookup").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 = { "cnpjs": [
        "33.000.167/0001-01",
        "00.000.000/0001-91",
        "60.701.190/0001-04",
    ] }

# Run the Actor and wait for it to finish
run = client.actor("tidydata/brazil-cnpj-lookup").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 '{
  "cnpjs": [
    "33.000.167/0001-01",
    "00.000.000/0001-91",
    "60.701.190/0001-04"
  ]
}' |
apify call tidydata/brazil-cnpj-lookup --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,tidydata/brazil-cnpj-lookup"
        }
    }
}
```

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/bXi5MbgRwD1gywXkL/builds/ZHoYyAh03RTWt027b/openapi.json
