### Discover Available Data Files using the 'available' Method (cURL) Source: https://github.com/metno/weatherapi-docs/blob/master/doc/GettingStarted.md For products with a distinct set of available data, use the `available` method to retrieve a list of downloadable files. This method returns a list in XML (default) or JSON format, with links to all available files. The example demonstrates filtering results by `area` and `type` parameters to significantly reduce the size of the returned list and speed up processing. While parameters are currently repeated in the URI, this might change in future API versions. ```shell curl -A "MyTestApp/0.1 support@example.com" -s 'https://api.met.no/weatherapi/radar/2.0/available.json?type=lx_reflectivity&area=central_norway'|json_pp ``` -------------------------------- ### Example API Request for Sunrise 2.0 Test Node Source: https://github.com/metno/weatherapi-docs/blob/master/doc/sunrise/astro.md Shows a GET request to the public test node for the Sunrise 2.0 service, which is available for development purposes and may contain the latest features. ```APIDOC http://157.249.72.176/astro/cgi-bin/small.pl?lat=59.93&lon=10.71&date=2018-05-11&offset=+01:00&days=1 ``` -------------------------------- ### Example API Request for Sunrise 2.0 Service Source: https://github.com/metno/weatherapi-docs/blob/master/doc/sunrise/astro.md Demonstrates a typical GET request to the Sunrise 2.0 API, specifying latitude, longitude, date, offset, and number of days to retrieve astronomical data. ```APIDOC https://api.met.no/weatherapi/sunrise/2.0?lat=59.93&lon=10.71&date=2018-05-11&offset=+01:00&days=1 ``` -------------------------------- ### Making a Basic API Request with curl Source: https://github.com/metno/weatherapi-docs/blob/master/doc/GettingStarted.md Demonstrates how to fetch weather forecast data for a specific location using the MET Weather API's Locationforecast service via `curl`. It highlights the importance of including a `User-Agent` header to avoid 403 Forbidden errors, as required by the API's Terms of Service. ```Shell $ curl -s 'https://api.met.no/weatherapi/locationforecast/2.0/compact?lat=51.5&lon=0'|json_pp ``` ```Shell $ curl -A "MyTestApp/0.1 support@example.com" -s 'https://api.met.no/weatherapi/locationforecast/2.0/compact?lat=51.5&lon=0'|json_pp ``` -------------------------------- ### Root-Relative Link Example in Documentation Source: https://github.com/metno/weatherapi-docs/blob/master/README.md Shows how to create root-relative links within the documentation to ensure they function correctly across different subdomains. This example links to the 'locationforecast' API documentation. ```Markdown ... see [locationforecast](/weatherapi/locationforecast/2.0/) for info. ``` -------------------------------- ### Inspecting API Response Headers with curl Source: https://github.com/metno/weatherapi-docs/blob/master/doc/GettingStarted.md Shows how to retrieve and examine HTTP response headers from the MET Weather API using `curl`'s `-I` (HEAD request) or `-i` options. Explains the meaning of the '203 Non-Authoritative Information' status code and its implications for API usage. ```Shell $ curl -A "MyTestApp/0.1 support@example.com" -I -s 'https://api.met.no/weatherapi/locationforecast/2.0/compact?lat=51.5&lon=0' ``` -------------------------------- ### Running Jekyll Locally for Documentation Preview Source: https://github.com/metno/weatherapi-docs/blob/master/README.md Command to start the Jekyll server locally, allowing developers to preview the documentation in a web browser before deployment. ```Shell ./site run ``` -------------------------------- ### Implement Efficient Caching with If-Modified-Since Header (cURL) Source: https://github.com/metno/weatherapi-docs/blob/master/doc/GettingStarted.md To optimize data retrieval and reduce bandwidth, clients should utilize the `Expires` and `Last-Modified` HTTP headers. After the `Expires` time, use the `If-Modified-Since` header with the `Last-Modified` value from a previous response. This approach allows the API to return a `304 Not Modified` status, indicating the data hasn't changed and avoiding unnecessary re-downloads. Note that `If-Modified-Since` may not work with beta or deprecated products. ```shell curl -A "MyTestApp/0.1 support@example.com" -i -H 'If-Modified-Since: Tue, 16 Jun 2020 12:11:59 GMT' \ -s 'https://api.met.no/weatherapi/locationforecast/2.0/compact?lat=51.5&lon=0' ``` -------------------------------- ### Example XML Response from Sunrise 2.0 Test Node Source: https://github.com/metno/weatherapi-docs/blob/master/doc/sunrise/astro.md Presents the XML output from the Sunrise 2.0 test node, which may include new information or a slightly different format compared to the production version. ```XML ``` -------------------------------- ### GitHub API HTTP to HTTPS Redirect Example Source: https://github.com/metno/weatherapi-docs/blob/master/_posts/2019-08-21-defcon.md This example demonstrates how the GitHub API handles an initial HTTP request by issuing a 301 Moved Permanently redirect to its corresponding HTTPS URL, followed by a successful 200 OK response from the HTTPS endpoint. This illustrates a common best practice for securing API traffic. ```Shell $ GET -Se http://api.github.com/users/octocat/orgs GET http://api.github.com/users/octocat/orgs 301 Moved Permanently Connection: close Date: Fri, 23 Aug 2019 11:08:56 GMT Location: https://api.github.com/users/octocat/orgs Content-Length: 0 Client-Date: Fri, 23 Aug 2019 11:08:57 GMT Client-Peer: 140.82.118.6:80 Client-Response-Num: 1 GET https://api.github.com/users/octocat/orgs 200 OK ``` -------------------------------- ### Example XML Response from Sunrise 2.0 API Source: https://github.com/metno/weatherapi-docs/blob/master/doc/sunrise/astro.md Illustrates the XML structure and data returned by the Sunrise 2.0 API for a typical request, detailing various moon and sun events and positions for specified dates. ```XML ``` -------------------------------- ### Indented Code Block Example (Working) Source: https://github.com/metno/weatherapi-docs/blob/master/README.md Demonstrates the correct way to define code blocks in the documentation using 4-space indentation, which is supported by the API's Markdown parser. This example shows a simple JSON object. ```JSON { "foo": "bar" } ``` -------------------------------- ### Example HTTP Headers from WeatherAPI Source: https://github.com/metno/weatherapi-docs/blob/master/doc/ProxyForBackends.md Illustrates the typical HTTP headers included in requests from the WeatherAPI, which should be used by backend services to construct links. ```JSON { "Accept-Encoding": "gzip", "Content-Length": "0", "Host": "edge.api.met.no:8080", "User-Agent": "WeatherAPI/edge.api.met.no:8080", "X-Forwarded-Host": "edge.api.met.no:8080", "X-Forwarded-Proto": "https" } ``` -------------------------------- ### YAML Front Matter for Documentation Pages Source: https://github.com/metno/weatherapi-docs/blob/master/README.md Example of the required YAML front matter (preamble) for all documentation files, specifying metadata such as title, date, author, layout type (page or post), and a short summary for external portals. ```YAML --- title: Heading of document (do not write this in the body text) date: when you wrote it author: your name layout: page (for docs) or post (for blog) summary: > A short description of the subject matter (used on developer.yr.no) --- ``` -------------------------------- ### Fenced Code Block Example (Non-Working) Source: https://github.com/metno/weatherapi-docs/blob/master/README.md Illustrates a fenced code block using backticks, which is *not* supported by the API's Markdown parser and should be avoided. This example also shows a JSON object. ```JSON ```json { "foo": "bar" } ``` ``` -------------------------------- ### Example XML Output for Astronomical Data Source: https://github.com/metno/weatherapi-docs/blob/master/doc/sunrise/astro.md This XML fragment illustrates the structure of astronomical data provided by the API, detailing moonset, sunset, sun position, and moon position with various attributes like time, azimuth, elevation, and illumination for specific dates. ```XML ``` -------------------------------- ### Recommended Client Libraries for Metno Weather API Source: https://github.com/metno/weatherapi-docs/blob/master/doc/locationforecast/HowTO.md A list of suggested third-party HTTP user-agent and JSON parsing libraries across various programming languages for interacting with the Metno Weather API. ```APIDOC | Language | HTTP useragent | JSON parser | | ---------- | ------------------------------------------------------------ | --------------------------------------------------- | | JavaScript | [Fetch](https://javascript.info/fetch) | [Fetch](https://javascript.info/fetch) | | Python | [requests](https://requests.readthedocs.io/en/master/) ([example](https://stackoverflow.com/questions/10606133/sending-user-agent-using-requests-library-in-python)) | [json](https://docs.python.org/3/library/json.html) | | Go | http-client | json | | Perl | Mojo::Useragent | Mojo::JSON::XS | ``` -------------------------------- ### Valid User-Agent String Examples for API Identification Source: https://github.com/metno/weatherapi-docs/blob/master/doc/TermsOfService.md Examples demonstrating the required format for the User-Agent header, which must be included in API requests for identification. The User-Agent string should contain the application/domain name, optionally a version number, and contact information like an email address or a link to a company website. Failure to provide a valid User-Agent may result in being blocked. ```Text "acmeweathersite.com support@acmeweathersite.com" "AcmeWeatherApp/0.9 github.com/acmeweatherapp" ``` -------------------------------- ### Example JSON Output for Sun Data Source: https://github.com/metno/weatherapi-docs/blob/master/doc/sunrise/celestial.md Illustrates the JSON response structure for Sun-related astronomical events, including coordinates, time intervals, and properties like solarmidnight, solarnoon, sunrise, and sunset with their respective times and elevations/azimuths. ```JSON { "type" : "Feature", "copyright" : "MET Norway", "licenseURL" : "https://api.met.no/license_data.html", "geometry" : { "coordinates" : [ 10.716667, 59.933333 ], "type" : "Point" }, "when" : { "interval" : [ "2022-12-17T23:17:00Z", "2022-12-18T23:17:00Z" ] }, "properties" : { "body" : "Sun", "solarmidnight" : { "disc_centre_elevation" : -53.47, "time" : "2022-12-19T00:13+01:00", "visible" : false }, "solarnoon" : { "disc_centre_elevation" : 6.67, "time" : "2022-12-18T12:13+01:00", "visible" : true }, "sunrise" : { "azimuth" : 140.12, "time" : "2022-12-18T09:16+01:00" }, "sunset" : { "azimuth" : 219.87, "time" : "2022-12-18T15:10+01:00" } } } ``` -------------------------------- ### Example: Forecast Metadata Structure Source: https://github.com/metno/weatherapi-docs/blob/master/doc/ForecastJSON.md Illustrates the structure of the 'meta' object within the forecast data, including 'updated_at' timestamp and 'units' for various weather parameters. ```JSON "meta": { "updated_at": "2020-06-10T13:04:26Z", "units": { "air_pressure_at_sea_level": "hPa", "air_temperature": "celsius", "air_temperature_max": "celsius", "air_temperature_min": "celsius", "cloud_area_fraction": "%", "cloud_area_fraction_high": "%", "cloud_area_fraction_low": "%", "cloud_area_fraction_medium": "%", "dew_point_temperature": "celsius", "fog_area_fraction": "%", "precipitation_amount": "mm", "precipitation_amount_max": "mm", "precipitation_amount_min": "mm", "probability_of_precipitation": "%", "probability_of_thunder": "%", "relative_humidity": "%", "ultraviolet_index_clear_sky": "1", "wind_from_direction": "degrees", "wind_speed": "m/s", "wind_speed_of_gust": "m/s" } } ``` -------------------------------- ### Index File Entry for Multi-Directory Products Source: https://github.com/metno/weatherapi-docs/blob/master/doc/indexfiles.md For products where data files are distributed across multiple directories, this example shows the inclusion of the 'dir' parameter. This parameter specifies the directory name where the file is located, enabling correct merging of index files in production environments. ```Data Format dir=web-portalen,filename=webnorge2km_20170324T100000Z.gif,radarsite=yr-norway,content=image,type=reflectivity,size=normal,time=2017-03-24T10:00:00Z ``` -------------------------------- ### Example JSON Output for Moon Data Source: https://github.com/metno/weatherapi-docs/blob/master/doc/sunrise/celestial.md Illustrates the JSON response structure for Moon-related astronomical events, including coordinates, time intervals, and properties like moonrise, moonset, high_moon, low_moon, and moonphase with their respective times, elevations, and azimuths. ```JSON { "copyright": "MET Norway", "licenseURL": "https://api.met.no/license_data.html", "type": "Feature", "geometry": { "type": "Point", "coordinates": [ 10.716667, 59.933333 ] }, "when": { "interval": [ "2022-12-17T23:17:00Z", "2022-12-18T23:17:00Z" ] }, "properties": { "body": "Moon", "moonrise": { "time": "2022-12-18T02:01+01:00", "azimuth": 98.49 }, "moonset": { "time": "2022-12-18T13:01+01:00", "azimuth": 255.99 }, "high_moon": { "time": "2022-12-18T07:41+01:00", "disc_centre_elevation": 23.89, "visible": true }, "low_moon": { "time": "2022-12-18T20:03+01:00", "disc_centre_elevation": -39.17, "visible": false }, "moonphase": { "value": 288.54 } } } ``` -------------------------------- ### Basic Index File Entry for Single Directory Source: https://github.com/metno/weatherapi-docs/blob/master/doc/indexfiles.md This example demonstrates the fundamental structure of an index file entry. Each line represents a single file, using comma-separated key=value pairs. It includes the mandatory 'filename' and 'time' parameters, crucial for identifying and managing data within a single directory. ```Data Format filename=World-IR-20170119140000.png,area=World,size=normal,type=IR,time=2017-01-19T14:00:00Z ``` -------------------------------- ### Example Meteorological Forecast JSON Response Source: https://github.com/metno/weatherapi-docs/blob/master/doc/ForecastJSON.md An excerpt illustrating the full structure of a forecast response, including geographical description, metadata, and a timeseries of detailed forecast data for various meteorological parameters. ```JSON { "type": "Feature", "geometry": { "type": "Point", "coordinates": [ 10, 60.1, 267 ] }, "properties": { "meta": { "updated_at": "2020-06-10T13:04:26Z", "units": { "air_pressure_at_sea_level": "hPa", "air_temperature": "celsius", "air_temperature_max": "celsius", "air_temperature_min": "celsius", "cloud_area_fraction": "%", "cloud_area_fraction_high": "%", "cloud_area_fraction_low": "%", "cloud_area_fraction_medium": "%", "dew_point_temperature": "celsius", "fog_area_fraction": "%", "precipitation_amount": "mm", "precipitation_amount_max": "mm", "precipitation_amount_min": "mm", "probability_of_precipitation": "%", "probability_of_thunder": "%", "relative_humidity": "%", "ultraviolet_index_clear_sky": "1", "wind_from_direction": "degrees", "wind_speed": "m/s", "wind_speed_of_gust": "m/s" } }, "timeseries": [ { "time": "2020-06-10T13:00:00Z", "data": { "instant": { "details": { "air_pressure_at_sea_level": 1020.5, "air_temperature": 20.7, "cloud_area_fraction": 58.0, "cloud_area_fraction_high": 47.7, "cloud_area_fraction_low": 17.7, "cloud_area_fraction_medium": 1.7, "dew_point_temperature": 9.5, "fog_area_fraction": 0.0, "relative_humidity": 48.6, "ultraviolet_index_clear_sky": 4.7, "wind_from_direction": 151.8, "wind_speed": 2.5, "wind_speed_of_gust": 6.6 } }, "next_12_hours": { "summary": { "symbol_code": "partlycloudy_day" }, "details": { "probability_of_precipitation": 2.2 } }, "next_1_hours": { "summary": { "symbol_code": "partlycloudy_day" }, "details": { "precipitation_amount": 0.0, "precipitation_amount_max": 0.0, "precipitation_amount_min": 0.0, "probability_of_precipitation": 0.0, "probability_of_thunder": 0.0 } }, "next_6_hours": { "summary": { "symbol_code": "partlycloudy_day" }, "details": { "air_temperature_max": 20.7, "air_temperature_min": 18.4, "precipitation_amount": 0.0, "precipitation_amount_max": 0.0, "precipitation_amount_min": 0.0, "probability_of_precipitation": 1.1 } } } } ] } ``` -------------------------------- ### Metno Weather API Request Handling Workflow Source: https://github.com/metno/weatherapi-docs/blob/master/doc/locationforecast/HowTO.md Detailed steps for making compliant and efficient requests to the Metno Weather API, including best practices for user-agent, caching, and error handling to avoid throttling or blacklisting. ```APIDOC 1. Initialize `sitename` with your website name and contact info. 2. Construct Locationforecast URL using HTTPS. 3. Generate a `User-Agent` object with `sitename` as value. 4. Call request method with URL, using non-blocking I/O (callback/promise). 5. Check HTTP Status (203, 429), `Expires`, and `Last-Modified` headers. 6. If 2xx status, parse JSON response body. 7. Store parsed data, `expires`, and `last_modified` locally. 8. Process and present forecast JSON data. 9. Before repeating request, check if current time is later than `expires`. 10. If `expires` is past, repeat request using `If-Modified-Since` header with `last_modified` value. If 304, continue using stored data. ``` -------------------------------- ### Locationforecast v1.9 Precipitation Output Example Source: https://github.com/metno/weatherapi-docs/blob/master/_posts/2019-11-13-changes.md An example XML snippet illustrating the updated precipitation element in Locationforecast version 1.9. This change introduces 'minvalue' and 'maxvalue' attributes for precipitation, applicable to the entire forecast duration in Nordic and Arctic regions. ```XML ``` -------------------------------- ### Perform a Preflighted CORS Request with XMLHttpRequest Source: https://github.com/metno/weatherapi-docs/blob/master/doc/WebClients.md Illustrates how to make a preflighted cross-origin request using XMLHttpRequest. This example sets a custom header (X-PINGOTHER) and a Content-Type of application/xml, which triggers an OPTIONS preflight request before the actual POST. ```JavaScript const xhr = new XMLHttpRequest(); xhr.open('POST', 'https://bar.other/resources/post-here/'); xhr.setRequestHeader('X-PINGOTHER', 'pingpong'); xhr.setRequestHeader('Content-Type', 'application/xml'); xhr.onreadystatechange = handler; xhr.send('Arun'); ``` -------------------------------- ### Ocean Forecast Wave Direction XML Example Source: https://github.com/metno/weatherapi-docs/blob/master/doc/FAQ.md This XML snippet illustrates the representation of wave and sea current directions in MET Norway's Oceanforecast and Gribfiles. It shows how 'meanTotalWaveDirection' and 'seaCurrentDirection' are expressed with a 'uom' (unit of measure) attribute in degrees. ```XML 45.2 131.4 ``` -------------------------------- ### Weather API Data Type Definitions Source: https://github.com/metno/weatherapi-docs/blob/master/doc/usage.md Defines the complete set of data types accepted by WeatherAPI products, using regular expressions and examples. All input parameters and URLs must use UTF-8 encoding. ```APIDOC Integer: Description: One or more occurrences of the number 0-9, possibly with plus or minus in front. Regex: /[+-]?\d+/ String: Description: One or more of any alphanumeric character plus underscore (_), but the first character must be a letter. Regex: /\p{Alphabetic} [\p{Alphabetic}\d_]*/ Float: Description: An integer optionally followed by a dot (.) and one or more integers. Possibly prefixed with plus or minuses. Regex: /[+-]?\d+(\.\d+)?/ Datetime: Description: An ISO 8601 date string. The timezone specifier, Z, is mandatory. Currently, only UTC dates are accepted. Example: 2007-01-01T08:00:00Z Regex: /\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}Z/ ``` -------------------------------- ### Oceanforecast Wave Direction Convention Change Example Source: https://github.com/metno/weatherapi-docs/blob/master/_posts/2021-03-26-oceanforecast.md Illustrates the change in wave direction convention from oceanographic ('going to') in Oceanforecast 0.9 XML to meteorological ('coming from') in Oceanforecast 2.0 JSON, along with the corresponding value change. ```XML 89.7 ``` ```JSON "sea_surface_wave_from_direction": 269.7 ``` -------------------------------- ### Handling CORS for Browser-based Metno API Requests Source: https://github.com/metno/weatherapi-docs/blob/master/doc/locationforecast/HowTO.md Explanation of Cross-Origin Resource Sharing (CORS) issues when accessing the Metno Weather API directly from a browser using JavaScript, emphasizing the importance of the Origin header and risks of production use. ```APIDOC When contacting the API directly from the browser using Javascript, you will run into [CORS issues](https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS). For example it is not possible to add your own `User-Agent` header; instead the browser will send an `Origin` header identifying your website by its URL. If this is missing, is `localhost` or a local IP address behind a firewall, you risk being throttled and/or blacklisted. Do not use this in production environments! ``` -------------------------------- ### Extract Metadata from a NetCDF File using ncdump Source: https://github.com/metno/weatherapi-docs/blob/master/doc/thredds.md This example demonstrates how to use the `ncdump` command-line tool to extract header metadata from a remote netCDF file accessible via OPeNDAP. It first sets an environment variable `CMEPS` to the URL of the dataset, then uses `ncdump -h` to print only the header (metadata) in CDL format. The output details the dimensions, variables, and their attributes for the weather forecast data. ```Shell export CMEPS=https://thredds.met.no/thredds/dodsC/metpplatest/met_forecast_1_0km_nordic_latest.nc ncdump -h $CMEPS ``` ```netCDF CDL netcdf met_forecast_1_0km_nordic_latest { dimensions: time = UNLIMITED ; // (57 currently) x = 1796 ; y = 2321 ; variables: double forecast_reference_time ; forecast_reference_time:units = "seconds since 1970-01-01 00:00:00 +00:00" ; forecast_reference_time:standard_name = "forecast_reference_time" ; int projection_lcc ; projection_lcc:grid_mapping_name = "lambert_conformal_conic" ; projection_lcc:standard_parallel = 63., 63. ; projection_lcc:longitude_of_central_meridian = 15. ; projection_lcc:latitude_of_projection_origin = 63. ; projection_lcc:earth_radius = 6371000. ; projection_lcc:proj4 = "+proj=lcc +lat_0=63 +lon_0=15 +lat_1=63 +lat_2=63 +no_defs +R=6.371e+06" ; double time(time) ; time:long_name = "time" ; time:standard_name = "time" ; time:units = "seconds since 1970-01-01 00:00:00 +00:00" ; time:_ChunkSizes = 1 ; double x(x) ; x:standard_name = "projection_x_coordinate" ; x:units = "m" ; x:_ChunkSizes = 1796 ; double y(y) ; y:standard_name = "projection_y_coordinate" ; y:units = "m" ; y:_ChunkSizes = 2321 ; float altitude(y, x) ; altitude:units = "m" ; altitude:standard_name = "surface_altitude" ; altitude:grid_mapping = "projection_lcc" ; altitude:coordinates = "longitude latitude" ; altitude:_ChunkSizes = 31, 1796 ; float land_area_fraction(y, x) ; land_area_fraction:standard_name = "land_area_fraction" ; land_area_fraction:grid_mapping = "projection_lcc" ; land_area_fraction:coordinates = "longitude latitude" ; land_area_fraction:units = "1" ; land_area_fraction:_ChunkSizes = 31, 1796 ; double latitude(y, x) ; latitude:units = "degree_north" ; latitude:long_name = "latitude" ; latitude:standard_name = "latitude" ; latitude:grid_mapping = "projection_lcc" ; latitude:_ChunkSizes = 31, 1796 ; double longitude(y, x) ; longitude:units = "degree_east" ; longitude:long_name = "longitude" ; longitude:standard_name = "longitude" ; longitude:grid_mapping = "projection_lcc" ; longitude:_ChunkSizes = 31, 1796 ; float air_temperature_2m(time, y, x) ; air_temperature_2m:coordinates = "longitude latitude" ; air_temperature_2m:units = "K" ; air_temperature_2m:standard_name = "air_temperature" ; air_temperature_2m:grid_mapping = "projection_lcc" ; air_temperature_2m:_ChunkSizes = 1, 31, 1796 ; float precipitation_amount(time, y, x) ; precipitation_amount:coordinates = "longitude latitude" ; precipitation_amount:units = "kg/m^2" ; precipitation_amount:standard_name = "precipitation_amount" ; precipitation_amount:grid_mapping = "projection_lcc" ; precipitation_amount:_ChunkSizes = 1, 31, 1796 ; float wind_direction_10m(time, y, x) ; wind_direction_10m:coordinates = "longitude latitude" ; wind_direction_10m:units = "degrees" ; wind_direction_10m:standard_name = "wind_direction" ; wind_direction_10m:grid_mapping = "projection_lcc" ; wind_direction_10m:_ChunkSizes = 1, 31, 1796 ; float wind_speed_10m(time, y, x) ; wind_speed_10m:coordinates = "longitude latitude" ; wind_speed_10m:units = "m/s" ; wind_speed_10m:standard_name = "wind_speed" ; wind_speed_10m:grid_mapping = "projection_lcc" ; wind_speed_10m:_ChunkSizes = 1, 31, 1796 ; float wind_speed_of_gust(time, y, x) ; wind_speed_of_gust:coordinates = "longitude latitude" ; wind_speed_of_gust:units = "m/s" ; wind_speed_of_gust:standard_name = "wind_speed_of_gust" ; wind_speed_of_gust:grid_mapping = "projection_lcc" ; } ``` -------------------------------- ### Example JSON-FG Feature with Temporal Interval Source: https://github.com/metno/weatherapi-docs/blob/master/doc/GeoJSON.md Illustrates a JSON-FG Feature object, showcasing the `when` attribute with an `interval` subunit for defining a temporal range. This structure is adopted by WeatherAPI for formats like General Area Forecast JSON, aligning with the OGC standard draft. ```json { "type": "Feature", "when": { "interval": [ "2021-09-29T12:00:00Z", "2021-09-30T12:00:00Z" ] }, "geometry": { "type": "Polygon", "coordinates": [ [ [ 8.709204563652449, 51.50352856284526, 100 ], [ 8.709312860802727, 51.503457005181794, 100 ], [ 8.709391968693081, 51.50350306810203, 100 ], [ 8.709283757429898, 51.503574715968284, 100 ], [ 8.709204563652449, 51.50352856284526, 100 ] ] ] }, "properties": { "lastChange": "2014-04-24T10:50:18Z", ... } } ``` -------------------------------- ### Index File Entry with Expiration and Update Timestamps Source: https://github.com/metno/weatherapi-docs/blob/master/doc/indexfiles.md This example illustrates how to include 'updated' and 'expires' parameters in an index file entry. The 'updated' timestamp indicates the last modification time for users, while the 'expires' timestamp facilitates automatic deletion and removal of files from the API, ensuring data freshness and efficient storage management. ```Data Format dir=halo-accumulated-precipitation,filename=halo-trondelagromsdal-pcappi-acrr-24h-polarWGS84-1000_20190109T060000Z.png,radarsite=central_norway,content=image,type=accumulated_24h,size=normal,time=2019-01-09T06:00:00Z,updated=2019-01-09T05:23:54Z,expires=2019-01-10T18:00:00Z ``` -------------------------------- ### Specify Temporal Validity with GeoJSON-T Timespan Source: https://github.com/metno/weatherapi-docs/blob/master/doc/GeoJSON.md This example illustrates a GeoJSON-T Feature object, which extends standard GeoJSON by adding a 'when' attribute to define temporal validity using 'timespans'. It shows how to set a start and end time for a feature's validity range. ```json { "type":"Feature", "when": { "timespans": [ { "start": { "in": "2021-09-29T12:00:00Z" }, "end": { "in": "2021-09-30T12:00:00Z" } } ] } } ``` -------------------------------- ### Project File Structure for WeatherAPI Documentation Source: https://github.com/metno/weatherapi-docs/blob/master/README.md Illustrates the typical Jekyll directory structure used for organizing documentation files, including 'doc' for Markdown content, '_layouts' for templates, '_posts' for blog articles, 'schemas' for XML schemas, and 'products' for non-WeatherAPI products. ```Text weatherapi-docs/ ├── doc │   ├── assets │   ├── locationforecast │   ├── metalerts │   ├── nowcast │   ├── oceanforecast │   └── sunrise ├── _layouts ├── _posts ├── products ├── schemas ├── _site └── README.md ``` -------------------------------- ### Access API Product Documentation (Newer Products) Source: https://github.com/metno/weatherapi-docs/blob/master/doc/usage.md Shows the simplified URL path for accessing documentation for newer API products, typically at the product root. ```URL https://api.met.no/weatherapi/dummy/0.3/ ``` -------------------------------- ### Access API Product Documentation (Traditional) Source: https://github.com/metno/weatherapi-docs/blob/master/doc/usage.md Illustrates the traditional URL path to access the reference documentation for an API product. ```URL https://api.met.no/weatherapi/dummy/0.3/documentation ``` -------------------------------- ### Recommended Map Service Providers Source: https://github.com/metno/weatherapi-docs/blob/master/doc/MapClients.md Overview of recommended map service providers, their licenses, and supported protocols. ```APIDOC |Name | License | Protocols | | OpenStreetMap | Open | WMS | | QGIS | Open | WMS | | Kartverket | Partly open | WMS | | Google Maps | Closed | KML | | [Apple MapKit](https://developer.apple.com/documentation/mapkit) | Closed | ? | | MapBox | Closed | WMS | | ArcGIS | Closed | WMS | ``` -------------------------------- ### List Available API Data (Default XML) Source: https://github.com/metno/weatherapi-docs/blob/master/doc/usage.md Demonstrates how to retrieve a list of available data files for a product, returning the default XML format. Not all handlers support this action. ```URL https://api.met.no/weatherapi/dummy/0.3/available ``` -------------------------------- ### Locationforecast 2.0 Complete API Endpoint Source: https://github.com/metno/weatherapi-docs/blob/master/doc/ForecastJSON.md An example API endpoint for retrieving a complete meteorological forecast response from the Met.no Weather API's Locationforecast 2.0 service, specifying latitude and longitude parameters. ```APIDOC GET /weatherapi/locationforecast/2.0/complete Description: Retrieves a complete meteorological forecast response for a specific geographical point. Parameters: lat: number (required) - Latitude of the location. lon: number (required) - Longitude of the location. Example: https://api.met.no/weatherapi/locationforecast/2.0/complete?lat=60.10&lon=10 ``` -------------------------------- ### Fetch API Data with Endpoint and Query String Source: https://github.com/metno/weatherapi-docs/blob/master/doc/usage.md Demonstrates how to retrieve data from the API by specifying an endpoint and query parameters after the product root URL. This is the recommended method for newer products. ```URL https://api.met.no/weatherapi/dummy/0.3/precipitation?area=Oslo ``` -------------------------------- ### Recommended Geocoding Service Providers Source: https://github.com/metno/weatherapi-docs/blob/master/doc/MapClients.md Lists recommended geocoding service providers and their licensing models. ```APIDOC |Name | License | | [GeoNames](https://www.geonames.org/) | Open | | [Nominatim](https://nominatim.org/) | Open | | [Google Geocoding API](https://developers.google.com/maps/documentation/geocoding/overview) | Closed | | MapBox | Closed | | ArcGIS | Closed | | QGIS plugins | Open | | Kartverket? | Partly open | ``` -------------------------------- ### Group Features in a GeoJSON FeatureCollection with Polygon Source: https://github.com/metno/weatherapi-docs/blob/master/doc/GeoJSON.md This example shows a GeoJSON 'FeatureCollection' containing multiple 'Feature' objects. It uses the 'Polygon' geometry type to define an area, illustrating the nested array structure for coordinates, which can include outer rings and holes. ```json { "type": "FeatureCollection", "features": [ { "type": "Feature", "geometry": { "type": "Polygon", "coordinates": [ [ [8.215333,58.089167], [8.525500,58.246167], [8.808833,58.396500] ... ] ] }, "properties": { ... } }, { ... ``` -------------------------------- ### textforecast 1.6 API Product Changes Source: https://github.com/metno/weatherapi-docs/blob/master/_posts/2019-03-04-new-products.md Outlines the removal of specific products from textforecast 1.6 and suggests their replacements in textforecast 2.0. ```APIDOC Product: textforecast 1.6 Removed Products: - "land" (use "landoverview" in 2.0) - "seaoslofjord" (use "coast_no" and "seabank_no" in 2.0) ``` -------------------------------- ### Locationforecast 2.0 API Endpoints Overview Source: https://github.com/metno/weatherapi-docs/blob/master/_posts/2020-06-12-locfc2.md Details the three main service endpoints for Locationforecast 2.0, outlining their purpose, included parameters, and intended use cases. This includes the 'complete' endpoint for all parameters, 'compact' for a core set, and 'classic' for backward compatibility. ```APIDOC /weatherapi/locationforecast/2.0/complete Description: Returns a response with all available forecast parameters. New parameters will be added here. Some geographical areas may have more parameters. /weatherapi/locationforecast/2.0/compact Description: Returns a response with only a core set of forecast parameters. All parameters in this endpoint are available for every location. New parameters will be added rarely. /weatherapi/locationforecast/2.0/classic Description: Exists only for backwards compatibility. Parameters and XML format are identical to /locationforecast/1.9, but with more time intervals. No new parameters expected. ``` -------------------------------- ### WeatherAPI Timeseries Data Structure Example Source: https://github.com/metno/weatherapi-docs/blob/master/doc/GeoJSON.md Demonstrates WeatherAPI's approach to temporal data within timeseries, where `time` attributes are embedded directly within `data` objects under a `timeseries` array. This structure is used for Locationforecast, Nowcast, and Oceanforecast, differing from JSON-FG's feature-per-timestamp approach. ```json "timeseries": [ { "time": "2020-06-10T13:00:00Z", "data": { ``` -------------------------------- ### textforecast 2.0 API Product Overview Source: https://github.com/metno/weatherapi-docs/blob/master/_posts/2019-03-04-new-products.md Details the new version of the text forecast API, featuring a new XML format, consistent data structure, and clearly defined areas. It also explains how areas are identified and where area files can be downloaded. ```APIDOC Product: textforecast 2.0 Status: New, launching soon Format: New XML format (validated) Structure: More consistent data structure, clearly defined areas Shared Format/Schema for: - landoverview - coast_en, coast_no - seabank_en, seabank_no, seabank_wmo - seahigh_en, seahigh_no, seahigh_wmo Area Identification: Areas identified with an ID for geographical coordinate polygon lookup (aids transition from textlocation). Area Files: Downloadable from the /areas endpoint (eventually to be included directly in the forecast). ``` -------------------------------- ### List Available API Data (JSON Format) Source: https://github.com/metno/weatherapi-docs/blob/master/doc/usage.md Shows how to request a list of available data files in JSON format. This action's availability depends on the specific product handler. ```URL https://api.met.no/weatherapi/dummy/0.3/available.json ``` -------------------------------- ### Jekyll Default Layout for Documentation Pages Source: https://github.com/metno/weatherapi-docs/blob/master/_layouts/post.html This Jekyll layout (`default.html`) provides the foundational structure for all documentation pages within the Metno Weather API project. It dynamically inserts the page title, optional tags, author, and date, wrapping the main content. It relies on Jekyll's built-in variables and Liquid templating for rendering. ```Liquid \--- layout: default --- {{ page.title }} ================ {% if page.tags %} tags: _{{ page.tags | join: "_ - _" }}_ {% endif %} {{content}} —{{ page.author | default: site.author }}, {{ page.date | date: "%-"d %B %Y" }} ``` -------------------------------- ### Metno Weather API Direct Client Connection Guidelines Source: https://github.com/metno/weatherapi-docs/blob/master/doc/TermsOfService.md Advises against direct client-to-API connections, recommending a local proxy (backend for frontend) for caching and authentication, with exceptions for low-volume simple requests and explicit non-support for non-simple JavaScript requests and CORS preflights. ```APIDOC Browsers and mobile apps should not contact the API directly, but instead use a local proxy (backend for frontend) server where you can cache data and add identification/authentication details (this is the canonical way of doing authentication in React since you cannot store client secrets in Javascript). ***Note: The conditions for using CORS are still under review and will be finalized later.*** Low-volume websites and mobile apps may use *simple* cross-origin Javascript requests and direct image links, provided the sites identifies itself as described above. If you start generating a lot of traffic against the API, you must set up a caching proxy gateway and route all traffic through this. Non-simple javascript requests (i.e. using authentication or other custom headers) and CORS preflights (whitelisting of your domain in the ``Access-Control-Allow-Origin` header) is explicitly not supported. ``` -------------------------------- ### Fetch API Data with Legacy Query String Source: https://github.com/metno/weatherapi-docs/blob/master/doc/usage.md Shows an older method of fetching data where query parameters are specified directly after the product root URL, without a specific endpoint. This practice is being phased out. ```URL https://api.met.no/weatherapi/dummy/0.3/?type=precipitation&area=Oslo ``` -------------------------------- ### NLAroutes API Available List with Region Filter Source: https://github.com/metno/weatherapi-docs/blob/master/_posts/2022-05-22-metalerts-nlaroutes.md Example of using the NLAroutes API to filter available routes and locations by a specific region. The 'region' parameter is new, and available regions include 'north', 'middle', 'southeast', 'southwest', 'coast', and 'old'. The 'old' region, affecting 16 routes and 13 locations, is scheduled for removal on July 1, 2022. ```APIDOC https://api.met.no/weatherapi/nlaroutes/1.0/available.json?region=middle Available regions: - north - middle - southeast - southwest - coast - old ``` -------------------------------- ### Airqualityforecast API Product Status Source: https://github.com/metno/weatherapi-docs/blob/master/_posts/2019-03-04-new-products.md Provides an update on the air quality forecast API, noting its development in cooperation with other public services and its expected exit from beta. ```APIDOC Product: Airqualityforecast Status: In cooperation with several public services, expected to go out of beta soon. ``` -------------------------------- ### Example GeoJSON Area Forecast Structure Source: https://github.com/metno/weatherapi-docs/blob/master/doc/AreaForecastJSON.md This snippet illustrates the overall structure of the area forecast JSON, which uses a GeoJSON FeatureCollection. It includes a sample feature with geometry (Polygon), a time interval, and properties like forecast type, area name, and the actual text forecast. The `lastChange` and `lang` attributes are also shown at the collection level, indicating when the forecast was generated and its language. ```json { "type" : "FeatureCollection", "lang" : "no", "lastChange" : "2022-09-16T12:00:00Z", "features" : [ { "type" : "Feature", "geometry" : { "type" : "Polygon", "coordinates" : [ [ [ 10.5443, 57.7603 ], [ 11.5058, 57.8628 ], [ 11.1707, 58.3362 ], [ 10.9042, 58.9392 ], [ 10.6532, 59.0437 ], [ 10.2247, 58.9727 ], [ 10.0482, 58.9565 ], [ 9.7847, 58.93 ], [ 9.595, 58.8522 ], [ 9.3692, 58.7597 ], [ 9.1537, 58.629 ], [ 8.8087, 58.3963 ], [ 10.5443, 57.7603 ] ] ] }, "when": { "interval": [ "2022-09-16T12:00:00Z", "2022-09-17T00:00:00Z" ] }, "properties" : { "forecasttype" : "sea", "name" : "Indre Skagerrak", "text" : "Nordlig periodevis frisk bris 10 m/s. Oppholdsvær og god sikt. I kveld kan hende enkelte regnbyger med moderat sikt." } } ] } ```