OpenWeatherMapAPI - Ruby API Client

Get Weather and Forecast for the city you want easily.

Installation

Add this line to your application's Gemfile:

gem 'open_weather_map_api'

And then execute:

$ bundle install

Usage Examples

Get weather by city

OpenWeatherMapApi.get_weather(q: 'florianopolis', appid: <APPID>)

Get weather by latitude an longitude

OpenWeatherMapApi.get_weather(lat: '51.5085', lon: '-0.1257', appid: <APPID>)

Get forecast by city

OpenWeatherMapApi.get_forecast(q: 'florianopolis', appid: <APPID>)

Get forecast by latitude an longitude

OpenWeatherMapApi.get_forecast(lat: '51.5085', lon: '-0.1257', appid: <APPID>)

Get weather in Celsius

OpenWeatherMapApi.get_weather(q: 'florianopolis', units: 'metric', appid: <APPID>)

Get weather in Fahrenheit

OpenWeatherMapApi.get_weather(q: 'florianopolis', units: 'imperial', appid: <APPID>)

Get weather response in Portuguese

OpenWeatherMapApi.get_weather(q: 'florianopolis', lang: 'pt_br', appid: <APPID>)

Get weather response format in xml

OpenWeatherMapApi.get_weather(q: 'florianopolis', mode: 'xml', appid: <APPID>)

Get weather response format in html

OpenWeatherMapApi.get_weather(q: 'florianopolis', mode: 'html', appid: <APPID>)

Props

Weather

Prop Type Default Note
lat, lon string required Geographical coordinates (latitude, longitude)
appid string required Your unique API key. Learn more
mode json, xml, html json Response format
units standard, metric, imperial standard Units of measurement: standard: Kelvin, metric: Celsius, imperial: Fahrenheit
lang string en You can use this parameter to get the output in your language. Learn more

Forecast

Prop Type Default Note
lat, lon string required Geographical coordinates (latitude, longitude)
appid string required Your unique API key. Learn more
mode json, xml, html json Response format
units standard, metric, imperial standard Units of measurement: standard: Kelvin, metric: Celsius, imperial: Fahrenheit
lang string en You can use this parameter to get the output in your language. Learn more
cnt string optional A number of timestamps, which will be returned in the API response