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

Company Search

In the Commercial API, in the Premium Plan, you can perform searches using filters to find companies that meet your requirements.

Attention: Access to this endpoint is exclusive to Premium Plan subscribers.

Method: GET

Endpoint: https://comercial.cnpj.ws/pesquisa?ADD_FILTERS

Filters

You can use the filters below in your queries:

Field
Description

atividade_principal_id

CNAE Code

atividade_secundaria_id

CNAE Code

atividade_id

CNAE Code (search in the primary and secondary activity)

natureza_juridica_id

Legal Nature Code

razao_social

Company Name

nome_fantasia

Trade Name

pais_id

BACEN Country Code

estado_id

IBGE State Code

cidade_id

IBGE City Code

cep

ZIP Code

situacao_cadastral

Registration status with the Federal Revenue

data_situacao_cadastral_de

Registration Status Date (From this date) in YYYY-MM-DD format

data_situacao_cadastral_ate

Registration Status Date (Until this date) in YYYY-MM-DD format

porte_id

Company size ID

socio_nome

Partner's Name

data_inicio_atividade_de

Start Date of Activity (From this date) in YYYY-MM-DD format

data_inicio_atividade_ate

Start Date of Activity (Until this date) in YYYY-MM-DD format

It is crucial to highlight that the queries made in this endpoint are based on our database and not on the Federal Revenue database. Therefore, discrepancies may occur between the information, as our database may have a lag of up to 45 days compared to the updated data from the Federal Revenue. It is worth noting that, although we perform daily registrations due to CNPJ queries made in the API, the lag can still occur.

List of Registration Statuses:

  • Active

  • Closed

  • Inactive

  • Null

  • Suspended

List of Registered Sizes:

ID
Description

01

Not informed

02

Micro Enterprise

03

Small Business

05

Others

Request Examples

We have a package that can help you integrate with JavaScript:

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

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

  const data = await consultarCNPJ.pesquisa(
    { atividade_principal_id: "6203100", estado_id: 28 },
    token,
    page
  );
  console.log(data);
}

Pagination

If the search returns more than 20 CNPJs, the API will divide the response into pages. You can check this in the API's JSON response, in the "pagination" property, which shows the current page, the total number of pages, and the total number of CNPJs:

{
  "paginacao": {
    "limite": 20,
    "pagina": 1,
    "paginas": 5,
    "total": 87
  }
}

To search for a specific page, simply provide the page number in the request:

curl -X GET https://comercial.cnpj.ws/pesquisa?atividade_principal_id=6203100&pagina=2 -H "x_api_token: YOUR_TOKEN"

It is also possible to change the number of CNPJs returned, the default is 20 but it can be up to 100:

curl -X GET https://comercial.cnpj.ws/pesquisa?atividade_principal_id=6203100&pagina=2&limite=100 -H "x_api_token: YOUR_TOKEN"

Return Example

Below is an example of the JSON returned when searching by CNAE 6203100:

{
  "paginacao": {
    "limite": 20,
    "pagina": 1,
    "paginas": 1494,
    "total": 29865
  },
  "ordenacao": [],
  "filtros_disponiveis": [
    "cnpj",
    "cnpj_raiz",
    "natureza_juridica_id",
    "porte_id",
    "razao_social",
    "nome_fantasia",
    "pais_id",
    "estado_id",
    "cidade_id",
    "cep",
    "atividade_principal_id"
  ],
  "filtros_aplicados": {
    "atividade_principal_id": "6203100"
  },
  "data": [
    "19323263000160",
    "03124023000104",
    "64919913000199",
    "36427967000100",
    "06370042000109",
    "01056469000105",
    "03292219000108",
    "94338217000664",
    "01645901000101",
    "02868026000181",
    "04957691000177",
    "01755516000109",
    "04970015000133",
    "65144347000153",
    "04810384000169",
    "74641804000106",
    "82296112000104",
    "03035876000161",
    "33643305009801",
    "05121798000143"
  ]
}
PreviousConsulting by CNPJ RootNextConsulting Monthly Request Consumption

Last updated 5 months ago

Was this helpful?

More information about the package

Retorna pesquisa sobre empresas

get
Authorizations
Query parameters
atividade_principal_idstringOptional

Código CNAE da atividade principal

atividade_secundaria_idstringOptional

Código CNAE da atividade secundária

atividade_idstringOptional

Código CNAE (pesquisa na atividade principal e secundária)

natureza_juridica_idstringOptional

Código da Natureza Jurídica

razao_socialstringOptional

Razão Social

nome_fantasiastringOptional

Nome Fantasia

pais_idstringOptional

Código do País do BACEN

estado_idstringOptional

Código IBGE do estado

cidade_idstringOptional

Código IBGE da Cidade

cepstringOptional

CEP

situacao_cadastralstringOptional

Situação cadastral na Receita Federal

data_situacao_cadastral_destring · dateOptional

Data da Situação Cadastral (A partir dessa data) no formato YYYY-MM-DD

data_situacao_cadastral_atestring · dateOptional

Data da Situação Cadastral (Até essa data) no formato YYYY-MM-DD

porte_idstringOptional

Id do porte da empresa

socio_nomestringOptional

Nome do Sócio

data_inicio_atividade_destring · dateOptional

Data de Inicio de Atividade (A partir dessa data) no formato YYYY-MM-DD

data_inicio_atividade_atestring · dateOptional

Data de Inicio de Atividade (Até essa data) no formato YYYY-MM-DD

Responses
200
Sucesso
application/json
401
Não autenticado
application/json
get
GET /pesquisa HTTP/1.1
Host: comercial.cnpj.ws
Authorization: Bearer JWT
Accept: */*
{
  "paginacao": {
    "limite": 1,
    "pagina": 1,
    "paginas": 1,
    "total": 1
  },
  "ordenacao": [
    "text"
  ],
  "filtros_disponiveis": [
    "text"
  ],
  "filtros_aplicados": {
    "atividade_principal_id": "text"
  },
  "data": [
    "text"
  ]
}
  • Filters
  • Request Examples
  • GETRetorna pesquisa sobre empresas