Publicada con documentos de Google
SmartCampus - User data api documentation
Actualizado automáticamente cada 5 minutos

 SmartCampus

2 october 2014 – Version 1.0

Written by: Cyril Cecchinel / I3S-Modalis

 

 

 

User data API

Technical documentation

 


Queries

Queries respect the HTTP 1.1 standard. A GET request only read and returns resources. A POST request may cause the creation of a new resource and is not idempotent. A PUT request is idempotent and refers directly to a resource that will be created if it doesn’t exists, or updated otherwise. A DELETE request delete a resource.

Parameters specified in this documentations refers to data that can or must be transmitted to the server. Depending on the type of request, the parameters are given in a different way:

Return codes

The API returns standard HTTP codes, and in particular:

200

Request processed successfully. Indicates that recovery, modification or deletion of a resource was successful.

201

Resource created successfully. Indicates that the operation of adding the resource was successful (after a PUT or POST for example).

400

Incorrect parameters. Indicates that the request parameters are incorrect (e.g. required parameter unspecified).

404

Resource not found. Indicates that one wants to access a resource that does not exist (e.g with the wrong ID).


Resource: Sensors

A sensor can be a real sensor (physical device plugged into a sensor platform) or virtual (virtual aggregation of several sensors providing data).

Object : SENSOR

{

  "name" : (String) Sensor name (unique),

  "kind" : (String) Kind of sensor (light, temp …),

  "sensorType" : (String) Sensor type, either physical or virtual,

  "frequency" : (Integer) Mesure period (in second),

  "endpoint" : {

         "ip" : (String) Endpoint IP/URL,

         "port" : (Integer) Endpoint port

                }

  // Bellow: Physical sensors only

  "pin" : (Integer) Pin number on the sensor platform,

  "board" : (String) Sensor platform ID,

   // Bellow: Virtual sensors only

   "script" : (Groovy script) Transformation rule

}

GET /sensors

DESCRIPTION

Get the list of registered sensors

RESULTS

JSON table of sensor objects

Example: http://smartcampus.unice.fr/data-api/sensors


GET /sensors/<name>/data

DESCRIPTION

Get the data for a given sensor

URL STRUCTURE

name Sensor name

PARAMETERS

date  Date of the wished data or date range:

YYYY-MM-DD hh:mm:ss[/YYYY-MM-DD hh:mm:ss]

If no date is given, all sensor data will be returned.

convert (Boolean) If set to true, the date will be converted in a “human-readable” date

RESULT

JSON object containing the sensor data

id  Sensor name.

values  Table of data :

     date  Date of measurement  (YYYY-MM-DD hh:mm:ss).

     value Measure at that date

EXAMPLE with data = 2014-01-13 10:41:00

{

  "id" : "PAR-OUEST-1-PLACE-200",

  "values" : [

    { "date" : "1389606060", "value" : "1" }

  ]

}

EXAMPLE with data = 2014-01-13 10:41:00 and convert = true

{

  "id" : "PAR-OUEST-1-PLACE-200",

  "values" : [

    { "date" : "Mon Jan 13 10:41:00 CEST 2014", "value" : "1" }

  ]

}

EXAMPLE with data = 2014-01-13 10:39:00/2014-01-13 10:53:00

{

  "id" : "PAR-OUEST-1-PLACE-200",

  "values" : [

    { "date" : "1389605940", "value" : "1" },

    { "date" : "1389606300", "value" : "0" },

    { "date" : "1389606600", "value" : "0" }

  ]

}

GET /sensors/<name>/data/last

DESCRIPTION

Get the last data for a given sensor

URL STRUCTURE

name Sensor name

PARAMETERS

convert (Boolean) If set to true, the date will be converted in a “human-readable” date

RESULT

JSON object containing the last sensor data

id  Sensor name.

values  Table of data :

     date  Date of measurement  (YYYY-MM-DD hh:mm:ss).

     value Measure at that date

EXAMPLE

{

  "id" : "PAR-OUEST-1-PLACE-200",

  "values" : [

    { "date" : "1389606060", "value" : "1" }

  ]

}

EXAMPLE with convert = true

{

  "id" : "PAR-OUEST-1-PLACE-200",

  "values" : [

    { "date" : "Mon Jan 13 10:41:00 CEST 2014", "value" : "1" }

  ]

}