Petrel
A RubyGem wrapp for OpenWeatherMap's Free API
Installation
gem install petrel
or in your Gemfile...
gem 'petrel'
Configuration
You will need to set your OpenWeather api_key
before making requests. You can get one here.
Petrel.configure do |c|
c.api_key = 'YOUR_API_KEY'
end
Alternatively, you can do:
Petrel.api_token = 'YOUR_API_TOKEN'
Usage / Examples
Once configured, you have access to the below methods. They correspond to the available endpoints, listed on OpenWeatherMap's API.
query = { q: 'San Francisco' }
Petrel.forecat(query)
query = { lat: 37, lon: -122 }
Petrel.one_call(query)
query = { lat: 37, lon: -122 }
Petrel.weather(query)
Full documentation on what can be in query
can be found in OpenWeatherMap's API documentation here.