USDA Hardiness Zone API - Ruby Gem
Hardiness Zone is a simple tool for getting the USDA Plant Hardiness Zone for a given zip code
Installation
Add this line to your application's Gemfile:
gem 'apiverve_hardinesszone'
And then execute:
$ bundle install
Or install it yourself as:
$ gem install apiverve_hardinesszone
Getting Started
Get your API key at APIVerve
Basic Usage
require 'apiverve_hardinesszone'
# Initialize the client
client = APIVerve::Hardinesszone::Client.new(api_key: "YOUR_API_KEY")
# Make a request
response = client.execute({ zip: "97201" })
# Print the response
puts response
Error Handling
begin
response = client.execute({ zip: "97201" })
puts response["data"]
rescue APIVerve::Hardinesszone::ValidationError => e
puts "Validation error: #{e.errors.join(', ')}"
rescue APIVerve::Hardinesszone::APIError => e
puts "API error: #{e.}"
puts "Status code: #{e.status_code}"
end
Debug Mode
# Enable debug logging
client = APIVerve::Hardinesszone::Client.new(
api_key: "YOUR_API_KEY",
debug: true
)
Example Response
{
"status": "ok",
"error": null,
"data": {
"zipCode": "97201",
"zone": "8b",
"tempRange": "15 to 20",
"zoneTitle": "8b: 15 to 20",
"details": {
"tempRange": "15°F to 20°F (-9°C to -7°C)",
"description": "Mild and relatively warm, found in parts of southern U.S. like the Gulf Coast and parts of Texas.",
"plantSurvival": "A wide range of plants, including many Mediterranean and subtropical varieties."
}
}
}
Documentation
For more information, visit the API Documentation.
Support
- Website: https://hardinesszone.apiverve.com?utm_source=ruby&utm_medium=readme
- Email: hello@apiverve.com
License
This gem is available under the MIT License.