• Cloud API


  • Introduction
  • Generating API Key
  • Controlling API Status
  • Requests
  • Commands
    • 1 Digital Write
    • 2 Digital Read
    • 3 Analog Write
    • 4 Analog Read
    • 5 Serial Begin
    • 6 Serial Write
    • 7 Serial Read
    • 8 Version
    • 9 Restart
    • 10 Is Alive
  • Sample Code
    • 1 Python
    • 2 PHP
	 
	 
	 

Introduction

Bolt platform takes commands over http GET and POST method. Hence the following set of commands can be executed using a web browser by typing them in the URL . Our RESTful API allows users to perform actions enabled by Bolt Cloud control panel programmatically. The Bolt Cloud API allows user to control devices within the Bolt Cloud in a simple, programmatic way using conventional HTTP requests. The endpoints are intuitive and powerful, allowing you to easily make calls to retrieve information or to execute actions. Most of the functionality that you are familiar with in the Bolt Cloud control panel is also available through the API, allowing you to script the complex actions that your situation requires.

Generating API key

To Generate API key user have to go in control panel and click on Generate New API key. Button .You will get a new API key. You can also enable and disable API key here. If he disabled API key then all the API requested will be aborted.

Controlling API Status

You can enable and disable API key status.If you disabled the API key status then all the API request will be aborted by our server.

Requests

Any tool that is fluent in HTTP can communicate with the API simply by requesting the correct URI. The interface responds to different methods depending on the action required. These two HTTP methods are allwoed in Bolt API.
  • GET
  • POST

Simple Request Example

This is the simple syntax for API request. In this request the first parameter is API key and the second parameter is the command that we want to execute and the last parameter is ID of Bolt device. The general syntax for the API request is: http://cloud.boltiot.com/remote/your_api_key/command?param1=...¶m2=...&deviceName=BOLTXXXXXX

http://cloud.boltiot.com/remote/your_api_key/command? parameter1=....& parameter2=....&deviceName=BOLTXXXXXXX

http://cloud.boltiot.com/remote/357c2467-a33a-4fd6-b43e-75d6e677ab40/ restart?& deviceName=BOLT9161541

