Project

viacep

0.01
No release in over 3 years
Low commit activity in last 3 years
Gem sem dependências e fácil de usar para busca de endereços a partir do CEP utilizando o ViaCEP
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 3.7
~> 3.8.3
 Project Readme

viacep Tests GitHub license

Dependency-less zipcode lookup gem for Brazilian addresses with an easy-to-use API and useful features such as timeout.

Installing

You can easily install viacep through RubyGems:

gem install viacep
=> Rock on! 🚀

or add the following to your Gemfile:

gem "viacep"

Usage

require 'viacep'

# with unformatted zipcodes... =)
ViaCep::Address.new('80210130')
=> #<ViaCep::Address:0x00007fe52a8a0568 @cep="80210-130", @address="Rua José Ananias Mauad", @neighborhood="Jardim Botânico", @city="Curitiba", @state="PR", @ibge="4106902", @gia="">

# with formatted zipcodes... =)
ViaCep::Address.new('13035-680')
=> #<ViaCep::Address:0x00007fe52a99e730 @cep="13035-680", @address="Avenida João Jorge", @neighborhood="Vila Industrial", @city="Campinas", @state="SP", @ibge="3509502", @gia="2446">

# or even an nonexistent zipcode... =(
ViaCep::Address.new('12345678')
=> exception thrown: ViaCep::ApiRequestError

# and specifying a timeout in seconds... =)
ViaCep::Address.new('80210130', timeout: 0.2)
=> exception thrown: Timeout::Error (execution expired)

Docs

The documentation is available on RubyDoc. Starting on ViaCep::Address might be a good start.

Contributing

  1. Create a fork (https://github.com/vnbrs/viacep/fork)
  2. Create a branch (git checkout -b my-new-feature)
  3. Make a commit (git commit -am 'Add some feature')
  4. Push your code (git push origin my-new-feature)
  5. Create a Pull Request
  6. Thanks! 🤙🏼