BrasilAPI CNPJ icon

BrasilAPI CNPJ

Consulta CNPJ usando BrasilAPI

BrasilAPI CNPJ

AI-generated

Overview

This node performs a lookup of Brazilian company registration numbers (CNPJ) using the BrasilAPI service. It is designed to retrieve detailed information about a company based on its CNPJ identifier. This can be useful in scenarios such as validating company data, enriching records with official company details, or automating business workflows that require company verification.

For example, a user might input a list of CNPJs to verify their existence and obtain associated company information like name, address, and status directly within an n8n workflow.

Properties

Name Meaning
CNPJ The Brazilian company registration number to be queried. It must be provided as a string in numeric format without punctuation (e.g., "00000000000191").

Output

The node outputs an array of JSON objects, each corresponding to one input CNPJ query. Each output item contains:

  • json: An object with the full response from the BrasilAPI for the given CNPJ. This includes detailed company information such as name, address, status, and other official data fields returned by the API.
  • In case of an error during the request (e.g., invalid CNPJ or network issues), the output JSON will contain:
    • error: A message describing the error encountered.
    • cnpj: The CNPJ value that caused the error.

No binary data is produced by this node.

Dependencies

  • Requires internet access to call the public BrasilAPI endpoint at https://brasilapi.com.br/api/cnpj/v1/{cnpj}.
  • No authentication or API key is needed since the API is publicly accessible.
  • The node uses HTTP GET requests to fetch data.

Troubleshooting

  • Common Issues:

    • Invalid or malformed CNPJ input may cause the API to return errors.
    • Network connectivity problems can prevent successful API calls.
    • Rate limiting or temporary unavailability of BrasilAPI could result in errors.
  • Error Messages:

    • If the API returns an error, it will be captured and included in the output JSON under the error field.
    • Typical error messages might include "Invalid CNPJ" or network-related errors.
  • Resolution Tips:

    • Ensure the CNPJ is correctly formatted as a numeric string without special characters.
    • Verify network connectivity and retry if transient errors occur.
    • Consider adding error handling logic in your workflow to manage failed lookups gracefully.

Links and References

Discussion