The following document describes the REST API provided by DSAPI2, as of Feb 22 2011.
The DSAPI2 REST service provides endpoints that allow clients to fetch data and metadata about DSAPI2 streams, as well as token data from the streams. In addition, the REST service can generate simple charts for numeric data, suitable for user-facing display.
Many of the REST calls provide output in more than one format. Supported formats include the following (note that not every endpoint supports every format):
REST endpoints are in the following syntax:
/{request}/{param1}/{value1}/{param2}/{value2}/.../{paramN}/{valueN} |
where "request" identifies the type of request being made, and "param" and "value" refer to parameters and their values. For example, the following endpoint is a "list" request, with a "format" parameter whose value is "xml":
/list/format/xml |
most endpoints take a "uri" parameter which identifies the stream being queried. Note that any "/" characters in the URI need to be escaped; the exception to this requirement is if "uri" is the final parameter in the request. For example, the following "window" request is targeting the stream with the URI "urn:streams/snorb7/twitter":
/window/start/first/end/last/format/html/uri/urn:streams/snorb7/twitter |
Here's an equivalent call:
/window/start/first/end/last/format/html/uri/urn%3Astreams%2Fsnorb7%2Ftwitter |
List streams. Returns the URIs of all (or selected) streams. For HTML format, returns a list with human-readable names for each stream, which are hyperlinked to calls against the "window" endpoint.
Parameters:
Example:
/list/format/xml |
Return all frames (optionally, with data) from a given stream within a given time range. The time range is specified with the start and end parameters. The values of these parameters are either timestamps represented as ms since the *nix epoch, or one of several other notations:
Parameters:
Example:
/window/start/1297791028800/end/last/format/xml/data/true/uri/http%3A%2F%2Fiacat-enviro.ncsa.illinois.edu%2FEBIWeatherStations%2FNE%2FAvg15%23PAR_APOGE_Avg |
Example output:
<?xml version="1.0" encoding="UTF-8"?><streams> <stream> <streamURL>http://iacat-enviro.ncsa.illinois.edu/EBIWeatherStations/NE/Avg15#PAR_APOGE_Avg</streamURL> <frames> <frame> <time>1297791900000</time> <dateTime>Tue Feb 15 11:45:00 CST 2011</dateTime> <data>1157</data> </frame> <frame> <time>1297792800000</time> <dateTime>Tue Feb 15 12:00:00 CST 2011</dateTime> <data>1020</data> </frame> </frames> </stream> </streams> |
When data is set to true, the format and encoding of the contents of the data field will depend on the MIME type associated with the stream. If the stream's major MIME type is "text", the data field will contain unicode text; for binary MIME types, the data field will be Base64-encoded. MIME types are associated with streams in the fetching stage, via a filter called TypeRegisterFilter.
Return a single frame of data from a stream. Note that the MIME type of the response is determined by the stream. If each frame is plain text, it will be set to text/plain; if each stream is a TIFF image, it will be set to image/tiff, etc.
Parameters:
Depending on the server configuration, this endpoint may require authentication.
Example:
/frame/time/1278614700000/uri/http://iacat-enviro.ncsa.illinois.edu/EBIWeatherStations/SE/Avg15%23WindSpd_Max |
Return the temporal range of the stream (i.e., the time of the earliest frame and the time of the most recent frame).
Parameters:
Example response:
[ { "streamURL": "urn:streams/snorb/twitter", "start" : 1296859710000, "end" : 1297101208000 } ] |
Return the MIME type of the given stream.
Parameters:
Example output (CSV):
stream,format http://ncsa.edu/dsapi/twitter/cufire2,text/plain |
Return all metadata about the given stream.
Parameters:
Example output (rdf):
<rdf:RDF> <a:DataStream rdf:about="http://ncsa.edu/dsapi/twitter/cufire2"> <a:characterEncoding>UTF-8</a:characterEncoding> <dc:format>text/plain</dc:format> <dc:title>Twitter search for fire near CU</dc:title> <rdfs:label>Twitter search for fire near CU</rdfs:label> </a:DataStream> </rdf:RDF> |