Skip to content
Migrate from OpenCNPJ
API · Migration

Migrate from OpenCNPJ

How to replace the OpenCNPJ CNPJ lookup with the CNPJá API, with live or cached Receita Federal data: parameters, fields and behavior differences.

This guide moves an integration that queries the OpenCNPJ receita dataset to Lookup CNPJ in the CNPJá API. It covers swapping the request, mapping parameters and fields, and the behavior differences that require changes in your code.

Overview

  • The GET /{cnpj}?datasets=receita lookup becomes GET /v2/establishments/{taxId}, with the API key in the Authorization header.
  • Only the receita dataset has an equivalent. The other datasets, the dataset download and the analytics table don’t exist in the CNPJá API.
  • Fields are renamed to English and grouped: company data goes in company, the address in address and the partners in company.partners.
  • Descriptive values such as registration status, company size and head office or branch become code and label pairs. Your logic compares the code.
  • Simples Nacional and MEI options are no longer returned by default: request expand=company.taxRegime.
  • OpenCNPJ publishes the dataset monthly. In CNPJá, each CNPJ comes from a live query at the Receita Federal or from the cache, depending on the maximum age you accept in maxAge.

Effort: low to medium. If you only use the receita dataset, the switch involves one operation and one response format, and the work centers on mapping fields.

Prerequisites

  • Account and key: sign up and create a key in API keys. The walkthrough is in First request.
  • Authentication: send the key as the entire value of the Authorization header, with no prefix: Authorization: YOUR_API_KEY. With Bearer, the request is rejected with 401 API_KEY_INVALID. See Authentication.
  • Base URL: https://api.cnpja.com/v2.
  • What carries over: the 14-character unmasked CNPJ, alphanumeric included, dates in YYYY-MM-DD format, 7-digit CNAEs and the partners’ masked CPF, in the ***650245** format.
  • What changes: field names and structure, codes instead of text, numeric share capital, phones in international format, missing fields instead of empty strings, and a masked CNPJ in the URL, which is now rejected.

Important: without a key, Lookup CNPJ only accepts requests with no query parameters at all. Carrying ?datasets=receita over to the new URL results in 401 API_KEY_MISSING. See Public access.

Matching operations

OpenCNPJCNPJáNotes
GET /{cnpj} with datasets=receita or without datasetsLookup CNPJOne establishment per request. See CNPJ lookup.
GET /{cnpj} with other datasetsNo equivalentCNO, RNTRC and Portal da Transparência are not part of the CNPJá API.
Dataset downloadNo equivalentTo extract establishments by criteria, use Search CNPJ, which is paginated. See CNPJ search and lists.
opencnpj-bigquery.public.receita tableNo equivalentSearch CNPJ filters by activity, address, size, status and tax regime, and sorts by relevance, CNPJ, opening date, share capital or legal name.
Contract at /schemaAPI referenceEvery CNPJá API operation, parameter and field.

CNPJá also has operations with no OpenCNPJ counterpart, such as Lookup company, which lists every establishment of a CNPJ root, and Lookup person, which lists a partner’s companies. See Partners and people.

Request example

OpenCNPJ:

GET /37335118000180?datasets=receita HTTP/1.1
Host: api.opencnpj.org
Accept: application/json

CNPJá, with the tax regime:

GET /v2/establishments/37335118000180?expand=company.taxRegime HTTP/1.1
Host: api.cnpja.com
Authorization: YOUR_API_KEY

Parameters

OpenCNPJCNPJáNotes
cnpj (path)taxId (path)OpenCNPJ accepts the CNPJ with or without a mask. CNPJá requires exactly 14 characters, unmasked, and rejects a masked CNPJ with 400.
datasets=receitaNot neededLookup CNPJ always returns the Receita Federal registration.
datasetNot neededSame as datasets.
datasets with cno, rntrc, favorecidos_pj, ceis, cepim, cnep, acordos_leniencia, licitacoes, contratos, renuncias_fiscais, notas_fiscais, convenios, emendas_parlamentares or emendas_documentosNo equivalent
No equivalentmaxAgeMaximum data age you accept, from 5m to 1y, default 45d. See Max age and partial success.
No equivalentexpandOptional resources: company.taxRegime, stateRegistry, suframa and address.coordinates. See CNPJ lookup.

