PHP code example of gutocf / brasil-api-php-sdk

1. Go to this page and download the library: Download gutocf/brasil-api-php-sdk library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

gutocf / brasil-api-php-sdk example snippets


use Gutocf\BrasilAPI\BrasilAPI;

$BrasilAPI = new BrasilAPI();

//Gets a bank by its code.
$cep = $BrasilAPI->cepV1()->get('88045540');

//Gets a bank by its code.
$cep = $BrasilAPI->cepV2()->get('88045540');

//Gets all banks.
$banks = $BrasilAPI->banksV1()->getAll();

//Gets a bank by its code.
$bank = $BrasilAPI->banksV1()->get(1);

//Gets holidays by year
$banks = $BrasilAPI->holidaysV1()->getByYear(2022);

//Gets information about a CNPJ
$banks = $BrasilAPI->cnpjV1()->get('39729684000100');

//Gets information about a DDD
$ddd = $BrasilAPI->dddV1()->get(48);

use Gutocf\BrasilAPI\Entity\V1\Fipe\Enum\VehicleType;

//Gets all reference tables
$referenceTables = $BrasilAPI->fipeV1()->getAllReferenceTables();

//Gets vehicle price information by FIPE code
$vehicles = $BrasilAPI->fipeV1()->getAllVehicleByCode('003281-6');
//Gets vehicle price information by FIPE code for a specific table
$vehicles = $BrasilAPI->fipeV1()->getAllVehicleByCode('003281-6', 123);

use Gutocf\BrasilAPI\Entity\V1\Fipe\Enum\VehicleType;

//Gets all brands
$brands = $BrasilAPI->fipeV1()->getAllBrandsByType();
//Gets all brands by vehicle type
$brands = $BrasilAPI->fipeV1()->getAllBrandsByType(VehicleType::CARS());
//Gets all brands by vehicle type for a specific table
$brands = $BrasilAPI->fipeV1()->getAllBrandsByType(VehicleType::CARS(), 123);

$cities = $BrasilAPI->ibgeV1()->getCitiesByState('SC');

$states = $BrasilAPI->ibgeV1()->getAllStates();

$state = $BrasilAPI->ibgeV1()->getState('sc');
//OR
$state = $BrasilAPI->ibgeV1()->getState(42);