Zip Codes Lookup finds all postal codes within a US city or resolves a five-digit ZIP code to its city and state. Paid plans add the IANA time zone, geographic coordinates and the distance from the ZIP to a second ZIP.
Add this line to your application's Gemfile:
gem 'apiverve_zipcodes'And then execute:
$ bundle installOr install it yourself as:
$ gem install apiverve_zipcodesGet your API key at APIVerve
require 'apiverve_zipcodes'
# Initialize the client
client = APIVerve::Zipcodes::Client.new(api_key: "YOUR_API_KEY")
# Make a request
response = client.execute({
zip: "64082",
distanceTo: "64106"
})
# Print the response
puts responsebegin
response = client.execute({ zip: "64082", distanceTo: "64106" })
puts response["data"]
rescue APIVerve::Zipcodes::ValidationError => e
puts "Validation error: #{e.errors.join(', ')}"
rescue APIVerve::Zipcodes::APIError => e
puts "API error: #{e.message}"
puts "Status code: #{e.status_code}"
end# Enable debug logging
client = APIVerve::Zipcodes::Client.new(
api_key: "YOUR_API_KEY",
debug: true
){
"status": "ok",
"error": null,
"data": {
"zipcode": "64082",
"state_abbr": "MO",
"latitude": "38.850243",
"longitude": "-94.39570",
"city": "Lees Summit",
"state": "Missouri",
"timezone": "America/Chicago",
"distance": {
"zipcode": "64106",
"city": "Kansas City",
"state_abbr": "MO",
"miles": 19.94,
"kilometers": 32.09
}
}
}For more information, visit the API Documentation.
- Website: https://apiverve.com/marketplace/zipcodes?utm_source=ruby&utm_medium=referral&utm_content=readme
- Email: hello@apiverve.com
This gem is available under the MIT License.