Response fields

CNPJá paths are relative to the Lookup CNPJ response. OpenCNPJ empty strings, such as "", correspond in CNPJá to null or a missing field, as explained in Missing vs empty values.

Identification and status

OpenCNPJCNPJáNotes
cnpjtaxIdSame format.
updated_atupdatedAtIn OpenCNPJ, the release of the whole base, the same for every CNPJ; in CNPJá, the establishment’s last update from the Receita Federal.
nome_fantasiatradeNamenull when there is no trade name.
matriz_filialtype.codeHEAD (Matriz) or BRANCH (Filial).
data_inicio_atividadeincorporationDateSame format.
situacao_cadastralstatus.codeFixed code, with the text in status.label. See the code table below.
data_situacao_cadastralstatusDateSame format.
motivo_situacao_cadastral.codigostatusReason.codestatusReason only appears when the establishment is not active.
motivo_situacao_cadastral.descricaostatusReason.label
situacao_especialspecialStatus.label3-digit code in specialStatus.code. Missing outside a special status.
data_situacao_especialspecialStatusDateMissing outside a special status.
lgpd_anonimizadoNo equivalent

Address and contacts

OpenCNPJCNPJáNotes
tipo_logradouroNo field of its ownThere is no separate field for the street type.
logradouroaddress.street
numeroaddress.numberText or null.
complementoaddress.details
bairroaddress.district
cepaddress.postalCode8 digits.
ufaddress.stateUF abbreviation.
municipioaddress.city
codigo_municipioNo equivalentOpenCNPJ returns the Receita Federal municipality code, such as 9701 for Brasília. CNPJá returns the 7-digit IBGE code in address.municipality.
nome_cidade_exteriorNo equivalent
codigo_pais and pais.codigoaddress.country.code2-letter country code, such as BR.
pais.descricaoaddress.country.label
emailemails[].addressA list of emails, each with its type in emails[].type.
telefones[].ddd and telefones[].numerophones[].numberA single field in international format: area code 11 and number 900000000 become +5511900000000.
telefones[].is_faxNo equivalentCNPJá tells landline from mobile in phones[].type.code: LANDLINE or MOBILE.

Activities

OpenCNPJCNPJáNotes
cnae_principalprimaryActivity.code7 digits.
cnaes_secundarios[]secondaryActivities[].code
cnaes[].codigo and cnaes[].descricaoprimaryActivity and secondaryActivities[], with code and labelThe primary activity has a field of its own, replacing cnaes[].is_principal.

Company and partners

OpenCNPJCNPJáNotes
razao_socialcompany.legalName
codigo_natureza_juridicacompany.legalNature.codeSame 4-digit format.
natureza_juridicacompany.legalNature.label
capital_socialcompany.shareCapitalA number with a decimal point: "99999,99" becomes 99999.99.
porte_empresacompany.size.codeMICRO, SMALL or OTHER.
ente_federativocompany.federativeEntityAn object with code and label, present only when the legal nature is public administration.
qualificacao_responsavelNo equivalent
QSA[]company.partners[]
QSA[].nome_sociocompany.partners[].person.legalName
QSA[].cnpj_cpf_sociocompany.partners[].person.taxIdMasked CPF or CNPJ. null for foreign or unknown partners.
QSA[].identificador_sociocompany.partners[].person.type.codeSee the code table below.
QSA[].qualificacao_sociocompany.partners[].role.label2-digit code in role.code.
QSA[].data_entrada_sociedadecompany.partners[].admissionDate
QSA[].codigo_pais and QSA[].pais.codigocompany.partners[].person.domicileCountry.code2-letter country code.
QSA[].pais.descricaocompany.partners[].person.domicileCountry.label
QSA[].faixa_etariacompany.partners[].person.ageGroupA code with no label: 41 a 50 anos becomes 41-50. Present only for individuals.
QSA[].representante_legalcompany.partners[].legalRepresentative.person.taxIdlegalRepresentative only appears when the partner has a legal representative.
QSA[].nome_representantecompany.partners[].legalRepresentative.person.legalName
QSA[].qualificacao_representantecompany.partners[].legalRepresentative.rolecode and label.

