CNPJws
English
English
  • Overview
  • Data Models
    • Countries
    • States
    • Cities
    • Legal Natures
    • Company Sizes
    • Economic Activities
    • Corporate Qualifications
    • Partners
    • Simples Nacional and MEI
    • Establishments
    • State Registrations
    • Suframa
    • Tax Regimes
    • Registration Statuses
    • Error Messages
  • Changelog
  • API Reference
    • API - Commercial
      • Consulting CNPJ in the Commercial API
      • Consulting by CNPJ Root
      • Company Search
      • Consulting Monthly Request Consumption
      • Validating Suframa Registration
    • API - Public
      • Consulting CNPJ in the Public API
      • Validating Suframa Registration in the Public API
      • Limitations
  • BLOG
    • What is CNPJ
    • Consult CNPJ with Java
    • Consult CNPJ for Free with Excel
    • Consult CNPJ with PHP
    • Trigger to Consult CNPJ in Protheus
    • Keep Customer and Supplier Records Updated
    • Consult CNPJ with Javascript and Node.JS
    • Consult CNPJ with ADVPL (Protheus)
    • CNPJ.ws Project
Powered by GitBook
On this page

Was this helpful?

  1. API Reference
  2. API - Commercial

Consulting by CNPJ Root

PreviousConsulting CNPJ in the Commercial APINextCompany Search

Last updated 4 months ago

Was this helpful?

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

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": {}
}

Mais informações do pacote

Recupera dados de uma empresa pelo CNPJ raiz

get
Authorizations
Path parameters
cnpj-raizintegerRequired
Responses
200
Sucesso
application/json
401
Não autenticado
application/json
404
Não encontrado
application/json
get
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-05-19T02:58:42.854Z",
  "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-05-19",
      "cpf_representante_legal": "text",
      "nome_representante": "text",
      "faixa_etaria": "text",
      "atualizado_em": "2025-05-19T02:58:42.854Z",
      "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-05-19",
    "data_exclusao_simples": "2025-05-19",
    "mei": "text",
    "data_opcao_mei": "2025-05-19",
    "data_exclusao_mei": "2025-05-19",
    "atualizado_em": "2025-05-19T02:58:42.854Z"
  },
  "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-05-19",
    "data_inicio_atividade": "2025-05-19",
    "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-05-19",
    "atualizado_em": "2025-05-19T02:58:42.854Z",
    "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-05-19T02:58:42.854Z",
        "estado": {
          "id": 1,
          "nome": "text",
          "sigla": "text",
          "ibge_id": 1
        }
      }
    ]
  }
}
  • Request Example
  • GETRecupera dados de uma empresa pelo CNPJ raiz