https://github.com/prodis/correios-cep-elixir
Find Brazilian addresses by postal code, directly from Correios API. No HTML parsers.
https://github.com/prodis/correios-cep-elixir
cep correios correios-cep elixir elixir-lang prodis zipcode
Last synced: 7 days ago
JSON representation
Find Brazilian addresses by postal code, directly from Correios API. No HTML parsers.
- Host: GitHub
- URL: https://github.com/prodis/correios-cep-elixir
- Owner: prodis
- License: apache-2.0
- Created: 2018-11-12T08:16:38.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2020-10-03T16:54:15.000Z (over 4 years ago)
- Last Synced: 2025-03-29T02:12:21.041Z (24 days ago)
- Topics: cep, correios, correios-cep, elixir, elixir-lang, prodis, zipcode
- Language: Elixir
- Homepage:
- Size: 102 KB
- Stars: 38
- Watchers: 2
- Forks: 4
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
- freaking_awesome_elixir - Elixir - Find Brazilian addresses by zip code, directly from Correios database. No HTML parsers. (Third Party APIs)
- fucking-awesome-elixir - correios_cep - Find Brazilian addresses by zip code, directly from Correios database. No HTML parsers. (Third Party APIs)
- awesome-elixir - correios_cep - Find Brazilian addresses by zip code, directly from Correios database. No HTML parsers. (Third Party APIs)
README
# 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 postal code, directly from Correios API. No HTML parsers.
## DEPRECATION NOTE
`Correios.CEP.Address.zipcode` was removed in the version `0.6.0`. Use `Correios.CEP.Address.postal_code` instead.
## 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.7.0"}
]
end
```## Usage
```elixir
iex> Correios.CEP.find_address("54250610")
{:ok,
%Correios.CEP.Address{
street: "Rua Fernando Amorim",
neighborhood: "Cavaleiro",
complement: "",
city: "Jaboatão dos Guararapes",
state: "PE",
postal_code: "54250610"
}}iex> Correios.CEP.find_address("00000-000")
{:error,
%Correios.CEP.Error{
type: :postal_code_not_found,
message: "Postal code not found",
reason: "CEP NAO ENCONTRADO"
}}iex> Correios.CEP.find_address!("54250-610")
%Correios.CEP.Address{
street: "Rua Fernando Amorim",
neighborhood: "Cavaleiro",
complement: "",
city: "Jaboatão dos Guararapes",
state: "PE",
postal_code: "54250610"
}iex> Correios.CEP.find_address!("00000-000")
** (Correios.CEP.Error) Postal code not found
```### Options
There are some supported options that can be added to the request, as timeouts, proxy and URL
configuration.The example below shows the use of `request_timeout` and `proxy` options:
```elixir
iex> Correios.CEP.find_address("54250610", request_timeout: 3000, proxy: {"localhost", 8888})
{:ok,
%Correios.CEP.Address{
street: "Rua Fernando Amorim",
neighborhood: "Cavaleiro",
complement: "",
city: "Jaboatão dos Guararapes",
state: "PE",
postal_code: "54250610"
}}
```See [`Correios.CEP.find_address/2`](https://hexdocs.pm/correios_cep/Correios.CEP.html#find_address/2)
documentation to check the details of the available options.## 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)
