# Correios CEP
[](https://hex.pm/packages/correios_cep)
[](https://hexdocs.pm/correios_cep)
[](https://travis-ci.org/prodis/correios-cep-elixir)
[](https://coveralls.io/github/prodis/correios-cep-elixir?branch=master)
[](LICENSE)

Find Brazilian addresses by zip code, directly from Correios API. No HTML parsers.
## Installation
The package can be installed by adding `correios_cep` to your list of dependencies in `mix.exs`:
```elixir
def deps do
[
{:correios_cep, "~> 0.3.0"}
]
end
```
## Usage
```elixir
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("54250610", request_timeout: 3000)
{: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!("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 timeouts and URL are supported. Check the
[`Correios.CEP.find_address/2`](https://hexdocs.pm/correios_cep/Correios.CEP.html#find_address/2)
documentation to see all available options as well as their default values.
## Documentation
The full documentation is available at [https://hexdocs.pm/correios_cep](https://hexdocs.pm/correios_cep).
## Contributing
See the [contributing guide](https://github.com/prodis/correios-cep-elixir/blob/master/CONTRIBUTING.md).
## License
Correios CEP is released under the Apache 2.0 License. See the [LICENSE](https://github.com/prodis/correios-cep-elixir/blob/master/LICENSE) file.
Copyright © 2018-2020 Fernando Hamasaki de Amorim
## Author
[Fernando Hamasaki de Amorim (prodis)](https://github.com/prodis)
