Zip Codes Lookup finds all postal codes within a US city or resolves a five-digit ZIP code to its city and state. Every ZIP also returns its primary county. Paid plans add the county and state FIPS codes, every county a ZIP crosses with its land share, 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",
"county": "Jackson County",
"countyFips": "29095",
"stateFips": "29",
"counties": [
{
"name": "Jackson County",
"fips": "29095",
"landShare": 0.9077
},
{
"name": "Cass County",
"fips": "29037",
"landShare": 0.0923
}
],
"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.