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
  • Installation
  • Usage
  • Return
  • Conclusion

Was this helpful?

  1. BLOG

Consult CNPJ with Javascript and Node.JS

Learn how to consult company data through the CNPJ using the CNPJ.ws API, with data from Receita Federal, Sintegra, and Suframa using Javascript/Node.js

PreviousKeep Customer and Supplier Records UpdatedNextConsult CNPJ with ADVPL (Protheus)

Last updated 4 months ago

Was this helpful?

Consulting a CNPJ using the CNPJ.ws API with Javascript and Node.JS is very easy!

Keeping customer/supplier records up to date or even querying company data to facilitate some internal registration of your system is very common, and the CNPJ.ws API provides an easy and quick way to develop this integration.

With the integration, we can use the API to query the address, state registration, registration status, CNAE, and many other information that may be important when registering a customer or supplier through the CNPJ.

The data returned by the API is obtained from various public agencies (Receita Federal, Sintegra, SERPRO, Suframa, etc.), aggregated and organized to facilitate use by other systems through a Rest API.

Installation

We have developed a package to facilitate this integration, see it on .

Remember that you can use our free API to consult CNPJ or you can purchase one of our commercial plans.

To get started, let's install the package:

Using YARN:

yarn add consultar-cnpj

Using NPM:

npm i consultar-cnpj --save

Usage

CNPJ.ws has a Public API and a Commercial API. To use the Public API, you do not need a token, but you can only make up to 3 queries per minute. If you are using the Commercial API, you must pass the token as the second parameter in the query to use its benefits. You can see more details about the commercial plans on our .

const consultarCNPJ = require("consultar-cnpj");

async function getCNPJ() {
  const token = "INFORME O SEU TOKEN DE ACESSO";

  try {
    // O Token é opcional
    const empresa = await consultarCNPJ("40154884000153", token);
    console.log(empresa);
  } catch (e) {
    console.log(e);
  }
}

Return

Below is the JSON returned by the API:

{
  "cnpj_raiz": "40154884",
  "razao_social": "STARLINK BRAZIL SERVICOS DE INTERNET LTDA.",
  "capital_social": "800000.00",
  "responsavel_federativo": "",
  "atualizado_em": "2021-07-20T08:21:13.130Z",
  "porte": {
    "id": "05",
    "descricao": "Demais"
  },
  "natureza_juridica": {
    "id": "2062",
    "descricao": "Sociedade Empresária Limitada"
  },
  "qualificacao_do_responsavel": {
    "id": 5,
    "descricao": "Administrador "
  },
  "socios": [
    {
      "cpf_cnpj_socio": "***966178**",
      "nome": "VITOR JAMES URNER",
      "tipo": "Pessoa Física",
      "data_entrada": "2020-12-18",
      "cpf_representante_legal": "***000000**",
      "nome_representante": null,
      "faixa_etaria": "71 a 80 anos",
      "atualizado_em": "2021-07-21T06:13:26.688Z",
      "pais_id": "1058",
      "qualificacao_socio": {
        "id": 5,
        "descricao": "Administrador "
      },
      "qualificacao_representante": null
    },
    {
      "cpf_cnpj_socio": "39523686000130",
      "nome": "STARLINK BRAZIL HOLDING LTDA.",
      "tipo": "Pessoa Jurídica",
      "data_entrada": "2020-12-18",
      "cpf_representante_legal": "***966178**",
      "nome_representante": "VITOR JAMES URNER",
      "faixa_etaria": "Não se aplica",
      "atualizado_em": "2021-07-21T06:13:26.688Z",
      "pais_id": "1058",
      "qualificacao_socio": {
        "id": 22,
        "descricao": "Sócio"
      },
      "qualificacao_representante": {
        "id": 5,
        "descricao": "Administrador "
      }
    }
  ],
  "simples": null,
  "estabelecimento": {
    "cnpj": "40154884000153",
    "atividades_secundarias": [
      {
        "id": "6190699",
        "secao": "J",
        "divisao": "61",
        "grupo": "61.9",
        "classe": "61.90-6",
        "subclasse": "6190-6/99",
        "descricao": "Outras atividades de telecomunicações não especificadas anteriormente"
      },
      {
        "id": "6462000",
        "secao": "K",
        "divisao": "64",
        "grupo": "64.6",
        "classe": "64.62-0",
        "subclasse": "6462-0/00",
        "descricao": "Holdings de instituições não financeiras"
      },
      {
        "id": "7739099",
        "secao": "N",
        "divisao": "77",
        "grupo": "77.3",
        "classe": "77.39-0",
        "subclasse": "7739-0/99",
        "descricao": "Aluguel de outras máquinas e equipamentos comerciais e industriais não especificados anteriormente, sem operador"
      }
    ],
    "cnpj_raiz": "40154884",
    "cnpj_ordem": "0001",
    "cnpj_digito_verificador": "53",
    "tipo": "Matriz",
    "nome_fantasia": null,
    "situacao_cadastral": "Ativa",
    "data_situacao_cadastral": "2020-12-18",
    "data_inicio_atividade": "2020-12-18",
    "nome_cidade_exterior": null,
    "tipo_logradouro": "ALAMEDA",
    "logradouro": "SANTOS",
    "numero": "74",
    "complemento": "ANDAR 7                   CONJ  72                  SALA  10",
    "bairro": "CERQUEIRA CESAR",
    "cep": "01418000",
    "ddd1": "11",
    "telefone1": "30229503",
    "ddd2": null,
    "telefone2": null,
    "ddd_fax": null,
    "fax": null,
    "email": "VITOR@URNER.COM.BR",
    "situacao_especial": null,
    "data_situacao_especial": null,
    "atividade_principal": {
      "id": "6130200",
      "secao": "J",
      "divisao": "61",
      "grupo": "61.3",
      "classe": "61.30-2",
      "subclasse": "6130-2/00",
      "descricao": "Telecomunicações por satélite"
    },
    "pais": {
      "id": "1058",
      "iso2": "BR",
      "iso3": "BRA",
      "nome": "Brasil",
      "comex_id": "105"
    },
    "estado": {
      "id": 26,
      "nome": "São Paulo",
      "sigla": "SP",
      "ibge_id": 35
    },
    "cidade": {
      "id": 3832,
      "nome": "São Paulo",
      "ibge_id": 3550308,
      "siafi_id": "7107"
    },
    "motivo_situacao_cadastral": null,
    "inscricoes_estaduais": [
      {
        "inscricao_estadual": "130287771116",
        "ativo": true,
        "atualizado_em": "2021-08-25T16:59:58.589Z",
        "estado": {
          "id": 26,
          "nome": "São Paulo",
          "sigla": "SP",
          "ibge_id": 35
        }
      }
    ]
  }
}

Conclusion

If you have any questions, we are here to support you. Send an email to contato@cnpj.ws!

Using the CNPJ.ws API, you can obtain data from Brazilian companies in a simple and easy way. Take a look at our .

To learn more about our plans and payment methods, visit .

Github
main page
documentation
CNPJ.ws