# Brazilian Companies Finder — by CNAE & State (CNPJ Discovery) (`gangary/cnpj-discovery`) Actor

Find every active Brazilian company matching a CNAE activity code and state in seconds — no scraping, powered by an official Receita Federal data index. Filter further by city and company size. Get CNPJ, legal name, trade name, activity, city, size and opening date.

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

## Pricing

from $2.00 / 1,000 per 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.

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

## What's an Apify Actor?

Actors are web data automations that power AI and operations. They run on the Apify platform to scrape websites, process data, connect APIs, and automate workflows.
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.

- **AI agents and MCP clients** — the [Apify MCP server](https://docs.apify.com/integrations/mcp.md) at `https://mcp.apify.com` (remote, streamable HTTP, OAuth on first use).
- **Agentic workflows and local Actor development** — [Agent Skills](https://apify.com/.well-known/agent-skills/index.json) with the [Apify CLI](https://docs.apify.com/cli/docs.md): `npm install -g apify-cli`, then `apify login`.
- **JavaScript/TypeScript projects** — the official [JS/TS client](https://docs.apify.com/api/client/js/docs.md): `npm install apify-client`.
- **Python projects** — the official [Python client](https://docs.apify.com/api/client/python/docs.md): `pip install apify-client`.
- **Any other language** — 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

## Brazilian Companies Finder — by CNAE & State (CNPJ Discovery)

Pick an economic activity (CNAE) and a state — get back **every active Brazilian company that matches**: CNPJ, legal name, trade name, city, size and opening date. Search across **27.8 million active companies** indexed from the official Federal Revenue (Receita Federal) open dataset. No scraping, no login, no API key.

![Cover](https://empresas-por-cnae.vercel.app/covers/cnpj-discovery.png)

Also searchable in Portuguese: *lista de empresas por CNAE e estado, empresas ativas por segmento, prospecção B2B com dados da Receita Federal*.

**This is the discovery layer**: it finds the companies. Pair it with [CNPJ Lookup](https://apify.com/gangary/cnpj-lookup) (full registry data per company) and the [Lead Enricher & ICP Scorer](https://apify.com/gangary/lead-enricher-icp) (verify and score before outreach) for a complete prospecting pipeline — or run [B2B Leads Brazil](https://apify.com/gangary/b2b-leads-brazil), which does all three steps in a single call and hands you the finished, scored list.

### Input example

Dental clinics in São Paulo and Minas Gerais, up to 500 results:

```json
{
  "cnae": "8630-5/04",
  "ufs": ["SP", "MG"],
  "limit": 500
}
```

- `cnae` accepts the full code (`8630-5/04`), digits only (`8630504`) or a **prefix** (`8630` = every outpatient activity, `86` = all of healthcare).
- `municipio` narrows to one city (accent-insensitive: `"Sao Paulo"` works).
- `porte` filters by declared company size (`MEI/micro`, `small`, `other`).
- `offset` + `limit` paginate a big segment across cheap runs.

### Output example

```json
{
  "cnpj": "12345678000195",
  "cnpj_formatado": "12.345.678/0001-95",
  "razao_social": "CLINICA ODONTOLOGICA EXEMPLO LTDA",
  "nome_fantasia": "Sorriso Exemplo",
  "cnae_principal": "8630504",
  "cnae_formatado": "8630-5/04",
  "municipio": "SAO PAULO",
  "uf": "SP",
  "porte": "MICRO EMPRESA",
  "data_abertura": "2019-03-14",
  "tem_email": true,
  "tem_telefone": true
}
```

### Output fields

| Field | Description |
|---|---|
| `cnpj` / `cnpj_formatado` | The company's tax ID, digits-only and formatted. |
| `razao_social` | Exact legal name from the federal registry (unmodified). |
| `nome_fantasia` | Trade name, when declared. |
| `cnae_principal` | Primary economic activity code (what the company actually does). |
| `municipio` / `uf` | City and state of the establishment. |
| `porte` | Declared size (MEI/micro, small, other). |
| `data_abertura` | Opening date (YYYY-MM-DD). |
| `tem_email` / `tem_telefone` | Whether the registry has an email/phone on file for this company — useful to estimate contactability before running [CNPJ Lookup](https://apify.com/gangary/cnpj-lookup). |

### Use cases

- **Build a prospecting list by niche + region** — every active dental clinic in SP, every trucking company in the South, every software house in your city
- **Size a market (TAM)** — how many active companies exist per CNAE per state, with zero sampling bias (it's the full registry)
- **Feed your sales pipeline** — Discovery finds them → [CNPJ Lookup](https://apify.com/gangary/cnpj-lookup) pulls addresses, partners and contacts → [Lead Enricher](https://apify.com/gangary/lead-enricher-icp) verifies and scores them
- **Territory planning** — split a segment by city/size before assigning reps

### Pricing (Pay per event)

| Event | When | Price |
|---|---|---|
| `actor-start` | once per run | $0.005 |
| `company-found` | per company returned | $0.002 |

A 500-company list costs $0.005 + 500 × $0.002 = **$1.005**. A 5,000-company segment costs **$10.005**. Runs that find nothing only pay the start fee.

### Where the data comes from

The official **CNPJ open dataset published by Receita Federal** (Brazil's Federal Revenue), rebuilt into a fast index **every month** — you always query the latest published registry snapshot, with only **active** (situação ATIVA) establishments included.

### Is this compliant?

Yes — the CNPJ registry is **public information** that Receita Federal itself publishes as open data. No scraping, no logins, no private or behind-auth data. LGPD note: these are company registry records, published officially for public consultation.

### Limitations

- Data is a **monthly snapshot** of the official registry — a company opened yesterday appears after the next monthly rebuild.
- Returns registry firmographics, **not contact details** — `tem_email`/`tem_telefone` tell you they exist; [CNPJ Lookup](https://apify.com/gangary/cnpj-lookup) retrieves them per company.
- Filters use the **primary** CNAE (secondary activities are not indexed).
- Only **active** companies — closed (BAIXADA) or suspended ones are excluded by design.

### From the same maker

- **[B2B Leads Brazil — Find, Enrich & Score in One Run](https://apify.com/gangary/b2b-leads-brazil)** — this Actor's job plus the next two, in a single run: discovers the companies, pulls each one's public contact data and scores every lead 0–100 against your ICP, sorted best-first. Use it when you want the finished call list instead of assembling it yourself.
- **[CNPJ Lookup — Brazilian Company Registry Data](https://apify.com/gangary/cnpj-lookup)** — full official record per CNPJ: status, address, partners, capital, phone and email when on file.
- **[Lead Enricher & ICP Scorer](https://apify.com/gangary/lead-enricher-icp)** — clean, verify, dedupe and score any lead list 0–100 against your ideal customer profile.
- **[Newly Opened Brazilian Companies](https://apify.com/gangary/new-brazilian-companies)** — same index, filtered by opening date: brand-new companies still choosing their first suppliers.

**Full pipeline:** this Actor finds the companies → Lookup pulls the official record → Enricher scores what's worth contacting. **Want all three in one step?** [B2B Leads Brazil](https://apify.com/gangary/b2b-leads-brazil) runs the whole funnel for you.

# Actor input Schema

## `cnae` (type: `string`):

Codigo completo (8630-5/04) ou prefixo (8630, 86) da atividade economica.

## `ufs` (type: `array`):

Siglas de 2 letras (ex: MG, SP). Pelo menos 1 e obrigatoria.

## `municipio` (type: `string`):

Nome do municipio (com ou sem acento). Filtra dentro das UFs escolhidas.

## `porte` (type: `string`):

Restringe pelo porte declarado na Receita.

## `limit` (type: `integer`):

Maximo de empresas retornadas nessa execucao.

## `offset` (type: `integer`):

Pula os N primeiros resultados (paginacao).

## Actor input object example

```json
{
  "cnae": "8630-5/04",
  "ufs": [
    "MG"
  ],
  "limit": 100,
  "offset": 0
}
```

# 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 = {
    "cnae": "8630-5/04",
    "ufs": [
        "MG"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("gangary/cnpj-discovery").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 = {
    "cnae": "8630-5/04",
    "ufs": ["MG"],
}

# Run the Actor and wait for it to finish
run = client.actor("gangary/cnpj-discovery").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 '{
  "cnae": "8630-5/04",
  "ufs": [
    "MG"
  ]
}' |
apify call gangary/cnpj-discovery --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "command": "npx",
            "args": [
                "mcp-remote",
                "https://mcp.apify.com/?tools=gangary/cnpj-discovery",
                "--header",
                "Authorization: Bearer <YOUR_API_TOKEN>"
            ]
        }
    }
}

```

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/acts/IOMAa73chUImeVAFr/builds/LhoTw7CMnRPquc8qr/openapi.json