Each partner gets a person.id, a stable identifier to look up all of the person’s participations. See Partners and people.

Simples Nacional and MEI

These fields require expand=company.taxRegime, billed separately. See Tax regime.

OpenCNPJCNPJáNotes
opcao_simplescompany.taxRegime.type.codeSIMPLES_NACIONAL, SIMPLES_NACIONAL_HYBRID or SIMPLES_NACIONAL_SIMEI for Simples Nacional optants, with SIMPLES_NACIONAL_HYBRID for those that also opt into the IBS or CBS regular regime and SIMPLES_NACIONAL_SIMEI for MEIs. Other regimes are reported too, such as PRESUMED_PROFIT. With no annual declaration, the regime is estimated, as explained in Tax regime.
data_opcao_simplescompany.taxRegime.simplesNacionalStartDateStart of the current period. Present only when type.code is SIMPLES_NACIONAL, SIMPLES_NACIONAL_HYBRID or SIMPLES_NACIONAL_SIMEI, and may be null. Previous periods are in company.taxRegime.timeline[].startDate, with company.taxRegime.view=DETAILED.
data_exclusao_simplescompany.taxRegime.timeline[].endDateItems whose type.code is SIMPLES_NACIONAL_PERIOD. Requires company.taxRegime.view=DETAILED.
opcao_meicompany.taxRegime.type.codeS matches SIMPLES_NACIONAL_SIMEI.
data_opcao_meicompany.taxRegime.simeiStartDateStart of the current SIMEI period. Present only when type.code is SIMPLES_NACIONAL_SIMEI, and may be null.
data_exclusao_meicompany.taxRegime.timeline[].endDateItems whose type.code is SIMEI_PERIOD. Requires company.taxRegime.view=DETAILED.

When company.taxRegime.type.code is SIMPLES_NACIONAL_HYBRID, company.taxRegime.view=DETAILED also returns company.taxRegime.regularIbsStartDate and company.taxRegime.regularCbsStartDate, the start of the current IBS and CBS regular regime periods, which come only from live queries at the Simples Nacional. Either may be null when the company opts into only one of the two.

Codes instead of text

Each OpenCNPJ text matches a fixed CNPJá code, which your logic compares instead.

CNPJá fieldOpenCNPJ text and CNPJá code
statusAtiva becomes ACTIVE, Baixada becomes CLOSED, Inapta becomes NONCOMPLIANT, Suspensa becomes SUSPENDED and Nula becomes VOID.
typeMatriz becomes HEAD and Filial becomes BRANCH.
company.sizeMicroempresa (ME) becomes MICRO, Empresa de Pequeno Porte (EPP) becomes SMALL, and Demais and Não informado become OTHER.
company.partners[].person.typePessoa Física becomes INDIVIDUAL, Pessoa Jurídica becomes ESTABLISHMENT and Estrangeiro becomes FOREIGNER. CNPJá also has UNKNOWN, a partner known only by name.

New fields

  • company.id, the CNPJ root, for use with Lookup company.
  • With expand: state registrations (stateRegistry), SUFRAMA registrations (suframa) and address coordinates (address.coordinates). See State registrations, SUFRAMA and Location and maps.

Behavior differences

Freshness and caching

OpenCNPJ publishes the receita dataset monthly, and a CNPJ outside the release returns 404. In CNPJá, each resource comes from the cache while it is within maxAge and is queried live, before the response, when it is older or was never fetched. maxAge ranges from 5m to 1y, with a 45d default, and each resource reports its last update in its own updatedAt. With a key, a CNPJ not yet in the cache is queried live at the Receita Federal. See Max age and partial success.

Partial success

