CEP Aberto SDK (.NET)

Logo

🇧🇷 📍 CEPAberto API client wrapper for .NET projects

View the Project on GitHub guibranco/CEPAberto

CEP Aberto SDK .NET

CEP Aberto API wrapper written in C# (.NET).

Implements all V3 features

GitHub license time tracker

CEPAberto

CI/CD

Build status Last commit Tests Coverage Code Smells LOC
Build status GitHub last commit AppVeyor tests (branch) Coverage Code Smells Lines of Code

Code Quality

Codacy Badge Codacy Badge

codecov CodeFactor

Maintainability Test Coverage

Quality Gate Status Maintainability Rating

Technical Debt Duplicated Lines (%)

Reliability Rating Security Rating

Bugs Vulnerabilities


Installation

Github Releases

GitHub last release Github All Releases

Download the latest zip file from the Release page.

Nuget package manager

Package Version Downloads
CEPAberto CEPAberto NuGet Version CEPAberto NuGet Downloads

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 (A free registration is required!)


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


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)


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!


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)


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)


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");