Skip to main content

Integration of Weather City Forecasts Manager in Wagtail Projects.

Project description

Developer Guide: Adding City Forecasts to ClimWeb

This guide explains three ways to add city forecast data to ClimWeb, and how to retrieve forecasts via the read API (see Retrieving Forecast Data). For a more hands-on guide visit the Forecast Manager Guide:


1. Using the API

Endpoint

  • POST /api/forecasts/post

Authentication

  • Requires Token.
  • Obtain a token via POST to /api/token/ (TokenAuthentication) with payload
{
    "username":"your_username",
    "password":"your_password"
}
  • Add header: Authorization: Token <token>

Payload Example

{
  "forecast_date": "2026-03-11",
  "effective_time": "06:00:00",
  "source": "local",
  "replace_existing": true,
  "city_forecasts": [
    {
      "city": "nairobi",
      "condition": "Partly Cloudy",
      "data_values": {
        "max_temp": 28.5,
        "min_temp": 18.2,
        "humidity": 64
      }
    }
  ]
}

Example Python Script

import requests
API_URL = "http://<domain_name>/api/forecasts/post"
TOKEN = "your_token_here"
payload = { ... }
headers = {"Authorization": f"Token {TOKEN}", "Content-Type": "application/json"}
response = requests.post(API_URL, json=payload, headers=headers)
print(response.status_code)
print(response.json())

2. Automated City Forecast from Meteorological Providers

  • This is simply implemented by enabling the automated forecasts checkbox under Forecast Settings > Forecast Source, then choosing a forecast provider. The forecast is updated automatically every three hours and has a 1 hour time interval (24 readings in a day).
  • Two providers are supported:
    • yr.no (Meteorological Norway)source value yr.
    • Open-Meteosource value open_meteo.
  • Each provider exposes its own set of source fields (e.g. air temperature, humidity, wind speed, precipitation) which an admin maps onto local forecast parameters under the parameter-mapping settings.

To read more about the providers visit:


3. Manual CSV Upload

  • Use the admin interface or dedicated upload page to upload city forecast data via CSV. Visit guide here.
  • Download the CSV template .
  • Fill in city forecast data in the template.
  • Upload the CSV file using the web interface (typically via a form).
  • The system will parse, validate, and import the data.
  • Optionally, set 'overwrite existing' if you want to replace previous forecasts.

Retrieving Forecast Data (Read API)

All read endpoints serve published forecasts only (drafts are withheld until reviewed) and are publicly accessible — no token required.

Method & Endpoint Description
GET /api/cities List cities. Optional ?name= filter (case-insensitive contains).
GET /api/forecasts All published forecasts as GeoJSON. Optional ?forecast_date= and ?effective_period= filters.
GET /api/forecast_mobile Single nearest-city forecast in Met Norway timeseries format (see below).
GET /api/forecast-settings Configured data parameters and effective periods.
GET /api/weather-icons Available weather condition icons with full URLs.
GET /api/forecast_template.csv Download the CSV upload template.

Mobile Forecast Endpoint

  • GET /api/forecast_mobile?lat=<lat>&lon=<lon>

Returns the forecast for the city nearest to the supplied coordinates, structured like the Met Norway location forecast model. The lat/lon query parameters are required and are matched to the closest stored city. Each timeseries step carries only:

  • time — the forecast's effective datetime (UTC).
  • data.instant.details — the city's forecast data values.
  • data.next_1_hours.summary.symbol_code — the weather condition symbol.

The meta block reports whether the match was the exact city or the nearest one, plus the unit for each parameter.

Example Response

{
  "type": "Feature",
  "geometry": {
    "type": "Point",
    "coordinates": [35.05, -15.04]
  },
  "properties": {
    "meta": {
      "updated_at": "2026-06-25T09:00:00Z",
      "city": "Lilongwe",
      "location_source": "nearest",
      "location_description": "Forecast for the nearest city (Lilongwe).",
      "units": {
        "air_temperature": "°C",
        "cloud_area_fraction": "%",
        "precipitation_amount": "mm",
        "wind_from_direction": "degrees",
        "wind_speed": "m/s"
      }
    },
    "timeseries": [
      {
        "time": "2026-06-25T06:00:00Z",
        "data": {
          "instant": {
            "details": {
              "air_temperature": 20.5,
              "wind_speed": 2.3
            }
          },
          "next_1_hours": {
            "summary": { "symbol_code": "clearsky_day" }
          }
        }
      }
    ]
  }
}

Note: lat is treated as latitude and lon as longitude. The units and symbol_code values reflect how each parameter and weather condition is configured in the admin.


Notes

  • All methods require valid city and parameter references.
  • For API and automated methods, ensure authentication is set up.
  • For manual upload, follow the template format and check for errors after upload.
  • All weather symbols used are from yr.no

For further details, see the API documentation .

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

forecastmanager-0.6.4.tar.gz (3.7 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

forecastmanager-0.6.4-py3-none-any.whl (3.6 MB view details)

Uploaded Python 3

File details

Details for the file forecastmanager-0.6.4.tar.gz.

File metadata

  • Download URL: forecastmanager-0.6.4.tar.gz
  • Upload date:
  • Size: 3.7 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for forecastmanager-0.6.4.tar.gz
Algorithm Hash digest
SHA256 092908d311ce59d638db32e714e4eb05b58084ef279e6da4b4016844aa2b096e
MD5 96b05819dbd3f5dd6c5f693a266f77b6
BLAKE2b-256 c575d9155cd88df3f7daf9a7433295db56a3398caf95bf378569069b0fdf326d

See more details on using hashes here.

Provenance

The following attestation bundles were made for forecastmanager-0.6.4.tar.gz:

Publisher: publish.yml on wmo-raf/forecastmanager

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file forecastmanager-0.6.4-py3-none-any.whl.

File metadata

File hashes

Hashes for forecastmanager-0.6.4-py3-none-any.whl
Algorithm Hash digest
SHA256 4d4080a80d587917ea5df937fa49ab41bf24fe7388bcfb53401d1e2712f9a4e2
MD5 c5fccec3a44097569b0ecd95841433df
BLAKE2b-256 26ff0e01181cbbd705d163d23b868a6aeca5725699a4ade4f5df2376b1b0d3a5

See more details on using hashes here.

Provenance

The following attestation bundles were made for forecastmanager-0.6.4-py3-none-any.whl:

Publisher: publish.yml on wmo-raf/forecastmanager

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page