Back to top

This REST API collects data from dustDuino air sensors and allow users to query them.

Resource Group 

The API Root 

This resource does not have any attributes. Instead it offers the initial API affordances in the form of the links in the JSON body.

It is recommend to follow the “url” link values, Link or Location headers where applicable to retrieve resources. Instead of constructing your own URLs, to keep your client decoupled from implementation details.

Retrieve the Entry Point
/api/v1
  • Response  200
  • Headers
    Content-Type: application/json
    Body
    {
        "readings": "http://brazil-sensor.herokuapp.com/api/v1/readings/",
        "sensors": "http://brazil-sensor.herokuapp.com/api/v1/sensors/"
    }
    

Readings 

List readings

Returns all readings from sensors. Please note that the readings are returned per hour. Each fields is the average value of readings during the hour.

A reading object has the following attributes:

  • pm10 - Particulate matter smaller than about 10 micrometers

  • pm25 - Particulate matter smaller than about 25 micrometers

  • pm10count - Particulate matter counter for paricles smaller than about 10 micrometers

  • pm25count - Particulate matter counter for paricles smaller than about 25 micrometers

  • sensor - Sensor ID

  • hour_code - The hour in which the reading average is calculated | format: YYYYMMDDHH

Retrieve Readings List
/api/v1/readings/{?sensor_id,email,start,end}
  • Parameters
  • sensor_id
    number (optional) Example: 1

    ID for a particular sensor

    email
    string (optional) Example: email@example.com

    email address with which the sensor is registered

    start
    date (optional) Example: 2014-12-31

    The start date for readings | format: YYYY-MM-DD

    end
    date (optional) Example: 2015-12-31

    The end date for readings | format: YYYY-MM-DD

  • Response  200
  • Headers
    Content-Type: application/json
    Body
    {
        "count": 3,
        "next": null,
        "previous": null,
        "results": [
            {
                "pm25count": 0.0,
                "pm10": 1.0,
                "pm10count": 3.0,
                "hour_code": "2015042818",
                "sensor": 2,
                "pm25": 2.0
            },
            {
                "pm25count": 7.0,
                "pm10": 6.0,
                "pm10count": 3.0,
                "hour_code": "2015042819",
                "sensor": 2,
                "pm25": 2.0
            },
            {
                "pm25count": 100.0,
                "pm10": 1.0,
                "pm10count": 300.0,
                "hour_code": "2015042820",
                "sensor": 4,
                "pm25": 45.0
            }
        ]
    }
    
Create a New Reading
/api/v1/readings/{?sensor_id,email,start,end}
  • Parameters
  • pm10
    number (optional) Example: 1

    Particulate matter smaller than about 10 micrometers

    pm25
    number (optional) Example: 1

    Particulate matter smaller than about 25 micrometers

    pm10count
    number (optional) Example: 1

    Particulate matter counter for paricles smaller than about 10 micrometers

    pm25count
    number (optional) Example: 1

    Particulate matter counter for paricles smaller than about 25 micrometers

  • Request
  • Headers
    Authorization: Token yourtoken
  • Response  200
  • Headers
    Content-Type: application/json
    Body
    {
        "id": 1,
        "created": "2015-04-28T19:43:20.141296Z",
        "hour_code": "2015042819",
        "pm10": 12,
        "pm25": 0,
        "pm10count": 100,
        "pm25count": 130,
        "sensor": 3
    }
    

Sensors 

Returns the list of active sensors.

A sensor object has the following attributes:

  • id - unique sensor ID

  • sensor_name - sensor’s name

  • lat - sensor’s latitude

  • lon - sensor’s longitude

  • address - sensor’s address

  • serial - sensor’s serial number

  • description - sensor’s description

  • account - user account associated with the sensor

  • last_reading - the latest reading object

View Sensors List
/api/v1/sensors/{sensor_id}
  • Parameters
  • sensor_id
    number (optional) Example: 1

    sensor unique ID

  • Response  200
  • Headers
    Content-Type: application/json
    Body
    {
        "count": 1,
        "next": null,
        "previous": null,
        "results": [
            {
                "id": 2,
                "sensor_name": "jumpy-bronze-mongrel",
                "lat": -23.55187083133668,
                "lon": -46.65361404418945,
                "address": null,
                "serial": null,
                "description": "Enter a description of your device",
                "account": 7,
                "last_reading": {
                    "sensor_id": 2,
                    "pm25count": 12,
                    "pm10": 10,
                    "created": "2015-04-28T19:52:17.836Z",
                    "pm10count": 3,
                    "hour_code": "2015042819",
                    "id": 3,
                    "pm25": 2
                }
            }
        ]
    }
    

Generated by aglio on 12 Jun 2015