PHPackages                             gutocf/brasil-api-php-sdk - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. gutocf/brasil-api-php-sdk

ActiveLibrary[API Development](/categories/api)

gutocf/brasil-api-php-sdk
=========================

SDK for BrasilAPI

1.1.3(2y ago)32.5k↓64.3%MITPHPPHP ^8.0

Since May 23Pushed 2y ago2 watchersCompare

[ Source](https://github.com/gutocf/brasil-api-php-sdk)[ Packagist](https://packagist.org/packages/gutocf/brasil-api-php-sdk)[ RSS](/packages/gutocf-brasil-api-php-sdk/feed)WikiDiscussions main Synced 2d ago

READMEChangelog (10)Dependencies (7)Versions (15)Used By (0)

Brasil API PHP SDK
==================

[](#brasil-api-php-sdk)

[![CI](https://github.com/gutocf/brasil-api-php-sdk/actions/workflows/ci.yml/badge.svg)](https://github.com/gutocf/brasil-api-php-sdk/actions/workflows/ci.yml)[![Coverage Status](https://camo.githubusercontent.com/8b12341dbfb9fb2293421c2a8b44b110da9ea002ce3530b4a3ea0836d7ad8d13/68747470733a2f2f696d672e736869656c64732e696f2f636f6465636f762f632f6769746875622f6775746f63662f62726173696c2d6170692d7068702d73646b2e7376673f7374796c653d666c61742d737175617265)](https://codecov.io/github/gutocf/brasil-api-php-sdk)[![PHPStan](https://camo.githubusercontent.com/ec8329f0ec20497dd5501573126668867d62c0b926e60c7813affce74ead5f3c/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048505374616e2d4c6576656c253230372d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265266c6f676f3d706870)](https://shields.io/#/)[![PHP Version Require](https://camo.githubusercontent.com/0630907d62e188b21c21803fed6e92f47f72f1d8a16768c230b221f38ad40609/687474703a2f2f706f7365722e707567782e6f72672f6775746f63662f62726173696c2d6170692d7068702d73646b2f726571756972652f706870)](https://packagist.org/packages/gutocf/brasil-api-php-sdk)[![Packagist Version](https://camo.githubusercontent.com/0363a85c5ba26d0759ce5a886403d698f1c9766beb83d3e55ff4dffea83cfaa1/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6775746f63662f62726173696c2d6170692d7068702d73646b3f7374796c653d666c61742d737175617265)](https://packagist.org/packages/gutocf/brasil-api-php-sdk)[![License](https://camo.githubusercontent.com/942e017bf0672002dd32a857c95d66f28c5900ab541838c6c664442516309c8a/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d626c75652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/gutocf/brasil-api-php-sdk)[![Total Downloads](https://camo.githubusercontent.com/b19096977b7d79635e185ca13340ca2bacef485f803064aeb6e3c3370ae1d131/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6775746f63662f62726173696c2d6170692d7068702d73646b2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/gutocf/brasil-api-php-sdk)

PHP SDK for [BrasilAPI](https://brasilapi.com.br/).

Requirements
------------

[](#requirements)

- PHP ^8.0

Note: this package requires php:^8.0. For php:7.4 check out version 1.0.

***Note: this package requires php:^8.0. For php:7.4 check out version 1.0.***

Installation
------------

[](#installation)

You can install the package via composer:

```
composer require gutocf/brasil-api-php-sdk

```

Usage
-----

[](#usage)

First you need to get an instance of the BrasilAPI class:

```
use Gutocf\BrasilAPI\BrasilAPI;

$BrasilAPI = new BrasilAPI();
```

After that, you can use the service methods as follows. All services methods return an object or array of objects children of `DataTransferObject` from the [spatie/data-transfer-object](https://github.com/spatie/data-transfer-object/) library.

### CEP (V1)

[](#cep-v1)

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

### CEP (V2)

[](#cep-v2)

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

### Banks

[](#banks)

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

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

### Holidays

[](#holidays)

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

### CNPJ

[](#cnpj)

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

### DDD

[](#ddd)

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

### FIPE

[](#fipe)

#### Reference Tables

[](#reference-tables)

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

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

#### Vehicles

[](#vehicles)

```
//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);
```

#### Brands

[](#brands)

```
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);
```

### IBGE

[](#ibge)

#### Cities by State

[](#cities-by-state)

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

#### States

[](#states)

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

#### State by initials or code

[](#state-by-initials-or-code)

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

Error handling
--------------

[](#error-handling)

HTTP errors communicating with the **Brasil API** will throw exceptions as follows:

Status codeException400`Gutocf\BrasilAPI\Exception\NotFoundException`404`Gutocf\BrasilAPI\Exception\BadRequestException`500`Gutocf\BrasilAPI\Exception\InternalServerErrorException`

###  Health Score

31

—

LowBetter than 66% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity22

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity61

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~50 days

Recently: every ~162 days

Total

14

Last Release

847d ago

Major Versions

0.4.3-alpha → 1.0.02022-05-29

PHP version history (2 changes)0.1.0-alphaPHP &gt;=7.4

1.1.1PHP ^8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/25c8fabd439555323d7f489142fc8ae905c6880fc7d6b510c65d287b81605f7a?d=identicon)[gutocf](/maintainers/gutocf)

---

Top Contributors

[![gutocf](https://avatars.githubusercontent.com/u/70781531?v=4)](https://github.com/gutocf "gutocf (84 commits)")

---

Tags

apibrasilapicepcnpjdddfipeibgephpphp-librarysdkphpapisdkbrasilBrasilApigutocf

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP\_CodeSniffer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/gutocf-brasil-api-php-sdk/health.svg)

```
[![Health](https://phpackages.com/badges/gutocf-brasil-api-php-sdk/health.svg)](https://phpackages.com/packages/gutocf-brasil-api-php-sdk)
```

###  Alternatives

[openai-php/laravel

OpenAI PHP for Laravel is a supercharged PHP API client that allows you to interact with the Open AI API

3.7k9.5M89](/packages/openai-php-laravel)[hubspot/api-client

Hubspot API client

24016.2M20](/packages/hubspot-api-client)[resend/resend-php

Resend PHP library.

617.2M43](/packages/resend-resend-php)[php-opencloud/openstack

PHP SDK for OpenStack APIs. Supports BlockStorage, Compute, Identity, Images, Networking and Metric Gnocchi

2312.4M25](/packages/php-opencloud-openstack)[checkout/checkout-sdk-php

Checkout.com SDK for PHP

563.6M13](/packages/checkout-checkout-sdk-php)[eslazarev/wildberries-sdk

Wildberries OpenAPI clients (generated).

273.0k](/packages/eslazarev-wildberries-sdk)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
