# Heat Management System
## BASE URL: http://172.104.180.56:8000
## Authentication APIs
### 1. User Token API
```json
POST /api/v1/users/token/ HTTP/1.1
Request Body:
{
"username": "01740999768",
"password": "01740999768"
}
Response:
status code: 200
{
"success": true,
"message": "Status OK",
"data": {
"token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjoyLCJ1c2VybmFtZSI6IjAxNzQwOTk5NzY4IiwiZXhwIjoxNjQwNjI0MDUyLCJlbWFpbCI6bnVsbCwib3JpZ19pYXQiOjE2NDA2MjM3NTJ9.fknaHat7DYmlb2RkARoSEdzl2xMISquphTIqO1MvfCg"
}
}
```
### 2. Refresh Token API
```json
POST /api/v1/users/refresh-token/ HTTP/1.1
Request Body:
{
"token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjoyLCJ1c2VybmFtZSI6IjAxNzQwOTk5NzY4IiwiZXhwIjoxNjQwNjIxMTIxLCJlbWFpbCI6bnVsbCwib3JpZ19pYXQiOjE2NDA2MjA4MjF9.zYAN22CU6ftQ9PNTrij3tyYHDoxgqHkIfmy8LlbQebw"
}
Response:
status code: 200
{
"success": true,
"message": "Status OK",
"data": {
"token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjoyLCJ1c2VybmFtZSI6IjAxNzQwOTk5NzY4IiwiZXhwIjoxNjQwNjIxMTgyLCJlbWFpbCI6bnVsbCwib3JpZ19pYXQiOjE2NDA2MjA4MjF9.9vgmV43AIMg3ClDy8necU7x8YqQXypTG45GXtbjHc00"
}
}
```
## Dashboard APIs
### 1. Farm Type API
##### By this API user will get the different types of farm. Each firm will have different section on home page.
```json
GET /api/v1/farm/types/ HTTP/1.1
Authorization: jwt eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjoyLCJ1c2VybmFtZSI6IjAxNzQwOTk5NzY4IiwiZXhwIjoxNjQwNjI0MDUyLCJlbWFpbCI6bnVsbCwib3JpZ19pYXQiOjE2NDA2MjM3NTJ9.fknaHat7DYmlb2RkARoSEdzl2xMISquphTIqO1MvfCg
Response:
status code: 200
Response:
{
"success": true,
"meta_data": {
"count": 3,
"page_size": 10,
"next": null,
"previous": null
},
"data": [
{
"id": 1,
"name": "dairy"
},
{
"id": 2,
"name": "broiler"
},
{
"id": 3,
"name": "layer"
}
]
}
```
### 2. Device List API (According to farm type)
```json
GET /api/v1/farm/devices?farm_type=1 HTTP/1.1
Authorization: jwt eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjoyLCJ1c2VybmFtZSI6IjAxNzQwOTk5NzY4IiwiZXhwIjoxNjQwNjI0MDUyLCJlbWFpbCI6bnVsbCwib3JpZ19pYXQiOjE2NDA2MjM3NTJ9.fknaHat7DYmlb2RkARoSEdzl2xMISquphTIqO1MvfCg
Response:
status code: 200
{
"success": true,
"meta_data": {
"count": 1,
"page_size": 10,
"next": null,
"previous": null
},
"data": [
{
"id": 2,
"username": "01740999768",
"name": "MSI SHAFIK",
"email": null,
"device_id": "D001",
"farm_type": 1,
"address": null,
"is_active": true
}
]
}
```
### 3. All Data API
##### By this API user will get the device data according to the device
```json
GET /api/v1/farm/all-data/?user=2&start_date=2021-12-1&end_date=2021-12-10 HTTP/1.1
Authorization: jwt eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjoyLCJ1c2VybmFtZSI6IjAxNzQwOTk5NzY4IiwiZXhwIjoxNjQwNjI0MDUyLCJlbWFpbCI6bnVsbCwib3JpZ19pYXQiOjE2NDA2MjM3NTJ9.fknaHat7DYmlb2RkARoSEdzl2xMISquphTIqO1MvfCg
Response:
status code : 200
{
"success": true,
"meta_data": {
"count": 500,
"page_size": 10,
"next": 2,
"previous": null
},
"data": [
{
"Temperature": 23.0,
"Humidity": 47.0,
"CO2": 17.0,
"SO2": 59.0,
"SO6": 117.0,
"created_at": "2021-12-08T03:29:43.159684+06:00"
},
{
"Temperature": 17.0,
"Humidity": 74.0,
"CO2": 18.0,
"SO2": 67.0,
"SO6": 71.0,
"created_at": "2021-12-08T03:14:43.159684+06:00"
},
{
"Temperature": 35.0,
"Humidity": 58.0,
"CO2": 20.0,
"SO2": 46.0,
"SO6": 75.0,
"created_at": "2021-12-08T02:59:43.159684+06:00"
},
{
"Temperature": 32.0,
"Humidity": 65.0,
"CO2": 18.0,
"SO2": 35.0,
"SO6": 83.0,
"created_at": "2021-12-08T02:44:43.159684+06:00"
}
]
}
```
### 3.1. Chart Data API
##### By this API user will get the device data according to the device
```json
GET /api/v1/farm/chart-data/?user=2&start_date=2021-12-1&end_date=2021-12-10 HTTP/1.1
Authorization: jwt <token>
Response:
status code : 200
{
"success": true,
"meta_data": {
"count": 500,
"page_size": 10,
"next": 2,
"previous": null
},
"data": [
{
"Temperature": 23.0,
"Humidity": 47.0,
"CO2": 17.0,
"SO2": 59.0,
"SO6": 117.0,
"created_at": "2021-12-08T03:29:43.159684+06:00"
},
{
"Temperature": 17.0,
"Humidity": 74.0,
"CO2": 18.0,
"SO2": 67.0,
"SO6": 71.0,
"created_at": "2021-12-08T03:14:43.159684+06:00"
},
{
"Temperature": 35.0,
"Humidity": 58.0,
"CO2": 20.0,
"SO2": 46.0,
"SO6": 75.0,
"created_at": "2021-12-08T02:59:43.159684+06:00"
},
{
"Temperature": 32.0,
"Humidity": 65.0,
"CO2": 18.0,
"SO2": 35.0,
"SO6": 83.0,
"created_at": "2021-12-08T02:44:43.159684+06:00"
}
]
}
```
### 4. Alert Setting Create API
##### By this API user will create Alert Setting
```json
POST /api/v1/farm/alert-settings/ HTTP/1.1
Request Body:
{
"farm_type": 1,
"value": 50,
"level": "greater", # two fixed dropdown: 1. greater 2. lower
"sensor_name": "Humidity", # This value will come from Map Data List API (7 No API)
"sensor_code": "v2" # # This value will come from Map Data List API (7 No API)
}
Response:
status code: 201
{
"success": true,
"message": "Created",
"data": {
"id": 2,
"value": 50.0,
"level": "greater",
"sensor_name": "Humidity",
"sensor_code": "v2",
"status": true,
"created_at": "2021-12-26T23:22:43.802020+06:00",
"farm_type": 1
}
}
```
### 5. Alert Setting List API
```json
GET /api/v1/farm/alert-settings/?farm_type=1 HTTP/1.1
Content-Type: application/json
Authorization: jwt eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjoyLCJ1c2VybmFtZSI6IjAxNzQwOTk5NzY4IiwiZXhwIjoxNjQwNjI0MDUyLCJlbWFpbCI6bnVsbCwib3JpZ19pYXQiOjE2NDA2MjM3NTJ9.fknaHat7DYmlb2RkARoSEdzl2xMISquphTIqO1MvfCg
Response:
status code: 200
{
"success": true,
"meta_data": {
"count": 1,
"page_size": 10,
"next": null,
"previous": null
},
"data": [
{
"id": 1,
"farm_type": {
"id": 1,
"name": "dairy"
},
"value": 28.0,
"level": "greater",
"sensor_name": "Temperature"
}
]
}
```
### 6. Update Alert Setting API
```json
PATCH /api/v1/farm/alert-settings/1/ HTTP/1.1
Content-Type: application/json
Authorization: jwt eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjoyLCJ1c2VybmFtZSI6IjAxNzQwOTk5NzY4IiwiZXhwIjoxNjQwNjI0MDUyLCJlbWFpbCI6bnVsbCwib3JpZ19pYXQiOjE2NDA2MjM3NTJ9.fknaHat7DYmlb2RkARoSEdzl2xMISquphTIqO1MvfCg
Request Body: (Anyting from create payload)
{
"value": 28
}
Response:
status code: 200
{
"success": true,
"message": "Status OK",
"data": {
"id": 1,
"value": 28.0,
"level": "greater",
"sensor_name": "Temperature",
"sensor_code": "v1",
"status": true,
"created_at": "2021-12-27T22:16:56.569798+06:00",
"farm_type": 1
}
}
```
### 7. Map Data List API
```json
GET /api/v1/farm/map-value?farm_type=1 HTTP/1.1
Authorization: jwt eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjoyLCJ1c2VybmFtZSI6IjAxNzQwOTk5NzY4IiwiZXhwIjoxNjQwNjI0MDUyLCJlbWFpbCI6bnVsbCwib3JpZ19pYXQiOjE2NDA2MjM3NTJ9.fknaHat7DYmlb2RkARoSEdzl2xMISquphTIqO1MvfCg
Response:
status code: 200
{
"success": true,
"meta_data": {
"count": 5,
"page_size": 10,
"next": null,
"previous": null
},
"data": [
{
"sensor_name": "Temperature",
"sensor_code": "v1"
},
{
"sensor_name": "Humidity",
"sensor_code": "v2"
},
{
"sensor_name": "CO2",
"sensor_code": "v3"
},
{
"sensor_name": "SO2",
"sensor_code": "v4"
},
{
"sensor_name": "SO6",
"sensor_code": "v5"
}
]
}
```
### 8. SMS Text Settings API
##### By this setting user will set predefined SMS text.
```json
POST /api/v1/farm/sms-text/ HTTP/1.1
N.B.: text length will not be more than 64 characters.
Request Body:
{
"farm_type": 1,
"text": "আপনার খামারের তাপমাত্রা দ্রুত কমাতে হবে।"
}
Response:
status code: 201
```
### 9. List of SMS Text Settings
```json
GET /api/v1/farm/sms-text/ HTTP/1.1
Content-Type: application/json
Authorization: jwt eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjoyLCJ1c2VybmFtZSI6IjAxNzQwOTk5NzY4IiwiZXhwIjoxNjQwNjI5MDE2LCJlbWFpbCI6bnVsbCwib3JpZ19pYXQiOjE2NDA2Mjg3MTZ9.8npZmvcsL953DFLMAX5LxqlUQnvJalftgb_igPvEV00
Response:
status code: 200
{
"success": true,
"meta_data": {
"count": 2,
"page_size": 10,
"next": null,
"previous": null
},
"data": [
{
"id": 2,
"text": "আপনার খামারের তাপমাত্রা দ্রুত কমাতে হবে।",
"created_at": "2021-12-27T22:03:38.722709+06:00",
"farm_type": {
"id": 2,
"name": "broiler"
}
},
{
"id": 1,
"text": "আপনার খামারের তাপমাত্রা দ্রুত কমাতে হবে।",
"created_at": "2021-12-27T21:48:47.306470+06:00",
"farm_type": {
"id": 1,
"name": "dairy"
}
}
]
}
```
### 10. Update SMS Text Setting
```json
PATCH /api/v1/farm/sms-text/1/ HTTP/1.1
Content-Type: application/json
Authorization: jwt eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjoyLCJ1c2VybmFtZSI6IjAxNzQwOTk5NzY4IiwiZXhwIjoxNjQwNjMwNjAzLCJlbWFpbCI6bnVsbCwib3JpZ19pYXQiOjE2NDA2MzAzMDN9.5mentllSo3
Request Body:
{
"text": "আপনার খামারের তাপমাত্রা দ্রুত কমাতে হবে।"
}
Response:
status code: 200
{
"success": true,
"message": "Status OK",
"data": {
"id": 1,
"text": "আপনার খামারের তাপমাত্রা দ্রুত কমাতে হবে।",
"created_at": "2021-12-27T22:19:48.446459+06:00",
"farm_type": 1
}
}
```
### 11. Send Data Report to Email API
```json
GET /api/v1/farm/report/?user_id=2&recipient=shafik.te@gmail.com&start_date=2021-12-1&end_date=2021-12-27 HTTP/1.1
Authorization: jwt eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjoyLCJ1c2VybmFtZSI6IjAxNzQwOTk5NzY4IiwiZXhwIjoxNjQwNjMwNjAzLCJlbWFpbCI6bnVsbCwib3JpZ19pYXQiOjE2NDA2MzAzMDN9.5mentllSo3bUuf_dP_FXkLZfee0I1Emj__vhPmsVV4k
N.B.: recipient email can be mulitple. so it will be sperated by comma (,). e.g- recipient=shafik.te@gmail.com,shafik.tx@gmail.com
Response:
status code: 200
```
### [NEW] 12. Download Excel File Report Locally
##### By this API user will download the excel report locally (when you click this url it will be automatically downloaded)
```json
GET /api/v1/farm/download-report/?user_id=2&start_date=2021-12-1&end_date=2021-12-27&token=<token>
```
### [NEW] 13. Device Wise Production List API
##### It will be shown in a table below chart
```json
GET /api/v1/farm/production/?user=1&start_date=2021-12-01&end_date=2022-01-21 HTTP/1.1
Content-Type: application/json
Authorization: jwt <token>
This is paginated response (default 10 item). You can get the more data by using "page_size" and "page" parameters. Suppose if you want to get 15 response from second page, then you have to call the API like this-
GET /api/v1/farm/production/?page=2&page_size=15
Response:
status code: 200
{
"success": true,
"meta_data": {
"count": 1,
"page_size": 10,
"next": null,
"previous": null
},
"data": [
{
"id": 1,
"total_amount": 50.5,
"total_number": 5,
"created_at": "2022-01-11T21:24:42.466098+06:00",
"user": 2
}
]
}
```
### 14. Send Manual SMS
```json
POST /api/v1/farm/send-sms/ HTTP/1.1
Content-Type: application/json
Authorization: jwt <token>
N.B.: Message length should not be more than 125 characters.
Request Body:
{
"message": "আমার সোনার বাংলা, আমি তোমায় ভালোবাসি। চিরদিন তোমার আকাশ, তোমার বাতাস, আমার প্রাণে বাজায় বাশি, সোনার বাংলা, আমি",
"recipient": ["01740999768", "01689252523"]
# if you want to send SMS for all user then -> "recipient": "all"
}
Response:
status code: 200
{
"success": true,
"message": "Success"
}
```
## Mobile APP API
##### Above 1 & 2 APIs for login
### 1. Home Page API (for current conditions of farm)
```json
GET /api/v1/farm/customer-status/ HTTP/1.1
Authorization: jwt <token>
Response data:
status code: 200
{
"success": true,
"message": "Status OK",
"data": {
"temperature": 30.0,
"humidity": 71.0,
"updated_at": "2021-12-07 21:21:47.688973+00:00",
"network_status": "Failed",
"environment_status": "সঠিক মনিটরিং এর জন্য আপনার ডিভাইসের ইন্টারনেট নিশ্চিত করুন"
}
}
```
### 2. Daily Production InfoUpdate API
##### By this API user will send daily production data to the server
```json
POST /api/v1/farm/production/ HTTP/1.1
Content-Type: application/json
Authorization: jwt <token>
Request Data:
{
"total_amount": 50.5,
"total_number": 5
}
Response:
status code: 201
{
"success": true,
"message": "Created",
"data": {
"id": 1,
"total_amount": 50.5,
"total_number": 5,
"created_at": "2022-01-11T21:24:42.466098+06:00",
"user": 2
}
}
```
### 3. User Production Data History
##### By this API user will see the production history of his farm
```json
GET /api/v1/farm/production/ HTTP/1.1
Content-Type: application/json
Authorization: jwt <token>
This is paginated response (default 10 item). You can get the more data by using "page_size" and "page" parameters. Suppose if you want to get 15 response from second page, then you have to call the API like this-
GET /api/v1/farm/production/?page=2&page_size=15
Response:
status code: 200
{
"success": true,
"meta_data": {
"count": 1,
"page_size": 10,
"next": null,
"previous": null
},
"data": [
{
"id": 1,
"total_amount": 50.5,
"total_number": 5,
"created_at": "2022-01-11T21:24:42.466098+06:00",
"user": 2
}
]
}
```