Consult CNPJ with Java
Learn how to consult company data through the CNPJ using the CNPJ.ws API, with data from Receita Federal, Sintegra, and Suframa using Java.
Last updated
Was this helpful?
Learn how to consult company data through the CNPJ using the CNPJ.ws API, with data from Receita Federal, Sintegra, and Suframa using Java.
Last updated
Was this helpful?
If you are looking for an efficient and free way to consult CNPJ data directly from your Java application, you have come to the right place! In this guide, we will explore how you can integrate your Java application with the API to access detailed information about companies registered with Receita Federal.
provides a public API for queries where you can make up to 3 queries per minute. .
We will divide this tutorial into sections for easier understanding. Follow along!
Java: Make sure you have the JDK installed on your machine. IDE: A Java development environment, such as Eclipse or IntelliJ IDEA.
Create a new Java project in your favorite IDE.
Add the OkHttp library: We will use the OkHttp library to facilitate HTTP requests. Add the dependency to your pom.xml file if you are using Maven:
Create a new Java class called ConsultaCNPJ. In this class, we will implement the method to perform the CNPJ query:
OkHttpClient: We use this class to send HTTP requests.
Request: Here we build our request, defining the URL with the CNPJ number we want to query.
Response: We store the API response to process it later.
Run the ConsultaCNPJ class and check the console. You should see the JSON response containing detailed information about the queried CNPJ.
In this guide, you learned how to perform CNPJ queries for free using the CNPJ.WS public API in a Java application. Use this functionality to enrich your Java projects with accurate and up-to-date business data.
See you soon!
To learn more about our plans and payment methods, visit .