# CNPJ Lookup - Brazil Company Data (`cloway/cnpj-lookup`) Actor

Consulta dados de empresas brasileiras pelo CNPJ (Receita Federal). Razao social, socios, endereco, CNAE, situacao cadastral. Lote ate 50 CNPJs. Gratuito.

- **URL**: https://apify.com/cloway/cnpj-lookup.md
- **Developed by:** [Cloway](https://apify.com/cloway) (community)
- **Categories:** SEO tools, E-commerce
- **Stats:** 19 total users, 3 monthly users, 94.4% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

$10.00 / 1,000 results

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?

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

## CNPJ Lookup - Brazil Company Data

Consulte dados de empresas brasileiras em tempo real usando o CNPJ (Cadastro Nacional da Pessoa Juridica). Este Actor busca informacoes diretamente da base da Receita Federal via BrasilAPI -- **gratuito, rapido e confiavel**.

### Por que usar este Actor?

- **GRATUITO** -- Sem custo adicional alem do consumo de computacao do Apify
- **Dados oficiais** -- Informacoes diretamente da Receita Federal do Brasil
- **Batch processing** -- Consulte ate 50 CNPJs por execucao
- **Dados completos** -- Razao social, nome fantasia, CNAE, endereco, socios, capital social, situacao cadastral e mais
- **Rate limit inteligente** -- Delay configuravel entre requisicoes para evitar bloqueios

### Casos de uso

| Caso de Uso | Descricao |
|---|---|
| **Due Diligence** | Verifique dados cadastrais de empresas antes de fechar negocios |
| **KYC (Know Your Customer)** | Validacao de clientes PJ para compliance |
| **Lead Enrichment** | Enriqueca sua base de leads B2B com dados cadastrais completos |
| **Contabilidade** | Automatize a busca de dados cadastrais para escritorios contabeis |
| **Analise de Mercado** | Colete dados de empresas de um setor especifico |

### Input

| Campo | Tipo | Descricao |
|---|---|---|
| `cnpjs` | Array de strings | Lista de CNPJs para consultar (ate 50) |
| `cnpj` | String | CNPJ unico para consultar |
| `delayBetweenQueries` | Number | Delay entre consultas em ms (padrao: 300) |

#### Exemplo de input

```json
{
  "cnpjs": [
    "18.236.120/0001-58",
    "60701190000104",
    "47960950000121"
  ],
  "delayBetweenQueries": 300
}
```

Voce pode usar CNPJ formatado (XX.XXX.XXX/XXXX-XX) ou apenas digitos.

### Output

Cada CNPJ consultado gera um item no dataset com os seguintes campos:

```json
{
  "cnpj": "18236120000158",
  "cnpj_formatado": "18.236.120/0001-58",
  "razao_social": "NU PAGAMENTOS S.A.",
  "nome_fantasia": "NUBANK",
  "situacao_cadastral": "ATIVA",
  "data_situacao_cadastral": "2013-12-20",
  "cnae_fiscal": 6613400,
  "cnae_fiscal_descricao": "Administracao de cartoes de credito",
  "logradouro": "RUA CAPOTE VALENTE",
  "numero": "39",
  "complemento": "ANDAR 10 A 14",
  "bairro": "PINHEIROS",
  "cep": "05409000",
  "municipio": "SAO PAULO",
  "uf": "SP",
  "ddd_telefone_1": "1130420808",
  "qsa": [
    {
      "nome_socio": "DAVID VELEZ OSORNO",
      "qualificacao_socio": "Diretor"
    }
  ],
  "capital_social": 1000000,
  "porte": "DEMAIS",
  "natureza_juridica": "Sociedade Anonima Fechada",
  "data_inicio_atividade": "2013-12-20",
  "consulta_timestamp": "2025-01-15T10:30:00.000Z",
  "status": "success"
}
```

#### Quando o CNPJ nao existe ou e invalido:

```json
{
  "cnpj": "00000000000000",
  "cnpj_formatado": "00.000.000/0000-00",
  "status": "error",
  "error_message": "CNPJ nao encontrado na base da Receita Federal",
  "consulta_timestamp": "2025-01-15T10:30:05.000Z"
}
```

### Integracao

#### Com a API do Apify

```javascript
import { ApifyClient } from 'apify-client';

const client = new ApifyClient({ token: 'SEU_TOKEN' });

const run = await client.actor('seu-usuario/cnpj-lookup').call({
  cnpjs: ['18236120000158', '60701190000104']
});

const { items } = await client.dataset(run.defaultDatasetId).listItems();
console.log(items);
```

#### Via API REST

```bash
curl -X POST "https://api.apify.com/v2/acts/seu-usuario~cnpj-lookup/runs?token=SEU_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"cnpjs": ["18236120000158"]}'
```

### Preco

**GRATUITO!** Voce paga apenas o consumo de computacao do Apify (centavos por execucao).

### Limites

- Maximo de 50 CNPJs por execucao
- Delay minimo de 100ms entre consultas (BrasilAPI rate limit)
- Dados podem ter atraso de atualizacao da Receita Federal (geralmente ate 1 semana)

### Sobre a fonte de dados

Os dados sao obtidos via [BrasilAPI](https://brasilapi.com.br/), que disponibiliza informacoes publicas da Receita Federal do Brasil de forma gratuita e aberta.

***

**Precisa gerar nomes para sua empresa?** Conheca o [NomePronto](https://nomepronto.com.br) -- gerador inteligente de nomes para empresas brasileiras. Encontre o nome perfeito para seu negocio em segundos!

# Actor input Schema

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

Array of CNPJ numbers to look up (up to 50). Each CNPJ can be formatted (XX.XXX.XXX/XXXX-XX) or plain digits (XXXXXXXXXXXXXXXX).

## `cnpj` (type: `string`):

A single CNPJ number to look up. Use this field if you only need to query one CNPJ. If both 'cnpj' and 'cnpjs' are provided, they will be merged.

## `delayBetweenQueries` (type: `integer`):

Delay in milliseconds between each CNPJ query to respect BrasilAPI rate limits. Minimum 100ms, default 300ms.

## Actor input object example

```json
{
  "cnpjs": [
    "18236120000158",
    "60701190000104"
  ],
  "cnpj": "18236120000158",
  "delayBetweenQueries": 300
}
```

# Actor output Schema

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

Resultados da consulta 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": [
        "18236120000158"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("cloway/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": ["18236120000158"] }

# Run the Actor and wait for it to finish
run = client.actor("cloway/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": [
    "18236120000158"
  ]
}' |
apify call cloway/cnpj-lookup --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,cloway/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/um2QMv8geNePhEucp/builds/aqOA0dDLhf8YXBai9/openapi.json
