Environmental WebAPIs State of Art
Environmental WebAPIs State of Art
Environmental WebAPIs State of Art
net/publication/315712161
CITATIONS READS
0 1,278
1 author:
Peter Taylor
The Commonwealth Scientific and Industrial Research Organisation
24 PUBLICATIONS 92 CITATIONS
SEE PROFILE
All content following this page was uploaded by Peter Taylor on 31 March 2017.
Peter Taylor
30 June 2016
Environmental monitoring agencies deliver huge value through data delivery. From primary
industries and infrastructure to the general public, there are many consumers of environmental
data. Industries such as aviation, agriculture, emergency management, mining, defence, planning,
and health all make use of environmental data. People access environmental data through a
variety of channels but delivery is increasingly driven by software. Whether powering websites,
social media, email, or publications, data must be timely, reliable and fit for use.
Increasingly organisations are providing web-based access to data to allow development of
innovative applications and third-party products and services. This report reviews current
practices of Web-based Application Programming Interfaces (APIs) for delivery of environmental
data. Also referred to as Web services, APIs are increasingly being used for data delivery through
multiple media channels. We focus on practices that emerged through the ‘Web 2.0’ progression
of Web technologies. These technologies addressed rapid delivery of data to Web-based
applications, such as Facebook, Twitter, and so on. These approaches have strongly influenced
data delivery on the modern Web.
All environmental organisations have an opportunity to improve their ability to assist industries
and drive creation of new businesses by providing clear and descriptive access to its data through
Web APIs. In this report we cover four distinct aspects of the problem, as shown in Figure 1.
Nature of Related
environmental domain Web
data APIs
The structure follows from this: Section 2 defines what Web APIs are and why they are needed;
Section 3 provides a brief overview of the challenges associated with environmental data; Section
1.1 Scope
While this report originates within a hydrology-specific activity (WIRADA), it takes a broader look
at publishing environmental data on the Web. The report does not target any specific areas, but
attempts to look across a range of areas within environmental monitoring and data acquisition.
This report does not review existing standards of the Open Geospatial Consortium (OGC), as these
have been covered in other activities (Swain et al., 2015)(Percivall, 2010) and within the OGC test
beds. We do touch on a number of relevant activities related to the OGC (e.g. the GeoServices
API). Additionally the report does not investigate vocabulary (e.g. code lists) management and
delivery services. We also do no provide an in-depth review of Linked Data services (Heath and
Bizer, 2011), but acknowledge there is influence occurring between Linked Data and Web APIs
(see following section).
The term ‘Web API’ has no widely agreed formal definition. It generally refers to a server-side
Application Programming Interface (API). Such APIs provide software interfaces for message
systems based on a request-response pattern.
For the purposes of this report, the following statements apply to the term Web API:
• Mostly associated with the REpresentational State Transfer (REST) architectural style;
• Mostly use JSON encodings;
• The focus tends to be on web and mobile developers as consumers.
• There tends to be less focus on service-to-service interaction, and more on serving web
applications directly.
While Web APIs can be described using the more traditional term ‘Web Services’, these are often
associated with the suite of World Wide Web Consortium (W3C) Web Services standards. In this
sense, ‘Web Services’ typically use some or all of the following standards:
• Simple Object Access Protocol (SOAP);
• Web Service Definition Language (WSDL);
• Universal Description Discovery and Integration (UDDI);
• XML encodings.
The two terms also usually reflect a different user base. Table 1 provides a summary of service
types and related technologies, their typical users and origin. While this report focuses on the
‘Web 2.0’ style of APIs, there appears to be increasing convergence and cross-pollination of ideas
between Linked Data and Web APIs.
Table 1 - Service type categorisation
1
http://www.w3.org/2014/data-shapes/charter
Companies are using APIs as platforms for building their own services, as well as building a
community around their services. It is becoming an engagement model with their customers that
create positive feedback into their businesses.
When a company provides an API, it is providing a service to the developer community. This
involves making data available in some form. Designing Web APIs should be about minimising
friction for developers. This involves carefully balancing complexity with functionality. If a balance
is achieved then developers will use the API, build applications, tools, and write documentation.
An ecosystem begins to form. This greatly benefits the service provider as such an ecosystem
exploits the inherent value in data. It is also begins a feedback loop to services provided by the
service provider.
There are many reasons environmental organisations should provide APIs, including:
Build mobile apps more quickly. Having a managed API that provides easy access to data
lowers the entry for developers of mobile applications. The application may be developed
externally or internally; the API is part of the platform.
Customers increasingly want direct access to environmental data. Environmental data is
used in a myriad of ways. And the demand is only increasing. From agricultural services
providing decision support to farmers, to aquaculture companies managing fish pens,
environmental data is crucial to making informed decisions.
Avoid screen-scraping. Organisations typically provide many web sites with HTML data
tables, and graphics showing data as graphs and maps. Developers sometimes try to get
the underlying data by ‘scraping’ the web-page, sometimes even involving inferring data
from graphics. This is a brittle way to share data. Changes to websites break software;
Understanding the user base (end users) gives us an idea of the requirements for specific
applications. Some of these requirements we may know already (applications exist), some may
have been requested (indicates a need), others we may never predict (novel uses of data).
Describing the potential user groups is a useful starting point for understanding requirements.
A report for the Australian Water Resource Information System (AWRIS) (National Water
Commission, 2006) includes an initial analysis of user requirements for hydrological data. The
scope of this report is wider than hydrological data, however the AWRIS report serves as a useful
starting point.
The bold terms in the scenario description identify data requirements. We further break the
scenario into two phases: an analysis phase focused on viability of the plant, and an operational
phase once a plant is in place. It would be sensible for the company consider other non-water data
sources. Figure 4 describes a fictional way in which different Web APIs could support these two
phases. Third parties are introduced to identify the role of data brokers/service providers. These
providers may offer analytical services to Blue Sky to support the project phases. Blue Sky or the
originating organisation may even provide this role. A scenario like this also provides interesting
options for cost structures for data, analytics and support.
The following environmental data products have potential for use in such a scenario:
Analysis phase
Seasonal forecasts – what are the mid-term expectations around water availability?
Climate statistics – how can previous conditions inform analysis of the plant viability?
Water quality – does the water quality match plant operation requirements?
Catchments/spatial regions – analysis of suitable regions would require an understanding
of catchment areas and general spatial features (nearby assets, hydrological features etc.).
Operational phase
Short-term weather – monitoring for severe weather events;
Flow predictions – manage quantities for intakes;
Seasonal forecasts – medium-term production forecasts based on access to water;
Water quality – ensure adequate water quality is being maintained.
These are fictional usages of data, but most already exist in industry in some form. The scenario is
used to indicate the new ways in which organisations are becoming more data-driven. Increasing
the ways and ease in which organisations can access data is an important catalyst in the creation
of these businesses.
“organizations which design systems ... are constrained to produce designs which are copies of
the communication structures of these organizations”
This is typical for organisations with long histories - there are systems that are isolated and not
connected to other relevant parts. The result is data access over the Internet is segregated: there
are multiple ways to get to similar data, there is overlap between reporting services, and it’s
difficult for developers to find where best to access data.
Additionally, environmental agencies deal in data that are inherently complex. Providing a single,
simple Web API to access data is not trivial. We cannot simply follow the ‘develop a REST service
for your products’ tutorial. Environmental data are diverse and dynamic. From a simple analysis of
a typical environmental agency’s data products and services, we identified 63 distinct Internet
offerings. These range from observations to forecasts, weather to hydrology, and point data to
gridded data.
This leads to the primary question explored in this report: how do organisations provide
consistent Web APIs across a range of environmental data products?
2
https://en.wikipedia.org/wiki/Conway%27s_law
Environmental data suffers from all the Big Data challenges, known as the ‘Vs’ of Big Data. This
provides a useful frame to describe the challenges environmental agencies face in handling its
data. Figure 5 provides some examples of how environmental data relate to each of the ‘V’
challenges, which are discussed below.
Organisational complexity
Meteorology, Synchronisation
Climatalogy, with other Data validity
Hydrology organisations
Organisational
differences
Variety – There is huge variety in the data managed by environmental agencies. Issues requiring
consideration include:
Temporal nature: observations and forecasts;
Structure: point and gridded;
Multi-modal: images, video, spectra, point clouds etc.
Domain specific: meteorological, hydrological, climatological, oceanography, etc.
There is an enormous number of APIs on the Web. ProgrammableWeb3 lists over 14,000 available
APIs in their catalog of APIs. These include APIs for sports, social, weather, finance, design and so
on. Many of these APIs are location or context specific – for example providing an API to Norway’s
library catalog, or an event search API for Europe.
There are environmental APIs within this catalog. Many are registrations of federal/national data
services, such as NOAA, USGS for the US. There has been enormous growth in weather prediction
services, and 182 APIs listed are associated with weather data. In turn, this has spawned services
that aggregate and compare forecast quality across services4.
Reviewing all these APIs was not feasible for this analysis. In this section we cover some of the
main environmental data APIs we have been able to identify. The focus is on environmental
agencies operating meteorological, hydrological, oceanographic, and related monitoring and
forecasting programs. We seek to categorise the key characteristics of these APIs with the aim of
describing the current practices, and direction that Web APIs are heading. In Appendix A we
provide a summary of the APIs and their key characteristics.
3 http://ww.programmableweb.com
4
http://www.weatherapi.net/compare-forecasts/
Most service links lead to a specific data centre’s web site and associated web service, which,
understandably, shows integration is a long-term goal. There is a large number of APIs available; a
selection from some of the categories are shown in Table 2. The Climate API v2 provides a RESTful
API and is summarised in the following section.
Table 2 - Selection of NOAA APIs
Climate Data API v2 Search and access datasets and station and/or location JSON
data.
Climate REST Services Station network locations and climatological GIS JSON, XML
products.
Catalog Services A catalog service that conforms to the HTTP protocol XML
(CSW) binding of the OpenGIS Catalog Service ISO Metadata
Application Profile specification.
Severe Weather Data NEXRAD Storm Cell Attributes, Storm Reports. XML, CSV, KMZ,
Inventory Shapefile
The basic resources of the NOAA Climate API are summarised in Figure 7.
•Monitoring stations
/stations •Individual automatic weather station
The API provides a landing page (Code listing 1) that describes the available resource end points,
available parameters and whether they are required. This is good practice and generally
recommended within RESTful APIs.
[
{
"path": "v2/lcd/availablereporttypes",
"method": "GET",
"parameters": [
{
"name": "stationid",
"required": false
},
{
"name": "locationid",
"required": false
},
{
"name": "startdate",
"required": true
},
{
"name": "enddate",
"required": true
}
]
},
The resources in this API do not make use of embedded links within the JSON response
documents, which would allow automated traversal of the API. It also requires the client
understand the relationship between relevant resources. For example to find precipitation data,
one must use the ‘datatype’ resource to retrieve a list of all the codes; see example HTTP request
and JSON response in Listing 2.
Listing 2 - example datatype listing
{
"metadata": {
"resultset": {
"offset": 1,
"count": 1461,
"limit": 1000
}
},
"results": [
{
"mindate": "1994-03-19",
"maxdate": "1996-05-28",
"name": "Average cloudiness midnight to midnight from 30-second ceilometer data (percent)",
"datacoverage": 1,
"id": "ACMC"
},
{
"mindate": "1965-01-01",
"maxdate": "2005-12-31",
"name": "Average cloudiness midnight to midnight from manual observations (percent)",
"datacoverage": 1,
"id": "ACMH"
},
{
"mindate": "1994-02-01",
"maxdate": "1996-05-28",
"name": "Average cloudiness sunrise to sunset from 30-second ceilometer data (percent)",
"datacoverage": 1,
"id": "ACSC"
},
{
"metadata": {
"resultset": {
"offset": 1,
"count": 7480,
"limit": 25
}
},
"results": [
{
"elevation": 408.4,
"mindate": "1980-01-01",
"maxdate": "2012-08-31",
"latitude": -14.31667,
"name": "AASUFOU, US",
"datacoverage": 1,
"id": "GHCND:AQC00914000",
"elevationUnit": "METERS",
"longitude": -170.76667
},
{
"elevation": 3.7,
"mindate": "1945-08-01",
"maxdate": "2015-12-30",
"latitude": -14.33056,
"name": "PAGO PAGO WEATHER SERVICE OFFICE AIRPORT, US",
"datacoverage": 1,
"id": "GHCND:AQW00061705",
"elevationUnit": "METERS",
"longitude": -170.71361
},
In addition to the datatype ID, a dataset ID is required, in the example case this is requested as
shown in Listing 4.
Listing 4 - requesting a dataset for a specific datatype
This then allows a query to be made against the ‘data’ resource itself, as shown in Listing 5.
Listing 5 - requesting data for multiple stations of a particular datatype, within a time window
GET http://www.ncdc.noaa.gov/cdo-web/api/v2/data?datatypeid=ANN-PRCP-AVGNDS-
GE001HI&startdate=2010-01-01&enddate=2010-02-06&datasetid=NORMAL_ANN (auth header required)
{
"metadata": {
"resultset": {
"offset": 1,
"count": 7484,
"limit": 25
}
},
"results": [
{
"date": "2010-01-01T00:00:00",
"datatype": "ANN-PRCP-AVGNDS-GE001HI",
"station": "GHCND:AQC00914000",
"attributes": "P",
"value": 2275
},
{
"date": "2010-01-01T00:00:00",
"datatype": "ANN-PRCP-AVGNDS-GE001HI",
"station": "GHCND:AQW00061705",
"attributes": "C",
"value": 2495
},
continues for 7848 points
The use of disjoint resources allows query flexibility, but also requires the client to understand the
resource model and which queries are logical. This is done through a combination of reading
documentation and making example queries.
Key characteristics:
Incomplete metadata.
Uses code lists without much description of code specifics.
No use of links/hypermedia.
The service does not provide links and thus lacks the hypermedia component of RESTful APIs. The
JSON representation appears to be a direct translation from XML, and thus mimics XML’s
structure. This in itself is not a problem, however in some cases it maps attributes using an
ampersand character (e.g. “@name”), which is OK for plain JSON but may conflict in Linked Data
JSON (JSON-LD) where ampersands are used for semantic mark-up.
The capabilities requests provide a summary of available datasets within a particular product; see
Listing 6 for an example listing of forecast layers. An example site listing response is shown in
Listing 7. There is no paging applied to this response, which results in all sites being returned
(1.4MB JSON response). Listing 8 shows an example of a regional text forecast encoded in JSON.
Listing 6 - example capabilities for forecast layers (modified for formatting)
GET
http://datapoint.metoffice.gov.uk/public/data/layer/wxfcs/all/json/capabilities?res=hourly&key=<K
EY>
5
http://www.metoffice.gov.uk/datapoint
GET http://datapoint.metoffice.gov.uk/public/data/val/wxfcs/all/json/sitelist?key=<KEY>
{
"Locations": {
"Location": [
{
"elevation": "933.0",
"id": "3072",
"latitude": "56.879",
"longitude": "-3.42",
"name": "Cairnwell",
"nationalPark": "Cairngorms National Park",
"region": "ta",
"unitaryAuthArea": "Perth and Kinross"
},
{
"elevation": "134.0",
"id": "3088",
"latitude": "56.852",
"longitude": "-2.264",
"name": "Inverbervie",
"region": "gr",
"unitaryAuthArea": "Aberdeenshire"
},
{
"elevation": "4.0",
"id": "3094",
"latitude": "57.698",
"longitude": "-2.121",
"name": "Rosehearty Samos",
"region": "gr",
"unitaryAuthArea": "Aberdeenshire"
}
…continues
GET http://datapoint.metoffice.gov.uk/public/data/txt/wxfcs/regionalforecast/json/507?key=<KEY>
GET http://datapoint.metoffice.gov.uk/public/data/txt/wxobs/ukextremes/json/latest?key=<KEY>
Key characteristics:
Observations and forecasts supported
Capabilities for discovery of available time slices
Text-based documentation
No linking
JSON or XML responses available
Supports imagery and descriptive text outputs
Implicit CRS for lat/lon values
Key characteristics:
6 https://developer.forecast.io/docs/v2
7
http://darkskyapp.com/
GET
http://waterservices.usgs.gov/nwis/iv/?format=json,1.1&sites=01646500¶meterCd=00060,00065
8
http://waterservices.usgs.gov/rest/
The USGS has also recently introduced a statistics web service and is similar in design (key-value
pairs). It provides daily, monthly and annual statistics for continuous monitoring stations. It
currently only supports CSV responses, with JSON and XML planned for future work.
Key characteristics:
Species Profile Taxonomic name, concept Search for all ‘Acacia’ species
lookups, autocomplete
services.
Occurrence Specimen & observation data Search for the records for the
searching. genus Macropus returning
taxonomic, geospatial,
temporal information for
occurrences.
Data Providers Data provider metadata Get data from the CSIRO
including taxonomic scope, National Fish Collection.
attribution.
General data Dashboard data feeds, data Get list of all licences used by
licences, region lists etc. ALA.
Taxonomy Taxonomic services. E.g. name Higher taxa for Macropus rufus
lookups, higher order lookups.
Species lists Web services for storage, Get a species list for ‘Red
creation and querying of lists. Kangaroo’.
GET http://collections.ala.org.au/ws/institution/in25
GET http://spatial.ala.org.au/ws/object/3742602
{
"name": "Australian Capital Territory",
"id": "Australian Capital Territory",
"description": "Australian Capital Territory, Territory",
"pid": "3742602",
"wmsurl":
"http://spatial.ala.org.au/geoserver/wms?service=WMS&version=1.1.0&request=GetMap&layers=ALA:Objects&fo
rmat=image/png&viewparams=s:3742602",
"area_km": 2428.0110849586404,
"bbox": "POLYGON((148.761582 -35.92208,148.761582 -35.1119459999999,150.772781 -
35.1119459999999,150.772781 -35.92208,148.761582 -35.92208))",
"fid": "cl22",
"fieldname": "Australian States and Territories"
}
The ALA documentation also provides some interesting features, such as the ability to view
historical calls to the public API, including frequency, slow requests, error requests etc. (Figure 9).
Key characteristics:
A lot of use of linked resources.
Good level of metadata.
9 http://api.ala.org.au/
10
http://www.odata.org/
SensorThings splits the O&M model across two classes: Datastream and Observation. Datastreams
are the top-level class with a subset of the O&M Observation properties: observedProperty,
resultTime, phenomenonTime (see example in Listing 13). The observations property is analogous
to result in the OM_Observation type, but in this case contains a set of Observation objects (see
example in Listing 14). Each of these is typed according to its observation type from O&M
(Measurement, Geometry etc.).
Listing 13 – A SensorThing Datastream
{
"@iot.id": 1,
"@iot.selfLink": "http://example.org/v1.0/Datastreams(1)",
"Thing@iot.navigationLink": "HistoricalLocations(1)/Thing",
"Sensor@iot.navigationLink": "Datastreams(1)/Sensor",
"ObservedProperty@iot.navigationLink": "Datastreams(1)/ObservedProperty",
"Observations@iot.navigationLink": "Datastreams(1)/Observations",
"description": "This is a datastream measuring the temperature in an oven.",
"unitOfMeasurement": {
"name": "degree Celsius",
"symbol": "°C",
"definition": "http://unitsofmeasure.org/ucum.html#para-30"
},
"observationType": "http://www.opengis.net/def/observationType/OGCOM/2.0/OM_Measurement",
"observedArea": {
"type": "Polygon",
"coordinates": [[[100,0],[101,0],[101,1],[100,1],[100,0]]]
},
"phenomenonTime": "2014-03-01T13:00:00Z/2015-05-11T15:30:00Z",
"resultTime": "2014-03-01T13:00:00Z/2015-05-11T15:30:00Z"
}
{
"@iot.id": 1,
"@iot.selfLink": "http://example.org/v1.0/Observations(1)",
"FeatureOfInterest@iot.navigationLink": "Observations(1)/FeatureOfInterest",
"Datastream@iot.navigationLink":"Observations(1)/Datastream",
"phenomenonTime": "2014-12-31T11:59:59.00+08:00",
"resultTime": "2014-12-31T11:59:59.00+08:00",
"result": 70.4
}
The structure of the JSON encoding follows patterns defined by OData. It does not strictly follow
the OData specification (Liang et al., 2015, p. 19), but reuses the common patterns, identifier, and
link structures.
Key characteristics:
Uses OData as a pattern for response encoding and link handling.
Generic IoT problem space – applicable to most sensor applications.
Light metadata.
Linked resources.
Implicit CRS.
11
https://data.nbn.org.uk/Documentation/Web_Services/Web_Services-REST/resources/restapi/application.wadl
Catalog Provides a simple catalog of available Catalog Service for the Web
services. (CS/W)
Map Service Access to maps as images, tiled maps, Web Mapping Service (WMS)
maps with coordinate transformations,
time-indexed maps, request/identify
features using specific geometries, search
maps using query parameters.
Feature Service Retrieve, add, update and delete spatial Web Feature Service (WFS)
features. Add attachments to features.
Search relationships between features.
Geometry Service Provides common geometry operations, Web Processing Service (WPS),
including: project, simplify, length and
area calculations, distance, convex hull,
cut, difference, intersect etc.
Image Service Service to retrieve and query imagery Web Coverage Service (WCS),
data (e.g. satellite imagery). Supports Web Mapping Service (WMS).
Geoprocessing Service Execute and monitor geoprocessing tasks Web Processing Service (WPS)
asynchronously or synchronously.
Geocoding Service Lookup addresses relating to locations OGC Open Location Services
and visa versa (reverse geocoding). (OpenLS)
Key characteristics:
Wide geospatial functionality.
No use of links.
No use of existing OGC standards.
Uses JSON Schema to describe responses.
Good separation of API endpoints into clear functions.
Formal, not adopted, document-based specification.
The RESTful API is documented using Swagger (see section 5.1.1) as shown in Figure 12. The
potential information available through is API is vast. Faceted search is available that supports
spatial and thematic drill-down style discovery12 of resources. A SPARQL endpoint is also
available13 for Linked Data clients. Multiple response formats are available to maximise data
availability. For example, an organisation may be viewed as images of linked resources (e.g.
CSIRO14). This facilitates exploration of the related resources, such as exploring reports published
from people within an organisation.
12 https://gcis-search.jpl.net/search
13 http://data.globalchange.gov/sparql
14
http://data.globalchange.gov/organization/commonwealth-scientific-industrial-research-organisation.svg
Key characteristics:
Expansive scope.
Swagger-based documentation.
Lots of use of linking.
Support for Linked Data encodings and access.
The Agency also provides a Bathing Water Profile16 as a way of grouping information relating to
specific bathing locations, such as the beach, rivers streams and pollution sources.
Key characteristics:
Detailed documentation.
Re-use of standard/common vocabularies.
‘Native’ Linked Data – supports multiple formats.
Clear URI guidelines and adherence to LDA guidelines17.
4.11 CKAN
The Comprehensive Knowledge Archive Network (CKAN) is an open source data management
system that supports registration of data assets by third parties. It is used by a range of open data
15 https://code.google.com/p/linked-data-api/wiki/Specification
16 http://environment.data.gov.uk/bwq/doc/api-bwp-reference-v0.1.html#BathingWaterProfile
17
https://github.com/UKGovLD/linked-data-api/blob/wiki/Specification.md
THREDDS is not a Web API in the sense of the definition within this report, however it does
provide some REST-like interfaces and is a component within larger aggregated environmental
data system discussed below.
18
http://www.unidata.ucar.edu/software/thredds/current/netcdf-java/CDM/index.html
Resource URL
info http://coastwatch.pfeg.noaa.gov/erddap/info/index.htmlTable?page=1&itemsPerP
age=1000
search http://coastwatch.pfeg.noaa.gov/erddap/search/index.htmlTable?page=1&itemsPe
rPage=1000&searchFor=
categorize http://coastwatch.pfeg.noaa.gov/erddap/categorize/index.htmlTable?page=1&item
sPerPage=1000
griddap http://coastwatch.pfeg.noaa.gov/erddap/griddap/index.htmlTable?page=1&itemsP
erPage=1000
tabledap http://coastwatch.pfeg.noaa.gov/erddap/tabledap/index.htmlTable?page=1&items
PerPage=1000
wms http://coastwatch.pfeg.noaa.gov/erddap/wms/index.htmlTable?page=1&itemsPerP
age=1000
Using its key abstraction, ERDAPP can source data from SOS, WCS, WFS, ArcGIS, text, DAP, NetCDF
among others, and republish using KML, JSON, R, WFS, SOS, WCS and so on. In this sense it is a
powerful data server that can operate as a broker between a users’ desired output and the
original data source.
Key characteristics:
Aggregator of common data access protocols and standards
RESTful API using grid and table simplification pattern
Supports multiple service interfaces and response formats
Swagger is a set of tools and services that help API developers generate documentation for APIs.
The Swagger UI19 renders a documentation page that provides full description of endpoints, with
in-line forms allowing test calls to be made to services. The UI can be generated from an API
specification document, which could be handwritten or generated from a service.
The specification of a service is done using JSON or YAML that follows the Swagger specification
schema20. A JSON Schema is available to validate specification documents21. The specification
defines all the standard parts of a RESTful API: the resource endpoints, supported functions (GET,
POST, DELETE, OPTIONS etc.), media types, parameters, and responses.
Swagger was used in the WaterML2.0 part 2 Interoperability Experiment to document the CSIRO
RESTful API22, as shown in Figure 15. The addition of inline parameter description and testing
provides an interactive document that is useful for developers. The service description is also
rendered as a RESTful API, which shows and example of the service description document23.
19 http://petstore.swagger.io/
20 http://swagger.io/specification/
21 https://github.com/swagger-api/validator-badge
22 http://waterml2.csiro.au/rgs-api/v1/docs
23
http://waterml2.csiro.au/rgs-api/v1/docs/api-docs/conversion
The RESTful API Modeling Language (RAML) is a non-proprietary open specification that is similar
to the Swagger specification in terms of its scope and implementation. It provides a JSON and
YAML description of RESTful APIs24.
5.1.3 RESTDesc
RESTDesc25 uses semantic approaches to define the functionality of hypermedia APIs. It uses the
RDF Turtle encoding to describe the resources and hypermedia links using existing semantic
vocabularies. In this sense it is simply a set of patterns for how to use existing vocabularies to
describe RESTful APIs.
The Web Application Description Language (WADL)26 is a W3C member submission (not a
standard), which provides an XML schema to describe Web API interfaces. It does this through
defining the API’s resources, the supported operations on each resource, and available query
24 http://raml.org/spec.html
25 http://restdesc.org/
26
http://www.w3.org/Submission/wadl/
Mashery29 has a suite of API offerings including services for API management, development,
documentation, security, and testing. The documentation engine is very similar to that of Swagger.
It offers generated HTML pages with forms to interact with an API. Its specification does not
appear to be open.
The RESTful Service Description Language (RSDL)30 is an XML format for describing RESTful
services, including resources, media types, methods, links, authentication, parameters etc.
5.2.1 I-JSON
Internet JSON (I-JSON) is a specification that adds additional constraints to the IETF JSON31 to aid
interoperability and software compatibility for JSON on the Web. It is not a specific definition of
27 http://www.w3.org/Submission/wadl/wadl.xsd
28 https://apiblueprint.org/
29 http://www.mashery.com/api/io-docs
30 http://www.balisage.net/Proceedings/vol10/html/Robie01/BalisageVol10-Robie01.html
31
https://www.ietf.org/rfc/rfc4627.txt
HAL32 provides a standardised response structuring for JSON and XML responses for Web APIs. The
basis for the structure is through the separation of resources, links, and embedded resources, as
shown in Figure 16.
32 http://stateless.co/hal_specification.html
HAL makes strong use of the hypermedia aspect of RESTful APIs through the use of link encodings.
It also supports URL templates33 in its link definitions. An example response is shown below.
{
"_links": {
"self": { "href": "/orders" },
"curies": [{ "name": "ea", "href": "http://example.com/docs/rels/{rel}", "templated": true }],
"next": { "href": "/orders?page=2" },
"ea:find": {
"href": "/orders{?id}",
"templated": true
},
"ea:admin": [{
"href": "/admins/2",
"title": "Fred"
}, {
"href": "/admins/5",
"title": "Kate"
}]
},
"currentlyProcessing": 14,
"shippedToday": 20,
"_embedded": {
"ea:order": [{
"_links": {
"self": { "href": "/orders/123" },
"ea:basket": { "href": "/baskets/98712" },
"ea:customer": { "href": "/customers/7809" }
},
"total": 30.00,
"currency": "USD",
"status": "shipped"
}, {
"_links": {
"self": { "href": "/orders/124" },
33
https://tools.ietf.org/html/rfc6570
Collection + JSON35 specifies a common structuring for retrieving, updating and deleting
collections of resources through an API. It does this through specifying patterns for using HTTP
Link Headers and providing a common structuring of collections with embedded objects. It has
similar goals to that of HAL.
A collection + JSON media type (application/vnd.collection+json) has been registered with IANA as
a common media type36. However the actual structuring has no status as a standard.
5.2.4 SIREN
SIREN37 is a structuring specification for JSON responses in Web APIs. Its scope is very similar to
that of HAL and Collection + JSON. It separates three key aspects: entities (resources), links and
actions. There is structure for embedding entities in the same way HAL does.
An example response is shown below.
{
"class": [ "order" ],
"properties": {
"orderNumber": 42,
"itemCount": 3,
"status": "pending"
},
"entities": [
{
"class": [ "items", "collection" ],
"rel": [ "http://x.io/rels/order-items" ],
"href": "http://api.x.io/orders/42/items"
},
{
"class": [ "info", "customer" ],
"rel": [ "http://x.io/rels/customer" ],
"properties": {
"customerId": "pj123",
"name": "Peter Joseph"
},
"links": [
{ "rel": [ "self" ], "href": "http://api.x.io/customers/pj123" }
]
34 https://tools.ietf.org/html/draft-kelly-json-hal-07
35 http://amundsen.com/media-types/collection/format/
36 http://www.iana.org/assignments/media-types/application/vnd.collection+json
37
https://github.com/kevinswiber/siren/blob/master/README.md
UBER38 is a document format that supports state transfers (hypermedia) and object encoding. It is
designed to be protocol-agnostic, with guidance on how to implement it using HTTP with XML or
JSON. It achieves this through use of reserved string properties that carry specific semantics in
terms of state transitions (actions), templates, and embedded or linked resources.
JSON API39 is a specification of conventions for structuring JSON responses from Web APIs. It
addresses encoding issues such as content negotiation, document structure (links, compound
documents, metadata), sorting, pagination, and creating/updating/deleting resources. The
implementations appear to growing40 and the Github repository is very active. It addresses a
number of common issues across APIs, some of which have been identified in OGC REST activities.
5.2.7 Hydra
Hydra41 uses JSON-LD with a vocabulary42 to allow a server to advertise its state transitions to
clients, again to enable HATEOAS properties of Web APIs. The vocabulary defines the common
concepts within a RESTful API: Resources, Operations, Status Codes, Paged Collections, and Links.
A summary of the vocabulary is shown in Figure 17.
38 https://rawgit.com/uber-hypermedia/specification/master/uber-hypermedia.html
39 http://jsonapi.org/
40 http://jsonapi.org/implementations/
41 http://www.markus-lanthaler.com/hydra/
42
http://www.hydra-cg.com/spec/latest/core/
This vocabulary is then used to embed JSON-LD descriptions in JSON documents that describe a
Web API. There is an active W3C Community Group43 supporting the Hydra specification. The
Hydra vocabulary is used within the Linked Data Fragments44 implementations, which is a
generalisation on access mechanisms for Linked Data.
43 https://www.w3.org/community/hydra/
44
http://www.hydra-cg.com/spec/latest/linked-data-fragments/
These features are becoming increasingly important as organisations deploy more APIs, and look
to manage and monetise their APIs. There are many API management frameworks available, with
products focussing on specific features or supporting the suite of API management tools. An in
depth review of these is out of scope for this report, however a summary is provided in Table 6.
The table represents a very superficial review: no installations or testing of features was
performed. There are components that focus on particular features and some that have richer
support within a feature category. For example, ‘security’ can range from basic HTTP
authentication to OAuth2.0, single sign-on, and encryption etc. The categories are only to indicate
some level of support. A more in depth analysis would be required to make a well-informed
decision.
49 Via https://market.mashape.com
Web APIs hold great potential for agencies to provide on-demand, tailored and robust
environmental data. Accordingly, the design and implementation of Web APIs should be done with
careful consideration of existing practices. It is beneficial to be consistent with existing practices,
while being wary not to adopt practices that gain no traction.
It is obvious that most organisations are tackling the API design challenges. Many services have
evolved from the ground up and organisations are attempting to consolidate into more simple,
cohesive Web APIs. All these APIs have made simplifications and trade-offs when designing their
APIs to suit their intended audience. This report summarises a broad range of existing practices
with the aim of informing the design of future environmental data Web APIs. To complement the
analysis within this report, we provide some general observations and learnings based on our
experiences using and developing Web APIs.
6.1 General
Recommendation 1 – focus on core requirements
When designing APIs it is important to understand your users, while keeping in mind they may not
yet exist. Try to identify core requirements as a starting point, and build out as your user’s
requirements and needs grow.
Recommendation 2 – clearly separate functionality into separate APIs
Highly abstracted APIs can be difficult to understand and may be a barrier for new users. Trying to
do too many things in a single API or Web Service can result in an overly complex, hard to
understand API. Partitioning APIs into concrete API endpoints, each having clearly stated functions
help to build understanding.
RESTful APIs have a natural separation into ‘sub APIs’ through the use of the resource end points.
This can be a useful way of separating clear logical parts of the API that reflect nouns. For example
the GitHub API resources use very concrete nouns that reflect the nature of the API interaction –
see Figure 18.
Often successful APIs reflect the product of the company very closely. It is even sometimes the
case that a company’s product uses its own API, which can be very beneficial.
Recommendation 4 - publish targeted documentation
Informal, tutorial style, documentation appeals to developers and is the most commonly read
documentation. Avoid publishing only example URLs.
There are some excellent documentation engines available on the web. These provide navigation
structures, with narrative sections, and example code sections. For example, the Stripe API (a web-
based payment system) structures its documentation page into three parts: resources, description
and code examples; as shown in Figure 20.
6.2 Technical
Recommendation 9 – Use API documentation frameworks
Make use of automated API documentation where possible. These can often be synched directly
with an implementation version, which helps to minimise divergence. Some also provide
interactive (e.g. Swagger) documentation that allows inline requests to be made. This helps to
lower the barrier of entry for developers and quickly builds understanding.
Recommendation 10 – be cautious when selecting API description languages
Avoid cutting edge/emerging API description languages and response patterns. As discussed in 5.1
and 5.2, there has been an explosion in the number of these. Picking a winner is difficult. Using an
Web APIs for environmental data | 62
overly complex, non-supported service description framework and/or response structure can be
an impediment to developers. Ensure there is at least some uptake and solid usage before
adopting a practice.
Recommendation 11 – Consider using an API manager
There is a range of these available. Some may require customisation, or even coupling with other
technologies. A more in depth analysis of these is recommended if selecting one for use; along
with alignment of organisational IT practices (e.g. supported OS, languages, open source licencing
etc.). Generally they offer solutions to some very common problems in deployment and
management of APIs.
Recommendation 12 – Consider conforming to the I-JSON specification
The I-JSON Message Format (Bray, 2016) defines some precise restrictions (see 5.2.1) on the use of
JSON to aid interoperability, without adding implementation burden.
Recommendation 13 – Don’t do anything strange
There are many Web API best practices (see references), many of which agree on some common
patterns, some of which are already part of the HTTP standard. Always strive to use HTTP
consistently. The use of best practices requires consideration in each case. HTTP related practices
include:
Structuring URIs (Masse, 2011a): use of slashes/hashes, prefer all lowercase, hyphens not
underscores, use of sub-domains.
Use of HTTP request methods: use of GET, POST, PUT, DELETE and OPTIONS. Some
convergence is occurring on the use of these within Web APIs (Masse, 2011b).
Use HTTP response status codes: these are generally well documented and their proper
use appears to be growing.
Use HTTP headers, including (but not limited to):
o Use content-types and media-type syntax for specifying message content type,
o Use last-modified, cache-control, expires and date headers for proper cache
interactions,
o Use Location headers for URIs of newly created resources.
Recommendation 14 – Use consistent link representation and error messages
These are two areas where there is no widely agreed approach (see section 5.2). Even so, it is
important to choose an approach, clearly document it and be consistent across all Web APIs being
implemented.
Recommendation 15 – Define your versioning practices
There’s an extensive online debate (Dierking, 2016)(Zazueta, 2015)(Overflow, 2016) (Sahni, 2016)
about versioning RESTful APIs. The two prevailing options are to include a version in the URI (the
‘pragmatic approach’) or use HTTP headers (the ‘academic’ approach). Understand the trade-offs,
choose one, and stick with it.
50
http://www.w3.org/2015/spatial/wiki/Main_Page
UK Bathing Linked Data* Yes GET Obserations, spatial Dynamic linked-data http://www.epimorphics.com/web/wiki/
Bechhofer, S., J. Ainsworth, J. Bhagat, I. Buchan, P. Couch, D. Cruickshank, D. De Roure, et al. 2010.
“Why Linked Data Is Not Enough for Scientists.” In , 300–307. doi:10.1109/eScience.2010.21.
Bray, Tim. 2016. “The I-JSON Message Format.” https://tools.ietf.org/html/rfc7493.
Brooks, F. P. 1987. No Silver Bullet. April.
https://books.google.com.au/books?hl=en&lr=&id=eT7uBwAAQBAJ&oi=fnd&pg=PA11&dq=
no+silver+bullet&ots=bUfoIuR0Oz&sig=XGUpG1-_9A-XjdaG4X8tqDuoa4k.
Bureau of Meteorology. 2015. “Bureau of Meteorology Strategic Plan 2015-2020.”
http://www.bom.gov.au/info/leaflets/strategic-plan-2015-20.pdf.
Cartwright, John, Jesse Varner, and Susan McLean. 2015. “Data Stewardship: How NOAA Delivers
Environmental Information for Today and Tomorrow.” Marine Technology Society Journal 49
(2): 107–11.
Cornillon, P., J. Gallagher, and T. Sgouros. 2003. “OPeNDAP: Accessing Data in a Distributed,
Heterogeneous Environment.” Data Science Journal 2: 164–74. doi:10.2481/dsj.2.164.
Cox, Simon JD, Jonathan Yu, and Terry Rankine. 2014. “SISSVoc: A Linked Data API for Access to
SKOS Vocabularies.” Semantic Web 7 (1): 9–24.
Cox, Simon, and Peter Taylor. 2015. “Observations & Measurements JSON Encoding - Discussion
Paper. OGC 15-100r1.” 15-100.
D’Amore, F., S. Cinnirella, and N. Pirrone. 2013. “Data and Metadata Management Automation for
an Effective Approach to Sharing Environmental Data.” Edited by N. Pirrone. Proceedings of
the 16th International Conference on Heavy Metals in the Environment 1: 18003.
doi:10.1051/e3sconf/20130118003.
Dierking, Howard. 2016. “Versioning RESTful Services | Howard Dierking.”
http://codebetter.com/howarddierking/2012/11/09/versioning-restful-services/.
DiGiuseppe, Nicholas, Line C. Pouchard, and Natalya F. Noy. 2014. “SWEET Ontology Coverage for
Earth System Sciences.” Earth Science Informatics 7 (4): 249–64.
Dow, Andrew K., Eli M. Dow, Thomas D. Fitzsimmons, and Maurice M. Materise. 2015.
“HARNESSING THE ENVIRONMENTAL DATA FLOOD A Comparative Analysis of Hydrologic,
Oceanographic, and Meteorological Informatics Platforms.” Bulletin of the American
Meteorological Society 96 (5): 725–36. doi:10.1175/BAMS-D-13-00178.1.
Elkhatib, Y., G.S. Blair, and B. Surajbali. 2013. “Experiences of Using a Hybrid Cloud to Construct an
Environmental Virtual Observatory.” In , 13–18.
Evans, Eric. 2003a. “BOUNDED CONTEXT.” In Domain-Driven Design: Tackling Complexity in the
Heart of Software. Addison-Wesley Professional.
http://proquest.safaribooksonline.com/book/project-
management/0321125215/fourteendot-maintaining-model-integrity/ch14lev1sec1.
Evans, Eric. 2003. Domain-Driven Design: Tackling Complexity in the Heart of Software. Addison-
Wesley Professional. http://proquest.safaribooksonline.com/book/project-
management/0321125215.
Fowler, Marting. 2003. “MultipleCanonicalModels.” Martinfowler.com.
http://martinfowler.com/bliki/MultipleCanonicalModels.html.
Fowler, Marting. 2014. “BoundedContext.” Martinfowler.com.
http://martinfowler.com/bliki/BoundedContext.html.
Gong, Jianya, Jing Geng, and Zeqiang Chen. 2015. “Real-Time GIS Data Model and Sensor Web
Service Platform for Environmental Data Management.” International Journal of Health
Geographics 14 (1): 2. doi:10.1186/1476-072X-14-2.
Heritage, Laura. 18:07:26 UTC. “API Description Languages.”
http://www.slideshare.net/SOA_Software/api-description-languages.
Hilbring, Desiree, Anastasia Moumtzidou, Juergen Mossgraber, and Stefanos Vrochidis. 2014.
“Semantically Enriching an Open Source Sensor Observation Service Implementation for
Accessing Heterogeneous Environmental Data Sources.” Transactions in Gis 18 (4): 480–95.
doi:10.1111/tgis.12055.
H, Jeremy. 2011. “There Is No Right Way: Versioning and Types in REST/HTTP API Resources.”
There Is No Right Way. February 24.
http://thereisnorightway.blogspot.com.au/2011/02/versioning-and-types-in-resthttp-
api.html.
Horsburgh, Jeffery S., David G. Tarboton, Michael Piasecki, David R. Maidment, Ilya Zaslavsky,
David Valentine, and Thomas Whitenack. 2009. “An Integrated System for Publishing
Environmental Observations Data.” Environmental Modelling & Software 24 (8): 879–88.
doi:10.1016/j.envsoft.2009.01.002.
Houbie, Frédéric. 2015. “Testbed 11 REST Interface Engineering Report.” OGC Engineering Report
OGC 15-052.
Jacobson, Daniel, Greg Brail, and Dan Woods. 2011a. APIs: A Strategy Guide. O’Reilly Media, Inc.
http://proquest.safaribooksonline.com/book/information-technology-and-software-
development/9781449321628.
Jacobson, Daniel, Greg Brail, and Dan Woods. 2011. “Defining the Value Chain: Ask Key
Questions.” In APIs: A Strategy Guide. O’Reilly Media, Inc.
http://proquest.safaribooksonline.com/book/information-technology-and-software-
development/9781449321628/5dot-key-design-principles-for-apis/id2809367.
Jacobson, Daniel, Greg Brail, and Dan Woods. 2011. “Why You Might Need an API.” In APIs: A
Strategy Guide. O’Reilly Media, Inc.
http://proquest.safaribooksonline.com/book/information-technology-and-software-
development/9781449321628/2dot-apis-as-a-business-strategy/id2743825.