🇧🇷 📍 CEPAberto API client wrapper for .NET projects
CEP Aberto API wrapper written in C# (.NET).
Implements all V3 features
Build status | Last commit | Tests | Coverage | Code Smells | LOC |
---|---|---|---|---|---|
Download the latest zip file from the Release page.
Package | Version | Downloads |
---|---|---|
CEPAberto |
This client supports the following operations/features of the API V3:
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");
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);
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!");
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 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);
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");