DMI Weather API

Danish Meteorological Institute Weather Data Proxy

API Documentation

This API provides access to current weather, forecasts, and historical weather data from the Danish Meteorological Institute (DMI).

GET /api/weather/current/{location}

Get current weather conditions for a specified location in Denmark.

Path Parameters

Parameter Type Description
location string City name, postal code, or coordinates (lat,lon)

Query Parameters

Parameter Type Required Description
parameters array Optional Weather parameters to include: temperature, humidity, wind, pressure

Example Request

GET https://dmi.cma.dk/api/weather/current/copenhagen

Example Response

{
  "location": {
    "name": "Copenhagen",
    "coordinates": {
      "lat": 55.6761,
      "lon": 12.5683
    },
    "station": "Copenhagen"
  },
  "timestamp": "2025-01-15T12:00:00+00:00",
  "temperature": {
    "value": 15.2,
    "unit": "celsius"
  },
  "humidity": 65.0,
  "wind": {
    "speed": 5.5,
    "direction": 180.0,
    "unit": "meters_per_second",
    "chill": 3.2,
    "chill_unit": "celsius"
  },
  "pressure": {
    "value": 1013.25,
    "unit": "hectopascals"
  }
}

Note: Wind chill is automatically calculated and included when temperature is ≤10°C and wind speed is >1.3 m/s.

GET /api/weather/forecast/{location}

Get weather forecast for a specified location in Denmark.

Path Parameters

Parameter Type Description
location string City name, postal code, or coordinates (lat,lon)

Query Parameters

Parameter Type Required Default Description
hours integer Optional 48 Number of hours to forecast (1-72)

Example Request

GET https://dmi.cma.dk/api/weather/forecast/aarhus?hours=24

Example Response

{
  "location": {
    "name": "aarhus",
    "coordinates": {
      "lat": 56.1629,
      "lon": 10.2039
    }
  },
  "generated_at": "2025-01-15T12:00:00+00:00",
  "forecast": [
    {
      "timestamp": "2025-01-15T13:00:00+00:00",
      "temperature": 14.5,
      "wind_speed": 6.0,
      "wind_direction": 190.0,
      "wind_chill": 3.8,
      "precipitation": 0.5,
      "cloud_cover": 50.0
    }
  ]
}

Note: Wind chill is automatically calculated and included in forecast data when conditions meet the criteria (temperature ≤10°C and wind speed >1.3 m/s).

GET /api/weather/historical/{location}

Get historical weather data for a specified location in Denmark.

Path Parameters

Parameter Type Description
location string City name, postal code, or coordinates (lat,lon)

Query Parameters

Parameter Type Required Default Description
from date Required - Start date (YYYY-MM-DD)
to date Required - End date (YYYY-MM-DD)
resolution string Optional day Time resolution: hour, day, month, year
parameters array Optional - Weather parameters: temperature, precipitation, wind, humidity, sunshine

Example Request

GET https://dmi.cma.dk/api/weather/historical/odense?from=2024-01-01&to=2024-01-31&resolution=day

Example Response

{
  "location": {
    "name": "odense",
    "coordinates": {
      "lat": 55.4038,
      "lon": 10.4024
    },
    "station": "Odense"
  },
  "period": {
    "from": "2024-01-01T00:00:00+00:00",
    "to": "2024-01-31T00:00:00+00:00",
    "resolution": "day"
  },
  "data": [
    {
      "timestamp": "2024-01-01T00:00:00+00:00",
      "temperature": 5.5,
      "precipitation": 2.3,
      "wind_speed": 4.5,
      "wind_chill": 1.2
    }
  ]
}

Note: Wind chill is automatically calculated and included in historical data when conditions meet the criteria (temperature ≤10°C and wind speed >1.3 m/s).

Wind Chill Calculation

Wind chill is automatically calculated using the North American and UK wind chill index formula. It represents how cold the air feels on exposed skin due to the combined effect of temperature and wind.

When Wind Chill is Included

Wind chill values are only calculated and included when:

If conditions don't meet these criteria, the wind chill fields will be omitted from the response.

Wind Chill Formula

Wind Chill (°C) = 13.12 + 0.6215T - 11.37V^0.16 + 0.3965TV^0.16

Where:
  T = Air temperature (°C)
  V = Wind speed (km/h)

Location Formats

The API accepts locations in the following formats:

Format Example Description
City Name copenhagen, københavn, aarhus Danish city names (case-insensitive)
Postal Code 1000, 8000, 5000 4-digit Danish postal codes
Coordinates 55.6761,12.5683 Latitude and longitude (comma-separated)

Error Responses

The API returns standard HTTP status codes and JSON error responses:

400 Bad Request

{
  "error": "Unable to geocode location: unknowncity",
  "location": "unknowncity"
}

422 Unprocessable Entity

{
  "message": "The from field is required.",
  "errors": {
    "from": [
      "The from field is required."
    ]
  }
}

Rate Limiting & Caching