Motorbunny LINK API Reference

Third party apps need to pass 2 key values in Headers.

  1. Motorbunny mobile apps display a secret authorization token in settings ( user need to be logged into MB LINK Account for this to show). This needs to be passed in Authorization header in al the GET /share_token call shown below.
  2. 2nd header is X-API-KEY. This will be issued by Motorbunny for each third party app.  Third party developers must request a developer key.  Click here to request your app key.

 

GET /add_tip?tip=###

User app token from mobile app has to be passed in Authorization header.

Adds tip to the user mobile app. Tip is converted to Motorbunny fuel using app settings.

Example:

curl –request GET –url ‘https://api.motorbunny.com/add_tip?tip=100’ –header ‘X-API-KEY:DAACA7FC65DD444354EED97A16373’ –header ‘Authorization:eyJhbGci2lkIjoyOH0.K4EFqpIpvCuV-csJHZG8OVpKIc9Zkq_oEVAFok-hvYU’

Successful Response

{“status”:”success”,”share_token”:”379FB”}

Error Response

{

“error”: “Not Authorized”

}

GET /share_token

User app token from mobile app has to be passed in Authorization header.

Returns the current share token for the current (authenticated) user’s device.

Example:

curl –request GET –url ‘https://api.motorbunny.com/share_token’ –header ‘X-API-KEY:DAACA7FC65DD444354EED97A16373’ –header ‘Authorization:eyJhbGci2lkIjoyOH0.K4EFqpIpvCuV-csJHZG8OVpKIc9Zkq_oEVAFok-hvYU’

Successful Response

{

“share_token”: “952FD”

}

Error Response

{

“error”: “Not Authorized”

}

The client application can then subscribe to a WebSocket channel named with the provided token. The client will receive control messages on this channel.  The client application will also publish any control messages generated in the app on the same channel.  This will provide duplex control and communication between the client app and the controlling user interface.

Control WebPage

GET /control/

This call doesn’t require the headers.  This will open a webpage to control the Motorbunny device remotely. This page communicates with the mobile app to control the device.

Third party apps can use WebSocket to communicate with the mobile apps to control the device.

Testing Your App Without A Motorbunny

To test your app we’ve made a tour mode in the Motorbunny LINK app.  This means you do not need a Motorbunny in order to test your app!  Just tap tour mode upon opening the Motorbunny LINK app and then tap the online tab.  The app will display current buzz, twirl, or routine settings being received via the LINK API.

WebSockets Example

var socket = new WebSocket(‘wss://api.motorbunny.com/cable’)

Once the connection is established, subscribe to the device token channel using subscribe command. identifier is sent as a string and not as a json object.

Origin header must be set to ‘https://api.motorbunny.com’

Subscription

You need to subscribe to the token channel before sending/receiving other commands.

socket.send(JSON.stringify({‘command’: ‘subscribe’, ‘identifier’: JSON.stringify({‘channel’: ‘DevicesChannel’, ‘share_token’: ‘token_value’})}))

Example:

{“command”:”subscribe”,”identifier”:”{“channel”:”DevicesChannel”,”share_token”:”952FD”}”}
Once subscription is successful, you can send and receive other messages.

Buzz/Twirl

To change buzz or twirl, command name is message. data field will have the action and value.

Buzz value can be from 0 to 255.  This maps to the 0 to 11 scale in the device.

Example:

“{“command”:”message”,”identifier”:”{“channel”:”DevicesChannel”,”share_token”:”952FD”}”,”data”:”{“value”:5,”share_token”:”952FD”,”action”:”set_buzz”}”}

To Change Twirl, action is set_twirl. Twirl value ranges from -255 to 255.

Example:

{“command”:”message”,”identifier”:”{“channel”:”DevicesChannel”,”share_token”:”952FD”}”,”data”:”{“value”:2,”share_token”:”952FD”,”action”:”set_twirl”}”}

Predefined Routines:

There are 10 buzz routines and 10 twirl routines.

Buzz routine values range from 1001 to 1010. Twirl routines from 1011 to 1020.

Example:

{“command”:”message”,”identifier”:”{“channel”:”DevicesChannel”,”share_token”:”952FD”}”,”data”:”{“value”:1011,”share_token”:”952FD”,”action”:”set_twirl”}”}