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://devicemanager.bevywise.com/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://devicemanager.bevywise.com/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://devicemanager.bevywise.com/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"
      }

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: Bearer < usertoken >


Error Responses On using Authorization Header:

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

Logout API

This API helps your application to logout from the Bevywise IoT platform

Request:

Http Request:

Add Authorization Header


POST  https://devicemanager.bevywise.com/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://devicemanager.bevywise.com/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://devicemanager.bevywise.com/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://devicemanager.bevywise.com/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://devicemanager.bevywise.com/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://devicemanager.bevywise.com/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://devicemanager.bevywise.com/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://devicemanager.bevywise.com/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://devicemanager.bevywise.com/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://devicemanager.bevywise.com/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://devicemanager.bevywise.com/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://devicemanager.bevywise.com/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://devicemanager.bevywise.com/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://devicemanager.bevywise.com/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://devicemanager.bevywise.com/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://devicemanager.bevywise.com/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://devicemanager.bevywise.com/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
      }