If you have a Dylos or Shinyei sensor, and you would like to publish its data on the World Air Quality Index, then this page is for you. One of the easiest solution for uploading the Dylos data is to use the ready made scripts available on github. But if you need to brew your own system, or upload data from the Shinyei sensor, then you can use the APIs described on this page.
Note that this API specification is not final, but still on-going work, so if you meet any difficulty with the integration, just contact us to get the support.
--
API Endpoint
http://sensor.aqicn.org/
API Method: Uploading data
post /sensor/upload
Parameters
| Example:
|
result
: Can be eitherok
orerror
.
In case ofok
result, the returned value will contain the sensor id as well as the upload data ids (for information purpose only)....
In case oferror
, the returned value will contain a description (fieldmsg
) and an error code (fieldecode
) which can be one of the following:
101
: There are missing arugments from the posted data. Minimum arguments areid
,time
anddata
.102
: Key is not valid - the sensor is protected by password and the provided password is not correct.103
: No data posted (i.e empty array or data is not an array).104
: Unit, type of value information not available from the data field.105
: Sensor type is unknown.106
: The fieldvalue
is not numeric.107
: Time string can not be decode (is it ISO 8601 complaiant?)108
: SQL query failed.
...
Example
$ curl -i "http://sensor.aqicn.org/sensor/upload/" -d 'postdata={id:"dylos.test-sensor-id",time:"2014-10-16T19:20:31+08:00",data:[{type:"dylos-2.5",value:88,unit:"pc"}]}'
HTTP/1.1 200 OK
Date: Sun, 09 Nov 2014 08:28:34 GMT
Server: Apache/2.2.15 (CentOS)
X-Powered-By: PHP/5.3.3
Vary: Accept-Encoding
Connection: close
Transfer-Encoding: chunked
Content-Type: text/json; charset=utf-8
{"result":"ok","sensorID":"588","dataids":[2825275]}
API Method: Getting the raw sensor data
get /sensor/download
Parameters id
: Sensor ID, eg dylos.test-sensor-idcallback
: Optional JsonP callback (eg "foo").
http://sensor.aqicn.org/sensor/download/?id=dylos.test-sensor-id&callback=foo
Return value:
...
Example
$ curl -i "http://sensor.aqicn.org/sensor/download/?id=dylos.test-sensor-id&callback=foo"
HTTP/1.1 200 OK
Date: Sun, 09 Nov 2014 08:42:12 GMT
Server: Apache/2.2.15 (CentOS)
X-Powered-By: PHP/5.3.3
Vary: Accept-Encoding
Connection: close
Transfer-Encoding: chunked
Content-Type: text/json; charset=utf-8
{"id":"dylos.test-sensor-id","data":{"dylos-0.5":[{"time":"1413458432","value":"89"}],"dylos-2.5":[{"time":"1413458432","value":"89"},{"time":"1413458431","value":"88"}]}}