Skip to content
Chris Borrill edited this page Dec 8, 2015 · 27 revisions

API Description

Concepts:

You need to understands the basic concept of OpenSensorCloud, based on three important items:

  • Device : represent a physical device wheere your sensor reside
  • Feed: represent datas from a sensor, feeds are connected to a device, a represents a set of values

API URL:

http://api.opensensorcloud.com

AUTHENTIFICATION

To use the API you need to add X-ApiKey in the header with your API KEY. The API Key is available from your profile page You can also pass the API_KEY as a parameter of the URL with api_key=

GET DATAS

GET URL: http://api.opensensorcloud.com/device/'DEVICE_ID'

cUrl Example

curl -i --header "Accept: application/json" 
--header "Content-Type: application/json" 
--header "X-ApiKey: 5707e849499b5fb1037515dac8db1bd1" 
-X http://api.opensensorcloud.com/device/536e6066a38184a1ce000001

UPLOAD DATAS

Post to a device

URL: http://api.opensensorcloud.com/device/'DEVICE_ID'

Content:

An array of related feed measure. For each feed, there must be a either a data: field. The data field contains a list of data, this list can contains one or more element. Feeds are referenced eith by their ID or by ther name.

Format exemple:

Single feed update, single value

[{"name":"lum","value":20}]

Single feed update, multiple values with time stamp

[{"name":"lum","data":[
   {"value":20,"time_stamp":12333338888},
   {"value":20,"time_stamp":12333338888},
   {"value":20,"time_stamp":12333338888}
   ]}]

Multiple feed update, single value

[
  {"name":"lum" ,"value":  20},
  {"name":"temp","value":99.0},
  {"name":"door","value":true},
]

cUrl example with multiple feed update

curl -i --header "Accept: application/json" --header "Content-Type: application/json" --header "X-ApiKey: 5707e849499b5fb1037515dac8db1bd1" -X POST -d '[{"name":"lum","value":"20"},{"name":"temp","value":"99"}]' http://api.opensensorcloud.com/device/536e6066a38184a1ce000001

Post to a device using generic type payload (binary)

URL: http://api.opensensorcloud.com/device/'DEVICE_ID'/binary

POST DATA: datas: the payload that will be decoded by the server

This can be the direct URL called by the Sigfox backend

Post to a device using sigfox callback (binary)

URL: http://api.opensensorcloud.com/device/sigfox

POST DATA: datas: the payload that will be decoded by the server device: the device number send by Sigfox. Information must be entered on OpenSensorCloud signal: optional

This can be the direct URL called by the Sigfox backend

binary binding description

In order to decode binary format, you must provide a description of this format.

This description is a JSON description, like this one:

[{"name":"temp","type":"int"}]

We except a two byte value, stored into the temperature sensor

[
 {"name":"temp" ,"type":"int"},
 {"name":"power","type":"float"},
 {"name":"cell" ,"type":"uint"}
]

Here we excpet three value, an int mappend on temp, a float (4 bytes) mappend on power, and an unsinged int (2 bytes) mapped on cell For instance, the last example is the translation of the following C struct for Arduinoe

struct {
  int name;
  float power;
  unsigned int cell,
}Payload;

Complex type like structure can be described.

[{"name":"pos",
  "type":"position",
  "struct":[
   {"name":"lat","type":"float"},
   {"name":"lon","type":"float"},
   {"name":"alt","type":"float"}
  ]
 }
]

Download device measures

URL: http://api.opensensorcloud.com/sensor/'SENSOR_ID'/measures

(a callback parameter can be added to be jQuery compatible)

Options: numbers: the number of samples returned (default, 100000) page: the page, to be used in conjonction with numbers. For instance, to get numbers between 100 and 200, pages=1 and numbers=100, default 0 startTime: Timestamp in UTC, in the format dd_mm_yyyy or dd_mm_yyyy_hh_mm (ex: 18_12_1966_20_12 for 18/12/1966 at 20:12) endTime : Timestamp in UTC

Return: A json containing the measures for this device, in the form array of couple timestamp in milliseconds ,value.

Example:

[[1437326019000 , 1609.34],
 [1437326030000 , 1471.78],
 [1437326041000 , 1616.52],
 [1437326052000 , 1617.85],
 [1437326063000 , 1014.69],
 [1437326074000 , 171.89],
 [1437326084000 , 171.53]
]
Clone this wiki locally
You can’t perform that action at this time.