Bevywise IoT Platform API Documentation
Introduction
The REST API presented in this document can be used to communicate with Bevywise IoT Platform for creating a mobile application for your IoT Solution or for integrating Bevywise IoT Platfom with Amazon Alexa or other advanced applications.
Prerequisite for Bevywise IoT Platform
Bevywise IoT Platform supports two types of authentication mechanism which users can use our IoT Platform to integrate with Mobile application and with AlexaAmazon or other advanced applications.
Once you set up our IoT Platform in your cloud environment, login to the Admin console and go to below URL to set up authentication based on your application.
https://devicemanager.bevywise.com/o/applications/
Type 1: Authentication for direct login
If you want your mobile application to login with username and password directly via our API, fill the details as follows and save it.
Name: < name of the application > Client id: < it will be created automatically don't change it > Client secret: < it will be created automatically don't change it > Client type: Confidential Authorization grant type: Resource owner password based Redirect urls: < Leave it empty >
Once you have done the configuration, you will get client ID, client secret, Client type and Authorization grant type. Make a backup of the details for further usage.
Type 2: Authentication for Amazon Alexa skill set or other application
This authentication is based on the OAUTH2 Authentication which is used for a application with “OAUTH2 Authentication code grant flow”[ used in Amazon Alexa skill set or Google assistance]. Fill the details as follows and save it.
Name: < name of the application > Client id: < it will be created automatically don't change it > Client secret: < it will be created automatically don't change it > Client type: Confidential Authorization grant type: Authorization code Redirect urls: < redirect urls the alexa want >
Once you have done the configuration, you will get client ID, client secret, Client type and Authorization grant type. Make a backup of the details for further usage.
Sign Up API
This API will help you to create a new account in Bevywise IoT Platform.
Request:
Http Request:
POST https://server IP or domain name/bwiot/api/v1/auth/signup/
Parameters:
PARAMETER | VALUE DETAIL |
---|---|
username | email id of the user |
password | any password string |
client_id | paste the client id which generated while creating authentication |
client_secret | paste the client secret which generated while creating authentication |
grant_type | password [use the exact word “password” and not give the user password] |
Response:
On Success:
{ "bwapi-status": "success", "userid": "email_id", "token": "the token", "expires_in": "36000", "refresh_token": "the refresh token", "bwapi-status-reason": "successfullsignup" }
On Failure:
{ "bwapi-status-reason": "Reason", "bwapi-status": "fail" }
Login API
This API helps you to integrate the Bevywise IoT platform to your mobile application and also helps you to login to your application using the details which you got after setting up Authentication in Bevywise IoT platform. There are two types of login API, they are
Type 1:
To get token for normal or direct login to application using username and password
Request:
Http Request:
POST https://server IP or domain name/bwiot/api/v1/auth/login/
Parameter:
PARAMETER | VALUE DETAIL |
---|---|
username | user email id |
password | any password string |
client_id | paste the client id which generated while creating authentication |
client_secret | paste the client secret which generated while creating authentication |
grant_type | password [use the exact word “password” and not give the user password] |
Response:
On Success:
{ "bwapi-status-reason": "successfullsignup", "userid": "email_id", "token": "the token", "expires_in": "36000", "refresh_token": "refresh token value", "bwapi-status": "success" }
On Failure:
{ "bwapi-status-reason": "Reason", "bwapi-status": "fail" }
Type 2:
Use the details generated after setting up Authentication in Bevywise IoT platform to integrate Bevywise IoT Platform to your alexa skill set server or other server that has oauth2 authorization-code flow.
Provide the details based on the below details for other necessary url’s and example in oauth2 authorization-code flow
Authorization Grant Type: Auth Code Grant Authorization URL: https://devicemanager.bevywise.com/o/authorize/ Access Token URL: https://devicemanager.bevywise.com/o/token/ Client ID: copy and paste the client id created from Authentication Client Secret: copy and paste the Client Secret created from Authentication type 2 Client Authentication Scheme: Http Basic Scope: Read Write
Note: Only the login API must vary for normal application and the application with Amazon Alexa. Other than this, all following API’s are same for both applications.
Refresh Token API
The Token gathered from login or sign up will expire after some time, to refresh the token use the below API instead of re-login.
Request:
Http Request:
POST https://server IP or domain name/bwiot/api/v1/auth/refresh/
Parameters:
PARAMETER | VALUE DETAIL |
---|---|
client_id | paste the client id which generated while creating authentication |
client_secret | paste the client secret which generated while creating authentication |
grant_type | refresh_token [use the exact word “refresh_token” and not give the user password] |
refresh_token | refresh token from login or sign up or previous refresh |
Response:
On Success:
{ "bwapi-status-reason": "successfullsignup", "userid": "email_id", "token": "token value", "expires_in": "36000", "refresh_token": "refresh token value", "bwapi-status": "success" }
On Failure:
{ "bwapi-status-reason": "Reason", "bwapi-status": "fail" }
Logout API
This API helps your application to logout from the Bevywise IoT platform.
Request:
Http Request:
Add Authorization Header
POST https://server IP or domain name/bwiot/api/v1/auth/logout/
Parameters:
PARAMETER | VALUE DETAIL |
---|---|
client_id | paste the client id which generated while creating authentication |
client_secret | paste the client secret which generated while creating authentication |
token | user token |
Generate Auth Key
This API will provide Auth key[mqtt username] and Auth token[mqtt password] to connect your sensor or device with authentication.
Request:
Http Request:
Add Authorization Header
POST https://server IP or domain name/bwiot/api/v1/devicesecurity/generatekey/
Parameter:
PARAMETER | VALUE DETAIL |
---|---|
permissions | Read Write (or) Read (or) Write |
key_desc | a string description about key |
Response:
On Success:
{ "bwapi-status": "success", "userid": "email_id", "data": { "auth_key": "mqusername", "auth_token": "mqpassword", "description": "desc", "permissions": "permission" } }
On Failure:
{ "bwapi-status-reason": "Reason", "userid": "email_id", "bwapi-status": "fail" }
Push FCM Token API
This API will help you to push the notification to your mobile application using FCM integration.
Request:
Http Request:
Add Authorization Header
POST https://server IP or domain name/bwiot/api/v1/auth/pushfcm/
Parameters:
PARAMETER | VALUE DETAIL |
---|---|
notification_token | fcm token value |
device | ios or android or web |
Note: For device use the exact word for your device type. For example, if your device type is android, the use “android” as device
Get Device List
This API helps you get the both active and inactive connected device list.
Request:
Http Request:
Add Authorization Header
POST https://server IP or domain name/bwiot/api/v1/devices/
Parameter:
PARAMETER | VALUE DETAIL |
---|---|
page_no | no of the page |
Note : set page_no = -1 to get all devices
Response:
On Success:
{ "bwapi-status": "success", "userid": "email_id", "data": [ { "device_name": "name of the device", "device_id": "id of the device", "status": "active/inactive", "device_connected_time": "time" } ], "next_page": "True/False", "page_no": "pageno", }
On Failure:
If Auth_keys Not Generated
{ "bwapi-status-reason": "Device Auth Keys Not Found", "userid": "email_id", "bwapi-status": "fail", }
If No Device Found or No Data Found for the requested page no
{ "bwapi-status": "fail", "userid": "email_id", "bwapi-status-reason": "No Device / Invalid Page", }
If A server error
{ "bwapi-status-reason": "Internal Error", "userid": "email_id", "bwapi-status": "fail", }
Get Device Details
This API provides you details like user_id, device_name, device_id, will_topic of the device, will message and device_status for a particular device. Here user_id represent the user who connect the device.
Request:
Http Request:
Add Authorization Header
POST https://server IP or domain name/bwiot/api/v1/devices/get_device_detail
Parameters:
PARAMETER | VALUE DETAIL |
---|---|
device_id | id_of_the_device for which you want to know details |
Response:
On Success:
{ 'bwapi-status': 'success', 'userid': 'email_id', 'device_name':'device_name' 'device_id': 'id of the device', 'will_topic': 'willtopic', 'will_message': 'willmessage', 'device_status': 'status', }
On Failure:
If device_id parameter is not found
{ "bwapi-status-reason": "No Valid Parameter Found", "userid": "email_id", "bwapi-status": "fail", }
If No Device Found
{ "bwapi-status-reason": "Device Not Found", "userid": "email_id", "bwapi-status": "fail", }
If A server error
{ "bwapi-status-reason": "Internal Error", "userid": "email_id", "bwapi-status": "fail", }
Get Events from Device
This API provides the list of events like publish topic, message or payload received from a particular device.
Request:
Http Request:
Add Authorization Header
POSThttps://server IP or domain name/bwiot/api/v1/devices/get_device_recv_detail
Parameter:
PARAMETER | VALUE DETAIL |
---|---|
page_no | wanted page no |
device_id | id of the device |
Response:
On Success:
{ 'bwapi-status':'success', 'userid':'email_id', 'recv_data'':[ { 'device_name'':'name of the device'', 'device_id'':'id of the device'', 'topic_name'':'name of the topic the event occured'', 'message'' :'event'', 'timestamp'':'time the event occured'' } ], 'page_nav_data'': { 'next_page':true/false', 'total_pages'':'total pages'', 'page_no'':'current page'' } }
On Failure:
If no Event Found
{ "bwapi-status-reason": "no_data_found", "userid": "email_id", "bwapi-status": "fail", }
If device_id parameter is not found
{ "bwapi-status-reason": "No Valid Parameter Found", "userid": "email_id", "bwapi-status": "fail", }
If A server error
{ "bwapi-status-reason": "Internal Error", "userid": "email_id", "bwapi-status": "fail", }
Get Commands received in Device
This API provides the list of subscribed topics and messages of a particular device.
Request:
Http Request:
Add Authorization Header
POSThttps://server IP or domain name/bwiot/api/v1/devices/get_device_sent_detail
Parameter:
PARAMETER | VALUE DETAIL |
---|---|
page_no | wanted page no |
device_id | id of the device |
Response:
On Success:
{ 'bwapi-status':'success', 'bwapi-status':'success', 'recv_data': [ { 'device_name':'name of the device', 'device_id':'id of the device' 'topic_name':'name of the topic the event occured', 'message' :'event', 'timestamp':'time the event occured' } ], 'page_nav_data': { 'next_page':True/False, 'total_pages':'total pages' } }
On Failure:
If no Command Found
{ "bwapi-status-reason": "no_data_found", "userid": "email_id", "bwapi-status": "fail", }
If device_id parameter is not found
{ "bwapi-status-reason": "No Valid Parameter Found", "userid": "email_id", "bwapi-status": "fail", }
If A server error
{ "bwapi-status-reason": "Internal Error", "userid": "email_id", "bwapi-status": "fail", }
Get Dashboard Details
This API helps you get details from the Dashboard of Bevywise IoT Platform.
Request:
Http Request:
Add Authorization Header
GEThttps://server IP or domain name/bwiot/api/v1/dashboard/
Response:
On Success:
{ 'bwapi-status': 'success', 'userid': 'email_id', 'data': { 'active_client_count': 10, 'total_client_count': 10, 'total_received_messages': 100, 'total_topic_count': 100, 'sec_message_count': 0, 'recent_connections': [ { 'device_name': "-", 'device_id':'' 'device_time': '-' } ], 'recent_disconnects': [ { 'device_name':'' 'device_id':'' 'device_time':'' } ], 'recent_messages': [ { 'topic_name': "-", 'message_name': '-', 'recv_time': "-" } ], } }
On Failure:
If no data Found
{ "bwapi-status-reason": "no_data_found", "userid": "email_id", "bwapi-status": "fail", }
If A server error
{ "bwapi-status-reason": "Internal Error", "userid": "email_id", "bwapi-status": "fail", }
Get Active Subscription
Provide a list of subscribed topics for a particular active topics.
Request:
Http Request:
Add Authorization Header
GEThttps://server IP or domain name/bwiot/api/v1/ic/get_active_topics
Response:
On Success:
{ 'bwapi-status': 'success', 'userid': 'email_id', 'active_topics':[topic1,topic2], }
On Failure:
If no data Found
{ "bwapi-status-reason": "no_data_found", "userid": "email_id", "bwapi-status": "fail", }
If A server error
{ "bwapi-status-reason": "Internal Error", "userid": "email_id", "bwapi-status": "fail", }
Get List of Clients for a Topic
This API provides a list of clients based on the subscribed topics.
Request:
Http Request:
Add Authorization Header
POSThttps://server IP or domain name/bwiot/api/v1/ic/get_clients_related_to_the_topic
Parameter:
PARAMETER | VALUE DETAIL |
---|---|
Topic | name of the topic |
Response:
On Success:
{ 'bwapi-status': 'success', 'userid': 'email_id', 'topic':'name of the topic', 'clients':[client1,client2,...] }
On Failure:
If no data Found
{ "bwapi-status-reason": "no_data_found", "userid": "email_id", "bwapi-status": "fail", }
If A server error
{ "bwapi-status-reason": "Internal Error", "userid": "email_id", "bwapi-status": "fail", }
Send Command to a Topic
This API is used to send command or message to a particular topic.
Request:
Http Request:
Add Authorization Header
POSThttps://server IP or domain name/bwiot/api/v1/ic/send_command_to_topic
Parameter:
PARAMETER | VALUE DETAIL |
---|---|
Topic | name of the topic for which you want to command. |
command | command or message |
Response:
On Success:
{ 'bwapi-status': 'success', 'userid': 'email_id', 'bwapi-status-reason':'command send', }
On Failure:
If Invalid Parameter Found
{ "bwapi-status-reason": "No Valid Parameter Found", "userid": "email_id", "bwapi-status": "fail", }
If Not Able to Send
{ "bwapi-status": "fail", "userid": "email_id", "bwapi-status": "unable to send", }
If A server error
{ "bwapi-status-reason": "Internal Error", "userid": "email_id", "bwapi-status": "fail", }
Get Active Subscriptions for a Device
This API provides all the subscribed topics for a particular active device.
Request:
Http Request:
Add Authorization Header
POSThttps://server IP or domain name/bwiot/api/v1/ic/get_active_topics_for_this_device
Parameter:
PARAMETER | VALUE DETAIL |
---|---|
device_id | id of the device |
Response:
On Success:
{ 'bwapi-status': 'success', 'userid': 'email_id', 'topics':['topic1','topic2'], }
On Failure:
{ "bwapi-status-reason": "No Valid Parameter Found", "userid": "email_id", "bwapi-status": "fail", }
{ "bwapi-status": "fail", "userid": "email_id", "bwapi-status-reason": "No Topic Found", }
If server error
{ "bwapi-status-reason": "Internal Error", "userid": "email_id", "bwapi-status": "fail", }
Send Command to a Device
Using this API, you can manually send a command or message to the device based on its subscribed topic.
Request:
Http Request:
Add Authorization Header
POSThttps://server IP or domain name/bwiot/api/v1/ic/send_command_to_device
Parameter:
PARAMETER | VALUE DETAIL |
---|---|
Topic | name of the device |
command | command |
device_id | id of the device |
Response:
On Success:
{ 'bwapi-status': 'success', 'userid': 'email_id', 'bwapi-status-reason':'command send', }
On Failure:
{ "bwapi-status": "fail", "userid": "email_id", "bwapi-status-reason": "Device is not active/not found", }
{ "bwapi-status": "fail", "userid": "email_id", "bwapi-status-reason": "No Valid Parameter Found", }
If a server error
{ "bwapi-status-reason": "Internal Error", "userid": "email_id", "bwapi-status": "fail", }
Edit Device Name
This API is used to change or modify only name of the connected device.
Request:
Http Request:
Add Authorization Header
POSThttps://server IP or domain name/bwiot/api/v1/devices/edit_device_name
Parameter:
PARAMETER | VALUE DETAIL |
---|---|
new_device_name | device name to set |
device_id | ID of the device for which you want to change the name. |
Response:
On Success:
{ 'bwapi-status': 'success', 'userid': 'email_id', 'device_name': 'new devicename', }
On Failure:
{ "bwapi-status": "fail", "userid": "email_id", "bwapi-status-reason": "no_matching_device_id_found", }
{ "bwapi-status": "fail", "userid": "email_id", "bwapi-status-reason": "No Valid Parameter Found", }
If a server error
{ "bwapi-status-reason": "Internal Error", "userid": "email_id", "bwapi-status": "fail", }
Get Last Status of a Device
This API used to get a status like message received time stamp, device status, last received message etc for a particular device.
Request:
Http Request:
Add Authorization Header
POSThttps://server IP or domain name/bwiot/api/v1/devices/get_last_status_of_device
Parameter:
PARAMETER | VALUE DETAIL |
---|---|
device_id | id of the device |
Response:
On Success:
{ 'device_status': 'device status', 'userid': 'email_id', 'device_name': 'device name', 'bwapi-status': 'success', 'received_at': ' time at which last message is received', 'device_id': 'device ID', 'last_received_message': 'last message received', }
On Failure:
{ "bwapi-status": "fail", "userid": "email_id", "bwapi-status-reason": "Device Not Found", }
{ "bwapi-status": "fail", "userid": "email_id", "bwapi-status-reason": "No Valid Parameter Found", }
If a server error
{ "bwapi-status-reason": "Internal Error", "userid": "email_id", "bwapi-status": "fail", }
Delete Device
This API is used to delete a particular device from Bevywise IoT Platform permanently.
Http Request:
Add Authorization Header
POSThttps://server IP or domain name/bwiot/api/v1/devices/delete_device/
Parameters:
PARAMETER | VALUE DETAIL |
---|---|
device_id | id of the device |
Response:
On Success:
{ 'userid': '[email protected]', 'bwapi-status-reason': 'Device Not Found', 'bwapi-status': 'fail', }
On Failure:
{ "bwapi-status": "fail", "userid": "email_id", "bwapi-status-reason": "Device Not Found", }
Get Custom Data
This API will show the full details about all active devices.
POSThttps://server IP or domain name/bwiot/api/v1/devices_custom_data/
Parameter:
PARAMETER | VALUE DETAIL |
---|---|
page_no | -1 |
Example Response:
{
"next_page": false,
"userid": " [email protected]",
"bwapi-status": "success",
"error": "noerror",
"data": [
{
"last_received_message": "-",
"last_received_message_time": "-",
"last_active": "Inactive",
"active_topics": [
[
"soc1/onoff"
]
],
"device_name": "Socket1",
"device_connected_time": "03-08-2018 11:00:54",
"device_id": "demo1/s1",
},
{
"last_received_message_time": "04-08-2018 16:57:47",
"last_active": "Active",
"active_topics": [
[
"mytopic"
]
],
"device_name": 'test_device',
"device_connected_time": "04-08-2018 16:57:46",
"device_id": "publisherclient1",
"last_received_message": "hello I am publisher1"
},
],
"page_no": -1
}
Create Device Group
This API will help you group your devices or machines based on departments.
Request:
Http Request:
Add Authorization Header
POST https://server IP or domain name/bwiot/api/v1/admin/createDeviceGroup
Parameters:
PARAMETER | VALUE DETAIL |
---|---|
group_name | group name |
description | description |
Get Device Group
This API will help you get details about the particular device group.
Request:
Http Request:
Add Authorization Header
POST https://server IP or domain name/bwiot/api/v1/admin/getDeviceGroup
Remove Device Group
This API helps you remove the created or existing device group.
Request:
Http Request:
Add Authorization Header
POST https://server IP or domain name/bwiot/api/v1/admin/removeDeviceGroup
Parameters:
PARAMETER | VALUE DETAIL |
---|---|
group_name | group name |
Add Devices to the Device Group
This API will help you add new devices to the particular device group.
Request:
Http Request:
Add Authorization Header
POST https://server IP or domain name/bwiot/api/v1/admin/addDeviceToDeviceGroup
Parameters:
PARAMETER | VALUE DETAIL |
---|---|
group_name | group name |
deviceList | [“device1”, “device2”, …] |
Get Device Group Devices
This API will help you get details about the devices of the particular device group.
Request:
Http Request:
Add Authorization Header
POST https://server IP or domain name/bwiot/api/v1/admin/getGroupDevices
Parameters:
PARAMETER | VALUE DETAIL |
---|---|
group_name | group name |
Remove Device From Device Group
This API can be used to remove certain devices from the Device Group.
Request:
Http Request:
Add Authorization Header
POST https://server IP or domain name/bwiot/api/v1/admin/removeGroupDevice
Parameters:
PARAMETER | VALUE DETAIL |
---|---|
group_name | group name |
device_id | device_id |
Create User
This API will help you create a new user based on their mail id along with assigning permissions as standard / administrative to them.
Request:
Http Request:
Add Authorization Header
POST https://server IP or domain name/bwiot/api/v1/admin/createUser
Parameters:
PARAMETER | VALUE DETAIL |
---|---|
user_permission | standard/administrative |
display_name | name |
mobile_no | mobile no |
username | mail id |
User Status Change (Active/Inactive)
This API helps you change the status of user, either as Active or Inactive.
Request:
Http Request:
Add Authorization Header
POST https://server IP or domain name/bwiot/api/v1/admin/userStatusChanger
Parameters:
PARAMETER | VALUE DETAIL |
---|---|
username | mail id |
status | active/inactive |
Get all users
This API will help you get details about all the added tenants.
Request:
Http Request:
Add Authorization Header
POST https://server IP or domain name/bwiot/api/v1/admin/getUsers
Remove User
This API helps you remove the particular user from the admin console.
Request:
Http Request:
Add Authorization Header
POST https://server IP or domain name/bwiot/api/v1/admin/getUsers
Parameters:
PARAMETER | VALUE DETAIL |
---|---|
username | mail id |
User Role Change
You can change the role of a user at any time. This API helps you change the role of the user as an administrative / standard.
Request:
Http Request:
Add Authorization Header
POST https://server IP or domain name/bwiot/api/v1/admin/userRoleChange
Parameters:
PARAMETER | VALUE DETAIL |
---|---|
username | mail id |
role | administrative / standard |
Get User’s Device Group
This API will help you get the details about the device groups of the particular user.
Request:
Http Request:
Add Authorization Header
POST https://server IP or domain name/bwiot/api/v1/admin/getUserDeviceGroups
Parameters:
PARAMETER | VALUE DETAIL |
---|---|
username | mail id |
Add Device Group to User
This API will help you add a device group to the user and help in assigning permission to view or manage the newly added device group.
Request:
Http Request:
Add Authorization Header
POST https://server IP or domain name/bwiot/api/v1/admin/addDeviceGroupToUser
Parameters:
PARAMETER | VALUE DETAIL |
---|---|
username | mail id |
group_name | group name |
permission | view / manage |
Remove Device Group from User
This API will help you remove a particular device group from the user.
Request:
Http Request:
Add Authorization Header
POST https://server IP or domain name/bwiot/api/v1/admin/removeDeviceGroup
Parameters:
PARAMETER | VALUE DETAIL |
---|---|
username | mail id |
group_name | group_name |
User Group Permission Change
This API will help you change the permission of the user to either view or manage a particular device group.
Request:
Http Request:
Add Authorization Header
POST https://server IP or domain name/bwiot/api/v1/admin/groupPermissionChanger
Parameters:
PARAMETER | VALUE DETAIL |
---|---|
username | mail id |
group_name | group_name |
permission | view / manage |
Create Event Rule for Device
This API will help you create the condition based rules to create alert events based on the received topic or messages.
Http Request:
Add Authorization Header
POST https://server IP or domain name/bwiot/api/v1/rule_engine/create_event_rule/device_alert
Request:
{ 'mq_client': 'device_id', 'mq_topic': 'event_topic', 'msg_chk_type': 'with_out_key', 'whole_set_condition': 'match_any', 'check_set':[ { 'compare_with': message, 'condition': , 'value': 20, } { 'compare_with': time, 'condition': < , 'hour': 15, 'Minute': 7, } ] 'response_message_type': "send_defined", 'forward_mq_message': "message", 'forward_mq_client': "device_id", 'forward_mq_topic': "topic", }
Response:
{ "userid": "userId", "bwapi-status-reason": "rule_added", "bwapi-status": "success", }
Create mail event rule
This API will help you send the rules or alert messages as a mail to the specified mail id.
Http Request:
Add Authorization Header
POST https://server IP or domain name/bwiot/api/v1/rule_engine/create_event_rule/mail_alert
Request:
{ 'mq_client': 'device_id', 'mq_topic': 'event_topic', 'msg_chk_type': 'with_out_key', 'whole_set_condition': 'match_any', 'check_set':[ { 'compare_with': message, 'condition': , 'value': 20, } { 'compare_with': time, 'condition': < , 'hour': 15, 'Minute': 7, } ] 'response_message_type': "attach_meta", 'forwarding_mail': "mail_id", 'forwarding_subject': "subject", 'forwarding_body': "message", }
Response:
{ "userid": "userId", "bwapi-status-reason": "rule_added", "bwapi-status": "success", }
Create Websocket event rule for device
This API will help you create an event rule for device to push the alert message as a notification.
Http Request:
Add Authorization Header
POST https://server IP or domain name/bwiot/api/v1/rule_engine/create_event_rule/ws_alert
Request:
{ 'mq_client': 'device_id', 'mq_topic': 'event_topic', 'msg_chk_type': 'with_out_key', 'whole_set_condition': 'match_any', 'check_set':[ { 'compare_with': message, 'condition': , 'value': 20, } { 'compare_with': time, 'condition': < , 'hour': 15, 'minute': 7, } ] 'notification_title': "title", 'notification_body': "message", }
Response:
{ "userid": "userId", "bwapi-status-reason": "rule_added", "bwapi-status": "success", }
Create FCM event rule for device
This API will help you create an event rule for device to push the data as a notification to your android or ios app based on FCM token.
Http Request:
Add Authorization Header
POST https://server IP or domain name/bwiot/api/v1/rule_engine/create_event_rule/fcm_alert
Request:
{ 'mq_client': 'device_id', 'mq_topic': 'event_topic', 'msg_chk_type': 'with_out_key', 'whole_set_condition': 'match_any', 'check_set':[ { 'compare_with': message, 'condition': , 'value': 20, } { 'compare_with': time, 'condition': < , 'hour': 15, 'minute': 7, } ] 'notification_title': "title", 'notification_body': "message", }
Response:
{ "userid": "userId", "bwapi-status-reason": "rule_added", "bwapi-status": "success", }
Create timer rule
This API will help you create a timer rule to send data to a device for a specific time or in a specific time interval.
Http Request:
Add Authorization Header
POST https://server IP or domain name/bwiot/api/v1/rule_engine/create_timer_rule/device_alert
Request:
{ 'device_id': 'device_id', 'topic': 'topic', 'message': 'message', 'hour': '0-24', 'minute': '0-59', 'startdaterange': mm/dd/yyyy, 'enddaterange': mm/dd/yyyy , }
Response:
{ "userid": "userId", "bwapi-status-reason": "rule_added", "bwapi-status": "success", }
Get Rules
This API will help you get the list of all created rules.
Http Request:
Add Authorization Header
POST https://server IP or domain name/bwiot/api/v1/rule_engine/get_rule_list
Request:
{ 'page_no': 'number', }
Response:
{ 'rules':[ { "forward":{ "reaction_method": "send_via_mqtt", "mq_client": "device_id", "response_message_type": "send_defined", "mq_topic": "topic", "mq_message": "message", } "time": "1558690606980", "id": "105", "event":{ "time_check_set":[ [ "", "<", 15, 7, ] ] "whole_set_condition": "match_any", "mq_topic": "event_topic", "check_set": [], "msg_chk_type": "with_out_key", "mq_client": "device_id", } } { "forward": {, "reaction_method": "send_via_ws", "notification_title": "title", "notification_body": "message", } "time": "1558693863847", "id": "108", "event":{ "time_check_set":[ [ "", "<", 15, 7, ] ] "whole_set_condition": "match_any", "mq_topic": "event_topic", "check_set": [ [ "INCOMING_MSG", ">", 20 ] [ "INCOMING_MSG", "=", 15 ] ], "msg_chk_type": "with_out_key", "mq_client": "device_id", } }, { "msg_chk_type": { "reaction_method": "send_via_fcm", "notification_title": "title", "notification_body": "message", } "time": "1558694345964", "id": "109", "event":{ "time_check_set":[ [ "", "<", 15, 7, ] ] "whole_set_condition": "match_any", "mq_topic": "event_topic", "check_set": [ [ "INCOMING_MSG", ">", 20 ] [ "INCOMING_MSG", "=", 15 ] ], "msg_chk_type": "with_out_key", "mq_client": "device_id", } }, ] "page_nav_data": { "next_page": false "total_pages": 1, "page_no": 0 } "user_id": "user_id", "bwapi-status": "success",
Delete rule
This API will help you delete the created rule.
Http Request:
Add Authorization Header
POST https://server IP or domain name/bwiot/api/v1/rule_engine/delete_rule
Request:
{ 'rule_id': 'numeric', }
Response:
{ "bwapi-status": "success", "bwapi-status-reason": "Rule Deleted", "userid": "userid" }