ReceitaWS-compatible

Already integrated with ReceitaWS? CNPJAPI responds in the same format, field by field. To migrate, swap only the host of your call - the JSON body stays the same, so your parsing code does not change.

  • From: https://www.receitaws.com.br/v1/cnpj/{cnpj}
  • To: https://api.cnpjapi.com.br/v1/cnpj/{cnpj}

The only difference is authentication: CNPJAPI requires your API key in the Authorization header (see Authentication).

How to enable the ReceitaWS format

There are two equivalent ways to request the compatible response:

  • Same path as ReceitaWS: GET /v1/cnpj/{cnpj} - mirrors the ReceitaWS URL (migration = swap the host).
  • Parameter on the canonical endpoint: GET /{cnpj}?formato=receitaws.

Without either of the two, the response is CNPJAPI's native format (fields in PascalCase).

Authentication, plan limits and quota are identical to the normal lookup. The compatible mode only changes the shape of the body in the response.

Example (curl)

curl https://api.cnpjapi.com.br/v1/cnpj/00776574000156 \
  -H "Authorization: Bearer cnpj_sua_chave"

Response (200 OK, application/json)

{
  "status": "OK",
  "cnpj": "00.776.574/0001-56",
  "tipo": "MATRIZ",
  "nome": "...",
  "fantasia": "...",
  "abertura": "01/01/2000",
  "situacao": "ATIVA",
  "data_situacao": "01/01/2000",
  "motivo_situacao": "",
  "situacao_especial": "",
  "data_situacao_especial": "",
  "porte": "DEMAIS",
  "natureza_juridica": "0000 - ...",
  "atividade_principal": [ { "code": "00.00-0-00", "text": "..." } ],
  "atividades_secundarias": [ { "code": "00.00-0-00", "text": "..." } ],
  "qsa": [ { "nome": "...", "qual": "00 - ..." } ],
  "logradouro": "...",
  "numero": "...",
  "complemento": "...",
  "bairro": "...",
  "municipio": "...",
  "uf": "..",
  "cep": "00.000-000",
  "email": "...",
  "telefone": "(00) 0000-0000",
  "efr": "",
  "capital_social": "0.00",
  "simples": { "optante": false, "data_opcao": null, "data_exclusao": null, "ultima_atualizacao": null },
  "simei": { "optante": false, "data_opcao": null, "data_exclusao": null, "ultima_atualizacao": null },
  "ultima_atualizacao": "...",
  "extra": {}
}

What differs from ReceitaWS

The goal is property parity: the same field names, in the same place. A few points to note:

Point Behavior in CNPJAPI
status "OK" on success; "ERROR" on failure (see below)
atividades_secundarias When there are none, the sentinel value [{"code":"00.00-0-00","text":"Não informada"}] is returned (same as ReceitaWS)
simples / simei Always present; when the company is not an opter, the fields come back false/null
logradouro Street type + street name spelled out (ReceitaWS's abbreviation is its own convention)
ultima_atualizacao inside simples/simei null - it is an internal ReceitaWS timestamp, with no equivalent
billing Omitted - it is a ReceitaWS proprietary field

Dates come out in dd/MM/yyyy format, ZIP code as NN.NNN-NNN and phone as (DD) NNNN-NNNN, same as ReceitaWS.

Errors

Errors also mirror ReceitaWS, in the {"status":"ERROR","message":"..."} format:

  • Invalid CNPJ (wrong format): 400 with message: "CNPJ inválido".
  • Not found: {"status":"ERROR","message":"CNPJ não encontrado na base de dados"}.
  • Limit exceeded (429): keeps the Retry-After header. See Limits and plans.

Next steps

Create your free account at https://app.cnpjapi.com.br and migrate from ReceitaWS by swapping only the host.