{"id":20306514,"url":"https://github.com/gutocf/brasil-api-php-sdk","last_synced_at":"2025-04-11T15:06:08.414Z","repository":{"id":57680867,"uuid":"494925965","full_name":"gutocf/brasil-api-php-sdk","owner":"gutocf","description":"PHP SDK for BrasilAPI.","archived":false,"fork":false,"pushed_at":"2024-03-08T18:22:15.000Z","size":132,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-25T11:11:32.307Z","etag":null,"topics":["api","brasilapi","cep","cnpj","ddd","fipe","ibge","php","php-library","sdk"],"latest_commit_sha":null,"homepage":"https://brasilapi.com.br","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/gutocf.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2022-05-22T00:42:11.000Z","updated_at":"2022-12-26T14:12:44.000Z","dependencies_parsed_at":"2024-03-08T20:13:00.045Z","dependency_job_id":null,"html_url":"https://github.com/gutocf/brasil-api-php-sdk","commit_stats":{"total_commits":77,"total_committers":1,"mean_commits":77.0,"dds":0.0,"last_synced_commit":"fd4808d8f9646f2f1fe1f5348ad5a9b906041591"},"previous_names":[],"tags_count":14,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gutocf%2Fbrasil-api-php-sdk","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gutocf%2Fbrasil-api-php-sdk/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gutocf%2Fbrasil-api-php-sdk/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gutocf%2Fbrasil-api-php-sdk/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gutocf","download_url":"https://codeload.github.com/gutocf/brasil-api-php-sdk/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248429076,"owners_count":21101782,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["api","brasilapi","cep","cnpj","ddd","fipe","ibge","php","php-library","sdk"],"created_at":"2024-11-14T17:13:43.365Z","updated_at":"2025-04-11T15:06:08.395Z","avatar_url":"https://github.com/gutocf.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n\n# Brasil API PHP SDK\n\n[![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)\n[![Coverage Status](https://img.shields.io/codecov/c/github/gutocf/brasil-api-php-sdk.svg?style=flat-square)](https://codecov.io/github/gutocf/brasil-api-php-sdk)\n[![PHPStan](https://img.shields.io/badge/PHPStan-Level%207-brightgreen.svg?style=flat-square\u0026logo=php)](https://shields.io/#/)\n[![PHP Version Require](http://poser.pugx.org/gutocf/brasil-api-php-sdk/require/php)](https://packagist.org/packages/gutocf/brasil-api-php-sdk)\n[![Packagist Version](https://img.shields.io/packagist/v/gutocf/brasil-api-php-sdk?style=flat-square)](https://packagist.org/packages/gutocf/brasil-api-php-sdk)\n[![License](https://img.shields.io/badge/license-MIT-blue.svg?style=flat-square)](https://packagist.org/packages/gutocf/brasil-api-php-sdk)\n[![Total Downloads](https://img.shields.io/packagist/dt/gutocf/brasil-api-php-sdk.svg?style=flat-square)](https://packagist.org/packages/gutocf/brasil-api-php-sdk)\n\nPHP SDK for [BrasilAPI](https://brasilapi.com.br/).\n\n## Requirements\n\n - PHP ^8.0\n \nNote: this package requires php:^8.0. For php:7.4 check out version 1.0.\n\n___Note: this package requires php:^8.0. For php:7.4 check out version 1.0.___\n\n## Installation\n\nYou can install the package via composer:\n\n    composer require gutocf/brasil-api-php-sdk\n\n## Usage\n\nFirst you need to get an instance of the BrasilAPI class:\n\n```php\nuse Gutocf\\BrasilAPI\\BrasilAPI;\n\n$BrasilAPI = new BrasilAPI();\n```\nAfter 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.\n\n### CEP (V1)\n\n```php\n//Gets a bank by its code.\n$cep = $BrasilAPI-\u003ecepV1()-\u003eget('88045540');\n```\n### CEP (V2)\n\n```php\n//Gets a bank by its code.\n$cep = $BrasilAPI-\u003ecepV2()-\u003eget('88045540');\n```\n\n### Banks\n\n```php\n//Gets all banks.\n$banks = $BrasilAPI-\u003ebanksV1()-\u003egetAll();\n\n//Gets a bank by its code.\n$bank = $BrasilAPI-\u003ebanksV1()-\u003eget(1);\n```\n\n### Holidays\n\n```php\n//Gets holidays by year\n$banks = $BrasilAPI-\u003eholidaysV1()-\u003egetByYear(2022);\n```\n\n### CNPJ\n\n```php\n//Gets information about a CNPJ\n$banks = $BrasilAPI-\u003ecnpjV1()-\u003eget('39729684000100');\n```\n\n### DDD\n\n```php\n//Gets information about a DDD\n$ddd = $BrasilAPI-\u003edddV1()-\u003eget(48);\n```\n\n### FIPE\n\n#### Reference Tables\n```php\nuse Gutocf\\BrasilAPI\\Entity\\V1\\Fipe\\Enum\\VehicleType;\n\n//Gets all reference tables\n$referenceTables = $BrasilAPI-\u003efipeV1()-\u003egetAllReferenceTables();\n```\n#### Vehicles\n```php\n//Gets vehicle price information by FIPE code\n$vehicles = $BrasilAPI-\u003efipeV1()-\u003egetAllVehicleByCode('003281-6');\n//Gets vehicle price information by FIPE code for a specific table\n$vehicles = $BrasilAPI-\u003efipeV1()-\u003egetAllVehicleByCode('003281-6', 123);\n```\n#### Brands\n```php\nuse Gutocf\\BrasilAPI\\Entity\\V1\\Fipe\\Enum\\VehicleType;\n\n//Gets all brands\n$brands = $BrasilAPI-\u003efipeV1()-\u003egetAllBrandsByType();\n//Gets all brands by vehicle type\n$brands = $BrasilAPI-\u003efipeV1()-\u003egetAllBrandsByType(VehicleType::CARS());\n//Gets all brands by vehicle type for a specific table\n$brands = $BrasilAPI-\u003efipeV1()-\u003egetAllBrandsByType(VehicleType::CARS(), 123);\n```\n\n### IBGE\n\n####  Cities by State\n```php\n$cities = $BrasilAPI-\u003eibgeV1()-\u003egetCitiesByState('SC');\n```\n####  States\n```php\n$states = $BrasilAPI-\u003eibgeV1()-\u003egetAllStates();\n```\n####  State by initials or code\n```php\n$state = $BrasilAPI-\u003eibgeV1()-\u003egetState('sc');\n//OR\n$state = $BrasilAPI-\u003eibgeV1()-\u003egetState(42);\n```\n\n## Error handling\n\nHTTP errors communicating with the **Brasil API** will throw exceptions as follows:\n|Status code|Exception|\n|--|--|\n| 400 | ```Gutocf\\BrasilAPI\\Exception\\NotFoundException``` |\n| 404 |```Gutocf\\BrasilAPI\\Exception\\BadRequestException```|\n| 500 |```Gutocf\\BrasilAPI\\Exception\\InternalServerErrorException```|\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgutocf%2Fbrasil-api-php-sdk","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgutocf%2Fbrasil-api-php-sdk","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgutocf%2Fbrasil-api-php-sdk/lists"}