Integrate weather information from any location right into your Craft CMS 3 website
This plugin requires Craft CMS 3 or later and an active API key from openWeathermap.org
Access the weather information via TWIG functions or AJAX calls. You can choose between simplified and raw representation of weather data. Weather data is stored in your database and only updates when refresh interval has passed in order to save bandwidth and improve performance.
- Fill in the openWeathermap API key to use the plugin.
- Setup the refresh interval (minutes) to setup when weather should be updated.
- Use a default location (latitude, longitude) to get the weather.
There are two ways to use the plugin, via twig functions and HTTP requests.
craft.openWeather.simplified(lat, lon)
Given a latitude and longitude returns the simplified version of weather (array).craft.openWeather.raw(lat, lon)
Given a latitude and longitude returns the raw version of weather (array).craft.openWeather.defaultLocation()
Returns the latitude and longitude (as array) of the default location setup in the settings.
/api/openWeather/lat-lon/<latitude>,<latitude>,<label>
Given a latitude and longitude returns the simplified version of weather data; optionally pass a label parameter to set a custom label for the given location./api/openWeather/default
Returns the simplified version of weather data of the default location as setup in the settings./api/openWeather/raw/lat-lon/<latitude>,<latitude>,<label>
Given a latitude and longitude returns the raw version of weather data; optionally pass a label parameter to set a custom label for the given location./api/openWeather/raw/default
Returns the raw version of weather data of the default location as setup in the settings
Request
GET /api/openWeather/default
Response
{
"status": "clear",
"temperature": 22.30,
"city": "Jordaan",
"label": "Amsterdam",
"country_iso": "NL",
"clear": true,
"partial-clear": false,
"clouds": false,
"hot": false,
"mist": false,
"rain": false,
"thunderstorm": false,
"snow": false,
"ice": false,
"wind": false,
"wind_direction": "S",
"text": "Clear",
"day": true,
"night": false
}
Request
GET /api/openWeather/raw/default
Response
{
"status": "Clear",
"city": "Jordaan",
"label": "Amsterdam",
"country_iso": "NL",
"temperature": 22,
"humidity": 56,
"visibility": 10000,
"wind_speed": 3,
"wind_direction": 170,
"sunrise": "2018-10-16T08:08:24+02:00",
"sunset": "2018-10-16T18:42:41+02:00"
}
Made with ❤️ by Bolden and free to use!