Postjoy
Postal codes made easy
Get Started
Add this line to your application’s Gemfile:
gem 'postjoy'
Lookup postal code
Postjoy.find(94109)
# =>
{
city: "San Francisco",
state: "California",
state_code: "CA",
latitude: 37.7917,
longitude: -122.4186
}
Returns nil
if the postal code does not exist
Validations
Also adds validations for Rails
class Address < ActiveRecord::Base
validates :postal_code, postal_code: true
end
Credit
Data from GeoNames
TODO
- international postal codes
Contributing
Everyone is encouraged to help improve this project. Here are a few ways you can help:
- Report bugs
- Fix bugs and submit pull requests
- Write, clarify, or fix documentation
- Suggest or add new features
To update postal codes, download the updated list from GeoNames to US.txt
and run:
rake create