# API Server

This page contains information about private APIs developed and being developed for Web/Mobile applications to access data from DB server via API server.

## Development Information

| Info                        | Oizom REST APIs                                    |
| --------------------------- | -------------------------------------------------- |
| Development Platform        | Node.js 6.x                                        |
| Nodejs Framework            | Express.js                                         |
| Current Development Version | 1.0                                                |
| Database connection         | [IBM DashDB](https://github.com/ibmdb/node-ibm_db) |

## Deployment Information

| Info                 | Deployment           |
| -------------------- | -------------------- |
| API Request Manager  | Load Balancer        |
| API Server Ram       | 2 Gb                 |
| API Server Instances | 2                    |
| OS & Version         | Ubuntu 16.04 (Linux) |
| Web Server           | Node.js Web Server   |

## Rest APIs

All Private REST APIs are secured by [OAuth 2.0](https://oauth.net/2) Authentication method on expiry time of 7 day. Here are all the response code and response data explained:

| Response Code | Status                | Information                                                        |
| ------------- | --------------------- | ------------------------------------------------------------------ |
| 200           | OK                    | Response Data will be in JSON Object firm or JSON Array.           |
| 401           | Unauthorised          | Token failed, token not present in api request.                    |
| 400           | BAD Request           | Bad server request, issue in URL, or bad config request            |
| 201           | CREATED               | New Object creation successful                                     |
| 500           | Internal Server Error | Server side errors. should be fixed by developer team on priority. |

All the possible private APIs are mentioned below :

| Module             | Explanation                                                                                                                                                                                                            |
| ------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Auth API           | For new users to signup and login to oizom API server, "login", "signup" & "register" APIs are written over there.                                                                                                     |
| Users API          | 3 types of APIs (GET, PUT, DELETE) of users to fetch users data, to edit certain data and to delete some user's information.                                                                                           |
| Organisation API   | All types of REST APIs for organizational information to store and access from Database server                                                                                                                         |
| Devices API        | Certain users from particular organization can register for allowed/purchased device. So to register and edit information for those devices these APIs can be used.                                                    |
| Fields API         | Devices gas parameters do come in fkey perspective in respective devices' data payloads. To access those fields these APIs can be used.                                                                                |
| Limits API         | Every pollutant has it's range or limits from which one can determine is current pollutant status in air is good or satisfactory or moderate or poor or very poor or severe. Limits APIs gives access to those ranges. |
| Configurations API | To access devices configurations according to current time, these APIs can be used.                                                                                                                                    |
| Roles API          | Name suggests that these apis can be used to manage roles of different users as per their permissions and roles.                                                                                                       |
| Reports API        | Oizom allows users to subscribe to daily/weekly/monthly reports on certain devices. So to subscribe itself, user can use these apis.                                                                                   |
| Units API          | Every Pollutants has it's own unit it gives data in form of. To access such information Units APIs can be used.                                                                                                        |
| Device Types API   | Device's category and configurations can be different, such information can be contained or accessed by these APIs by defining/editing devicetypes.                                                                    |
| Limit Types API    | As Devices may have different configurations and categories, limits can be different according to device's location. These APIs can be used to access such data.                                                       |
