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.
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
- 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"}
- 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"}
- Read Analog value:
- Analog Output command:
- UART commands:
- UART commands:
- UART commands:
- 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)\"}"}
- 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"}
- 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;
?>