When a live query fails or runs past its time limit, the response is 206, with the same shape as 200: the affected resource keeps its cached data, or comes back empty if it was never fetched, and is not billed. With no cached data to fall back on, such as on a CNPJ’s first lookup, the request fails instead of returning 206. Treat 206 as success and compare each resource’s updatedAt with the limit you asked for. See Partial success.

Errors

OpenCNPJCNPJá
400, invalid CNPJ or dataset filter400 REQUEST_VALIDATION_FAILED, with the details in errors[]. For an invalid query parameter, errors[].field names it; for an invalid CNPJ in the path, it is empty.
404, CNPJ not in the published release404 ESTABLISHMENT_NOT_FOUND, after a live query confirms it doesn’t exist
502, temporary failure500 UNEXPECTED_ERROR or 504 REQUEST_TIMED_OUT, worth retrying with backoff

CNPJá also returns 401 for key problems, 402 for a used-up quota or overage budget and 429 for an exceeded limit. Every error body carries status, code, message and traceId. Handle errors by code, which is stable, and use message for display only. See Limits and errors.

Limits

With a key, the requests-per-second and concurrent-request limits apply to the whole organization, across all of its keys, and follow its plan; without a key, they apply to each source IP. The values are in Usage limits. Above them, the response is 429, not billed. Each request has a maximum duration, and the client timeout must stay above it, as shown in Timeout and size.

Billing

Each resource in the response is billed separately, as a live query, which costs more, or a cached query, and each unit has its own quota in the plan, renewed every month. On Pro, the quota of each unit can grow with packs, and the organization can set a budget to pay for each query beyond the quota at the per-query overage price, so an exhausted quota does not have to stop the integration. When a quota runs out with no overage budget, or the month’s budget runs out, every request made with one of the organization’s keys gets 402, as explained in Quota used up; on Free, which has no packs or budget, this happens as soon as the quota runs out. Requests without a key, rejected requests and server failures are not billed, as listed in What is not charged. In Lookup CNPJ, the registration and each resource requested in expand count separately. A 404 is billed too, as detailed in What is charged even without a useful result. Responses carry no cost headers: track usage under Usage. See Queries and quota, what each operation consumes in the Metering Rules and Pricing.

Language and labels

label values and error messages come in Portuguese by default; send Accept-Language: en-US to get them in English. Codes, field names and official source data are never translated. Use code in your logic and label for display only. See Language.

No equivalent

  • The CNO, RNTRC and Portal da Transparência datasets, queried through the other datasets values.
  • The full dataset download and the opencnpj-bigquery.public.receita analytics table.
  • The tipo_logradouro, codigo_municipio, nome_cidade_exterior, telefones[].is_fax, qualificacao_responsavel and lgpd_anonimizado fields.

Step by step

  1. List the OpenCNPJ fields your code reads and find each one in the tables above.
  2. Remove dependencies on the datasets and downloads that have no equivalent.
  3. Open in the browser, without a key and without parameters, a lookup such as https://api.cnpja.com/v2/establishments/37335118000180 to see the response format, as shown in Public access.
  4. Create an account and an API key, and keep the key in your backend.
  5. Change the URL, remove datasets and send the Authorization header.
  6. Add expand=company.taxRegime if you use the Simples Nacional or MEI fields, and set maxAge if the 45-day default doesn’t fit.
  7. Adapt your code to the new formats: code instead of text, numeric company.shareCapital, phones in international format and null or missing fields instead of empty strings.
  8. Handle errors by code, accept 206 as success and retry 429, 500 and 504 with a delay.
  9. Test with the key: compare both APIs’ responses for a sample of your CNPJs and track consumption in Usage.
  10. Move traffic gradually and turn off the old integration once the results check out.

Sources for this comparison

What this page says about OpenCNPJ comes from its public pages:

  • OpenCNPJ: the lookup, the dataset and the monthly update.
  • OpenCNPJ repository: the receita dataset, the fields and the BigQuery table.

Sources accessed on November 19, 2026.

Third-party trademarks on this page are used only to identify them, with no affiliation or endorsement (Terms of Use).

Informational content that may change without notice. It is not tax, accounting or legal advice, and CNPJá's terms and policies prevail over this page.