Skip to content
This repository has been archived by the owner on Apr 7, 2020. It is now read-only.

API routes to be implemented

Vitor George edited this page Jul 16, 2015 · 1 revision

Sensors

Register a sensor

POST /api/v1/sensors

Authentication required

Input

  • name: string Sensor identification name
  • latitude: number Sensor location latitude
  • longitude: number Sensor location longitude

Response

Status codes:

  • 201 Created successfully
  • 400 Bad request
  • 401 Unauthorized

On success, returns the created sensor

Update a sensor

PUT /api/v1/sensors/:id

Authentication required

Input

  • name: string Sensor identification name
  • latitude: number Sensor location latitude
  • longitude: number Sensor location longitude

Response

Status codes:

  • 200 Ok
  • 400 Bad request
  • 401 Unauthorized
  • 404 Not found

On success, returns the updated sensor

Delete a sensor

Warning: deletes a sensor and all of its readings

DELETE /api/v1/sensors/:id

Authentication required

Response

Status codes:

  • 204 Sensor deleted successfully
  • 401 Unauthorized
  • 404 Not found

List sensors

GET /api/v1/sensors

Input filter parameters

  • per_page: number default: 10. maximum: 20 (optional)
  • page: number (optional)

Response

Status codes:

  • 200 Ok
  • 400 Bad request

Response body:

  • count int
  • page int
  • data [sensor]

Response body example:

{
  "count": 32,
  "page": 1,
  "data": [
    {
      "id": 1,
      "name": "Belterra #1",
      "location": [-3.53198127, -10.3964720]
    },
    ...
  ]
}

Retrieve a sensor

GET /api/v1/sensors/:id

Response

Object containing sensor data

Response body:

  • id int
  • name string
  • location [lon, lat] pair of location coordinates

Response body example:

{
  "id": 1,
  "name": "Belterra #1",
  "location": [-3.53198127, -10.3964720]
}

Sensor readings

Register a reading

POST /api/v1/readings

Authentication required

Input

  • sensor_id: int Reader sensor identifier
  • timestamp: string ISO 8601 formatted string
  • water_temp: number Water temperature in celsius
  • luminosity: To be defined
  • water_conductivity: To be defined
  • turbidity: To be defined
  • ph: number
  • orp: To be defined
  • acceleration: To be defined
  • barometric_pressure: To be defined

Response

Status codes:

  • 201 Created successfully
  • 400 Bad request
  • 401 Unauthorized

On success, returns the created reading

Delete a reading

DELETE /api/v1/readings/:id

Authentication required

Response

Status codes:

  • 204 Reading deleted successfully
  • 401 Unauthorized
  • 404 Not found

List sensor readings

GET /api/v1/readings

Input

  • sensor_id int (optional)
  • since_date string (ISO 8601) (optional)
  • max_date string (ISO 8601) (optional)
  • count int default: 20 maximum: 100 (optional)
  • since_id int (optional)
  • max_id int (optional)

Response

Status codes:

  • 200 Ok
  • 400 Bad request

Response body:

Response body example:

{
  "data": [
    {
      "id": 2,
      "sensor_id": 59,
      "timestamp": "2015-03-01T13:00:00Z",
      "water_temp": 22,
      "luminosity": null,
      "water_conductivity": null,
      "turbidity": null,
      "ph": 4,
      "orp": null,
      "acceleration": null,
      "barometric_pressure": null
    },
    ...
  ]
}

Retrieve a reading

GET /api/v1/readings/:id

Response

Object containing reading data

Response body:

  • id: int
  • sensor_id: int Reader sensor identifier
  • timestamp: string ISO 8601 formatted string
  • water_temp: number Water temperature in celsius
  • luminosity: To be defined
  • water_conductivity: To be defined
  • turbidity: To be defined
  • ph: number
  • orp: To be defined
  • acceleration: To be defined
  • barometric_pressure: To be defined

Response body example:

{
  "id": 2,
  "sensor_id": 59,
  "timestamp": "2015-03-01T13:00:00Z",
  "water_temp": 22,
  "luminosity": null,
  "water_conductivity": null,
  "turbidity": null,
  "ph": 4,
  "orp": null,
  "acceleration": null,
  "barometric_pressure": null
}

Authentication

If you are a registered user you will receive an API Key to manage your sensors and readings. For an authenticated request you must include in your request the parameter api_key, the value being the key sent to you.