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 /lookup becomes{cnpj}?datasets=receita GET /, with the API key in thev2/ establishments/ {taxId} Authorizationheader. - Only the
receitadataset 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 inaddressand the partners incompany..partners - Descriptive values such as registration status, company size and head office or branch become
codeandlabelpairs. Your logic compares thecode. - 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
Authorizationheader, with no prefix:Authorization: YOUR_. WithAPI_ KEY Bearer, the request is rejected with401API_. See Authentication.KEY_ INVALID - Base URL:
https:/./ api. cnpja. com/ v2 - What carries over: the 14-character unmasked CNPJ, alphanumeric included, dates in
YYYY-MM-DDformat, 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=receitaover to the new URL results in401API_. See Public access.KEY_ MISSING
Matching operations
| OpenCNPJ | CNPJá | Notes |
|---|---|---|
GET / with datasets=receita or without datasets | Lookup CNPJ | One establishment per request. See CNPJ lookup. |
GET / with other datasets | No equivalent | CNO, RNTRC and Portal da Transparência are not part of the CNPJá API. |
| Dataset download | No equivalent | To extract establishments by criteria, use Search CNPJ, which is paginated. See CNPJ search and lists. |
opencnpj-bigquery. table | No equivalent | Search CNPJ filters by activity, address, size, status and tax regime, and sorts by relevance, CNPJ, opening date, share capital or legal name. |
Contract at /schema | API reference | Every 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
| OpenCNPJ | CNPJá | 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=receita | Not needed | Lookup CNPJ always returns the Receita Federal registration. |
dataset | Not needed | Same as datasets. |
datasets with cno, rntrc, favorecidos_, ceis, cepim, cnep, acordos_, licitacoes, contratos, renuncias_, notas_, convenios, emendas_ or emendas_ | No equivalent | |
| No equivalent | maxAge | Maximum data age you accept, from 5m to 1y, default 45d. See Max age and partial success. |
| No equivalent | expand | Optional resources: company., stateRegistry, suframa and address.. 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
| OpenCNPJ | CNPJá | Notes |
|---|---|---|
cnpj | taxId | Same format. |
updated_ | updatedAt | In OpenCNPJ, the release of the whole base, the same for every CNPJ; in CNPJá, the establishment’s last update from the Receita Federal. |
nome_ | tradeName | null when there is no trade name. |
matriz_ | type. | HEAD (Matriz) or BRANCH (Filial). |
data_ | incorporationDate | Same format. |
situacao_ | status. | Fixed code, with the text in status.. See the code table below. |
data_ | statusDate | Same format. |
motivo_ | statusReason. | statusReason only appears when the establishment is not active. |
motivo_ | statusReason. | |
situacao_ | specialStatus. | 3-digit code in specialStatus.. Missing outside a special status. |
data_ | specialStatusDate | Missing outside a special status. |
lgpd_ | No equivalent |
Address and contacts
| OpenCNPJ | CNPJá | Notes |
|---|---|---|
tipo_ | No field of its own | There is no separate field for the street type. |
logradouro | address. | |
numero | address. | Text or null. |
complemento | address. | |
bairro | address. | |
cep | address. | 8 digits. |
uf | address. | UF abbreviation. |
municipio | address. | |
codigo_ | No equivalent | OpenCNPJ returns the Receita Federal municipality code, such as 9701 for Brasília. CNPJá returns the 7-digit IBGE code in address.. |
nome_ | No equivalent | |
codigo_ and pais. | address. | 2-letter country code, such as BR. |
pais. | address. | |
email | emails[]. | A list of emails, each with its type in emails[].. |
telefones[]. and telefones[]. | phones[]. | A single field in international format: area code 11 and number 900000000 become +5511900000000. |
telefones[]. | No equivalent | CNPJá tells landline from mobile in phones[].: LANDLINE or MOBILE. |
Activities
| OpenCNPJ | CNPJá | Notes |
|---|---|---|
cnae_ | primaryActivity. | 7 digits. |
cnaes_ | secondaryActivities[]. | |
cnaes[]. and cnaes[]. | primaryActivity and secondaryActivities[], with code and label | The primary activity has a field of its own, replacing cnaes[].. |
Company and partners
| OpenCNPJ | CNPJá | Notes |
|---|---|---|
razao_ | company. | |
codigo_ | company. | Same 4-digit format. |
natureza_ | company. | |
capital_ | company. | A number with a decimal point: "99999,99" becomes 99999.. |
porte_ | company. | MICRO, SMALL or OTHER. |
ente_ | company. | An object with code and label, present only when the legal nature is public administration. |
qualificacao_ | No equivalent | |
QSA[] | company. | |
QSA[]. | company. | |
QSA[]. | company. | Masked CPF or CNPJ. null for foreign or unknown partners. |
QSA[]. | company. | See the code table below. |
QSA[]. | company. | 2-digit code in role.. |
QSA[]. | company. | |
QSA[]. and QSA[]. | company. | 2-letter country code. |
QSA[]. | company. | |
QSA[]. | company. | A code with no label: 41 a 50 anos becomes 41-50. Present only for individuals. |
QSA[]. | company. | legalRepresentative only appears when the partner has a legal representative. |
QSA[]. | company. | |
QSA[]. | company. | code and label. |
Each partner gets a person., 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., billed separately. See Tax regime.
| OpenCNPJ | CNPJá | Notes |
|---|---|---|
opcao_ | company. | SIMPLES_, SIMPLES_ or SIMPLES_ for Simples Nacional optants, with SIMPLES_ for those that also opt into the IBS or CBS regular regime and SIMPLES_ for MEIs. Other regimes are reported too, such as PRESUMED_. With no annual declaration, the regime is estimated, as explained in Tax regime. |
data_ | company. | Start of the current period. Present only when type. is SIMPLES_, SIMPLES_ or SIMPLES_, and may be null. Previous periods are in company., with company.. |
data_ | company. | Items whose type. is SIMPLES_. Requires company.. |
opcao_ | company. | S matches SIMPLES_. |
data_ | company. | Start of the current SIMEI period. Present only when type. is SIMPLES_, and may be null. |
data_ | company. | Items whose type. is SIMEI_. Requires company.. |
When company. is SIMPLES_, company. also returns company. and company., 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á field | OpenCNPJ text and CNPJá code |
|---|---|
status | Ativa becomes ACTIVE, Baixada becomes CLOSED, Inapta becomes NONCOMPLIANT, Suspensa becomes SUSPENDED and Nula becomes VOID. |
type | Matriz becomes HEAD and Filial becomes BRANCH. |
company. | Microempresa (ME) becomes MICRO, Empresa de Pequeno Porte (EPP) becomes SMALL, and Demais and Não informado become OTHER. |
company. | Pessoa 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., the CNPJ root, for use with Lookup company.id - With
expand: state registrations (stateRegistry), SUFRAMA registrations (suframa) and address coordinates (address.). See State registrations, SUFRAMA and Location and maps.coordinates
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
| OpenCNPJ | CNPJá |
|---|---|
400, invalid CNPJ or dataset filter | 400 REQUEST_, with the details in errors[]. For an invalid query parameter, errors[]. names it; for an invalid CNPJ in the path, it is empty. |
404, CNPJ not in the published release | 404 ESTABLISHMENT_, after a live query confirms it doesn’t exist |
502, temporary failure | 500 UNEXPECTED_ or 504 REQUEST_, 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
datasetsvalues. - The full dataset download and the
opencnpj-bigquery.analytics table.public. receita - The
tipo_,logradouro codigo_,municipio nome_,cidade_ exterior telefones[].,is_ fax qualificacao_andresponsavel lgpd_fields.anonimizado
Step by step
- List the OpenCNPJ fields your code reads and find each one in the tables above.
- Remove dependencies on the datasets and downloads that have no equivalent.
- Open in the browser, without a key and without parameters, a lookup such as
https:/to see the response format, as shown in Public access./ api. cnpja. com/ v2/ establishments/ 37335118000180 - Create an account and an API key, and keep the key in your backend.
- Change the URL, remove
datasetsand send theAuthorizationheader. - Add
expand=company.if you use the Simples Nacional or MEI fields, and settaxRegime maxAgeif the 45-day default doesn’t fit. - Adapt your code to the new formats:
codeinstead of text, numericcompany., phones in international format andshareCapital nullor missing fields instead of empty strings. - Handle errors by
code, accept206as success and retry429,500and504with a delay. - Test with the key: compare both APIs’ responses for a sample of your CNPJs and track consumption in Usage.
- 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
receitadataset, 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).