Look up CNPJ in batch
Need to process a list of CNPJs? CNPJAPI has a dedicated endpoint: POST /consulta/lote looks up up to 20 CNPJs in a single call - available for accounts with a paid plan (not included in the free plan).
Full reference (body, response, errors): Look up CNPJs in batch.
How it works
- Send up to 20 CNPJs at once in
{"cnpjs": [...]}. - The response brings one item per CNPJ, in the same order as the sent list, with
status:encontrado,nao_encontrado,invalidoorerro. - An item with a problem does not bring down the batch - the others are processed normally.
- The call counts as 1 request toward the per-minute limit; the monthly quota only debits the resolved CNPJs (
encontrado). - Have more than 20 in your list? Split it into several batches of up to 20, respecting the rate limit between calls.
Example (Python)
import requests
API_KEY = "cnpj_sua_chave"
cnpjs = ["00776574000156", "00000000000000", "abc"] # your list, up to 20 per call
resposta = requests.post(
"https://api.cnpjapi.com.br/consulta/lote",
headers={"Authorization": f"Bearer {API_KEY}"},
json={"cnpjs": cnpjs},
timeout=15,
)
resposta.raise_for_status()
for item in resposta.json():
if item["status"] == "encontrado":
print(item["cnpj"], "-", item["dados"]["RazaoSocial"])
else:
print(item["cnpj"], "-", item["status"])
The same pattern works in any language: a single POST, with the entire list in the body. See the per-language guides in Integration Guides and the complete examples at github.com/guidi-sistemas/cnpjapi-examples.
No paid plan?
Batch responds 403 for accounts without a paid plan. In that case (or for one-off lookups), use GET /{cnpj} once per CNPJ, respecting the rate limit - see Look up a CNPJ.
Tips
- More than 20 CNPJs? Split them into batches of 20 and spread the calls out over time.
- Handle
erro/nao_encontrado/invalidoper item: they do not stop the batch, but deserve handling separate fromencontrado. - ReceitaWS format?
?formato=receitawsalso works on batch - see the note about error items in Look up CNPJs in batch. - Need more volume? Compare plans at https://cnpjapi.com.br/#planos.
Next steps
- Look up CNPJs in batch - full reference for the endpoint.
- Limits and plans and Errors.
- Response fields.