Simple gem to get the city, state, and time zone for a given US zip code.
This is a fork of monterail/zip-codes. The upstream gem stores its data as YAML, which takes several hundred milliseconds to parse on first load. This fork stores the same data as JSON, which loads roughly an order of magnitude faster. The public API is unchanged.
The gem supports only US zip codes. The data origin is
https://download.geonames.org/export/zip/ (GeoNames, licensed
CC BY 4.0).
lib/data/US.json was converted from upstream's lib/data/US.yml as of
upstream version 0.3.7.
This gem is not published to RubyGems. Add it to your Gemfile as a git source:
gem 'zip-codes', github: 'PhotoDay/zip-codes'ZipCodes.identify('30301')
# => {:state_code=>"GA", :state_name=>"Georgia", :city=>"Atlanta", :time_zone=>"America/New_York"}The database is parsed lazily on first use. To pay that cost at boot instead (for example, before a preforking server forks its workers), call:
ZipCodes.loadMIT — see LICENSE.txt.