### Typical REST API GET Request Example Source: https://opendata.smhi.se/metobs/common Demonstrates a typical GET request to the SMHI REST API, including necessary headers like User-Agent and Accept-Encoding. The response section shows a 200 OK status and an example XML response body. ```http GET /api/version/1.0/parameter/1.atom HTTP/1.1 User-Agent: curl/7.19.7 (x86_64-redhat-linux-gnu) libcurl/7.19.7 NSS/3.15.3 zlib/1.2.3 libidn/1.18 libssh2/1.4.2 Host: opendata-download-metobs.smhi.se:80 Accept: */* Accept-Encoding: gzip, deflate ``` ```http HTTP/1.1 200 OK Server: Apache-Coyote/1.1 Accept-Ranges: bytes Last-Modified: Tue, 26 Aug 2014 13:03:25 GMT Content-Type: application/atom+xml Content-Length: 3117 Date: Tue, 26 Aug 2014 17:29:42 GMT Meterolog pada observationer från SMHI ... ``` -------------------------------- ### SMHI API Day Level Example Request (ATOM) Source: https://opendata.smhi.se/lightning/archive/resources/day An example of a GET request to retrieve daily data in ATOM format for a specific date. This demonstrates how to replace the placeholders with actual values. ```shell GET /api/version/latest/year/2017/month/6/day/2.atom ``` -------------------------------- ### Typical REST API GET Request (HTTP) Source: https://opendata.smhi.se/lightning/archive/common Example of a typical GET request to the SMHI Open Data API, including headers like User-Agent, Host, and Accept-Encoding. The response demonstrates a 200 OK status and content type. ```http GET /api/version/1.0/year/2017.atom HTTP/1.1 User-Agent: curl/7.19.7 (x86_64-redhat-linux-gnu) libcurl/7.19.7 NSS/3.15.3 zlib/1.2.3 libidn/1.18 libssh2/1.4.2 Host: opendata-download-lightning.smhi.se:80 Accept: */* Accept-Encoding: gzip, deflate ``` ```http HTTP/1.1 200 OK Server: Apache-Coyote/1.1 Accept-Ranges: bytes Last-Modified: Tue, 26 Aug 2017 13:03:25 GMT Content-Type: application/atom+xml Content-Length: 3117 Date: Tue, 26 Aug 2017 17:29:42 GMT 2017 ... ``` -------------------------------- ### GET Approved Time Data Daily API Request Source: https://opendata.smhi.se/metanalys/fwia/examples This snippet shows the GET request for retrieving approved time data on a daily basis from the OpenData SMHI SE API. It specifies the API endpoint and version. The expected response contains the approvedTime and referenceTime. ```http GET /api/category/fwia1g/version/1/daily/approvedtime.json ``` -------------------------------- ### GET /any/endpoint Source: https://opendata.smhi.se/metanalys/fwia/examples This endpoint retrieves weather forecast data for a specific location and time. It returns a list of forecast periods, each containing various meteorological parameters. ```APIDOC ## GET /any/endpoint ### Description Retrieves weather forecast data for a specific location and time, including parameters like precipitation, wind, temperature, and fire weather indices. ### Method GET ### Endpoint /any/endpoint ### Parameters #### Query Parameters - **latitude** (float) - Required - Latitude of the desired location. - **longitude** (float) - Required - Longitude of the desired location. - **start_time** (string) - Optional - The start of the forecast period (ISO 8601 format). - **end_time** (string) - Optional - The end of the forecast period (ISO 8601 format). ### Request Example ```json { "query": "?latitude=55.7&longitude=13.0&start_time=2024-04-28T00:00:00Z&end_time=2024-04-28T12:00:00Z" } ``` ### Response #### Success Response (200) - **validTime** (string) - The valid time for the forecast data (ISO 8601 format). - **parameters** (array) - An array of meteorological parameters. - **name** (string) - The name of the parameter (e.g., "t" for temperature, "prec1h" for precipitation). - **levelType** (string) - The type of level for the parameter (e.g., "hl"). - **level** (integer) - The level of the parameter. - **unit** (string) - The unit of the parameter (e.g., "Cel" for Celsius, "mm" for millimeters). - **values** (array) - An array of values for the parameter at the specified time. #### Response Example ```json { "validTime": "2024-04-28T06:00:00Z", "parameters": [ { "name": "prec1h", "levelType": "hl", "level": 0, "unit": "mm", "values": [0.0] }, { "name": "ws", "levelType": "hl", "level": 10, "unit": "m/s", "values": [2.7] }, { "name": "wd", "levelType": "hl", "level": 10, "unit": "degree", "values": [111.9] }, { "name": "t", "levelType": "hl", "level": 2, "unit": "Cel", "values": [6.5] } ] } ``` ``` -------------------------------- ### GET /content/data Source: https://opendata.smhi.se/metanalys/fwia/examples Retrieves weather data for a specified location and time. The response includes various meteorological parameters such as temperature, wind speed, and precipitation. ```APIDOC ## GET /content/data ### Description Retrieves weather data for a specified location and time. The response includes various meteorological parameters such as temperature, wind speed, and precipitation. ### Method GET ### Endpoint /content/data ### Parameters #### Query Parameters - **station** (string) - Required - The identifier for the weather station. - **from_time** (string) - Required - The start of the time period for the data (ISO 8601 format). - **to_time** (string) - Required - The end of the time period for the data (ISO 8601 format). ### Request Example ``` GET /content/data?station=SMHI_station_id&from_time=2024-04-27T08:00:00Z&to_time=2024-04-27T11:00:00Z ``` ### Response #### Success Response (200) - **validTime** (string) - The timestamp for the data point. - **parameters** (array) - An array of parameter objects, each containing: - **name** (string) - The name of the parameter (e.g., 't' for temperature, 'ws' for wind speed). - **levelType** (string) - The type of level for the parameter (e.g., 'hl'). - **level** (number) - The level value for the parameter. - **unit** (string) - The unit of measurement for the parameter (e.g., 'Cel', 'm/s'). - **values** (array) - An array of observed values for the parameter. #### Response Example ```json { "validTime": "2024-04-27T10:00:00Z", "parameters": [ { "name": "GLirr", "levelType": "hl", "level": 0, "unit": "W/m2", "values": [388.7] }, { "name": "t", "levelType": "hl", "level": 2, "unit": "Cel", "values": [7.6] } ] } ``` ``` -------------------------------- ### Example GET Request for Point Analysis Source: https://opendata.smhi.se/metanalys/strang/get_point An example of a GET request to the SMHI OpenData API to retrieve hourly data for parameter 118 at longitude 16.158 and latitude 58.5812, between February 1st and 2nd, 2020. ```http GET /api/category/strang1g/version/1/geotype/point/lon/16.158/lat/58.5812/parameter/118/data.json?from=2020-02-01&to=2020-02-02 ``` -------------------------------- ### Fetch Sample Data Resource from Period (Java) Source: https://opendata.smhi.se/metobs/examples Fetches the sample data resource associated with a MetObsPeriod. It searches for a link with the REL 'DATA' and type 'application/xml' within the period's data links. Dependencies include MetObsPeriod, LinksType, LinkType, UriBuilder, WebResource, and MediaType. ```java public MetObsSampleData getSampleData(MetObsPeriod period) { for (LinksType links : period.getData()) { for (LinkType link : links.getLink()) { if (DATA.equals(link.getRel()) && MediaType.APPLICATION_XML.equals(link.getType())) { URI uri = UriBuilder.fromUri(link.getHref()).build(); WebResource resource = client.resource(uri); return resource.accept(MediaType.APPLICATION_XML_TYPE).get(MetObsSampleData.class); } } } return null; } ``` -------------------------------- ### Example Multipoint Analysis Request Source: https://opendata.smhi.se/metanalys/strang/get_multipoint An example of a GET request to the SMHI API for monthly data of parameter '118' for August 2019. This demonstrates how to format the endpoint with specific values for category, version, validtime, and interval. ```HTTP GET /api/category/strang1g/version/1/geotype/multipoint/validtime/201908/parameter/118/data.json?interval=monthly ``` -------------------------------- ### SMHI Open Data Lightning API Entry Point Source: https://opendata.smhi.se/lightning/archive/introduction This is the main entry point for the SMHI Open Data Lightning API. It provides a collection of links to different versions of the API. ```APIDOC ## GET /api.json ### Description This is the entry point of the API. It provides a collection of links to different versions of the API, as well as links to metadata and other useful resources. ### Method GET ### Endpoint https://opendata-download-lightning.smhi.se/api.json ### Parameters None ### Request Example None ### Response #### Success Response (200) - **_links** (object) - A collection of links to different API versions and resources. #### Response Example ```json { "_links": { "self": {"href": "/api.json"}, "versions": {"href": "/version"} } } ``` ``` -------------------------------- ### Prompt User for Input (Java) Source: https://opendata.smhi.se/metobs/examples Displays a prompt message to the console and reads a single line of text from standard input. Returns the entered string. Throws IOException on input errors. Dependencies include System.out, System.in, and BufferedReader. ```java private String fetchFromStdIn(String prompt) throws IOException { System.out.print(String.format("Enter %s ", prompt)); BufferedReader buffer = new BufferedReader(new InputStreamReader(System.in)); return buffer.readLine(); } ``` -------------------------------- ### Get Point Analysis API Request Example (HTTP) Source: https://opendata.smhi.se/metanalys/mesan2gv2/get_point_analysis This snippet demonstrates how to make a GET request to the Get Point Analysis API. It includes placeholders for longitude, latitude, and optional parameters for filtering time series and specific data. The API returns data in JSON format. ```http GET /api/category/mesan2g/version/2/geotype/point/lon/{longitude}/lat/{latitude}/data.json?timeseries={timeseries}?parameters={parameters} ``` -------------------------------- ### Fetch Key from Standard Input (Java) Source: https://opendata.smhi.se/metobs/examples Prompts the user to input a key from standard input. It repeatedly asks for input until a key matching one of the available options (case-insensitive) is provided. Throws IOException on input errors. Dependencies include String, List, LinksType, System.in, and BufferedReader. ```java private String fetchKeyFromStdIn(String type, List links) throws IOException { // loop until the user inputs one of the keys while (true) { String key = fetchFromStdIn(type); for (LinksType link : links) { if (key.equalsIgnoreCase(link.getKey())) { return link.getKey(); } } } } ``` -------------------------------- ### MultiPoint Analysis GET Request - API Source: https://opendata.smhi.se/metanalys/mesan2gv2/get_multipoint_analysis Example of a GET request to the MultiPoint API endpoint for fetching analysis data. It specifies the time, parameter, and query options like 'with-geo' and 'downsample'. The 'Accept-Encoding: gzip' header is required for GZIP compression. ```http GET /api/category/mesan2g/version/2/geotype/multipoint/time/{YYMMDDThhmmssZ}/parameter/{p}/data.json?with-geo=false&downsample=2 Accept-Encoding: gzip ``` -------------------------------- ### Fetch and Print OpenDataMetobsXMLReader Data in Java Source: https://opendata.smhi.se/metobs/examples This Java main method demonstrates how to use the OpenDataMetobsXMLReader class to retrieve data. It fetches parameter keys, station names, period names, and finally the actual data, printing it to the console. It includes exception handling for IO, XML parsing, and XPath expressions. ```java public static void main(String... args) { OpenDataMetobsXMLReader openDataMetobsReader = new OpenDataMetobsXMLReader(); try { String parameterKey = openDataMetobsReader.getParameters(); String stationKey = openDataMetobsReader.getStationNames(parameterKey); String periodName = openDataMetobsReader.getPeriodNames(parameterKey, stationKey); String data = openDataMetobsReader.getData(parameterKey, stationKey, periodName); System.out.println(data); } catch (XPathExpressionException | IOException | ParserConfigurationException | SAXException e) { e.printStackTrace(); } } } ``` -------------------------------- ### Select Key from Standard Input (Java) Source: https://opendata.smhi.se/metobs/examples Prompts the user to select a key from a list of available options presented to standard input. It sorts the keys alphabetically and allows selection by responding 'yes' or 'y'. Throws IOException on input errors. Dependencies include List, LinksType, Comparator, System.in, and BufferedReader. ```java private String selectKeyFromStdIn(String type, List links) throws IOException { Collections.sort(links, new Comparator() { public int compare(LinksType a, LinksType b) { return a.getKey().compareTo(b.getKey()); } }); // loop until the user selects one of the keys while (true) { for (LinksType link : links) { if (selectFromStdIn(type, link.getKey())) { return link.getKey(); } } } } ``` -------------------------------- ### Example Data Request (XML) Source: https://opendata.smhi.se/metobs/resources/data An example HTTP GET request to retrieve weather data for a specific parameter, station, and period in XML format. This demonstrates the structure of a data retrieval query. ```http GET /api/version/1.0/parameter/1/station/159880/period/latest-day/data.xml ``` -------------------------------- ### Fetch Meteorological Data using SMHI OpenData API (Java) Source: https://opendata.smhi.se/metobs/examples This Java code snippet demonstrates the core logic for fetching meteorological data from the SMHI OpenData API. It initializes a client, navigates through categories, versions, parameters, stations, and periods, and then retrieves either sample or interval data based on the parameter's value type. Dependencies include the SMHI API client library. ```Java /** * @param args * No arguments * @throws IOException */ public static void main(String[] args) throws IOException { Client client = Client.create(new DefaultClientConfig()); try { // create the client MetObsApp app = new MetObsApp(client); // get root category Category category = app.getCategory(); // select version String versionKey = app.selectKeyFromStdIn("Version", category.getVersion()); Version version = app.getVersion(category, versionKey); // select parameter String parameterKey = app.selectKeyFromStdIn("Parameter", version.getResource()); MetObsParameter parameter = app.getParameter(version, parameterKey); // select station String stationKey = app.fetchKeyFromStdIn("Station", parameter.getStation()); MetObsStation station = app.getStation(parameter, stationKey); // select period String periodKey = app.selectKeyFromStdIn("Period", station.getPeriod()); MetObsPeriod period = app.getPeriod(station, periodKey); MetObsValueType valueType = parameter.getValueType(); switch (valueType) { case SAMPLING: // get sample data MetObsSampleData sampleData = app.getSampleData(period); System.out.println("Sample Data: " + sampleData.getValue().size()); for (MetObsSampleValueType value : sampleData.getValue()) { System.out.println(String.format("%s %s %s", value.getDate(), value.getQuality(), value.getValue())); } break; case INTERVAL: // get interval data MetObsIntervalData intervalData = app.getIntervalData(period); System.out.println("Interval Data: " + intervalData.getValue().size()); for (MetObsIntervalValueType value : intervalData.getValue()) { System.out.println(String.format("%s %s %s %s %s", value.getFrom(), value.getTo(), value.getRef(), value.getQuality(), value.getValue())); } break; default: System.out.println("No value type..."); } } finally { client.destroy(); } } ``` -------------------------------- ### Get MultiPoint Forecast API Request (HTTP) Source: https://opendata.smhi.se/metfcst/snow1gv1/get_multipoint_forecast This example demonstrates how to construct an HTTP GET request to the SMHI OpenData API for MultiPoint forecast data. It includes the necessary endpoint, time and parameter placeholders, and specifies `with-geo=false` and `downsample=2`. The `Accept-Encoding: gzip` header is crucial for handling compressed responses. ```http GET /api/category/snow1g/version/1/geotype/multipoint/time/{YYMMDDThhmmssZ}/parameter/{p}/data.json?with-geo=false&downsample=2 Accept-Encoding: gzip ``` -------------------------------- ### Fetch Period Resource from Station (Java) Source: https://opendata.smhi.se/metobs/examples Retrieves a specific period resource from a MetObsStation based on a provided periodKey. It iterates through the station's periods, matches the key, and then fetches the XML resource of type PERIOD. Dependencies include MetObsStation, LinksType, LinkType, UriBuilder, WebResource, and MediaType. ```java public MetObsPeriod getPeriod(MetObsStation station, String periodKey) { for (LinksType links : station.getPeriod()) { if (periodKey.equals(links.getKey())) { for (LinkType link : links.getLink()) { if (PERIOD.equals(link.getRel()) && MediaType.APPLICATION_XML.equals(link.getType())) { URI uri = UriBuilder.fromUri(link.getHref()).build(); WebResource resource = client.resource(uri); return resource.accept(MediaType.APPLICATION_XML_TYPE).get(sMetObsPeriod.class); } } } } return null; } ``` -------------------------------- ### Fetch SMHI MetObs API Category using Jersey Client (Java) Source: https://opendata.smhi.se/metobs/examples This Java method utilizes the Jersey Client to fetch the root 'Category' resource from the SMHI MetObs API. It requires an initialized Jersey Client instance and returns a Category object representing the API's top-level structure. Dependencies include the Jersey Client library and SMHI's model classes. ```java package se.smhi.sid.download.portal.client.metobs; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.net.URI; import java.util.Collections; import java.util.Comparator; import java.util.List; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.UriBuilder; import se.smhi.sid.download.portal.model.metobs.v1.MetObsIntervalData; import se.smhi.sid.download.portal.model.metobs.v1.MetObsIntervalValueType; import se.smhi.sid.download.portal.model.metobs.v1.MetObsParameter; import se.smhi.sid.download.portal.model.metobs.v1.MetObsPeriod; import se.smhi.sid.download.portal.model.metobs.v1.MetObsSampleData; import se.smhi.sid.download.portal.model.metobs.v1.MetObsSampleValueType; import se.smhi.sid.download.portal.model.metobs.v1.MetObsStation; import se.smhi.sid.download.portal.model.metobs.v1.MetObsValueType; import se.smhi.sid.download.portal.model.portal.Category; import se.smhi.sid.download.portal.model.portal.LinkType; import se.smhi.sid.download.portal.model.portal.LinksType; import se.smhi.sid.download.portal.model.portal.Version; import com.sun.jersey.api.client.Client; import com.sun.jersey.api.client.WebResource; import com.sun.jersey.api.client.config.DefaultClientConfig; /** * Example application for communication with the metobs api. */ public class MetObsApp { private static final String BASE_URL = "https://opendata-download-metobs.smhi.se/api.xml"; private static final String VERSION = "version"; private static final String PARAMETER = "parameter"; private static final String STATION = "station"; private static final String PERIOD = "period"; private static final String DATA = "data"; // jersey client private final Client client; // constructor public MetObsApp(Client client) { this.client = client; } /** * Fetch the root resource called category. * * @return The category */ public Category getCategory() { WebResource resource = client.resource(BASE_URL); return resource.accept(MediaType.APPLICATION_XML_TYPE).get(Category.class); } /** * Fetch a version resource from a category. * * @param category * The category * @param versionKey * The key of the version to fetch. * @return The version resource */ public Version getVersion(Category category, String versionKey) { for (LinksType links : category.getVersion()) { if (versionKey.equals(links.getKey())) { for (LinkType link : links.getLink()) { if (VERSION.equals(link.getRel()) && MediaType.APPLICATION_XML.equals(link.getType())) { URI uri = UriBuilder.fromUri(link.getHref()).build(); WebResource resource = client.resource(uri); return resource.accept(MediaType.APPLICATION_XML_TYPE).get(Version.class); } } } } return null; } /** * Fetch a parameter resource from a version. * * @param version * The version * @param parameterKey * The key of the parameter to fetch. * @return The parameter resource */ public MetObsParameter getParameter(Version version, String parameterKey) { for (LinksType links : version.getResource()) { if (parameterKey.equals(links.getKey())) { for (LinkType link : links.getLink()) { if (PARAMETER.equals(link.getRel()) && MediaType.APPLICATION_XML.equals(link.getType())) { URI uri = UriBuilder.fromUri(link.getHref()).build(); WebResource resource = client.resource(uri); return resource.accept(MediaType.APPLICATION_XML_TYPE).get(MetObsParameter.class); } } } } return null; } /** * Fetch a station resource from a parameter. * * @param parameter * The parameter * @param stationKey * The key of the station to fetch. * @return The station resource */ public MetObsStation getStation(MetObsParameter parameter, String stationKey) { for (LinksType links : parameter.getStation()) { if (stationKey.equals(links.getKey())) { for (LinkType link : links.getLink()) { if (STATION.equals(link.getRel()) && MediaType.APPLICATION_XML.equals(link.getType())) { URI uri = UriBuilder.fromUri(link.getHref()).build(); WebResource resource = client.resource(uri); return resource.accept(MediaType.APPLICATION_XML_TYPE).get(MetObsStation.class); } } } } ``` -------------------------------- ### GET /precipitation Source: https://opendata.smhi.se/metanalys/fwia/examples Retrieves precipitation data for a specified location and time range. This endpoint provides information on rainfall and snowfall. ```APIDOC ## GET /precipitation ### Description Retrieves precipitation data for a specified location and time range. This endpoint provides information on rainfall and snowfall. ### Method GET ### Endpoint /precipitation ### Parameters #### Query Parameters - **lon** (float) - Required - Longitude of the location. - **lat** (float) - Required - Latitude of the location. - **start_time** (string) - Optional - Start of the time range in ISO 8601 format (YYYY-MM-DDTHH:MM:SSZ). - **end_time** (string) - Optional - End of the time range in ISO 8601 format (YYYY-MM-DDTHH:MM:SSZ). ### Request Example ```http GET /precipitation?lon=18.0686&lat=59.3293&start_time=2024-04-27T15:00:00Z&end_time=2024-04-27T16:00:00Z ``` ### Response #### Success Response (200) - **validTime** (string) - The timestamp for the data in ISO 8601 format. - **parameters** (array) - An array of weather parameters. - **name** (string) - The name of the parameter (e.g., 'prec1h'). - **levelType** (string) - The type of level (e.g., 'hl'). - **level** (integer) - The level of the parameter. - **unit** (string) - The unit of the parameter (e.g., 'mm'). - **values** (array) - An array of values for the parameter. #### Response Example ```json { "validTime": "2024-04-27T15:00:00Z", "parameters": [ { "name": "prec1h", "levelType": "hl", "level": 0, "unit": "mm", "values": [0] } ] } ``` ``` -------------------------------- ### Prompt User for Yes/No Selection (Java) Source: https://opendata.smhi.se/metobs/examples Displays a prompt message to the console and reads a line from standard input to determine a 'yes' or 'no' response. Returns true if the input is 'yes' or 'y' (case-insensitive), false otherwise. Throws IOException on input errors. Dependencies include System.out, System.in, and BufferedReader. ```java private boolean selectFromStdIn(String prompt, String key) throws IOException { System.out.print(String.format("Select %s %s (yes/No) ", prompt, key)); BufferedReader buffer = new BufferedReader(new InputStreamReader(System.in)); String line = buffer.readLine(); return "yes".equalsIgnoreCase(line) || "y".equalsIgnoreCase(line); } ``` -------------------------------- ### Fetch Interval Data Resource from Period (Java) Source: https://opendata.smhi.se/metobs/examples Retrieves the interval data resource from a MetObsPeriod. Similar to fetching sample data, it looks for a link with REL 'DATA' and type 'application/xml' within the period's data links. Dependencies include MetObsPeriod, LinksType, LinkType, UriBuilder, WebResource, and MediaType. ```java public MetObsIntervalData getIntervalData(MetObsPeriod period) { for (LinksType links : period.getData()) { for (LinkType link : links.getLink()) { if (DATA.equals(link.getRel()) && MediaType.APPLICATION_XML.equals(link.getType())) { URI uri = UriBuilder.fromUri(link.getHref()).build(); WebResource resource = client.resource(uri); return resource.accept(MediaType.APPLICATION_XML_TYPE).get(MetObsIntervalData.class); } } } return null; } ``` -------------------------------- ### GET /wind_speed Source: https://opendata.smhi.se/metanalys/fwia/examples Retrieves wind speed data for a specified location and time range. This endpoint provides information on wind velocity. ```APIDOC ## GET /wind_speed ### Description Retrieves wind speed data for a specified location and time range. This endpoint provides information on wind velocity. ### Method GET ### Endpoint /wind_speed ### Parameters #### Query Parameters - **lon** (float) - Required - Longitude of the location. - **lat** (float) - Required - Latitude of the location. - **start_time** (string) - Optional - Start of the time range in ISO 8601 format (YYYY-MM-DDTHH:MM:SSZ). - **end_time** (string) - Optional - End of the time range in ISO 8601 format (YYYY-MM-DDTHH:MM:SSZ). ### Request Example ```http GET /wind_speed?lon=18.0686&lat=59.3293&start_time=2024-04-27T15:00:00Z&end_time=2024-04-27T16:00:00Z ``` ### Response #### Success Response (200) - **validTime** (string) - The timestamp for the data in ISO 8601 format. - **parameters** (array) - An array of weather parameters. - **name** (string) - The name of the parameter (e.g., 'ws'). - **levelType** (string) - The type of level (e.g., 'hl'). - **level** (integer) - The level of the parameter. - **unit** (string) - The unit of the parameter (e.g., 'm/s'). - **values** (array) - An array of values for the parameter. #### Response Example ```json { "validTime": "2024-04-27T15:00:00Z", "parameters": [ { "name": "ws", "levelType": "hl", "level": 10, "unit": "m/s", "values": [1.4] } ] } ``` ``` -------------------------------- ### GET /api.{ext} Source: https://opendata.smhi.se/metobs/resources/category This is the entry point of the API. Here you can select which version to use. It is recommended to use the version with the highest number to ensure a stable API. The 'latest' version is a reference to the latest published version and should not be used if you are not prepared for changes. ```APIDOC ## GET /api.{ext} ### Description This endpoint serves as the API's entry point, allowing users to select a specific version of the API to use. It is recommended to use the latest version for stability. The 'latest' version is a dynamic reference to the most recent version and may change. ### Method GET ### Endpoint /api.{ext} ### Parameters #### Path Parameters - **ext** (string) - Required - The suffix specifying which mediatype to use (e.g., atom, json, xml). ### Request Example ``` GET /api.json ``` ### Response #### Success Response (200) The response structure depends on the mediatype specified by the '.{ext}' extension. For example, a JSON response will contain a structure listing available API versions and their respective links. #### Response Example ```json { "feed": { "title": "Meteorologiska observationer från SMHI: Välj version (sedan parameter, station och tidsutsnitt)", "link": { "rel": "self", "type": "application/json", "href": "https://opendata-download-metobs.smhi.se/api.json" }, "author": { "name": "", "email": "dataleveranser@smhi.se" }, "subtitle": "Nedladdningstjänst för svenska meteorologiska observationsdata från SMHI...", "id": "https://opendata-download-metobs.smhi.se/api.json", "rights": "Copyright (c) 2013, SMHI; all rights reserved", "updated": "2014-09-15T13:28:04Z", "dc:date": "2014-09-15T13:28:04Z", "dc:rights": "Copyright (c) 2013, SMHI; all rights reserved", "entry": [ { "title": "Senaste versionen av nedladdningstjänsten", "link": { "rel": "enclosure", "type": "application/atom+xml", "href": "https://opendata-download-metobs.smhi.se/api/version/latest.atom" }, "author": { "name": "", "email": "dataleveranser@smhi.se" }, "id": "https://opendata-download-metobs.smhi.se/api/version/latest.atom", "updated": "2014-09-15T11:00:00Z", "published": "2014-09-15T11:00:00Z", "summary": { "type": "text", "content": "" }, "dc:date": "2014-09-15T11:00:00Z" }, { "title": "1.0 versionen av nedladdningstjänsten", "link": { "rel": "enclosure", "type": "application/atom+xml", "href": "https://opendata-download-metobs.smhi.se/api/version/1.0.atom" }, "author": { "name": "", "email": "dataleveranser@smhi.se" }, "id": "https://opendata-download-metobs.smhi.se/api/version/1.0.atom", "updated": "2014-09-15T11:00:00Z", "published": "2014-09-15T11:00:00Z", "summary": { "type": "text", "content": "" }, "dc:date": "2014-09-15T11:00:00Z" } ] } } ``` ``` -------------------------------- ### GET Approved Time Daily Source: https://opendata.smhi.se/metanalys/fwia/examples Retrieves the approved time for daily data. This endpoint is part of the Point Analysis Daily API. ```APIDOC ## GET /api/category/fwia1g/version/1/daily/approvedtime.json ### Description Retrieves the approved time for daily data. This endpoint is part of the Point Analysis Daily API. A correct answer contains 461 589 points or values. ### Method GET ### Endpoint /api/category/fwia1g/version/1/daily/approvedtime.json ### Parameters #### Query Parameters None #### Request Body None ### Request Example None ### Response #### Success Response (200) - **approvedTime** (string) - The approved time in ISO 8601 format. - **referenceTime** (string) - The reference time in ISO 8601 format. #### Response Example ```json { "approvedTime": "2024-04-29T00:55:10Z", "referenceTime": "2024-04-27T12:00:00Z" } ``` ``` -------------------------------- ### GET /wind_direction Source: https://opendata.smhi.se/metanalys/fwia/examples Retrieves wind direction data for a specified location and time range. This endpoint provides information on the direction from which the wind is blowing. ```APIDOC ## GET /wind_direction ### Description Retrieves wind direction data for a specified location and time range. This endpoint provides information on the direction from which the wind is blowing. ### Method GET ### Endpoint /wind_direction ### Parameters #### Query Parameters - **lon** (float) - Required - Longitude of the location. - **lat** (float) - Required - Latitude of the location. - **start_time** (string) - Optional - Start of the time range in ISO 8601 format (YYYY-MM-DDTHH:MM:SSZ). - **end_time** (string) - Optional - End of the time range in ISO 8601 format (YYYY-MM-DDTHH:MM:SSZ). ### Request Example ```http GET /wind_direction?lon=18.0686&lat=59.3293&start_time=2024-04-27T15:00:00Z&end_time=2024-04-27T16:00:00Z ``` ### Response #### Success Response (200) - **validTime** (string) - The timestamp for the data in ISO 8601 format. - **parameters** (array) - An array of weather parameters. - **name** (string) - The name of the parameter (e.g., 'wd'). - **levelType** (string) - The type of level (e.g., 'hl'). - **level** (integer) - The level of the parameter. - **unit** (string) - The unit of the parameter (e.g., 'degree'). - **values** (array) - An array of values for the parameter. #### Response Example ```json { "validTime": "2024-04-27T15:00:00Z", "parameters": [ { "name": "wd", "levelType": "hl", "level": 10, "unit": "degree", "values": [47.1] } ] } ``` ``` -------------------------------- ### GET /api/category/mesan2g/version/2/times.json Source: https://opendata.smhi.se/metanalys/mesan2gv2/examples Retrieves a list of available time steps for the 'mesan2g' category, version 2. This is useful for understanding the temporal coverage of the dataset. ```APIDOC ## GET /api/category/mesan2g/version/2/times.json ### Description Retrieves a list of available time steps for a specific data category and version. ### Method GET ### Endpoint /api/category/mesan2g/version/2/times.json ### Parameters None ### Request Example None ### Response #### Success Response (200) - **time** (array of strings) - A list of timestamps representing available data points. #### Response Example ```json { "time": [ "2025-04-28T11:00:00Z", "2025-04-28T10:00:00Z", "2025-04-28T09:00:00Z", "2025-04-28T08:00:00Z", "2025-04-28T07:00:00Z", "2025-04-28T06:00:00Z", "2025-04-28T05:00:00Z", "2025-04-28T04:00:00Z", "2025-04-28T03:00:00Z", "2025-04-28T02:00:00Z", "2025-04-28T01:00:00Z", "2025-04-28T00:00:00Z", "2025-04-27T23:00:00Z", "2025-04-27T22:00:00Z", "2025-04-27T21:00:00Z", "2025-04-27T20:00:00Z", "2025-04-27T19:00:00Z", "2025-04-27T18:00:00Z", "2025-04-27T17:00:00Z", "2025-04-27T16:00:00Z", "2025-04-27T15:00:00Z", "2025-04-27T14:00:00Z", "2025-04-27T13:00:00Z", "2025-04-27T12:00:00Z" ] } ``` ```