IOT Platform API Documentation

Introduction:


The REST API presented in this document can be used to communicate with the https://devicemanager.bevywise.com for creating mobile application for IOT device management or connecting the IOT Device manager with your application.

Create an Account

This API will help for creating a new user to manage their devices. The user will be able to login with the same user to the Device manager / IOT Platfrom on the web interface also.

Request:

Http Request:


/bwiot/api/v1/auth/signup/

Parameter:

Parameter Value Detail
username email id of the user
password any password

Response:

On Success:

											
  {  										
    'bwapi-status': 'success',
    'token': 'tokenvalue',
    'bwapi-status-reason': "successfulllogin"
  }

On Failure:

Reason Response
Username and password does not match {
"bwapi-status-reason":
"Email / password is Invalid",
"bwapi-status": "fail"
}

Access your Account

This API will help the User to Access the Device Manager/IOT Platform by using their Username and Password. With this Account you can manage the devices.

Request:

Http Request:


/bwiot/api/v1/auth/login/

Parameter:

Parameter Value Detail
username email id of the user
password password string

Response:

On Success:

												  
  { 
    'bwapi-status': 'success',
    'token': 'tokenvalue',
    'bwapi-status-reason': "successfulllogin"
  }

On Failure:

Reason Response
Username and password does not match {
"bwapi-status-reason":
"Email / password is Invalid",
"bwapi-status": "fail"
}

Authorization Header

Authorization header is the method of providing authentication information. All the API's below are accessing data specific to a user. We need to add the session token to all of them. The Session token should be set as part of the Request Header to provide authentication information. The format of the Authorization header is

Authorization:Token

Error Responses On using Authorization Header:

Reason Response
If Authorization header is not defined {
"detail":"Authentication credentials were not provided."
}
If Token is Invalid {
"detail": "Invalid token"
}

Sign-out

This API will help the user to disconnect the device from the Device Manager by Sign-out the Device Manager account.

Request:

Http Request:

Add Authorization Header


/bwiot/api/v1/auth/logout/

Parameter:

Parameter Value Detail
Logout 1

Generate Auth Key

Authentication Key is mandatory to secure all communications so to generate the permanent Auth Key, you need to send an authenticated HTTP-POST request to bevywise manger account using the following URL format:

Request:

Http Request:

Add Authorization Header


/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', 
    'data': 
   { 
    'auth_key':'mqusername', 
    'auth_token':'mqpassword', 
    'description':'desc', ' permissions':'permission' 
   } 
  }
    

On Failure:

Reason Response
If Valid Parameter not exist {
"bwapi-status-reason": "No Valid Parameter Found",
"bwapi-status": "fail" }
If A server error {
"bwapi-status-reason": "Internal Error",
"bwapi-status": "fail"
}

Get Device List

This API will list all the Active and Inactive devices with their Device name, Device ID, Status and Device connection time.

Request:

Http Request:

Add Authorization Header


/bwiot/api/v1/devices

Parameter:

Parameter Value Detail
page_no no of the page

Response:

