Lamps API Documentation
API Endpoint
https://mosquitokiller.csie.ncku.edu.tw/apisLamps is a API allowing administrators to view counts and mcc in them.
Allowed HTTPs requests:
PUT : To create resource POST : Update resource GET : Get a resource or list of resources DELETE : To delete resource
Description Of Usual Server Responses:
-
200
OK
- the request was successful (some API calls may return 201 instead). -
201
Created
- the request was successful and a resource was created. -
204
No Content
- the request was successful but there is no representation to return (i.e. the response is empty). -
400
Bad Request
- the request could not be understood or was missing required parameters. -
401
Unauthorized
- authentication failed or user doesn’t have permissions for requested operation. -
403
Forbidden
- access denied. -
404
Not Found
- resource was not found.
Lamp ¶
Represents Lamp Details
Lamp attributes:
-
lamp_id
(String)
: unique identifier. -
lamp_hash_id
(String)
: Hash identifier. -
lamp_location
([Number])
: Lamp location. -
lamp_deployed_date
(Date)
: optional. -
lamp_wifi_ssid
(String)
: optional . -
lamp_wifi_password
(String)
: optional . -
place_id
(Number)
: deploy place id . -
created_at
(Timestamps)
: – . -
updated_at
(Timestamps)
: – .
Lamp Collection ¶
Headers
Content-Type: application/json
Body
[
{
"lamp_id": "TEST01",
"lamp_location": [120.19151248216, 22.9997144678771],
"lamp_deployed_date": null,
"place_id": 1,
}, {
"lamp_id": "TEST02",
"lamp_location": [120.193272644465, 22.9963046536379],
"lamp_deployed_date": null,
"place_id": 1,
}
]
Headers
Content-Type: application/json
Body
{
"error": "not found"
}
List all lampsGET/lamps
Headers
Content-Type: application/json
Body
{
"lamp_id": "TEST02",
"lamp_location": [
120,
22
],
"lamp_deployed_date": "2017-09-26",
"lamp_wifi_ssid": "ssid",
"lamp_wifi_password": "sspw",
"place_id": 1
}
Headers
Content-Type: application/json
Location: /lamps/TEST02
Body
{
"lamp_id": "TEST02",
"lamp_hash_id": "2345",
"lamp_location": [
120,
22
],
"lamp_deployed_date": "2017-09-26",
"lamp_wifi_ssid": "ssid",
"lamp_wifi_password": "sspw",
"place_id": 1,
"created_at": "2017-09-24T11:14:56.044Z",
"updated_at": "2017-09-24T11:14:56.044Z"
}
Create a LampPOST/lamps
Lamp ¶
A single Lamp object with all its details
Headers
Content-Type: application/json
Body
{
"lamp_id": "TEST01",
"lamp_location": [120.19151248216, 22.9997144678771],
"lamp_deployed_date": null,
"place_id": 1,
}
Headers
Content-Type: application/json
Body
{
"error": "not found"
}
Retrieve a LampGET/lamps/{id}{?key}
- id
String
(required) Example: TEST01id
of the Lamp to perform action with.- key
String
(optional) Example: hashuse ‘?key=hash’ <= Query by
lamp_hash_id
pre 6 char
Headers
Content-Type: application/json
Body
{
"lamp_location": [120,22],
"lamp_deployed_date": "2017-09-26",
"lamp_wifi_ssid": "ssid",
"lamp_wifi_password": "sspw",
"place_id": 1,
}
Body
{
"lamp_id": "TEST01",
"lamp_hash_id": "2345",
"lamp_location": [
120,
22
],
"lamp_deployed_date": "2017-09-26",
"lamp_wifi_ssid": "ssid",
"lamp_wifi_password": "sspw",
"place_id": 1,
"created_at": "2017-09-24T11:14:56.044Z",
"updated_at": "2017-09-24T11:14:56.044Z"
}
Update a LampPUT/lamps/{id}{?key}
- id
String
(required) Example: TEST01id
of the Lamp to perform action with.- key
String
(optional) Example: hashuse ‘?key=hash’ <= Query by
lamp_hash_id
pre 6 char
Delete a LampDELETE/lamps/{id}{?key}
- id
String
(required) Example: TEST01id
of the Lamp to perform action with.- key
String
(optional) Example: hashuse ‘?key=hash’ <= Query by
lamp_hash_id
pre 6 char
Place ¶
Represents Place Details
Place attributes:
-
place_id
(Number)
: unique identifier. -
place_name
(String(25))
: Require. -
place_address
(String(50))
: Require. -
place_contact_person
(String(10))
: optional. -
place_phone
(String(25))
: optional . -
created_at
(Timestamps)
: – . -
updated_at
(Timestamps)
: – .
Place Collection ¶
Headers
Content-Type: application/json
Body
[
{
"place_id": 1,
"place_name": "成大幼兒園",
"place_address": "台南市東區大學路1號",
"place_contact_person": "張先生",
"place_phone": "09xx-xxxxxx",
"created_at": "2017-09-24T11:14:56.035Z",
"updated_at": "2017-09-24T11:14:56.035Z"
},
{
"place_id": 2,
"place_name": "NETDB",
"place_address": "台南市東區大學路1號",
"place_contact_person": "楊先生",
"place_phone": "09xx-xxxxxx",
"created_at": "2017-09-24T11:14:56.044Z",
"updated_at": "2017-09-24T11:14:56.044Z"
}
]
Headers
Content-Type: application/json
Body
{
"error": "not found"
}
List all placesGET/places
Headers
Content-Type: application/json
Body
{
"place_name": "資訊系館一樓",
"place_address": "台南市東區大學路1號",
"place_contact_person": "楊先生",
"place_phone": "09xx-xxxxxx",
}
Headers
Content-Type: application/json
Location: /places/3
Body
{
"place_id": 3,
"place_name": "資訊系館一樓",
"place_address": "台南市東區大學路1號",
"place_contact_person": "楊先生",
"place_phone": "09xx-xxxxxx",
"created_at": "2017-09-24T11:14:56.073Z",
"updated_at": "2017-09-24T11:14:56.073Z",
}
Create a PlacePOST/places
Place ¶
A single Place object with all its details
Headers
Content-Type: application/json
Body
{
"place_id": 1,
"place_name": "成大幼兒園",
"place_address": "台南市東區大學路1號",
"place_contact_person": "張先生",
"place_phone": "09xx-xxxxxx",
"created_at": "2017-09-24T11:14:56.035Z",
"updated_at": "2017-09-24T11:14:56.035Z"
}
Headers
Content-Type: application/json
Body
{
"error": "not found"
}
Retrieve a PlaceGET/places/{id}
- id
Number
(required) Example: 1Numeric
id
of the User to perform action with.
Headers
Content-Type: application/json
Body
{
"place_name": "成大商家",
"place_address": "台南市東區大學路1號",
"place_contact_person": "林先生",
"place_phone": "09xx-xxxxxx",
}
Body
{
"place_id": 1,
"place_name": "成大商家",
"place_address": "台南市東區大學路1號",
"place_contact_person": "林先生",
"place_phone": "09xx-xxxxxx",
"created_at": "2017-09-24T11:14:56.035Z",
"updated_at": "2017-09-24T11:14:56.035Z"
}
Update a PlacePUT/places/{id}
- id
Number
(required) Example: 1Numeric
id
of the User to perform action with.
Delete a PlaceDELETE/places/{id}
- id
Number
(required) Example: 1Numeric
id
of the User to perform action with.
Count ¶
Represents Count Details
Count attributes:
-
count_id
(Number)
: unique identifier. -
lamp_id
(String(25))
: Require. -
counts
(Number)
: Require. -
created_at
(Timestamps)
: – .
Count Collection ¶
Headers
Content-Type: application/json
Body
use /counts will return
[
{
"count_id": 1,
"lamp_id": "TEST01",
"counts": 1,
"created_at": "2017-09-24T11:14:56.035Z",
}, {
"count_id": 2,
"lamp_id": "TEST01",
"counts": 2,
"created_at": "2017-09-24T11:14:56.044Z",
}
]
Headers
Content-Type: application/json
Body
use /counts?lampID=TEST01 will return
[
{
"count_id": 1,
"lamp_id": "TEST01",
"counts": 1,
"created_at": "2017-09-24T11:14:56.035Z",
}
]
Headers
Content-Type: application/json
Body
use /counts?lampHashID=9b3814 will return
[
{
"count_id": 1,
"lamp_id": "9b3814",
"counts": 1,
"created_at": "2017-09-24T11:14:56.035Z",
}
]
Headers
Content-Type: application/json
Body
use /counts?formatBy=date will return
{
"2017-10-05": {
"KG0915-02": {
"lamp_id": "KG0915-02",
"sum": "30",
"date": "2017-10-05",
"size": 0
},
"KG0915-03": {
"lamp_id": "KG0915-03",
"sum": "95",
"date": "2017-10-05",
"size": 0
}
},
"2017-10-06": {
"KG0915-02": {
"lamp_id": "KG0915-02",
"sum": "51",
"date": "2017-10-06",
"size": 0
},
"KG0915-03": {
"lamp_id": "KG0915-03",
"sum": "92",
"date": "2017-10-06",
"size": 0
}
}
}
Headers
Content-Type: application/json
Body
use /counts?formatBy=date&lampHashID=9b3814 will return
{
"2017-10-05": {
"9b3814": {
"lamp_id": "9b3814",
"sum": "30",
"date": "2017-10-05",
"size": 0
}
},
"2017-10-06": {
"9b3814": {
"lamp_id": "9b3814",
"sum": "51",
"date": "2017-10-06",
"size": 0
}
}
}
Headers
Content-Type: application/json
Body
use /counts?formatBy=hour&lampHashID=9b3814 will return
{
"2017-10-05": {
"8": {
"sum": "30",
"date": "2017-10-05",
"hour": "8",
"lamp_id":"9b3814"
},
"9": {
"sum": "30",
"date": "2017-10-05",
"hour": "9",
"lamp_id":"9b3814"
}
},
"2017-10-06": {
"1": {
"sum": "30",
"date": "2017-10-05",
"hour": "8",
"lamp_id":"9b3814"
},
"2": {
"sum": "30",
"date": "2017-10-05",
"hour": "9",
"lamp_id":"9b3814"
}
}
}
Headers
Content-Type: application/json
Body
{
"error": "not found"
}
List all countsGET/counts{?formatBy,lampHashID,limit,lampID}
- formatBy
String
(optional) Example: dateuse ‘?formatBy=date’ <= Return data Group By date & lamp_id
- lampHashID
String
(optional) Example: 9b3814use ‘?formatBy=hour&lampHashID=9b3814’ <= Return one lamp data Group By date & hour
- limit
String
(optional) Example: 7user ‘?limit=7’ <= return past 7 days data. e.g. today 10/8, reutrn data from 10/1 00:00
- lampID
String
(optional) Example: KG0915-01use ‘?formatBy=hour&lampID=KG0915-01’ <= Return one lamp data Group By date & hour
Headers
Content-Type: application/json
Body
{
"lamp_id": "TEST01",
"counts": 1,
}
Headers
Content-Type: application/json
Location: /counts/3
Body
{
"count_id": 3,
"lamp_id": "TEST01",
"counts": "1",
"created_at": "2017-09-24T11:14:56.073Z",
}
Create a CountPOST/counts
Count ¶
A single Count object with all its details
Headers
Content-Type: application/json
Body
{
"count_id": 1,
"lamp_id": "TEST01",
"counts": "1",
"created_at": "2017-09-24T11:14:56.073Z",
}
Headers
Content-Type: application/json
Body
{
"error": "not found"
}
Retrieve a CountGET/counts/{id}
- id
Number
(required) Example: 1Numeric
id
of the User to perform action with.
Delete a CountDELETE/counts/{id}
- id
Number
(required) Example: 1Numeric
id
of the User to perform action with.
State ¶
Represents State Details
State attributes:
-
state_id
(Number)
: unique identifier. -
lamp_id
(String(25))
: Require. -
lamp_state
(Number)
: Require, 0~2. -
lamp_check_date
(Date)
: optional. -
lamp_check_person
(String(10))
: optional. -
state_description
(TEXT)
: optional . -
state_reason
TEXT)
: optional . -
created_at
(Timestamps)
: – . -
updated_at
(Timestamps)
: – .
State Collection ¶
Headers
Content-Type: application/json
Body
[
{
"state_id": 1,
"lamp_id": "TEST01",
"lamp_state": 2,
"lamp_check_date": "2017-09-26",
"lamp_check_person": "張同學",
"state_description": "無法傳送訊息",
"state_reason": "推測是晶片故障",
"created_at": "2017-09-24T11:14:56.035Z",
"updated_at": "2017-09-24T11:14:56.035Z"
},
{
"state_id": 2,
"lamp_id": "TEST02",
"lamp_state": 1,
"created_at": "2017-09-24T11:14:56.044Z",
"updated_at": "2017-09-24T11:14:56.044Z"
}
]
Headers
Content-Type: application/json
Body
{
"error": "not found"
}
List all statesGET/states
Headers
Content-Type: application/json
Body
{
"lamp_id": "TEST01",
"lamp_state": 1,
}
Headers
Content-Type: application/json
Location: /states/3
Body
{
"state_id": 3,
"lamp_id": "TEST01",
"lamp_state": 1,
"created_at": "2017-09-24T11:14:56.073Z",
"updated_at": "2017-09-24T11:14:56.073Z",
}
Create a StatePOST/states
State ¶
A single State object with all its details
Headers
Content-Type: application/json
Body
{
"state_id": 1,
"lamp_id": "TEST01",
"lamp_state": 2,
"lamp_check_date": "2017-09-26",
"lamp_check_person": "張同學",
"state_description": "無法傳送訊息",
"state_reason": "推測是晶片故障",
"created_at": "2017-09-24T11:14:56.035Z",
"updated_at": "2017-09-24T11:14:56.035Z"
}
Headers
Content-Type: application/json
Body
{
"error": "not found"
}
Retrieve a StateGET/states/{id}
- id
Number
(required) Example: 1Numeric
id
of the User to perform action with.
Headers
Content-Type: application/json
Body
{
"lamp_state": 2,
"lamp_check_date": "2017-09-27",
"lamp_check_person": "張同學",
"state_description": "燈不會亮",
"state_reason": "捕蚊燈故障,更換捕蚊燈",
}
Body
{
"state_id": 1,
"lamp_id": "TEST01",
"lamp_state": 2,
"lamp_check_date": "2017-09-27",
"lamp_check_person": "張同學",
"state_description": "燈不會亮",
"state_reason": "捕蚊燈故障,更換捕蚊燈",
"created_at": "2017-09-24T11:14:56.035Z",
"updated_at": "2017-09-24T11:14:56.035Z"
}
Update a StatePUT/states/{id}
- id
Number
(required) Example: 1Numeric
id
of the User to perform action with.
Delete a StateDELETE/states/{id}
- id
Number
(required) Example: 1Numeric
id
of the User to perform action with.
Mcc ¶
Represents Mcc Details
Mcc attributes:
-
mcc_id
(Number)
: unique identifier. -
mcc_keys
([String(25)])
: Require. -
mcc_points
([String(25)])
: Require. -
mcc_center
(Double)
: Require. -
rule_id
(Number)
: Require. -
created_at
(Timestamps)
: – .
Mcc Collection ¶
Headers
Content-Type: application/json
Body
[
{
"mcc_id": 1,
"mcc_keys": [
"TEST01",
"TEST02"
],
"mcc_points": [
"TEST01",
"TEST02"
],
"mcc_center": [
120.192393,
22.9980096
],
"rule_id": 1,
"created_at": "2017-09-24T11:14:56.073Z"
}
]
Headers
Content-Type: application/json
Body
{
"error": "not found"
}
List all mccGET/mcc
Headers
Content-Type: application/json
Body
{
"mcc_keys": ["TEST01", "TEST02"],
"mcc_points": ["TEST01", "TEST02", "TEST03"],
"mcc_center": [120.192393, 22.9980096],
"rule_id": 1,
}
Headers
Content-Type: application/json
Location: /mcc/2
Body
{
"mcc_id": 2,
"mcc_keys": ["TEST01", "TEST02"],
"mcc_points": ["TEST01", "TEST02", "TEST03"],
"mcc_center": [120.192393, 22.9980096],
"rule_id": 1,
"created_at": "2017-09-24T11:14:56.073Z",
}
Create a MccPOST/mcc
Mcc ¶
A single Mcc object with all its details
Headers
Content-Type: application/json
Body
{
"mcc_id": 1,
"mcc_keys": ["TEST01", "TEST02"],
"mcc_points": ["TEST01", "TEST02"],
"mcc_center": [120.192393, 22.9980096],
"rule_id": 1,
"created_at": "2017-09-24T11:14:56.035Z",
}
Headers
Content-Type: application/json
Body
{
"error": "not found"
}
Retrieve a MccGET/mcc/{id}
- id
Number
(required) Example: 1Numeric
id
of the User to perform action with.
Delete a MccDELETE/mcc/{id}
- id
Number
(required) Example: 1Numeric
id
of the User to perform action with.
Rules ¶
Represents Rules Details
Rules attributes:
-
rule_id
(Number)
: unique identifier. -
timeline_upper_limit
(Number)
: Require. -
distance_lower_limit
(Number)
: Require. -
points_lower_limit
(Number)
: Require. -
counts_lower_limit
(Number)
: Require. -
created_at
(Timestamps)
: – . -
updated_at
(Timestamps)
: – .
Rules Collection ¶
Headers
Content-Type: application/json
Body
[
{
"rule_id": 1,
"timeline_upper_limit": 3,
"distance_lower_limit": 500,
"points_lower_limit": 5,
"counts_lower_limit": 20,
"created_at": "2017-09-24T11:14:56.066Z",
"updated_at": "2017-09-24T11:14:56.066Z"
}
]
Headers
Content-Type: application/json
Body
{
"error": "not found"
}
List all rulesGET/rules
Headers
Content-Type: application/json
Body
{
"timeline_upper_limit": 3,
"distance_lower_limit": 500,
"points_lower_limit": 5,
"counts_lower_limit": 20,
}
Headers
Content-Type: application/json
Location: /rules/3
Body
{
"rule_id": 3,
"timeline_upper_limit": 3,
"distance_lower_limit": 500,
"points_lower_limit": 5,
"counts_lower_limit": 20,
"created_at": "2017-09-24T11:14:56.066Z",
"updated_at": "2017-09-24T11:14:56.066Z"
}
Create a RulesPOST/rules
Rules ¶
A single Rules object with all its details
Headers
Content-Type: application/json
Body
{
"rule_id": 1,
"timeline_upper_limit": 3,
"distance_lower_limit": 500,
"points_lower_limit": 5,
"counts_lower_limit": 20,
"created_at": "2017-09-24T11:14:56.066Z",
"updated_at": "2017-09-24T11:14:56.066Z"
}
Headers
Content-Type: application/json
Body
{
"error": "not found"
}
Retrieve a RulesGET/rules/{id}
- id
Number
(required) Example: 1Numeric
id
of the User to perform action with.
Headers
Content-Type: application/json
Body
{
"timeline_upper_limit": 3,
"distance_lower_limit": 500,
"points_lower_limit": 10,
}
Body
{
"rule_id": 1,
"timeline_upper_limit": 3,
"distance_lower_limit": 500,
"points_lower_limit": 10,
"counts_lower_limit": 20,
"created_at": "2017-09-24T11:14:56.066Z",
"updated_at": "2017-09-24T11:14:56.066Z"
}
Update a RulesPUT/rules/{id}
- id
Number
(required) Example: 1Numeric
id
of the User to perform action with.
Delete a RulesDELETE/rules/{id}
- id
Number
(required) Example: 1Numeric
id
of the User to perform action with.
Comments Collection ¶
Headers
Content-Type: application/json
Body
[{
"comments_id": 1,
"lamp_id": "TEST01",
"comment_content": "我不會用",
"created_at": "2017-09-24T11:14:56.066Z",
}]
Headers
Content-Type: application/json
Body
{
"error": "not found"
}
List all commentsGET/comments
Headers
Content-Type: application/json
Body
lamp_id should be 6 characters lamp_hash_id
{
"lamp_id": "9b3814",
"comment_content": "我不會用",
}
Headers
Content-Type: application/json
Location: /comments/3
Body
{
"comments_id": 3,
"lamp_id": "TEST01",
"comment_content": "我不會用",
"created_at": "2017-09-24T11:14:56.066Z",
}
Create a CommentsPOST/comments
Comments ¶
A single Comments object with all its details
Headers
Content-Type: application/json
Body
{
"comments_id": 1,
"lamp_id": "TEST01",
"comment_content": "我不會用",
"created_at": "2017-09-24T11:14:56.066Z",
}
Headers
Content-Type: application/json
Body
{
"error": "not found"
}
Retrieve a CommentsGET/comments/{id}
- id
Number
(required) Example: 1Numeric
id
of the User to perform action with.
Headers
Content-Type: application/json
Body
{
"comment_content": "我還是不會用",
}
Body
{
"comments_id": 1,
"lamp_id": "TEST01",
"comment_content": "我還是不會用",
"created_at": "2017-09-24T11:14:56.066Z",
}
Update a CommentsPUT/comments/{id}
- id
Number
(required) Example: 1Numeric
id
of the User to perform action with.
Delete a CommentsDELETE/comments/{id}
- id
Number
(required) Example: 1Numeric
id
of the User to perform action with.
Generated by aglio on 01 Dec 2017
Comments ¶
Represents Comments Details
Comments attributes:
comments_id
(Number)
: unique identifier.lamp_id
(Number)
: Require.comment_content
(Text)
: Require.created_at
(Timestamps)
: – .