Commands

  1. Digital Write command
    • (a) cmd:digitalWrite
    • (b) parameters: “pin=”+pin where pin is 0...7 and “A0”,“A1”“A2”,“A3”
    • (c) value: “state=” HIGH (5v) or LOW(0v)
    • (d) Example:
      • http://cloud.boltiot.com/remote/42d4acf4-2693-44ac-b4d3-4ded896abd4d/digitalWrite?pin=0&state=HIGH&deviceName=BOLT13819450
        • this command will give 5 volts on pin 0
        • browser output: {"success": "1", "value": "HIGH"}
      • http://cloud.boltiot.com/remote/42d4acf4-2693-44ac-b4d3-4ded896abd4d/digitalWrite?pin=0&state=LOW&deviceName=BOLT13819450
        • this command will give 0 volts on pin 0
        • browser output: {"success": "1", "value": "LOW"}
  2. Read Digital value:
    • (a) cmd:digitalRead
    • (b) parameters: “pin=”+pin where pin is 0...7 and “A0”,“A1”“A2”,“A3”
    • (c) value: None
    • (d) Example:
      • http://cloud.boltiot.com/remote/42d4acf4-2693-44ac-b4d3-4ded896abd4d/digitalRead?pin=0&deviceName=BOLT13819450
        • {"success": "1", "value": "1"} or
        • {"success": "1", "value": "0"}
      • http://cloud.boltiot.com/remote/42d4acf4-2693-44ac-b4d3-4ded896abd4d/digitalRead?pin=A0&deviceName=BOLT13819450
        • browser output: {"success":"1","value":"1"} or
        • browser output: {"success": "1", "value": "0"}
  3. Read Analog value:
    • (a) cmd:analogRead
    • (b) parameters: “pin=”+pin where pin is 0...7 and “A0”,“A1”“A2”,“A3”

      A0-A3 need to be strings of two characters

    • (c) value: None
    • (d) Example:
      • http://cloud.boltiot.com/remote/87fcca47-a888-4f8d-8302-6f8b22c34813/analogRead?pin=A0&state=HIGH&deviceName=BOLT1257632
        • browser output for 0 volts:
          {"success":"1","value":"0"} or
        • browser output for 2.5 volts:
          {"success": "1", "value": "245"} or
  4. Analog Output command:
    • (a) cmd:analogWrite
    • (b) parameters: “pin=”+pin 1-5

      0-7 are numbers whereas A0-A3 need to be strings of two characters

    • (c) value: “value=” 0...255
    • (d) Example:
      • http://cloud.boltiot.com/remote/87fcca47-a888-4f8d-8302-6f8b22c34813/analogWrite?pin=1&value=0&state=HIGH&deviceName=BOLT1257632
        • browser output for 0 volts:
          {"success":"1","value":"0"} or
        • browser output for 2.5 volts:
          {"success":"1","value":"511"} or
  5. UART commands:
    • (a) cmd:serialBegin
    • (b) parameters: “baud=” + baudrate

      where baudrate can be any of the above mentioned values 0-3


    • (c) value: “value=” 0...255
    • (d) Example:
      • http://cloud.boltiot.com/remote/42d4acf4-2693-44ac-b4d3-4ded896abd4d/serialBegin?baud=2&deviceName=BOLT13819450
        • to set baudrate to 9600.
        • Browser output:
          {"success":"1","value":"serialBegin successful"}
  6. UART commands:
    • (a) cmd:serialWrite
    • (b) parameters: “data=” + dataString

      where String will be transmitted as ASCII characters


    • (c) value: “value=” 0...255
    • (d) Example:
      • http://cloud.boltiot.com/remote/87fcca47-a888-4f8d-8302-6f8b22c34813/serialWrite?data=Hello&deviceName=BOLT8795377
        • to send string “Hello” over the Tx line.
        • Browser output:
          {"success":"1","value":"serialWrite successful"}
  7. UART commands:
    • (a) cmd:serialRead
    • (b) parameters: None

      where String will be transmitted as ASCII characters


    • (c) Example:
      • http://cloud.boltiot.com/remote/87fcca47-a888-4f8d-8302-6f8b22c34813/serialRead?&deviceName=BOLT8795377
        • to read string over the Rx line.
        • Browser output:
          {"success": "1", "value": "inventrom"}
  8. Version
    • (a) cmd:version
    • (b) parameters: None


    • (c) Example:
      • http://cloud.boltiot.com/remote/87fcca47-a888-4f8d-8302-6f8b22c34813/version?&deviceName=BOLT8795377
        • will return the version of your Bolt.
        • Browser output:
          {"success": "1", "value": "{\"Bolt Version\":\"1.3\",\"Firmware Version\":\"2.0(168)\"}"}
  9. Restarting Device
    • (a) cmd:restart
    • (b) parameters: None


    • (c) Example:
      • http://cloud.boltiot.com/remote/87fcca47-a888-4f8d-8302-6f8b22c34813/restart?&deviceName=BOLT8795377
        • to restart the Bolt device.
        • Browser output:
          {"success": "1", "value": "Restarted"}
  10. Device Status(Dead or Alive)
    • (a) cmd:isAlive
    • (b) parameters: None


    • (c) Example:
      • http://cloud.boltiot.com/remote/87fcca47-a888-4f8d-8302-6f8b22c34813/isAlive?&deviceName=BOLT8795377
        • will return the device status.
        • Browser output:
          {"success": "1", "value": "alive"} or
          {"success": "1", "value": "dead"}

Sample Code

  • Python

    	import requests 
    r = requests.get('http://cloud.boltiot.com/remote/42d4acf4-2693-44ac-b4d3-4ded896abd4d/digitalWrite?pin=0&state=HIGH&deviceName=BOLT13819450')
    r.text
  • PHP

    	
    $service_url = 'http://cloud.boltiot.com/remote/42d4acf4-2693-44ac-b4d3-4ded896abd4d/digitalWrite?pin=0&state=HIGH&deviceName=BOLT13819450'; 
    $curl = curl_init($service_url);
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
    $curl_response = curl_exec($curl);
    if ($curl_response === false) {
        $info = curl_getinfo($curl);
        curl_close($curl);
        die('error occured during curl exec. Additioanl info: ' . var_export($info));
    }
    curl_close($curl);
    if (isset($decoded->response->status) && $decoded->response->status == 'ERROR') {
        die('error occured: ' . $decoded->response->errormessage);
    }
    echo $curl_response;
    
    
    ?>
    	
    	
Back to Top expand_less
Facebook Twitter YouTube


Copyright 2015 All rights reserved | Inventrom | Designed byInventrom


10, Gaspar Apartments, Fontainhas, Mala, Panjim, Goa 403001