Consult CNPJ with PHP

Learn how to consult company data through the CNPJ using the CNPJ.ws API, with data from Receita Federal, Sintegra, and Suframa using PHP.

PHP is one of the most used languages in web development and with it, it is very simple to make a query in the CNPJ.wsarrow-up-right API.

With the integration, we can use the API to query the address, state registration, registration status, CNAE, and many other information that may be important when registering a customer or supplier through the CNPJ.

Public API

CNPJ.wsarrow-up-right provides a public API for queries where you can make up to 3 queries per minute. See the documentationarrow-up-right.

<?php

$url = "https://publica.cnpj.ws/cnpj/27865757000102";

$curl = curl_init($url);
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);

//for debug only!
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);

$resp = curl_exec($curl);
curl_close($curl);
var_dump($resp);

Commercial API

In the commercial API, you do not have a limit of requests per minute, but there is a monthly query limit according to the contracted plan, see our plansarrow-up-right.

See the Commercial API documentationarrow-up-right

Example of Return

Below is an example of the return from the CNPJ query: 27865757000102:

Conclusion

Using the CNPJ.ws API, you can obtain data from Brazilian companies in a simple and easy way. Take a look at our documentationarrow-up-right.

To learn more about our plans and payment methods, visit CNPJ.wsarrow-up-right.

If you have any questions, we are here to support you. Send an email to [email protected]!

Last updated

Was this helpful?