ViaCep 4.1.87
dotnet add package ViaCep --version 4.1.87
NuGet\Install-Package ViaCep -Version 4.1.87
<PackageReference Include="ViaCep" Version="4.1.87" />
paket add ViaCep --version 4.1.87
#r "nuget: ViaCep, 4.1.87"
// Install ViaCep as a Cake Addin
#addin nuget:?package=ViaCep&version=4.1.87
// Install ViaCep as a Cake Tool
#tool nuget:?package=ViaCep&version=4.1.87
ViaCEP
A .NET client wrapper for both .NET Core & .NET Framework projects of Via CEP API
CI/CD
Build status | Last commit | Tests | Coverage | Code Smells | LOC |
---|---|---|---|---|---|
Code Quality
Installation
Github Releases
Download the latest zip file from the Release page.
Nuget package manager
Package | Version | Downloads |
---|---|---|
ViaCEP |
Usage
The package has two classes:
- ViaCepClient: The main class (methods).
- ViaCepResult: The result class (data).
This package is fully compatible with Dependency Injection. Use the interface IViaCepClient and the constructor with HttpClient parameter with a IHttpClientFactory instance.
//your DI container
services.AddHttpClient<IViaCepClient, ViaCepClient>(client => { client.BaseAddress = new Uri("https://viacep.com.br/"); });
//then use in your domain service, handler, controller...
var viaCepClient = container.GetService<IViaCepClient>();
var result = await viaCepClient.SearchAsync("01001000", cancellationToken);
You can search using the zip code/postal code (AKA CEP) or using the address data (state initials - UF, city name and location name - street, avenue, park, square). Both methods support async and sync!
Querying by zip code / postal code (single result)
var result = new ViaCepClient().Search("01001000"); //searches for the postal code 01001-000
var address = result.Address; //Praça da Sé
var city = reuslt.City; //São Paulo
//do what you need with 'result' instance of ViaCEPResult.
Querying by address (list result)
var results = new ViaCepClient().Search("SP", "São Paulo", "Avenida Paulista"); //search for the Avenida Paulista in São Paulo / SP
foreach(var result in results){
var address = result.Address;
var neighborhood = result.Neighborhood;
var zipCode = result.ZipCode;
//do what you need with 'result' instance of ViaCEPResult.
}
Changelog
- 2023-03-03: Update dependencies, change branch name, update logo. @guibranco
- 2021-06-21: Update dependencies version. @guibranco
- 2020-10-23: Add support to .NET Standard 2.0 and .NET Framework v4.6.1 and above. @guibranco
Product | Versions |
---|---|
.NET | net5.0 net5.0-windows net6.0 net6.0-android net6.0-ios net6.0-maccatalyst net6.0-macos net6.0-tvos net6.0-windows net7.0 net7.0-android net7.0-ios net7.0-maccatalyst net7.0-macos net7.0-tvos net7.0-windows |
.NET Core | netcoreapp2.0 netcoreapp2.1 netcoreapp2.2 netcoreapp3.0 netcoreapp3.1 |
.NET Standard | netstandard2.0 netstandard2.1 |
.NET Framework | net461 net462 net463 net47 net471 net472 net48 net481 |
MonoAndroid | monoandroid |
MonoMac | monomac |
MonoTouch | monotouch |
Tizen | tizen40 tizen60 |
Xamarin.iOS | xamarinios |
Xamarin.Mac | xamarinmac |
Xamarin.TVOS | xamarintvos |
Xamarin.WatchOS | xamarinwatchos |
-
.NETStandard 2.0
- Microsoft.AspNet.WebApi.Client (>= 5.2.9)
- Newtonsoft.Json (>= 13.0.3)
-
.NETStandard 2.1
- Microsoft.AspNet.WebApi.Client (>= 5.2.9)
- Newtonsoft.Json (>= 13.0.3)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
4.1.87 | 33 | 3/25/2023 |
4.1.79 | 49 | 3/23/2023 |
4.1.76 | 109 | 3/3/2023 |
4.1.73 | 79 | 3/3/2023 |
4.1.57 | 80 | 3/3/2023 |
4.1.54 | 171 | 1/24/2023 |
4.1.53 | 157 | 1/15/2023 |
4.1.48 | 132 | 1/15/2023 |
4.1.45 | 134 | 1/14/2023 |
4.1.40 | 140 | 1/14/2023 |
3.2.35 | 137 | 1/14/2023 |
3.2.32 | 157 | 12/25/2022 |
3.2.27 | 148 | 12/25/2022 |
3.2.19 | 7,563 | 6/21/2021 |
3.1.5 | 5,496 | 10/23/2020 |
3.0.40 | 2,252 | 4/18/2020 |
3.0.38 | 1,036 | 4/7/2020 |
3.0.30 | 367 | 3/30/2020 |
3.0.23 | 378 | 3/29/2020 |
3.0.15 | 384 | 3/29/2020 |
3.0.12 | 393 | 3/29/2020 |
3.0.9 | 485 | 3/28/2020 |
2.0.93 | 1,279 | 3/28/2020 |
2.0.92 | 406 | 3/28/2020 |
2.0.89 | 394 | 3/28/2020 |
2.0.88 | 396 | 3/28/2020 |
2.0.80 | 405 | 3/28/2020 |
2.0.64 | 5,284 | 12/30/2019 |
2.0.61 | 8,334 | 12/3/2019 |
2.0.58 | 1,148 | 9/22/2019 |
2.0.48 | 2,360 | 2/15/2019 |
2.0.47 | 518 | 2/15/2019 |
1.0.0 | 513 | 2/15/2019 |