PHPackages                             devaguia/correios-php - 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. devaguia/correios-php

ActiveLibrary[API Development](/categories/api)

devaguia/correios-php
=====================

Correios API library for PHP

1.0.4(1y ago)294.3k↓50%10[1 PRs](https://github.com/devaguia/correios-php/pulls)1GPL-3.0PHP

Since Sep 8Pushed 1y ago4 watchersCompare

[ Source](https://github.com/devaguia/correios-php)[ Packagist](https://packagist.org/packages/devaguia/correios-php)[ RSS](/packages/devaguia-correios-php/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (4)Dependencies (2)Versions (7)Used By (1)

Correios PHP
============

[](#correios-php)

Correios API library for PHP

 [![GitHub Workflow Status (master)](https://camo.githubusercontent.com/8711a46063f91dbb3cbed5a59a55ea322809c5e59b894718524c15d2c3388d5f/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f64657661677569612f636f727265696f732d7068702f63692d63642d74657374732e796d6c)](https://github.com/devaguia/correios-php/actions) [![Total Downloads](https://camo.githubusercontent.com/454a356c4b77acd044b709c368cc5d51e295dffd872a30e00c4aa18ed708a6d2/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f64657661677569612f636f727265696f732d706870)](https://packagist.org/packages/devaguia/correios-php) [![Latest Version](https://camo.githubusercontent.com/42e5dfdd2d1576caa2e20e3cfbe2489cd984385e1e9cc7efa2826ec6d470986a/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f64657661677569612f636f727265696f732d706870)](https://packagist.org/packages/devaguia/correios-php) [![License](https://camo.githubusercontent.com/78e3cbd3a55340f7ac893b5cf9a75b966f4015085e7e49448a07c7ca5faa02de/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f64657661677569612f636f727265696f732d706870)](https://packagist.org/packages/devaguia/correios-php)

- **[Instalação (Installation)](#installation)**
- **[Utilização Básica (Basic Usage)](#usage)**
- **[Respostas API (API Response)](#response)**
- **[Autenticação (Authentication)](#auth)**
- **[Contribua - Contribute](#contribute)**
- **[Árvore de Arquivos (File Tree)](#tree)**

Instalação (Installation)
-------------------------

[](#instalação-installation)

### Instale utilizando o Composer (Install using Composer)

[](#instale-utilizando-o-composer-install-using-composer)

```
composer require devaguia/correios-php
```

Utilização Básica (Basic Usage)
-------------------------------

[](#utilização-básica-basic-usage)

### Configuração (Setup)

[](#configuração-setup)

```
// Parâmetros obrigatórios - Required Paramns
$correios = new \Correios\Correios(
    username: 'user',
    password: 'password',
    postcard: 'postcard',
    isTestMode: true
);

// Parâmetros opcionais - Optional parameters
$correios = new \Correios\Correios(
    username: 'user',
    password: 'password',
    postcard: 'postcard',
    isTestMode: true,
    token: 'string'
);

// Use um número de requisição e ID do lot personalizado - Use a custom request number and Lot ID
$correios->setRequestNumber(requestNumber: '20230831');
$correios->getRequestNumber();

$correios->setLotId(lotId: '20230831LT');
$correios->getLotId();
```

### Rastro (Tracking)

[](#rastro-tracking)

```
$response = $correios->tracking()->get(
    trackingCode: 'AASD546115A',
    filtered: 'U'
);
```

### Preço (Price)

[](#preço-price)

```
// Parâmetros obrigatórios - Required Paramns
$correios->price()->get(
    serviceCodes:['04162'],
    products:[
        ['weight' => 300]
    ],
    originCep:'71930000',
    destinyCep:'05336010'
);

// Parâmetros opcionais - Optional parameters
$correios->price()->get(
    serviceCodes:['04162'],
    products:[
        [
          'weight'      => 300,
          'length'      => 0,
          'height'      => 200,
          'width'       => 200,
          'diameter'    => 0,
          'cubicWeight' => 0,
          /** 1 - Envelope (Default); 2 - Caixa; 3 - Rolo*/
          'objectType' => 2
        ]
    ],
    originCep:'71930000',
    destinyCep:'05336010',
    fields: [
        'nuContrato' => '0000000000',
        'nuDR' => 20
    ]
);
```

### Prazo (Date)

[](#prazo-date)

```
// Parâmetros obrigatórios - Required Paramns
$response = $correios->date()->get(
    serviceCodes: ['39870'],
    originCep: '71930000',
    destinyCep: '05336010'
);

// Parâmetros opcionais - Optional parameters
$correios->date()->get(
    serviceCodes:['04162'],
    originCep:'71930000',
    destinyCep:'05336010',
    fields: [
        'dtEvento' => '2023-01-01T01:01:01.001Z',
    ]
);
```

### Endereço (Address)

[](#endereço-address)

```
$response = $correios->address()->get(cep: '05336010');
```

Respostas API (API Response)
----------------------------

[](#respostas-api-api-response)

```
$responseBody = $response->getResponseBody();
$responseCode = $response->getResponseCode();

if (empty($responseBody)) {
    $errors = $response->getErrors();
}
```

Autenticação (Authentication)
-----------------------------

[](#autenticação-authentication)

```
// Gerando um novo token - Generating a new token
$correios = new \Correios\Correios(
    username: 'user',
    password: 'password',
    postcard: 'postcard',
    isTestMode: true
);

$token           = $correios->authentication()->getToken();
$tokenExpiration = $correios->authentication()->getTokenExpiration();
$responseBody    = $correios->authentication()->getResponseBody();
$responseCode    = $correios->authentication()->getResponseCode();
$errors          = $correios->authentication()->getErrors();

// Pega o número do e da diretoria com base na responsta da autenticação - Gets the board number based on the authentication response
$contractNumber = $correios->authentication()->getContract();
$drNumber = $correios->authentication()->getDr();

// Usando um token gerado anteriormente - Using a token generated earlie
$correios = new \Correios\Correios(
    username: 'user',
    password: 'password',
    postcard: 'postcard',
    isTestMode: true
    token: 'eyJhbGciOiJSUzUxMiJ9.eyJhbWJpZW50ZSI6IlBST0RVQ0FPIiwiaWQiOiI0MDExMjE1NDAwMDE5MCIsInBmbCI6IlBKIiwiY25waiI6IjQwMTEyMTU0MDAwMTkwIiwiY29udHJhdG8iOnsibnVtZXJvIjoiOTkxMjYxNjgzOSIsImRyIjoyMCwiYXBpIjpbMjcsMzQsMzUsNDEsNzYsODcsNTY2XX0sImlwIjoiMTcwLjc4LjY4Ljg2LDE3MC43OC42OC44NiIsImlhdCI6MTY5MjY0MTU2MywiaXNzIjoidG9rZW4tc2VydmljZSIsImV4cCI6MTY5MjcyNzk2MywianRpIjoiZGViMTczM2EtYmVjYS00NmIyLWFkNGYtYWQ5ZjBkYWFlZjhlIn0.uxJCCQFj0c1qzI4BGk9JWTh6TT_Drp7YaMbKQoT9m-ie5wXRun4cOuQdbj28MQR3IYuntB2B9C8aqSoa_eXADtvf4J2H-ZTWS0wAnxsxxkNf1lXmHYrD2jCgRMVgQ_2dy40uBt0bJyk0M9e4jNg2almtZMlAwjbVrgSbopuNrqhHe49GuDIuQzJLqsNC60mA6KberD9eSSNZsvHbgNYQysK0mZTkIFdWy8DBJ7b5FrbLzbeikqKbRW9pDj_3Q-YrxhwQ79ZjEF8dLiAU3BcCDHwOxpSv6HKD5984mz1VppFXcaBAsqW6oB9iCHrENjVqtRXa8mx0nqbjelyz0Of6qA'
);
```

Contribua - Contribute
----------------------

[](#contribua---contribute)

Por favor, se for contribuir, leia os arquivos de **[Manual de contribuição](CONTRIBUTING.md)** e **[Código de Conduta](CODE_OF_CONDUCT.md)**.

### SonarLint

[](#sonarlint)

Durante o desenvolvimento, pedimos que use o plugin SonarLint, para que ele verifique a qualidade do código que está sendo desenvolvido - During development, we request that you use the SonarLint plugin to check the quality of the code being developed:

- [VSCode](https://marketplace.visualstudio.com/items?itemName=SonarSource.sonarlint-vscode)
- [PHPStorm](https://plugins.jetbrains.com/plugin/7973-sonarlint)

### Instalação - Installation

[](#instalação---installation)

Installing the composer dependencies

```
composer install
```

Running the unit tests

```
composer test
```

File Tree
---------

[](#file-tree)

```
.
├── CODE_OF_CONDUCT.md
├── composer.json
├── CONTRIBUTING.md
├── LICENSE
├── phpunit.xml
├── phpunit.xml.bak
├── README.md
├── src
│   ├── Correios.php
│   ├── Exceptions
│   │   ├── ApiRequestException.php
│   │   ├── InvalidCepException.php
│   │   ├── InvalidCorreiosServiceCode.php
│   │   ├── MissingProductParamException.php
│   │   └── SameCepException.php
│   ├── Helpers
│   │   ├── Cep.php
│   │   └── Settings.php
│   ├── Includes
│   │   ├── Cep.php
│   │   ├── Product.php
│   │   ├── Settings.php
│   │   └── Traits
│   │       └── CepHandler.php
│   └── Services
│       ├── AbstractRequest.php
│       ├── Address
│       │   └── Cep.php
│       ├── Authorization
│       │   └── Authentication.php
│       ├── Date
│       │   └── Date.php
│       ├── Price
│       │   └── Price.php
│       └── Tracking
│           └── Tracking.php
└── tests
    └── Unit
        ├── CorreiosTest.php
        ├── Helpers
        │   ├── CepTest.php
        │   └── SettingsTest.php
        ├── Includes
        │   ├── CepTest.php
        │   ├── ProductTest.php
        │   └── SettingsTest.php
        └── Services
            ├── Address
            │   └── CepTest.php
            ├── Authorization
            │   └── AuthenticationTest.php
            ├── Date
            │   └── DateTest.php
            ├── Price
            │   └── PriceTest.php
            └── Tracking
                └── TrackingTest.php

```

###  Health Score

37

—

LowBetter than 83% of packages

Maintenance37

Infrequent updates — may be unmaintained

Popularity35

Limited adoption so far

Community19

Small or concentrated contributor base

Maturity47

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 91.1% 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 ~103 days

Total

5

Last Release

571d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/71287681?v=4)[Matheus Aguiar](/maintainers/devaguia)[@devaguia](https://github.com/devaguia)

---

Top Contributors

[![devaguia](https://avatars.githubusercontent.com/u/71287681?v=4)](https://github.com/devaguia "devaguia (133 commits)")[![mauroagr](https://avatars.githubusercontent.com/u/5348884?v=4)](https://github.com/mauroagr "mauroagr (8 commits)")[![rafaelstz](https://avatars.githubusercontent.com/u/610598?v=4)](https://github.com/rafaelstz "rafaelstz (3 commits)")[![matheus-delazeri](https://avatars.githubusercontent.com/u/55641441?v=4)](https://github.com/matheus-delazeri "matheus-delazeri (2 commits)")

---

Tags

correioscorreios-apicorreios-cepcorreios-rastreioentregashippinglibrarycorreiosshippingrastreioenvio

###  Code Quality

TestsPest

### Embed Badge

![Health badge](/badges/devaguia-correios-php/health.svg)

```
[![Health](https://phpackages.com/badges/devaguia-correios-php/health.svg)](https://phpackages.com/packages/devaguia-correios-php)
```

###  Alternatives

[gabrielbull/ups-api

PHP UPS API

4642.4M10](/packages/gabrielbull-ups-api)[nunomaduro/pokio

Pokio is a dead simple asynchronous API for PHP that just works

711867.2k4](/packages/nunomaduro-pokio)[temporal/sdk

Temporal SDK

4002.2M18](/packages/temporal-sdk)[alibabacloud/client

Alibaba Cloud Client for PHP - Use Alibaba Cloud in your PHP project

2223.5M367](/packages/alibabacloud-client)[easypost/easypost-php

EasyPost Shipping API Client Library for PHP

1753.1M5](/packages/easypost-easypost-php)[shippo/shippo-php

A PHP library for connecting with multiple carriers (FedEx, UPS, USPS) using Shippo.

1711.8M2](/packages/shippo-shippo-php)

PHPackages © 2026

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