pkonkka / iaq-test-app

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

iaq-rest-api / iaq-test-app

Introduction

Simple REST API that manages IoT sensors, sensor groups and measurements.

Installation

  1. Install Git
  2. Clone repository from sensoan.visualstudio.com - Code - iaq-rest-api
  3. Install node from https://nodejs.org
  4. Run npm install
  5. Run node app
  6. Development version of the api is listening port 3000

Usage

  • Api can be used from any web browser or application.
  • Get commands can be executed from the browser: type in the URL box (e.g.): http://localhost:3000/v1/groups
  • Other commands can be executed for example with Postman (https://www.getpostman.com)
  • Setup the database first: GET /v1/setupDatabase

Groups

  • Get all groups: GET /v1/groups
  • Get one group by mongoDB ID: GET /v1/groups/document/
  • Get one group by group name: GET /v1/groups/document/
  • Update existing group: PUT /v1/groups, documentID in the request body
  • Add new group: POST /v1/groups, response: documentID, group name must be unique
  • Delete group: DELETE /v1/groups/, group can be removed only if it does not have any sensors

Sensors

  • Get all sensors: GET /v1/sensors
  • Get one sensor by sensorID: GET /v1/sensors/
  • Get all sensors by group name: GET /v1/sensors/group/
  • Get the document for mongoDB ID: GET /v1/sensors/document/
  • Update existing sensor: POST /v1/sensors, sensorID in the request body
  • Add new sensor: POST /v1/sensors/new, response: sensorID
  • Delete sensor: DELETE /v1/sensors/, sensor can be removed only if it does not have any measurements

Measurements

  • Get all measurements: GET /v1/measurements
  • Get all measurents that are equal or newer than date1: GET /v1/measurements?date1=, date format: YYYY-MM-DD, result sorted by timestamp in ascending order
  • Get all measurements that are between date1 and date2: GET /v1/measurements/?date1=&date2= date format: YYYY-MM-DD, result sorted by timestamp in ascending order
  • Get measurements for the sensor ID: GET /v1/measurements/sensor/, result sorted by timestamp in ascending order
  • Get measurements for the sensor ID that are equal or newer than date1: GET /v1/measurements/sensor//?date1=
  • Get measurements for the sensor ID that between date1 and date2: GET /v1/measurements/sensor//?date1=&date2=
  • Get the latest measurement for the sensor ID: GET /v1/measurements/sensor/latest/
  • Get the document for mongoDB ID: GET /v1/measurements/document/
  • Delete measurement: DELETE /v1/measuements/document/
  • Add new measurement: POST /v1/measurements

About


Languages

Language:JavaScript 76.3%Language:HTML 21.0%Language:CSS 2.7%