On Success:

  { 
    'bwapi-status':'success', 
    '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:

Reason Response
If Auth_keys Not Generated {
"bwapi-status-reason": "Device Auth Keys Not Found",
"bwapi-status": "fail"
}
If No Device Found or No Data Found for requested page no {
'bwapi-status': 'fail', 'bwapi-status-reason':
"No Device / Invalid Page"
}
If A server error {
"bwapi-status-reason": "Internal Error",
"bwapi-status": "fail"
}

Get Device Details API

This API will used to get the details of the Individual devices by means of the HTTP request.

Request:

Http Request:

Add Authorization Header


/bwiot/api/v1/devices/get_device_detail

Parameter:

Parameter Value Detail
device_id id_of_the_device

Response:

On Success:

												
  { 
    'bwapi-status': 'success', 
    'device_name': 'device_name', 
    'device_id':'id of the device' 
    'will_topic': 'willtopic', 
    'will_message': 'willmessage',     
    'device_status': 'status', 
  }

On Failure:

Reason Response
If device_id parameter is not found {
"bwapi-status-reason": "No Valid Parameter Found",
"bwapi-status": "fail"
}
If No Device Found {
"bwapi-status-reason": "Device Not Found",
"bwapi-status": "fail"
}
If A server error {
"bwapi-status-reason": "Internal Error",
"bwapi-status": "fail"
}

Get Events of a Device

This API will used to get the events which are published by the devices. With this the user can identify the topics of the Events wich has been Published.

Request:

Http Request:

Add Authorization Header


/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', '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:

Reason Response
No Event Found {
"bwapi-status-reason": "no_data_found",
"bwapi-status": "fail"
}
Device_id parameter is not found {
"bwapi-status-reason": "No Valid Parameter Found",
"bwapi-status": "fail"
}
Server error {
"bwapi-status-reason": "Internal Error",
"bwapi-status": "fail"
}

Get Commands received in Device

This API will used to view the Commands which are received by the Device from the IOT Platform by means of the HTTP-Request.

Request:

Http Request:

Add Authorization Header


/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', 
    '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:

Reason Response
No Command Found {
"bwapi-status-reason": "no_data_found",
"bwapi-status": "fail"
}
Device_id parameter is not found {
"bwapi-status-reason": "No Valid Parameter Found",
"bwapi-status": "fail"
}
Server error {
"bwapi-status-reason": "Internal Error",
"bwapi-status": "fail"
}

Get Dashboard Details

This API will help user to view the details of the Dashboard which is in the UI of the MQTT route.

The UI Dashboard helps the user to view the last happening in MQTT Route.

Request:

Http Request:

Add Authorization Header


/bwiot/api/v1/dashboard/

Response:

On Success:

  { 
    'bwapi-status': 'success', 
    '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:

Reason Response
No Data Found {
"bwapi-status-reason": "no_data_found",
"bwapi-status": "fail"
}
Server error {
"bwapi-status-reason": "Internal Error", "
bwapi-status": "fail"
}

Get Active Subscription

This API will show the Active subscribed topics on which the Device subscribed.This help the user to recognize the active Events based on the topic.

Request:

Http Request:

Add Authorization Header


/bwiot/api/v1/ic/get_active_topics

Response:

On Success:

  {
    'bwapi-status': 'success',
    'active_topics':[topic1,topic2], 
  }

  

On Failure:

Reason Response
If No Data Found {
"bwapi-status-reason": "no_data_found",
"bwapi-status": "fail"
}
Server error {
"bwapi-status-reason": "Internal Error", "
bwapi-status": "fail"
}

Get List of Clients for a Topic

This API will show the clients subscribed to the Topics. From this user can understand which client subscribed to which Topics.

Request:

Http Request:

Add Authorization Header


/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',
    'topic':'name of the topic',
    'clients':[client1,client2,...]
  }

  

On Failure:

Reason Response
If No Data Found {
"bwapi-status-reason": "no_data_found",
"bwapi-status": "fail"
}
If A server error {
"bwapi-status-reason": "Internal Error", "
bwapi-status": "fail"
}

Send Command to a Topic

This API will send Command to all the devices which are subscribed to this Topics.

Request:

Http Request:

Add Authorization Header


/bwiot/api/v1/ic/send_command_to_topic

Parameter:

Parameter Value Detail
Topic name of the topic
command command

Response:

On Success:

  { 
    'bwapi-status': 'success',
    'bwapi-status-reason':'command send', 
  }
  
  

On Failure:

Reason Response
If Invalid Parameter Found {
"bwapi-status-reason": "No Valid Parameter Found",
"bwapi-status": "fail"
}
If Not Able to Send {
'bwapi-status': 'fail',
'bwapi-status-reason': "unable to send"
}
If A server error {
"bwapi-status-reason": "Internal Error",
"bwapi-status": "fail"
}

Get Active Subscriptions for a Device

This API will show the Active Subscription for each device by mean of subscribed Topics.

Request:

Http Request:

Add Authorization Header


/bwiot/api/v1/auth/signup/

Parameter:

Parameter Value Detail
device_id id of the device

Response:

On Success:

												
  { 
    'bwapi-status': 'success', 
    'topics':['topic1','topic2'], 
  }

On Failure:

Reason Response
If Invalid Parameter found {
"bwapi-status-reason": "No Valid Parameter Found",
"bwapi-status": "fail"
}
If no Topics Found {
'bwapi-status': 'fail',
'bwapi-status-reason': "No Topic Found"
}
If A server error {
"bwapi-status-reason": "Internal Error",
"bwapi-status": "fail"
}

Send Command to a Device

This API will send command to the active Device and also the Device must subscribe to the Topics.

Request:

Http Request:

Add Authorization Header


/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', 
    'bwapi-status-reason':'command send',
  }

On Failure:

Reason Response
If no Active Device found {
'bwapi-status': 'fail',
'bwapi-status-reason': "Device is not active/not found"
}
If Invalid Parameter Found {
'bwapi-status': 'fail',
'bwapi-status-reason': "No Valid Parameter Found"
}
If A server error {
"bwapi-status-reason": "Internal Error",
"bwapi-status": "fail"
}

Modify Device Name

Exiting User can change the Device_Name through this API.

Request:

Http Request:

Add Authorization Header


/bwiot/api/v1/devices/edit_device_name

Parameter:

Parameter Value Detail
new_device_name device name to set
device_id id of the device

Response:

On Success:

 
  { 
    'bwapi-status': 'success', 
    'device_name': 'new devicename', 
  }
  
  

On Failure:

Reason Response
If Device ID not match {
'bwapi-status': 'fail',
'bwapi-status-reason': "no_matching_device_id_found"
}
If Invalid Parameter Found {
'bwapi-status': 'fail',
'bwapi-status-reason': "No Valid Parameter Found"
}
If A server error {
"bwapi-status-reason": "Internal Error",
"bwapi-status": "fail"
}