Consulting by CNPJ Root
In the commercial API, you can also query using the CNPJ root, which are the first 8 digits of the CNPJ and, in this case, will return all CNPJs of the company in question. In this endpoint, you must send the x_api_token
header with the token that was sent to you via email.
You can also pass the token as a parameter in the URL, example:
https://comercial.cnpj.ws/cnpj-raiz/27865757?token=YOUR_TOKEN
Method: GET
Endpoint: https://comercial.cnpj.ws/cnpj-raiz/CNPJ_ROOT
Request Example
GET /cnpj-raiz/{cnpj-raiz} HTTP/1.1
Host: comercial.cnpj.ws
Authorization: Bearer JWT
Accept: */*
{
"cnpj_raiz": "text",
"razao_social": "text",
"capital_social": "text",
"responsavel_federativo": "text",
"atualizado_em": "2025-07-04T02:29:47.774Z",
"porte": {
"id": "text",
"descricao": "text"
},
"natureza_juridica": {
"id": "text",
"descricao": "text"
},
"qualificacao_do_responsavel": {
"id": 1,
"descricao": "text"
},
"socios": [
{
"cpf_cnpj_socio": "text",
"nome": "text",
"tipo": "text",
"data_entrada": "2025-07-04",
"cpf_representante_legal": "text",
"nome_representante": "text",
"faixa_etaria": "text",
"atualizado_em": "2025-07-04T02:29:47.774Z",
"pais_id": "text",
"qualificacao_socio": {
"id": 1,
"descricao": "text"
},
"qualificacao_representante": "text",
"pais": {
"id": "text",
"iso2": "text",
"iso3": "text",
"nome": "text",
"comex_id": "text"
}
}
],
"simples": {
"simples": "text",
"data_opcao_simples": "2025-07-04",
"data_exclusao_simples": "2025-07-04",
"mei": "text",
"data_opcao_mei": "2025-07-04",
"data_exclusao_mei": "2025-07-04",
"atualizado_em": "2025-07-04T02:29:47.774Z"
},
"estabelecimento": {
"cnpj": "text",
"atividades_secundarias": [
{
"id": "text",
"secao": "text",
"divisao": "text",
"grupo": "text",
"classe": "text",
"subclasse": "text",
"descricao": "text"
}
],
"cnpj_raiz": "text",
"cnpj_ordem": "text",
"cnpj_digito_verificador": "text",
"tipo": "text",
"nome_fantasia": "text",
"situacao_cadastral": "text",
"data_situacao_cadastral": "2025-07-04",
"data_inicio_atividade": "2025-07-04",
"nome_cidade_exterior": "text",
"tipo_logradouro": "text",
"logradouro": "text",
"numero": "text",
"complemento": "text",
"bairro": "text",
"cep": "text",
"ddd1": "text",
"telefone1": "text",
"ddd2": "text",
"telefone2": "text",
"ddd_fax": "text",
"fax": "text",
"email": "text",
"situacao_especial": "text",
"data_situacao_especial": "2025-07-04",
"atualizado_em": "2025-07-04T02:29:47.774Z",
"atividade_principal": {
"id": "text",
"secao": "text",
"divisao": "text",
"grupo": "text",
"classe": "text",
"subclasse": "text",
"descricao": "text"
},
"pais": {
"id": "text",
"iso2": "text",
"iso3": "text",
"nome": "text",
"comex_id": "text"
},
"estado": {
"id": 1,
"nome": "text",
"sigla": "text",
"ibge_id": 1
},
"cidade": {
"id": 1,
"nome": "text",
"ibge_id": 1,
"siafi_id": "text"
},
"motivo_situacao_cadastral": "text",
"inscricoes_estaduais": [
{
"inscricao_estadual": "text",
"ativo": true,
"atualizado_em": "2025-07-04T02:29:47.774Z",
"estado": {
"id": 1,
"nome": "text",
"sigla": "text",
"ibge_id": 1
}
}
]
}
}
yarn add consultar-cnpj
const consultarCNPJ = require("consultar-cnpj");
async function getRaiz() {
const token = "INFORME O SEU TOKEN DE ACESSO";
const data = await consultarCNPJ.raiz("27865757", token);
console.log(data);
}
Paginação
Caso a empresa possua mais de 20 filiais a API irá dividir a resposta em páginas. Você pode verificar isso no JSON de retono da API, na propriedade "paginacao", que exibe a página atual, o total de páginas e o total de filiais:
{
"paginacao": {
"limite": 20,
"pagina": 1,
"paginas": 5,
"total": 87
}
}
Para buscar uma página específica basta informar o número da página na requisição:
curl -X GET https://comercial.cnpj.ws/cnpj-raiz/27865757?page=2 -H "x_api_token: SEU_TOKEN"
Exemplo de Retorno
Abaixo um exemplo do JSON retornado ao se buscar pela raiz do CNPJ 27865757:
{
"data": [
"27865757002148",
"27865757002229",
"27865757002300",
"27865757002490",
"27865757002571",
"27865757002652",
"27865757002733",
"27865757002814",
"27865757002903",
"27865757003039",
"27865757003110",
"27865757003209",
"27865757003381",
"27865757003462",
"27865757003543",
"27865757003624",
"27865757003705",
"27865757003896",
"27865757003977",
"27865757004000"
],
"paginacao": {
"limite": 20,
"pagina": 2,
"paginas": 5,
"total": 87
},
"ordenacao": [],
"filtros_disponiveis": ["nome_fantasia", "pais_id", "estado_id", "cidade_id"],
"filtros_aplicados": {}
}
Last updated
Was this helpful?