Correios CEP

Hex.pm Docs Build Status Coverage Status License

Find Brazilian addresses by zip code, directly from Correios database. No HTML parsers.

Installation

The package can be installed by adding correios_cep to your list of dependencies in mix.exs:

def deps do
  [{:correios_cep, "~> 0.1"}]
end

Usage

iex> Correios.CEP.find_address("54250610")
{:ok,
 %Correios.CEP.Address{
   city: "Jaboatão dos Guararapes",
   complement: "",
   neighborhood: "Cavaleiro",
   state: "PE",
   street: "Rua Fernando Amorim",
   zipcode: "54250610"
 }}

iex> Correios.CEP.find_address("00000-000")
{:error, %Correios.CEP.Error{reason: "CEP NAO ENCONTRADO"}}

iex> Correios.CEP.find_address!("54250-610")
%Correios.CEP.Address{
  city: "Jaboatão dos Guararapes",
  complement: "",
  neighborhood: "Cavaleiro",
  state: "PE",
  street: "Rua Fernando Amorim",
  zipcode: "54250610"
}

iex> Correios.CEP.find_address!("00000-000")
** (Correios.CEP.Error) CEP NAO ENCONTRADO

Options

Options for timeout are supported.

Consult the full documentation at https://hexdocs.pm/correios_cep.

Contributing

See the contributing guide.

License

Correios CEP is released under the Apache 2.0 License. See the LICENSE file.

Author

Fernando Hamasaki de Amorim (prodis)

Prodis Logo