https://github.com/guibranco/cepaberto
🇧🇷 :round_pushpin: CEPAberto API client wrapper for .NET projects
https://github.com/guibranco/cepaberto
api cep cepaberto csharp ddd geolocation hacktoberfest ibge nuget wrapper
Last synced: about 2 months ago
JSON representation
🇧🇷 :round_pushpin: CEPAberto API client wrapper for .NET projects
- Host: GitHub
- URL: https://github.com/guibranco/cepaberto
- Owner: guibranco
- License: mit
- Created: 2018-08-15T19:21:33.000Z (over 6 years ago)
- Default Branch: main
- Last Pushed: 2024-04-08T07:06:14.000Z (about 1 year ago)
- Last Synced: 2024-04-09T07:38:47.155Z (about 1 year ago)
- Topics: api, cep, cepaberto, csharp, ddd, geolocation, hacktoberfest, ibge, nuget, wrapper
- Language: C#
- Homepage: https://guibranco.github.io/CEPAberto/
- Size: 381 KB
- Stars: 4
- Watchers: 2
- Forks: 3
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# CEP Aberto SDK .NET
[CEP Aberto](htttp://www.cepaberto.com) API wrapper written in C# (.NET).
Implements all V3 features
[](https://github.com/guibranco/CEPAberto)
[](https://wakatime.com/badge/github/guibranco/CEPAberto)
## CI/CD
| Build status | Last commit | Tests | Coverage | Code Smells | LOC |
|--------------|-------------|-------|----------|-------------|-----|
| [](https://ci.appveyor.com/project/guibranco/CEPAberto) | [](https://github.com/guibranco/CEPAberto) | [](https://ci.appveyor.com/project/guibranco/CEPAberto) | [](https://sonarcloud.io/dashboard?id=guibranco_CEPAberto) | [](https://sonarcloud.io/dashboard?id=guibranco_CEPAberto) | [](https://sonarcloud.io/dashboard?id=guibranco_CEPAberto)## Code Quality
[](https://www.codacy.com/gh/guibranco/CEPAberto/dashboard?utm_source=github.com&utm_medium=referral&utm_content=guibranco/CEPAberto&utm_campaign=Badge_Grade)
[](https://www.codacy.com/gh/guibranco/CEPAberto/dashboard?utm_source=github.com&utm_medium=referral&utm_content=guibranco/CEPAberto&utm_campaign=Badge_Grade)[](https://codecov.io/gh/guibranco/CEPAberto)
[](https://www.codefactor.io/repository/github/guibranco/CEPAberto)[](https://codeclimate.com/github/guibranco/CEPAberto/maintainability)
[](https://codeclimate.com/github/guibranco/CEPAberto/test_coverage)[](https://sonarcloud.io/dashboard?id=guibranco_CEPAberto)
[](https://sonarcloud.io/dashboard?id=guibranco_CEPAberto)[](https://sonarcloud.io/dashboard?id=guibranco_CEPAberto)
[](https://sonarcloud.io/dashboard?id=guibranco_CEPAberto)[](https://sonarcloud.io/dashboard?id=guibranco_CEPAberto)
[](https://sonarcloud.io/dashboard?id=guibranco_CEPAberto)[](https://sonarcloud.io/dashboard?id=guibranco_CEPAberto)
[](https://sonarcloud.io/dashboard?id=guibranco_CEPAberto)---
## Installation
### Github Releases
[](https://github.com/guibranco/CEPAberto) [](https://github.com/guibranco/CEPAberto)
Download the latest zip file from the [Release](https://github.com/GuiBranco/CEPAberto/releases) page.
### Nuget package manager
| Package | Version | Downloads |
|------------------|:-------:|:-------:|
| **CEPAberto** | [](https://www.nuget.org/packages/CEPAberto/) | [](https://www.nuget.org/packages/CEPAberto/) |---
## Features
This client supports the following operations/features of the API V3:
1. Get data based on postal code (CEP).
2. Get data of a nearest geo location (lat/lon) (Max of 10km).
3. Get data based on state initials (UF), city, neighborhood and street/address.
4. Get list of cities of a state based on state initials.
5. Update the postal code (CEP).---
## Setup the CEPAbertoClient
Initializes a new instance of **CEPAbertoClient** class.
The API token can be found at [http://www.cepaberto.com/api_key](http://www.cepaberto.com/api_key) (A free registration is required!)```cs
var client = new CEPAbertoClient("my API token");
//var postalData = client.GetData("00000000");
//var cities = client.GetCities("SP");```
## Get data based on postal code (CEP)
Searches for a postal code data based on postal code
```cs
var client = new CEPAbertoClient("my API key");
var postalCode = "40010000";
var result = client.GetData(postalCode);if(result.Success)
{
Console.WriteLine("Postal data for the zip code {0} found!", postalCode);
Console.WriteLine("Lat: {0} | Lon: {1}", result.Latitude, result.Longitude);
}
else
Console.WriteLine("No data for the zip code {0} available", postalCode);```
### Get data of a nearest geo location (lat/lon) (Max of 10km)
Searches for the first postal code closest to the requested coordinates, limited to 10km (API limit, not library)
```cs
var client = new CEPAbertoClient("my API key");
var result = client.GetData("-20.55", "-43.63");if(result.Success)
Console.WriteLine("Postal code found: {0}", result.PostalCode);
else
Console.WriteLine("Unable to find a postal data for the coordinates supplied!");```
## Get data based on state initials (UF), city, neighborhood and street/address
Searches for a postal code data for the address supplied. Neighborhood and Street/Address are optional!
```cs
var client = new CEPAbertoClient("my API key");
var result = client.GetData("SP","Ubatuba");if(result.Success)
Console.WriteLine("Postal code found: {0}", result.PostalCode);
else
Console.WriteLine("Cannot find postal code for Ubatuba/SP");```
## Get list of cities of a state based on state initials
Get a list of cities for a given state (use state initials aka UF)
```cs
var client = new CEPAbertoClient("my API key");
var result = client.GetCities("AM");if(result.Success)
foreach(var city in result.Cities)
Console.WriteLine("Found city {0} in Amazonas (AM)", city.Name);```
## Update the postal code (CEP)
Request an update on postal codes that may be outdated or not registered.
Accepts upon 100 postal codes (CEP)```cs
var client = new CEPAbertoClient("my API key");
var result = client.Update("03177010");if(result.Success)
Console.WriteLine("Success on request update on postal code 03177-010");```