Skip to contents

This function retrieves public company registration data in Brazil by querying the BrasilAPI endpoint.

Usage

get_brazil_cnpj(cnpj)

Arguments

cnpj

A valid CNPJ number as a string (only digits, no punctuation).

Value

A tibble with selected essential fields:

  • cnpj: CNPJ identifier.

  • razao_social: Legal name.

  • nome_fantasia: Trade name.

  • capital_social: Registered capital (numeric).

  • data_inicio_atividade: Start date of activities.

  • cnae_fiscal_descricao: Main economic activity.

  • natureza_juridica: Legal nature.

  • descricao_situacao_cadastral: Registration status.

  • municipio: City.

  • uf: State.

  • cep: Postal code.

  • logradouro: Address (street).

  • numero: Address number.

  • bairro: Neighborhood.

Details

Example URL format: https://brasilapi.com.br/api/cnpj/v1/19131243000197

Replace 19131243000197 with any valid Brazilian CNPJ number.

It returns a tibble with essential information such as the company's legal name, trade name, address, primary activity, and registration status.

The function makes an HTTP GET request to the BrasilAPI CNPJ endpoint and processes the JSON response into a structured tibble. It only returns fields that are essential and informative for the user.

Note

Requires internet connection. The function returns NULL if the CNPJ is invalid or not found.

See also

Examples

if (FALSE) { # \dontrun{
get_brazil_cnpj("19131243000197")
} # }