GSN REST Interface - LSIR/gsn GitHub Wiki
Sensor readings
Calls
A REST http query service is offered, in order to access directly the dataset managed by GSN. The following http queries can be executed:
- Retrieve all the virtual sensors to which the user has access (own VS, private VS belonging to other users, to which the user was granted access and public VS not managed by the Access Control).
http://localhost:22001/rest/sensors?username=john&password=john
- Retrieve all the fields and their respective values in the time window (from, to), provided that the user has access to the given virtual sensor:
http://localhost:22001/rest/sensors/ivo2vs1?from=2013-05-30T08:30:04&to=2013-05-30T08:35:34&username=john2&password=john
- Retrieve the values for a given field in the time window (from, to), provided that the user has access to the given virtual sensor:
http://localhost:22001/rest/sensors/johnvs2/heap?from=2013-05-30T08:49:04&to=2013-05-30T08:51:34&username=john&password=johnpass
where http://localhost:22001 is the name of the site running GSN together with the associated port.
HTTP response codes
-
If the request is completed successfully, the HTTP code 200 is returned together with a .csv file having the appropriate contents.
-
If the request is unsuccessful, the HTTP code 203 is returned together with a .csv file describing the error that occurred on the first line.
(eg. no such user, no such VS, no access to the given VS, unknown request, ...)
The affected files are inside the directory: src/gsn/http/restapi (RestServlet.java and GetRequestHandler.java)
Examples
http://localhost:22001/rest/sensors?username=john&password=johnpass
## is_public == 1 if the VS is publicly accessed and 0, otherwise
##vsname,is_public,altitude,longitude,latitude,List(attribute_name,attribute_type)
ivovs2,0,0.0,-122.1419,37.5419,heap,double,non_heap,double,pending_finalization_count,double
memovs4,1,0.0,-122.1419,37.5419,heap,double,non_heap,double,pending_finalization_count,double
ivovs4,0,0.0,-122.1419,37.5419,heap,double,non_heap,double,pending_finalization_count,double
ivovs5,0,0.0,-122.1419,37.5419,heap,double,non_heap,double,pending_finalization_count,double
ivovs3,0,0.0,-122.1419,37.5419,heap,double,non_heap,double,pending_finalization_count,double
ivovs6,0,0.0,-122.1419,37.5419,heap,double,non_heap,double,pending_finalization_count,double
http://localhost:22201/rest/sensors/ivovs3?from=2013-07-05T11:00:04&to=2013-07-05T23:55:34&size=10&john=ivo&password=johnpass
Gets you the 10 newest elements in normal chronological order:
#heap,non_heap,pending_finalization_count
1.7401328E7,1.8929648E7,0.0,2013-07-05 16:09:31,1373033371353
1.5079304E7,1.8929648E7,0.0,2013-07-05 16:09:32,1373033372358
1.1731976E7,1.8929648E7,0.0,2013-07-05 16:09:33,1373033373364
1.8587384E7,1.8929648E7,0.0,2013-07-05 16:09:34,1373033374370
3.1267368E7,1.8929648E7,0.0,2013-07-05 16:09:35,1373033375380
3.2423632E7,1.8933136E7,0.0,2013-07-05 16:09:36,1373033376388
2.5295296E7,1.893336E7,0.0,2013-07-05 16:09:37,1373033377396
2.709836E7,1.893336E7,0.0,2013-07-05 16:09:38,1373033378416
2.327028E7,1.893336E7,0.0,2013-07-05 16:09:39,1373033379422
1.2819688E7,1.893336E7,0.0,2013-07-05 16:09:40,1373033380426
http://localhost:22201/rest/sensors/ivovs3/heap?from=2013-07-05T11:00:04&to=2013-07-05T23:55:34&username=john&password=johnpass
The above query just returns the values associated with a particular field of a sensor:
2.3760728E7,2013-07-05 11:51:30,1373017890052
2.1446256E7,2013-07-05 11:51:31,1373017891137
6.4076272E7,2013-07-05 11:51:32,1373017892149
2.8508416E7,2013-07-05 11:51:33,1373017893154
Grid sensors
For downloading grid data saved in GSN using the grid data wrapper.
Get grids for a time interval
Parameters:
- sensor: virtual sensor name
- from: starting timestamp (format yyyy-MM-dd'T'HH:mm:ss)
- to: ending timestamp (format yyyy-MM-dd'T'HH:mm:ss)
- username (optional, for protected sensors)
- password (optional, for protected sensors)
Example:
http://localhost:22001/griddata?sensor=esri_grid_sample&from=2013-10-01T00:00:00&to=2013-11-29T00:00:00
Result:
Filename : esri_grid_sample_1385333993000
NCOLS 4
NROWS 6
XLLCORNER 0.0
YLLCORNER 0.0
CELLSIZE 50.0
NODATA_VALUE -9999.0
-9999.0 -9999.0 5.0 2.0
-9999.0 120.0 100.0 36.0
3.0 8.0 35.0 10.0
32.0 42.0 50.0 6.0
88.0 75.0 27.0 9.0
13.0 5.0 1.0 -9999.0
Filename : esri_grid_sample_1385333994000
NCOLS 4
NROWS 6
XLLCORNER 0.0
YLLCORNER 0.0
CELLSIZE 50.0
NODATA_VALUE -9999.0
-9999.0 -9999.0 5.0 2.0
-9999.0 2.0 100.0 36.0
3.0 8.0 35.0 10.0
32.0 42.0 50.0 6.0
88.0 75.0 27.0 9.0
13.0 5.0 1.0 -9999.0
Filename : esri_grid_sample_1385333998000
NCOLS 4
NROWS 6
XLLCORNER 0.0
YLLCORNER 0.0
CELLSIZE 50.0
NODATA_VALUE -9999.0
-9999.0 -9999.0 5.0 2.0
-9999.0 22.0 100.0 36.0
3.0 8.0 35.0 10.0
32.0 42.0 50.0 6.0
88.0 75.0 27.0 9.0
13.0 5.0 1.0 -9999.0
Filename : esri_grid_sample_1385333997000
NCOLS 4
NROWS 6
XLLCORNER 0.0
YLLCORNER 0.0
CELLSIZE 50.0
NODATA_VALUE -9999.0
-9999.0 -9999.0 5.0 2.0
-9999.0 23.0 100.0 36.0
3.0 8.0 35.0 10.0
32.0 42.0 50.0 6.0
88.0 75.0 27.0 9.0
13.0 5.0 1.0 -9999.0
Filename : esri_grid_sample_1385333995000
NCOLS 4
NROWS 6
XLLCORNER 0.0
YLLCORNER 0.0
CELLSIZE 50.0
NODATA_VALUE -9999.0
-9999.0 -9999.0 5.0 2.0
-9999.0 29.0 100.0 36.0
3.0 8.0 35.0 10.0
32.0 42.0 50.0 6.0
88.0 75.0 27.0 9.0
13.0 5.0 1.0 -9999.0
Filename : esri_grid_sample_1385333999000
NCOLS 4
NROWS 6
XLLCORNER 0.0
YLLCORNER 0.0
CELLSIZE 50.0
NODATA_VALUE -9999.0
-9999.0 -9999.0 5.0 2.0
-9999.0 21.0 100.0 36.0
3.0 8.0 35.0 10.0
32.0 42.0 50.0 6.0
88.0 75.0 27.0 9.0
13.0 5.0 1.0 -9999.0
Filename : esri_grid_sample_1385333996000
NCOLS 4
NROWS 6
XLLCORNER 0.0
YLLCORNER 0.0
CELLSIZE 50.0
NODATA_VALUE -9999.0
-9999.0 -9999.0 5.0 2.0
-9999.0 25.0 100.0 36.0
3.0 8.0 35.0 10.0
32.0 42.0 50.0 6.0
88.0 75.0 27.0 9.0
13.0 5.0 1.0 -9999.0
Get sub grid for a time interval
Parameters:
- sensor: virtual sensor name
- from: starting timestamp (format yyyy-MM-dd'T'HH:mm:ss)
- to: ending timestamp (format yyyy-MM-dd'T'HH:mm:ss)
- xmin: left boundary of sub grid (cell index)
- xmax: right boundary of sub grid (cell index)
- ymin: upper boundary of sub grid (cell index)
- ymax: lower boundary of sub grid (cell index)
- username (optional, for protected sensors)
- password (optional, for protected sensors)
Example:
http://localhost:22001/griddata?sensor=esri_grid_sample&from=2013-10-01T00:00:00&to=2013-11-29T00:00:00&xmin=0&ymin=0&xmax=3&ymax=3
Result:
Filename : esri_grid_sample_1385333993000
NCOLS 4
NROWS 4
XLLCORNER 0.0
YLLCORNER 0.0
CELLSIZE 50.0
NODATA_VALUE -9999.0
-9999.0 -9999.0 5.0 2.0
-9999.0 120.0 100.0 36.0
3.0 8.0 35.0 10.0
32.0 42.0 50.0 6.0
Filename : esri_grid_sample_1385333994000
NCOLS 4
NROWS 4
XLLCORNER 0.0
YLLCORNER 0.0
CELLSIZE 50.0
NODATA_VALUE -9999.0
-9999.0 -9999.0 5.0 2.0
-9999.0 2.0 100.0 36.0
3.0 8.0 35.0 10.0
32.0 42.0 50.0 6.0
Filename : esri_grid_sample_1385333998000
NCOLS 4
NROWS 4
XLLCORNER 0.0
YLLCORNER 0.0
CELLSIZE 50.0
NODATA_VALUE -9999.0
-9999.0 -9999.0 5.0 2.0
-9999.0 22.0 100.0 36.0
3.0 8.0 35.0 10.0
32.0 42.0 50.0 6.0
Filename : esri_grid_sample_1385333997000
NCOLS 4
NROWS 4
XLLCORNER 0.0
YLLCORNER 0.0
CELLSIZE 50.0
NODATA_VALUE -9999.0
-9999.0 -9999.0 5.0 2.0
-9999.0 23.0 100.0 36.0
3.0 8.0 35.0 10.0
32.0 42.0 50.0 6.0
Filename : esri_grid_sample_1385333995000
NCOLS 4
NROWS 4
XLLCORNER 0.0
YLLCORNER 0.0
CELLSIZE 50.0
NODATA_VALUE -9999.0
-9999.0 -9999.0 5.0 2.0
-9999.0 29.0 100.0 36.0
3.0 8.0 35.0 10.0
32.0 42.0 50.0 6.0
Filename : esri_grid_sample_1385333999000
NCOLS 4
NROWS 4
XLLCORNER 0.0
YLLCORNER 0.0
CELLSIZE 50.0
NODATA_VALUE -9999.0
-9999.0 -9999.0 5.0 2.0
-9999.0 21.0 100.0 36.0
3.0 8.0 35.0 10.0
32.0 42.0 50.0 6.0
Filename : esri_grid_sample_1385333996000
NCOLS 4
NROWS 4
XLLCORNER 0.0
YLLCORNER 0.0
CELLSIZE 50.0
NODATA_VALUE -9999.0
-9999.0 -9999.0 5.0 2.0
-9999.0 25.0 100.0 36.0
3.0 8.0 35.0 10.0
32.0 42.0 50.0 6.0
Get a cell as time series for a time interval
Parameters:
- sensor: virtual sensor name
- from: starting timestamp (format yyyy-MM-dd'T'HH:mm:ss)
- to: ending timestamp (format yyyy-MM-dd'T'HH:mm:ss)
- xcell : x index of cell
- ycell : y index of cell
- username (optional, for protected sensors)
- password (optional, for protected sensors)
Example:
http://localhost:22001/griddata?sensor=esri_grid_sample&from=2013-10-01T00:00:00&to=2013-11-29T00:00:00&xcell=1&ycell=1
Result:
#Filename : esri_grid_sample
1385333993000, 120.0
1385333994000, 2.0
1385333998000, 22.0
1385333997000, 23.0
1385333995000, 29.0
1385333999000, 21.0
1385333996000, 25.0