SMHI APIsmhi.se ↗
Access Swedish weather forecasts, current conditions, MESAN observations, and active severe weather warnings for any location in Sweden via the SMHI API.
What is the SMHI API?
The SMHI API provides 5 endpoints covering Swedish weather data: search any Swedish place by name with search_locations, retrieve a 10-day hourly forecast with get_forecast, pull current conditions with get_current_weather, access MESAN model observations with get_analysis, and fetch all active national warnings with get_warnings. Every location-specific endpoint accepts a geonameid obtained from the search endpoint.
curl -X GET 'https://api.parse.bot/scraper/59cbac26-14c5-46e0-8e23-da063f04e411/search_locations?query=Stockholm' \ -H 'X-API-Key: $PARSE_API_KEY'
Typed, relational, agent-ready
A generated client with real types, enums, and the links between objects — the structure a flat JSON response can't carry. Autocompletes in your editor and reads cleanly to coding agents.
- Fully typed · autocompletes
- Objects link to objects
- Typed errors & pagination
Typed Python client. Set up the SDK in your uv project, then pull this API’s typed client:
uv add parse-sdk uv run parse init uv run parse add --marketplace smhi-se-api
uv run parse add --marketplace pulls a pinned snapshot of this canonical API — it won’t change underneath you. To customize it, subscribe and swap to your own copy.
"""SMHI Weather API — search locations, check conditions, read forecasts and warnings."""
from parse_apis.SMHI_Weather_API import SMHI, WarningLevel, LocationNotFound
client = SMHI()
# Search for a Swedish city and get the top result.
stockholm = client.locations.search(query="Stockholm", limit=3).first()
print(f"Found: {stockholm.place} ({stockholm.municipality}), pop {stockholm.population}")
# Get current weather for the location (instance method via constructible key).
current = stockholm.get_current_weather()
print(f"Current: {current.t}°C, symbol={current.wsymb2}, time_of_day={current.time_of_day}")
# Get the 10-day forecast and inspect the first day's summary.
forecast = stockholm.get_forecast()
day = forecast.forecast10d.days[0]
print(f"Today: {day.summary.min_temp}–{day.summary.max_temp}°C, precip={day.summary.acc_prec}mm")
# Get MESAN analysis (observations) for the location.
analysis = stockholm.get_analysis()
print(f"Analysis model: {analysis.modeltype}, approved: {analysis.approved_time}")
# List active weather warnings across Sweden.
for warning in client.warnings.list(limit=5):
print(f"⚠ {warning.area_name.en}: {warning.event_description.en} [{warning.warning_level.code}]")
# Typed error handling: catch LocationNotFound for an invalid geonameid.
try:
bad = client.location("0000000").get_current_weather()
except LocationNotFound as exc:
print(f"Not found: geonameid={exc.geonameid}")
print("Exercised: locations.search, get_current_weather, get_forecast, get_analysis, warnings.list")
Search for locations in Sweden by name. Returns a list of matching places with geonameid, coordinates, and administrative metadata. Results include nearby cities for larger metro areas. The geonameid from results is required for all weather data endpoints.
| Param | Type | Description |
|---|---|---|
| queryrequired | string | The city or place name to search for (e.g. 'Stockholm', 'Göteborg'). |
{
"type": "object",
"fields": {
"locations": "array of location objects with geonameid, place, lat, lon, type, municipality, county, country, district, population"
},
"sample": {
"data": {
"locations": [
{
"lat": 59.3294681359869,
"lon": 18.0626392364502,
"type": [
"PPLC"
],
"place": "Stockholm",
"county": "Stockholms län",
"country": "Sverige",
"district": "Stockholms domkyrkodistrikt",
"timezone": "Europe/Stockholm",
"geonameid": 2673730,
"population": 1253309,
"municipality": "Stockholm"
}
]
},
"status": "success"
}
}About the SMHI API
Location Search and Identifier Lookup
All weather data endpoints require a geonameid, which you get from search_locations. Pass a Swedish place name via the query parameter and receive an array of matching locations, each with geonameid, lat, lon, municipality, county, type, and population. Results include nearby cities for larger metropolitan areas, so it is worth checking multiple results when querying common place names.
Forecast and Current Conditions
get_forecast returns 10-day hourly weather data organized into three structures: forecast10d (a days array with per-hour temperature, precipitation, wind, and weather symbol codes), forecast24h (24-hour summary periods), and forecast6h (6-hour summary periods). Each day also exposes summary statistics. get_current_weather is narrower: it returns the next-hour temperature in Celsius (t), a wSymb2 weather symbol code on a 1–27 scale indicating conditions from clear sky to heavy snow, a day/night flag, and a refTime ISO timestamp — useful for lightweight current-conditions widgets.
Observations and Warnings
get_analysis exposes the MESAN numerical analysis model output, which reflects observed conditions rather than predictions. The response includes an approvedTime, referenceTime, and a days array of hourly measurements covering temperature, wind speed, humidity, visibility, and precipitation. get_warnings requires no parameters and returns all currently active national warnings with warningLevel values of Yellow, Orange, or Red, affected area names, event descriptions in both Swedish and English, approximate start and end times, and geographic polygons for mapping. The array is empty when no warnings are active.
The SMHI API is a managed, monitored endpoint for smhi.se — not a raw scraper you maintain. Every endpoint is automatically health-checked on a schedule, and when smhi.se changes and a check fails, the API is automatically queued for repair and re-verified. It is built to keep working as the site underneath it changes.
This isn't an official smhi.se API — it's an independent, maintained REST wrapper over public data. Where the source has no official API (or only a limited one), Parse gives you a stable contract over a source that never promised one, and keeps it current. Need a new endpoint or field? You can revise it yourself in plain English and the agent rebuilds it against the live site in minutes — contributing the change back to the shared API is free.
Will this API break when the source site changes?+
Is this an official API from the source site?+
Can I fix or extend this API myself if I need a new endpoint or field?+
What happens if I call an endpoint that has an issue?+
- Display current temperature and sky condition icons for any Swedish city using
wSymb2andtfromget_current_weather. - Build a 10-day forecast widget using the
forecast10ddays array fromget_forecastwith hourly precipitation and wind data. - Alert users to active severe weather events by polling
get_warningsand filtering onwarningLevelRed or Orange. - Plot warning polygons on a map using the geographic boundary data returned in each warning object from
get_warnings. - Compare observed vs. forecast conditions by pairing
get_analysisMESAN output withget_forecastdata for the samegeonameid. - Resolve user-typed Swedish city names to coordinates and administrative metadata using
search_locationswith themunicipalityandcountyfields. - Build an hourly visibility and humidity dashboard for logistics planning using the
daysarray fromget_analysis.
| Tier | Price | Credits/month | Rate limit |
|---|---|---|---|
| Free | $0/mo | 100 | 5 req/min |
| Hobby | $30/mo | 1,000 | 20 req/min |
| Developer | $100/mo | 5,000 | 100 req/min |
One credit = one API call regardless of which marketplace API you call. Exceeding the rate limit returns a 429 response. Authenticate with the X-API-Key header.
Does SMHI have an official developer API?+
What does `get_warnings` return when conditions are calm?+
warnings array will be empty. When warnings are active, each object includes id, areaName, warningLevel (Yellow/Orange/Red), eventDescription, affectedAreas, descriptions in Swedish and English, approximateStart, approximateEnd, and geographic polygon data.Does the API cover weather data outside Sweden?+
search_locations endpoint only returns results within Sweden, and all forecast, analysis, and warning data is scoped to Swedish geography. You can fork this API on Parse and revise it to add endpoints targeting other countries or data sources.How far back do the MESAN observations from `get_analysis` go?+
get_analysis response includes recent hourly measurements organized by day, but it does not expose a configurable historical date range — it reflects current model output near the time of the request. The API does not currently support querying historical weather records by date. You can fork it on Parse and revise to add a historical observations endpoint if the underlying data source exposes one.Can I get forecast data for specific coordinates rather than a `geonameid`?+
get_forecast, get_current_weather, and get_analysis — require a geonameid obtained from search_locations. Direct latitude/longitude input is not supported as a parameter. You can fork this API on Parse and revise it to add coordinate-based lookup.