Correios.DataProvider 1.1.0

dotnet add package Correios.DataProvider --version 1.1.0
                    
NuGet\Install-Package Correios.DataProvider -Version 1.1.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Correios.DataProvider" Version="1.1.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Correios.DataProvider" Version="1.1.0" />
                    
Directory.Packages.props
<PackageReference Include="Correios.DataProvider" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Correios.DataProvider --version 1.1.0
                    
#r "nuget: Correios.DataProvider, 1.1.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Correios.DataProvider@1.1.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Correios.DataProvider&version=1.1.0
                    
Install as a Cake Addin
#tool nuget:?package=Correios.DataProvider&version=1.1.0
                    
Install as a Cake Tool

Correios.DataProvider

Biblioteca .NET 8 para integração com APIs oficiais dos Correios. Cobre autenticação por contrato, consulta de CEP, cálculo de preço, prazo e consulta combinada de preço com prazo.

Requisitos

  • .NET 8 ou superior
  • Contrato ativo com os Correios
  • Usuario, codigo de acesso da API, cartao de postagem, contrato e codigo DR

Instalacao

dotnet add package Correios.DataProvider

Autenticacao

using Correios.DataProvider.Common;
using Correios.DataProvider.Models.Authorization;
using Correios.DataProvider.Services.Authentication;

var usuario = new UsuarioCorreios
{
    Usuario = "usuario",
    CodigoDeAcessoAPI = "codigo-api",
    CartaoDePostagem = "0000000000",
    Contrato = "0000000000",
    CodigoDR = CodigoDR.SaoPaulo
};

var login = await Login.InitializeAsync(usuario);

Login reutiliza token valido e renova autenticação quando necessário.

Consulta de CEP

using Correios.DataProvider.Services;

var service = new CEPService(login);
var response = await service.GetEnderecoAsync("01001-000");

if (response.Success)
{
    Console.WriteLine(response.Data?.Logradouro);
}

Consulta de preco

using Correios.DataProvider.Common;
using Correios.DataProvider.Requests;
using Correios.DataProvider.Services;

var request = new PrecoRequest
{
    IdLote = Guid.NewGuid().ToString(),
    ParametrosProduto =
    [
        new ParametroPrecoRequest
        {
            CoProduto = ProdutoCorreios.PAC_CONTRATO_AG,
            CepOrigem = "01001-000",
            CepDestino = "20040-020",
            Comprimento = "20",
            Largura = "15",
            Altura = "10",
            PsObjeto = "1000",
            NuContrato = usuario.Contrato,
            NuDR = usuario.CodigoDR
        }
    ]
};

var service = new PrecoService(login);
var response = await service.GetPrecoAsync(request);

Consulta de prazo

using Correios.DataProvider.Common;
using Correios.DataProvider.Requests;
using Correios.DataProvider.Services;

var request = new PrazoRequest
{
    IdLote = Guid.NewGuid().ToString(),
    ParametrosPrazo =
    [
        new ParametroPrazoRequest
        {
            CoProduto = ProdutoCorreios.SEDEX_CONTRATO_AG,
            CepOrigem = "01001-000",
            CepDestino = "20040-020"
        }
    ]
};

var service = new PrazoService(login);
var response = await service.GetPrazoAsync(request);

Preco com prazo

using Correios.DataProvider.Services;

var service = new PrecoPrazoService(login);
var response = await service.GetPrecoAsDtoAsync(request);

if (response.Success)
{
    Console.WriteLine(response.Data?.Valor);
    Console.WriteLine(response.Data?.PrazoDeEntrega);
}

Produtos suportados

Produtos ficam no enum ProdutoCorreios. Principais:

  • PAC_CONTRATO_AG
  • SEDEX_CONTRATO_AG
  • SEDEX_10_CONTRATO_AG
  • SEDEX_12_CONTRATO_AG
  • SEDEX_HOJE_CONTRATO_AG
  • CORREIOS_MINI_ENVIOS_CTR_AG

Use helpers para codigo e descricao:

var codigo = ProdutoCorreios.SEDEX_CONTRATO_AG.GetCodigo();
var descricao = ProdutoCorreios.SEDEX_CONTRATO_AG.GetDescricaoProduto();
var produto = ProdutoCorreiosExtensions.FromCodigo("03220");

Helpers

using Correios.DataProvider.Helper;

CEPHelper.IsValid("01001-000");
CEPHelper.Normalize("01001-000");
CEPHelper.Format("01001000");

var seguro = Calculadora.CalculaValorSeguro(1000m);

Validacao

A biblioteca limita consultas de preco e prazo a um produto por request. A API dos Correios aceita lotes, mas erros de um item podem quebrar a resposta inteira com mensagem genérica. Consulta individual preserva diagnóstico e compatibilidade.

Campos validados antes da chamada:

  • CEP de origem
  • CEP de destino
  • Contrato em consulta de preco
  • Lista de parametros com exatamente um item
  • NuRequisicao, gerado automaticamente quando nulo

Configuracao

Valores padrao da API dos Correios já vêm embutidos. Se precisar sobrescrever endpoints, crie appsettings.json no diretório de execução:

{
  "CorreiosApi": {
    "BaseUrl": "https://api.correios.com.br",
    "Endpoints": {
      "CEP": "cep/v2/enderecos/",
      "Autentica": "token/v1/autentica/cartaopostagem",
      "Prazo": "prazo/v1/nacional",
      "Preco": "preco/v1/nacional"
    }
  }
}

Testes

dotnet test Correios.DataProvider.sln

Stack atual:

  • xUnit
  • FluentAssertions
  • Microsoft.NET.Test.Sdk
  • coverlet.collector

Desenvolvimento

dotnet restore Correios.DataProvider.sln
dotnet build Correios.DataProvider.sln
dotnet test Correios.DataProvider.sln

Dependencias principais

  • ARSoft.RestApiClient 3.0.0
  • Microsoft.Extensions.Configuration.Json 8.0.1
  • Newtonsoft.Json 13.0.3

Observacoes

Esta biblioteca nao é oficial dos Correios. Valide valores críticos com as fontes oficiais antes de apresentar preço ou prazo ao cliente final.

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on Correios.DataProvider:

Package Downloads
SRA.DeliveryServicesAPIClient.BR

A .NET library for integrating with multiple Brazilian freight quotation services, providing a unified interface for shipping cost calculations.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.1.0 101 5/9/2026
1.0.2 164 3/14/2026

A .NET library for seamless integration with the official Brazilian Post Office (Correios) API, providing authenticated access to shipping calculations, address lookup, and delivery time estimates.