zipcode_locator

Get Zipcodes and Location info by using ZipCode APIs.

Usage

To use this gem, first you need to register your application at Zipcode API.

visit zipcodeapi registration, give your application name and email, then obtain an apikey which can be used to communicate with zipcode apis.

apikey = "xxxxxxxx"

then,

gem install zipcode_locator

initialize zipcode_locator object with this apikey

@object = ZipcodeLocator.new(apikey)

Zipcode Locator methods

zipcode_locator supports different units and reposnse formats, To get repsonse in particular format with a particulat unit, you can pass these as an optional parameter.

optional parameter includes unit and format for the request.

unit can be any of these availble units
    unit   : 'km', 'mile', 'degree', and 'radians'
and
    format : 'json', 'xml', and 'csv'

options = { :unit => "km", :format => "json" }

Zipcode Distance

zipcode1 = 10001
zipcode2 = 10005

@object.distance_between_zipcodes(zipcode1, zipcode2, options)

Zipcodes By Radius

zipcode = 10001
radius = 5

@object.get_zipcodes_by_radius(zipcode, radius, options)

Find close Zipcodes

zipcodes = "10001, 10005"

or zipcodes = [10001, 10005] distance = 5

@object.find_close_zipcodes(zipcodes, distance, options)

Zipcode to Location info

zipcode = 10005

@object.zipcode_location_info(zipcode, options)

Multi Zipcodes to Location info

zipcodes = "10001, 10005"

or zipcodes = [10001, 10005]

@object.multi_zipcodes_location_info(zipcodes, options)

Location to Zipcodes

city = "Brooklyn"
state = "NY"

@object.get_zipcodes_by_locations(city, state, options)

Run Tests

rake test