andreaskastl / openweatherapi
Displays a weather forecast from the Open-Meteo API in TYPO3 frontend.
Package info
github.com/andreaskastl/openweatherapi
Language:HTML
Type:typo3-cms-extension
pkg:composer/andreaskastl/openweatherapi
Requires
- php: ^8.2 || ^8.3 || ^8.4 || ^8.5
- typo3/cms-core: ^13.4 || ^14.3
Requires (Dev)
None
Suggests
None
Provides
None
Conflicts
None
Replaces
- typo3-ter/openweatherapi: 6.0.0
README
Displays daily weather forecasts for today and the next two or seven days from Open-Meteo in a TYPO3 frontend. The extension supports both the free Open-Meteo API for non-commercial use and the commercial Customer API.
Requirements
- TYPO3 13.4 or 14.3+
- PHP 8.2+
- Outbound HTTPS access from the TYPO3 web server to the selected Open-Meteo API
- Bootstrap 5 CSS for the frontend layout. The interactive 8-day tabs require the Bootstrap JavaScript bundle. The extension does not bundle Bootstrap; themes such as the TYPO3 Bootstrap Package can provide these assets.
Installation
Install the extension as usual with Composer or the TYPO3 Extension Manager.
For TYPO3 13.4 and 14, activate the Openweather API site set in Sites > Setup, or add it as a dependency in config/sites/<site-identifier>/config.yaml:
dependencies: - andreaskastl/openweatherapi
The site set automatically loads the extension's TypoScript setup and constants for that site. Existing installations remain compatible with the legacy Openweather API - Weather Forecast static TypoScript include in a sys_template record. Both load the same defaults. Use either the site set or the legacy static include, not both; remove the static include after activating the site set.
Site sets are supported starting with TYPO3 13.1, so this set works with the extension's supported TYPO3 13.4 and 14 releases. See the TYPO3 Site Sets documentation for details.
Upgrading existing installations
Before upgrading to TYPO3 14, run the Migrate Openweather API plugins to content elements upgrade wizard in the TYPO3 Install Tool if the installation still uses the previous list plugin content elements. The wizard migrates the content element type and backend group restrictions.
Configure the forecast plugin
Add the Weather Forecast content element. In the plugin settings:
- Select the API usage mode:
- Free API:
api.open-meteo.com; only for non-commercial use. - Commercial API:
customer-api.open-meteo.com; requires an Open-Meteo commercial API subscription and API key.
- Free API:
- Enter latitude and longitude as decimal degrees (for example,
52.52and13.405). - Save the content element.
In the backend, plugin settings are grouped into the General, Attributes to display, and Additional settings tabs.
The plugin settings are:
apiMode: API usage mode:free:api.open-meteo.com, for non-commercial use only.commercial:customer-api.open-meteo.com, requires a commercial subscription and API key.
latitudeandlongitude: location coordinates in decimal degrees.template: forecast layout:threeDay(FlexForm label: 2-day forecast (today + next 2 forecast days); compact, three-date layout): today plus the following two days in three panels labeled Today, Tomorrow, and Day after tomorrow. Today represents the daily forecast, not a live current-conditions observation.eightDay(default; FlexForm label: 8-day forecast (today + next 7 forecast days)): eight responsive day tabs above a summary grid and detail tabs. Temperature, precipitation, and wind curves plot the full local day with hourly values; axis labels and point values are shown every three hours from 02:00 to 23:00, with units shown beside chart values. Displayed temperatures and wind speeds are rounded to whole numbers.
iconStyle: Meteocons SVG style:flat(default),fill,line, ormonochrome.temperatureUnit:celsius(default) orfahrenheit.windSpeedUnit:kmh(default),ms,mph, orkn.precipitationUnit:mm(default) orinch. Open-Meteo applies this choice to precipitation, rain, showers, and snowfall amounts.timezone:auto(default; use the location's timezone),GMT, or one of the configured IANA timezones:Europe/Berlin,Europe/Vienna,Europe/Zurich,Europe/London,Europe/Paris,America/New_York,America/Chicago,America/Denver,America/Los_Angeles,Asia/Tokyo,Asia/Shanghai,Asia/Kolkata,Australia/Sydney. The chosen timezone determines the forecast dates, hourly humidity aggregation, sunrise, and sunset times.- Display options (
1= show,0= hide):- Enabled by default:
showWeather(description and icon),showTemperature(all temperature values and the 8-day temperature chart),showWindSpeed(daily maximum and 8-day wind chart),showWindDirection(daily direction and 8-day hourly arrows),showPrecipitationProbability,showPrecipitationAmount(daily total and 8-day chart),showHumidity(relative humidity). - Disabled by default:
showWeatherCode,showApparentTemperature,showWindGusts,showUvIndex,showSunshineDuration,showRainAmount,showShowersAmount,showSnowfallAmount,showSunrise,showSunset.
- Enabled by default:
When no display attributes are selected, each layout retains its date/navigation headings and shows a notice instead of an empty attribute area.
The API request includes daily data for today and the following seven days; the compact layout displays only the first three dates. Relative humidity is requested hourly and averaged by the selected timezone's calendar date. The selected units apply to all relevant forecast values; snowfall units follow Open-Meteo's precipitation unit response. Sunshine duration is returned in minutes.
API usage and commercial access
The free API is for non-commercial use only, is limited to 10,000 requests per day, and has no uptime guarantee. Commercial sites must use the Customer API with an appropriate Open-Meteo subscription and API key. Check the current pricing and API usage terms before choosing a mode. The Forecast API documentation describes the available data.
For commercial mode, configure the API key in your site-specific TypoScript. This works with either the site set or the legacy static TypoScript include:
plugin.tx_openweatherapi.settings {
apiMode = commercial
apiKey = YOUR_OPEN_METEO_API_KEY
}
Do not put the real key in the extension's tracked setup.typoscript or commit it to source control. Restrict access to the site-specific TypoScript file or record, and use your deployment's secret-management process when supplying the key. It is used only for commercial API requests and is not assigned to the frontend template.
Page cache and API request frequency
The weather plugin is cacheable. Keep page caching enabled for the page that contains it: on a cache hit, TYPO3 serves the rendered page without calling Open-Meteo again. After the cache expires or is cleared, the next request renders the page again and fetches a fresh forecast.
To control how often the forecast can refresh:
- In the TYPO3 backend, open the page containing the plugin and edit its page properties.
- Under Behaviour > Cache, set the page's cache lifetime (
cache_timeout). For example, a one-hour lifetime lets the next request after expiry fetch a fresh forecast, if the page is visited. - Save the page. If you need the new setting to take effect immediately, clear the page cache once.
A shorter lifetime can provide fresher data but may cause more API requests; a longer lifetime reduces API traffic but keeps the displayed forecast unchanged for longer. Cache clearing or other page changes can also cause an earlier API request.
As a site-wide TypoScript default, config.cache_period can be set in seconds, for example config.cache_period = 3600 for one hour. A positive cache_timeout on an individual page overrides this default. See the TYPO3 documentation for page caching and config.cache_period.
Attribution and weather icons
Open-Meteo data are published under CC BY 4.0. The rendered forecast credits Open-Meteo, links to the licence, and indicates when values may be converted or rounded for display.
Weather icons are local static SVG assets from Meteocons, package version @meteocons/svg-static 0.1.0. Only the 22 icons used by the weather-code mapping are included in each of the four styles (fill, flat, line, monochrome) under Resources/Public/Icons/meteocons/. Choose a style in the plugin's Additional settings.
The mapping uses severity-specific symbols where available. Freezing drizzle and rain use the sleet symbol because Meteocons has no dedicated freezing-precipitation icon; the weather descriptions retain the precise condition. The upstream MIT licence is included at Resources/Public/Icons/meteocons/LICENSE.
Custom templates
The site set loads the extension defaults. To override templates in a site package, add its template, partial, or layout paths after the extension paths in the site's TypoScript setup. For example, using a higher path index makes the site package template take precedence:
plugin.tx_openweatherapi.view.templateRootPaths.10 = EXT:my_site_package/Resources/Private/Extensions/Openweatherapi/Templates/
plugin.tx_openweatherapi.view.partialRootPaths.10 = EXT:my_site_package/Resources/Private/Extensions/Openweatherapi/Partials/
plugin.tx_openweatherapi.view.layoutRootPaths.10 = EXT:my_site_package/Resources/Private/Extensions/Openweatherapi/Layouts/
Both layouts receive forecast records in api.forecast.date. Each record contains:
d: date.weekday: localized short weekday label (available ineightDay).weekday_long: localized full weekday name (available ineightDay).wc: WMO weather code.w: local icon filename.w_txt: localized weather description.tn/tx: minimum / maximum temperature at the API's precision.temperature_average: average hourly temperature, rounded to a whole number, for the selected local calendar day (available ineightDay).temperature_min_rounded/temperature_max_rounded: minimum / maximum temperatures rounded to whole numbers (available in both layouts).temperature_unit: unit for temperature and apparent temperature values.atn/atx: minimum / maximum apparent temperature at the API's precision.apparent_temperature_min_rounded/apparent_temperature_max_rounded: minimum / maximum apparent temperatures rounded to whole numbers (available in both layouts).ws: maximum wind speed at the API's precision.wind_speed_max_rounded: maximum daily wind speed rounded to a whole number (available in both layouts).wind_speed_unit: unit for wind speed and gust values.wd_txt: dominant wind direction in degrees.wd: dominant wind direction in degrees for the eight-day layout's direction arrow.wg: maximum wind gusts at the API's precision.wind_gusts_max_rounded: maximum wind gusts rounded to a whole number (available in both layouts).pc: maximum precipitation probability.ps: daily total precipitation amount.precipitation_unit: unit for precipitation, rain, and showers.rs: rain amount.shs: showers amount.sn: snowfall amount.snowfall_unit: unit for snowfall.uv: maximum UV index.sd: sunshine duration in minutes.rh: average relative humidity for the local calendar day.sr/ss: local sunrise / sunset times.temperature_curve: SVG polyline coordinates for the full hourly temperatures (available ineightDay).precipitation_curve: SVG polyline coordinates for hourly precipitation (available ineightDay).wind_curve: SVG polyline coordinates for hourly wind speed (available ineightDay).hourly_wind: hourly time, rounded temperature and wind speed values, precipitation amount and probability, localized weather description and icon, wind direction, chart-point coordinates, and flags for 3-hour axis labels and values (available ineightDay).
The settings.show… values listed above control whether the selected layout renders the corresponding attribute. settings.strftime controls the forecast date heading format using PHP date format tokens (for example l, d.m.Y); the timezone setting controls the dates and times returned by Open-Meteo.
The eightDay template also receives current conditions in api.forecast.current, including current temperature, weather description and icon, apparent temperature, wind speed and direction, precipitation, humidity, and observation time. apparent_temperature_rounded is the current apparent temperature rounded to a whole number. For this layout, the API request adds hourly temperature, weather code, precipitation amount and probability, wind speed, wind direction, and relative humidity, plus current conditions. Other layouts request hourly relative humidity only; they do not request current conditions or the chart data.
To customize the date format, set plugin.tx_openweatherapi.settings.strftime, for example:
plugin.tx_openweatherapi.settings.strftime = l, d.m.Y