THE EASIEST

Pick-to-Light REST Integration

Pick to Light example device

Simple!  The way it should be.

REST API

This is a playlist of REST API tutorials on our Voodoo Robotics YouTube Channel

  • Get a list of all devices in your account.  Use a GET request on the endpoint https://www.voodoodevices.com/api/device/.  As with most REST servers, you can use XML or JSON in your request.  See the examples below.

  • Inspect Request

    Once you have a particular DeviceID, you can get more information about that device (voltage, uptime, etc.).  Use a GET request on the endpoint https://www.voodoodevices.com/api/device/FFFFFF:EEEEEE/.  As above, you can use XML or JSON in your request.

  • Update Request

    You can also update the message on a Device.  Use a POST request on the endpoint https://www.voodoodevices.com/api/device/FFFFFF:EEEEEE/.  You can submit your data as application/xml or application/json.  Notice that POST and PUT are equivalent in our REST API since there is no object creation mechanism.

  • Update Multiple

    You can also update multiple Devices in one API call.  Use a POST request on the endpoint https://www.voodoodevices.com/api/devices/.  (Note the plural ‘devices’.)  You can submit your data as application/xml or application/json.  This saves time and resources by consolidating API calls.  See the example below.

  • Inspect Turbos

    In a similar way to the device endpoint, you can use the turbo endpoint to get information about your Turbos.  Use a GET request on the endpoint https://www.voodoodevices.com/api/turbo/, or https://www.voodoodevices.com/api/turbo/SERIALNO/.

The examples on this page show you how to really leverage the power of REST with our modern Cloud Display Devices.  You can write your code in any language you choose.  We have chosen PHP for demonstration purposes–it is fairly easy for any programmer to read PHP and understand the critical steps.

Be sure to read the comments around the code.  They can be very useful, particularly if you do not know PHP.

Step by Step (in PHP)

Let’s walk through it together…

//This code is written in PHP.  (Revised January 2023)

//First define an initialization function to log in with username and password
//The key thing is that we have to capture both the session cookie and the CSRF token
//They will both be stored in the global $ch.
function init()
{
    global $ch;         //PHP is silly in the way scoping rules work!
    $ch = curl_init();  //initialize the cURL object

    curl_setopt($ch, CURLOPT_URL,"https://www.voodoodevices.com/api/user/login/");
    //note that we are using api and we first access the login endpoint
    //for REST API, you cannot use https://www.voodoodevices.com/api2/    <===BAD!!!

    curl_setopt($ch, CURLOPT_COOKIEJAR, "/tmp/cookie.txt");
    //use a cookiejar, because the session ID will be stored in the cookie

    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    //silly cURL, it should be like this by default! This alows us to do $x = curl_exec()

    curl_setopt($ch, CURLOPT_POST, true);
    //login requires a POST with username and password content

    curl_setopt($ch, CURLOPT_HTTPHEADER,array(  //specify XML for input and output (you could use JSON instead)
        "content-type: application/xml",        //format of the outbound data/commands
        "accept: application/xml",                //format of the inbound response
    ));
    //We could have used JSON here, but are sticking to both input and output in XML for simplicity

    //curl_setopt($ch, CURLOPT_VERBOSE, 1);
    //uncomment the above line if you encounter problems -- curl will give you some diagnostics

    $xml = "
        <item>
          <username>yourusername</username>
          <password>yourpassword</password>
        </item>
    ";

    curl_setopt($ch, CURLOPT_POSTFIELDS, $xml);

    $theXml = curl_exec($ch);    // this logs us in, puts a session cookie in the cookiejar, a
                                 // returns some XML that contains our super-secret token

    $response = simplexml_load_string($theXml);     // parse the returned XML

    curl_setopt($ch, CURLOPT_HTTPHEADER,array(                    //do what we did before, but this time add the CSRF token
                "content-type: application/xml",                  //format of the outbound data/commands
                "accept: application/xml",                        //format of the inbound response
                "referer: https://www.voodoodevices.com/api/",    //referer field is required. For more info see
                "x-csrf-token: ".$response->token,                // https://seclab.stanford.edu/websec/csrf/csrf.pdf
            ));
    //this is very important: the above updates the header with the token
    //and since $ch is global, it maintains the cookie and the CSRF token
    //we will rely on this in the functions below
    //some would argue that a CSRF token is overkill, but cookies are not very well protected
    //these days. For more information about session riding attacks, see
    //https://en.wikipedia.org/wiki/Cross-site_request_forgery

    //REST api, unlike QueryString api REQUIRES the x-csrf-token (both on Big Block and SKU-Keeper)
}

//As an example of getting device information, we get the voltage
//Just pass the function the Device ID like this:
//
//   print(getVoltage('FD02EF:AB9A16'));
//
function getVoltage($devID)
{
    global $ch;
    if (empty($ch)) init();  //initialize with the cookie and the CSRF token if needed

    curl_setopt($ch, CURLOPT_POST, false);
    //make sure we are doing a GET request

    curl_setopt($ch, CURLOPT_URL,"https://www.voodoodevices.com/api/device/".$devID."/");
    //to get info on a device, append the device ID to the endpoint

    $theXml = curl_exec($ch);                     // make the request -- the returned XML has everything in it

    $response = simplexml_load_string($theXml);  // parse the returned XML

    //print_r($response);  //uncomment this line to see all the fields you can access
    return $response->lastvoltage; //we only want the voltage in this example
}

//What if we did not know what our device IDs were? Here is a function that returns all of our device IDs 
//in an array.
function arrayOfDevices()
{
    global $ch;
    if (empty($ch)) init();  //initialize with the cookie and the CSRF token if needed

    curl_setopt($ch, CURLOPT_POST, false);
    //make sure we are doing a GET request

    curl_setopt($ch, CURLOPT_URL,"https://www.voodoodevices.com/api/device/");
    //without a device ID in the URL, we get a list of all of them

    $theXml = curl_exec($ch);    // make the request -- the returned XML has everything in it

    $response = simplexml_load_string($theXml);  // parse the returned XML

    return (array)$response->item;               //result is in the 'item'
}

//Now we show how we can _set_ device information.  
//Setting the command and associated fields forces a call to the device to light up.  
//* If the command is 'flash', the light flashes.
//* If the command is 'display', the light is solid.  (We recommend flash, as it uses less power.)
//For a command, you can set 'line1', 'line2', 'line3', 'line4', 'line5', 'sound', 'seconds', 'color',
//and 'nonce'.
//Our feedback protocol uses the nonce.
//See https://voodoorobotics.com/closed-loop-system/
//Sound strings are just the tempo followed by a series of notes. See our Section 6 of our page at
//https://voodoorobotics.com/constructing-a-url/ for some examples.
//Using long sounds consumes batteries quickly, so try to use simple sounds like a simple beep ('15,c5,4').
//See our new battery estimator at https://voodoorobotics.com/pick-light-batteries/
function messageDevice($devID,$line1,$line2,$line3,$line4,$line5,$time = 10,$sound = '15,c5,4',$color = 'r')
{
    global $ch;
    if (empty($ch)) init();  //initialize with the cookie and the CSRF token if needed

    curl_setopt($ch, CURLOPT_POST, true);
    //updating the static data or making the device flash requires a post

    curl_setopt($ch, CURLOPT_URL,"https://www.voodoodevices.com/api/device/".$devID."/");
    //append the device ID to the endpoint.  (The response is ignored.)

    $xml = "
        <item>
          <api>2.0</api>
          <command>flash</command>
          <line1>$line1</line1>
          <line2>$line2</line2>
          <line3>$line3</line3>
          <line4>$line4</line4>
          <line5>$line5</line5>
          <seconds>$time</seconds>
          <sound>$sound</sound>
          <color>$color</color>
        </item>
    ";

    curl_setopt($ch, CURLOPT_POSTFIELDS, $xml);

    curl_exec($ch); // make the request
}

//Here is an example using a nonce for feedback
function messageWithNonce($devID,$line1,$nonce,$time = 10,$sound = '15,c5,4',$color = 'r')
{
    global $ch;
    if (empty($ch)) init();  //initialize with the cookie and the CSRF token if needed

    curl_setopt($ch, CURLOPT_POST, true);
                            //updating the static data or making the device flash requires a post

    curl_setopt($ch, CURLOPT_URL,"https://www.voodoodevices.com/api/device/".$devID."/");
                            //append the Device ID to the endpoint.  (The response is ignored.)

    $xml = "
        <item>
          <api>2.0</api>
          <command>flash</command>
          <line1>$line1</line1>
          <nonce>$nonce</nonce>
          <seconds>$time</seconds>
          <sound>$sound</sound>
          <color>$color</color>
        </item>
    ";

    curl_setopt($ch, CURLOPT_POSTFIELDS, $xml);

    curl_exec($ch); // make the request
}

//Here is how you can terminate a currently pending command
//Note that you have to reference the command both by device ID and the nonce that
//you originally used when you sent the command
function killMessage($devID,$nonce)
{
    global $ch;
    if (empty($ch)) init(); //initialize with the cookie and the CSRF token if needed

    curl_setopt($ch, CURLOPT_POST, true);
                            //updating the static data or making the device flash requires a post

    curl_setopt($ch, CURLOPT_URL,"https://www.voodoodevices.com/api/device/".$devID."/");
                            //append the Device ID to the endpoint.  (The response is ignored.)

    $xml = "
        <item>
          <api>2.0</api>
          <command>kill</command>
          <nonce>$nonce</nonce>
        </item>
    ";

    curl_setopt($ch, CURLOPT_POSTFIELDS, $xml);

    curl_exec($ch); // make the request
}

//Resetting a device removes all commands in the device's queue (including overlapped commands)
function resetDevice($devID)
{
    global $ch;
    if (empty($ch)) init();  //initialize with the cookie and the CSRF token if needed

    curl_setopt($ch, CURLOPT_POST, true);
                            //updating the static data or making the device flash requires a post

    curl_setopt($ch, CURLOPT_URL,"https://www.voodoodevices.com/api/device/".$devID."/");
                            //append the device ID to the endpoint.  (The response is ignored.)

    $xml = "
        <item>
          <api>2.0</api>
          <command>reset</command>
        </item>
    ";

    curl_setopt($ch, CURLOPT_POSTFIELDS, $xml);

    curl_exec($ch);         // make the request
}

//Rebooting a device is like power-cycling the device, i.e. replacing the batteries
//All pending commands are lost
function rebootDevice($devID)
{
    global $ch;
    if (empty($ch)) init(); //initialize with the cookie and the CSRF token if needed

    curl_setopt($ch, CURLOPT_POST, true);
                            //updating the static data or making the device flash requires a post

    curl_setopt($ch, CURLOPT_URL,"https://www.voodoodevices.com/api/device/".$devID."/");
                            //append the device ID to the endpoint. (The response is ignored.)

    $xml = "
        <item>
          <api>2.0</api>
          <command>reboot</command>
        </item>
    ";

    curl_setopt($ch, CURLOPT_POSTFIELDS, $xml);

    curl_exec($ch);         // make the request
}

//The following function sets the static display of the device--what it displays by default
//when there are no active commands (like above).
//You can also set the default display timeout (not to be confused with 'seconds' above) with
//'timeout'.  Set a location override with 'location_override' and brightness with, yes, 'brightness'
//(a value between 0 and 100).
function displayOnDevice($devID,$line1,$line2,$line3 = '',$line4 = '',$line5 ='')
{
    global $ch;
    if (empty($ch)) init(); //initialize with the cookie and the CSRF token if needed

    curl_setopt($ch, CURLOPT_POST, true);
                            //updating the static data or making the device flash requires a post

    curl_setopt($ch, CURLOPT_URL,"https://www.voodoodevices.com/api/device/".$devID."/");
                            //append the Device ID to the endpoint.  (The response is ignored.)

    $xml = "
        <item>
          <api>2.0</api>
          <statica>$line1</statica>
          <staticb>$line2</staticb>
          <staticc>$line3</staticc>
          <staticd>$line4</staticd>
          <statice>$line5</statice>
        </item>
    ";
    //Note that we do not clear the other static fields here.  You may or may not want
    //to do that in your code.

    curl_setopt($ch, CURLOPT_POSTFIELDS, $xml);

    curl_exec ($ch); // make the request
}

//Want something fancier?  Here is some PHP to put a barcode on a Cloud Display device
//Use 'bc' for barcode, 'ic' for icon, and 'qr' for a QR Code
//For a list of possible icons see this discussion https://voodoorobotics.com/line-encodings
function messageWithBarcode($devID,$line1,$line2,$bc,$time = 10)
{
    global $ch;
    if (empty($ch)) init();  //initialize with the cookie and the CSRF token if needed

    curl_setopt($ch, CURLOPT_POST, true);
                            //updating the static data or making the device flash requires a post

    curl_setopt($ch, CURLOPT_URL,"https://www.voodoodevices.com/api/device/".$devID."/");
                            //append the device ID to the endpoint.  (The response is ignored.)

    $xml = "
        <item>
          <api>2.0</api>
          <command>flash</command>
          <line1>$line1</line1>
          <line2>$line2</line2>
          <line3>\bc$bc</line3>
          <seconds>$time</seconds>
        </item>
    ";

    curl_setopt($ch, CURLOPT_POSTFIELDS, $xml);

    curl_exec($ch); // make the request
}

//How about showing some quantity?  Here is some PHP to put the quantity in a corner box
//Use 'qt' for quantity as described on https://voodoorobotics.com/line-encodings
function messageWithQuantity($devID,$line1,$line2,$line3,$qt,$time = 10)
{
    global $ch;
    if (empty($ch)) init();     //initialize with the cookie and the csrf token if needed

    if ($qt <= 99) {
        $qt = "\qt".$qt;        //note that the qt syntax only supports integers up to 99
    }
    else {
        $qt = "Quantity: ".$qt; //if you have more than 99, display using text
    }

    curl_setopt($ch, CURLOPT_POST, true);
                        //updating the static data or making the device flash requires a post

    curl_setopt($ch, CURLOPT_URL,"https://www.voodoodevices.com/api/device/".$devID."/");
                        //append the Device ID to the endpoint.  (The response is ignored.)

    $xml = "
        <item>
          <api>2.0</api>
          <command>flash</command>
          <line1>$line1</line1>
          <line2>$line2</line2>
          <line3>$line3</line3>
          <line4>$qt</line4>
          <seconds>$time</seconds>
        </item>
    ";

    curl_setopt($ch, CURLOPT_POSTFIELDS, $xml);

    curl_exec($ch); // make the request
}

// THE FOLLOWING IS AN EXAMPLE THAT ILLUSTRATES WHAT YOU SHOULD NOT DO
// Here is a function to make the device light up and then set the background
// data at the same time.  Please don't do this.  It wastes batteries and slows down communications.
// Having a barcode and a QR code in close proximity might confuse some barcode scanners.
function ridiculouslyFancy($devID,$line1,$line2,$bc,$ic,$qr,$sound,$time,$color,$sline1,$sline2,$sbc,$sic,$sqr)
{
    global $ch;
    if (empty($ch)) init();  //initialize with the cookie and the CSRF token if needed

    curl_setopt($ch, CURLOPT_POST, true);
                            //updating the static data or making the device flash requires a post

    curl_setopt($ch, CURLOPT_URL,"https://www.voodoodevices.com/api/device/".$devID."/");
                            //append the Device ID to the endpoint.  (The response is ignored.)



    //NOTE AGAIN:  THIS IS WHAT _NOT_ TO DO!
    $xml = "
        <item>
          <api>2.0</api>
          <command>flash</command>
          <line1>$line1</line1>
          <line2>$line2</line2>
          <line3>\bc$bc</line3>
          <line4>\ic$ic</line4>
          <line5>\qr$qr</line5>
          <sound>$sound</sound>
          <seconds>$time</seconds>
          <color>$color</color>
          <statica>$sline1</statica>
          <staticb>$sline2</staticb>
          <staticc>\ic$sic</staticc>
          <staticd>\bc$sbc</staticd>
          <statice>\qr$sqr</statice>
        </item>
    ";
    //NOTE AGAIN:  THE ABOVE IS WHAT _NOT_ TO DO!



    curl_setopt($ch, CURLOPT_POSTFIELDS, $xml);

    curl_exec($ch); // make the request
}

//What about information about the Turbos?
//To get a list of Turbos in your account try this:
function arrayOfTurbos()
{
    global $ch;
    if (empty($ch)) init();  //initialize with the cookie and the CSRF token if needed

    curl_setopt($ch, CURLOPT_POST, false);
    //make sure we're doing a GET request

    curl_setopt($ch, CURLOPT_URL,"https://www.voodoodevices.com/api/turbo/");
    //without a device ID in the URL, we get a list of all of them

    $theXml = curl_exec($ch);    // make the request -- the XML returned has everything in it

    $response = simplexml_load_string($theXml);  // parse the returned XML

    return (array)$response->item; //result is in the 'item'
}

//Or to get specific information about a particular Turbos
function turboInfo($turboID)
{
    global $ch;
    if (empty($ch)) init();  //initialize with the cookie and the CSRF token if needed

    curl_setopt($ch, CURLOPT_POST, false);
    //make sure we are doing a GET request

    curl_setopt($ch, CURLOPT_URL,"https://www.voodoodevices.com/api/turbo/".$turboID."/");
    //without a device ID in the URL, we get a list of all of them

    $theXml = curl_exec($ch);    // make the request -- the XML returned has everything in it

    $response = simplexml_load_string($theXml);  // parse the returned XML
    
    //print_r($response);  //uncomment this line to see all the fields you can access

    return (array)$response->item; //result is in the 'item'
}


//OK, we saved the most useful for last:
//How about a single API call to light up multiple devices?
//Here we create an Array in XML for several commands to several Devices
//Note that we use the 'devices' endpoint, not the 'device' endpoint
function helloTimesFive($id1,$id2,$id3,$id4,$id5)
{
    global $ch;
    if (empty($ch)) init();  //initialize with the cookie and the CSRF token if needed

    curl_setopt($ch, CURLOPT_POST, true);
    //updating the static data or making the device flash requires a post

    curl_setopt($ch, CURLOPT_URL,"https://www.voodoodevices.com/api/devices/");
    //append the Device ID to the endpoint.  (The response is ignored.)

    //notice how building an array in XML is kind of tricky!  Using JSON to form an array is easier
    //We encourage the use of JSON instead, but we use XML here for consistency
    $xml = "
        <items>
            <array is_array="true">
                <item>
                    <api>2.0</api>
                    <deviceid>$id1</deviceid>
                    <command>flash</command>
                    <line1>Hello</line1>
                    <line2>Howdy</line2>
                    <seconds>10</seconds>
                    <sound>15,c5,4</sound>
                </item>
             <item>
                    <api>2.0</api>
                    <deviceid>$id2</deviceid>
                    <command>flash</command>
                    <line1>Hello</line1>
                    <line2>Howdy</line2>
                    <seconds>10</seconds>
                    <sound>15,c5,4</sound>
                </item>
                <item>
                    <api>2.0</api>
                    <deviceid>$id3</deviceid>
                    <command>flash</command>
                    <line1>Hello</line1>
                    <line2>Howdy</line2>
                    <seconds>10</seconds>
                    <sound>15,c5,4</sound>
                </item>
             <item>
                    <api>2.0</api>
                    <deviceid>$id4</deviceid>
                    <command>flash</command>
                    <line1>Hello</line1>
                    <line2>Howdy</line2>
                    <seconds>10</seconds>
                    <sound>15,c5,4</sound>
                </item>
                <item>
                    <api>2.0</api>
                    <deviceid>$id5</deviceid>
                    <command>flash</command>
                    <line1>Hello</line1>
                    <line2>Howdy</line2>
                    <seconds>10</seconds>
                    <sound>15,c5,4</sound>
                </item>
            </array>
        </items>
    ";

    //if we were using JSON, we would use
    $json = "
        [
           {
              'API': '2.0',
              'deviceID': $id1,
              'command': 'flash',
              'line1': 'Hello',
              'line2': 'Howdy',
              'seconds': '10',
              'sound': '15,c5,4'
           },
           {
              'API': '2.0',
              'deviceID': $id2,
              'command': 'flash',
              'line1': 'Hello',
              'line2': 'Howdy',
              'seconds': '10',
              'sound': '15,c5,4'
           },
           {
              'API': '2.0',
              'deviceID': $id3,
              'command': 'flash',
              'line1': 'Hello',
              'line2': 'Howdy',
              'seconds': '10',
              'sound': '15,c5,4'
           },
           {
              'API': '2.0',
              'deviceID': $id4,
              'command': 'flash',
              'line1': 'Hello',
              'line2': 'Howdy',
              'seconds': '10',
              'sound': '15,c5,4'
           },
           {
              'API': '2.0',
              'deviceID': $id5,
              'command': 'flash',
              'line1': 'Hello',
              'line2': 'Howdy',
              'seconds': '10',
              'sound': '15,c5,4'
           }
        ]
    ";
    //this demo ignores the above $json variable.  If you want to use it, you'd have to
    //modify the headers in init()

    //A special note for Stand-alone Server users only: (most customers can ignore this)
    //Another reason to use JSON is that the XML above will not work on the Stand-alone Server!
    //Your XML for the Stand-alone Server must be formatted as
    // <items><list-item>...</list-item><list-item>...</list-item></items>
    //Yuck!

    curl_setopt($ch, CURLOPT_POSTFIELDS, $xml);

    curl_exec($ch); // make the request
}

Sequence CRUD

The Big Block Server supports sequences of steps.  Here’s an example of how to Create, Read, Update, or Delete Sequences using the REST API.

//Again we define an init function.  This time we'll make it a little more flexible by
//defining a $base variable to hold the base URL of all the endpoints.  Note, we use
//this $base as the 'referer' in all requests after login.
function init()
{
    global $ch;  //Now we have two globals!
    global $base;
    
    $ch = curl_init();  //initialize the cURL object
    $base = "https://bblock.mydomain.com/api";  //use your own local server address here
    curl_setopt($ch, CURLOPT_URL,$base."/user/login/");
    //we first access the login endpoint
    curl_setopt($ch, CURLOPT_COOKIEJAR, "/tmp/cookie.txt");
    //use a cookiejar, because the session ID will be stored in the cookie
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    //as before, this allows us to do $x = curl_exec()
    curl_setopt($ch, CURLOPT_POST, true);
    //login requires a POST with username and password content
    curl_setopt($ch, CURLOPT_HTTPHEADER,array(    //specify XML for input and output (could use JSON instead)
        "content-type: application/xml",          //format of the outbound data/commands
        "accept: application/xml",                //format of the inbound response
    ));
    //curl_setopt($ch, CURLOPT_VERBOSE, 1);
    //uncomment the above line if you're having problems -- curl will give you some diagnostics
    $xml = "
        <item>
          <username>yourusername</username>
          <password>yourpassword</password>
        </item>
    ";
    curl_setopt($ch, CURLOPT_POSTFIELDS, $xml);
    $theXml = curl_exec($ch);    // this logs us in, puts a session cookie in the cookiejar, and
                                // returns some XML that contains our super-secret token
    $response = simplexml_load_string($theXml);  // parse the XML that was returned
    curl_setopt($ch, CURLOPT_HTTPHEADER,array(        //do what we did before, but this time add the csrf token
                "content-type: application/json",    //format of the outbound data/commands
                "accept: application/json",            //format of the inbound response
                "referer: ".$base,                    //referer field is required. For more info see
                "x-csrf-token: ".$response->token,    // https://seclab.stanford.edu/websec/csrf/csrf.pdf
            ));
    //this is very important:  the above updates the header with the token
    //and since $ch is global, it's maintaining the cookie and the csrf token
    //we'll rely on this in the functions below
}
//Let's get a list of all the Sequences and their Steps
//This will return ALL Sequences, unstarted, started, and completed
//Check the started and completed times to know if a step has been started or is in progress
function allSequences()
{
    global $ch;
    global $base;
    if (empty($ch)) init();  //initialize with the cookie and the csrf token if needed
    curl_setopt($ch, CURLOPT_POST, false);
    //make sure we're doing a GET request
    curl_setopt($ch, CURLOPT_URL,$base."/sequence/");
    //don't specify a Sequence ID and you'll get a list of all of them
    //if you specify a Sequence ID, you'll get only that one
    $theJSON = curl_exec($ch);    // make the request -- the JSON returned has everything in it
    $response = json_decode($theJSON);  // parse the JSON that was returned
    //print_r($response);    //uncomment this line to see the format of the response
                            //in particular, note that sequences are paginated at 50 per request
                            
    return $response; 
}
//Let's create a Sequence with a few Steps
function createSequence()  //uses POST (not PUT)
{
    global $ch;
    global $base;
    if (empty($ch)) init();  //initialize with the cookie and the csrf token if needed
    curl_setopt($ch, CURLOPT_POST, true);
    //make sure we're doing a POST request
    curl_setopt($ch, CURLOPT_URL,$base."/sequence/");
    //to get info on a device, append the device ID to the endpoint
    $newSequence = <<<JSN
{
     "sequenceid": "Picklist12345",
     "sequencenonce": "Order445-PickedBy-Betty",
     "steps": [
         {"order":1, "device":"E2FECE:E6C748", "command":"flash", "line1":"Take 4", "line2":"of SKU 567-554", "line3":"icleft", "seconds":300},
         {"order":2, "location": "Aisle3|Row4|Slot2", "command":"flash", "line1":"Take 4", "line2":"of SKU 567-554", "seconds":300},
         {"order":2, "device": "E37B17:D383D4", "command":"flash", "line1":"Betty is Done", "seconds":30, "color":"g"},
         {"order":4, "device": "F13C97:E97FCD", "command":"flash", "seconds":1, "stepnonce":"myLastDevice", "sound":"15,c5,4" }
     ]
}    
    
JSN;
//
//IMPORTANT!!!
//
//The above sequence can be launched by a picker.  The picker can override some of the above fields.
//Which fields can be overriden is set when the server is installed.  See /launchsequence/ on your Big Block Server.
//Launching the sequence means the steps are performed in order, using the 'order' field above.
//In this example, order 1 will come first.  Only when that device is acknowledged, will the next two
//steps fire in tandem, because they have the same 'order' values.  Only after both of those steps
//are acknowledged, will the fourth step fire.
//Each step can either specify an exising device, or a location name.  If a location is specified,
//the location name is used to find the (first) device associated with that location.  (Super-string matches)
//Each step can have five lines for a modern device (line 1-5), or two lines for a classic 
//(use 'lines' with a '|' character).  The stepnonce is sent to the feedback server (if specified)
//on an ack or nack (timeout).  The sequencenonce is sent after the last order step has been acknowledged.
//
//IMPORTANT!!!
//
    curl_setopt($ch, CURLOPT_POSTFIELDS, $newSequence);
    $theJSON = curl_exec($ch);    // make the request -- the JSON returned has everything in it
    $response = json_decode($theJSON);  // parse the JSON that was returned
    //print_r($response);    //the response is the full-blown sequence
    return $response;        // with all its fields and all steps and their fields 
}
function readSequence()
{
    global $ch;
    global $base;
    if (empty($ch)) init();  //initialize with the cookie and the csrf token if needed
    curl_setopt($ch, CURLOPT_POST, false);
    //make sure we're doing a GET request
    curl_setopt($ch, CURLOPT_URL,$base."/sequence/Picklist12345/");
    //we specify which Sequence ID in the endpoint
    $theJSON = curl_exec($ch);    // make the request -- the JSON returned has everything in it
    $response = json_decode($theJSON);  // parse the JSON that was returned
    //print_r($response);    //uncomment this line to see the format of the response
                            
    return $response; 
}
function updateSequence()  //uses PUT (not POST) 
{
    global $ch;
    global $base;
    if (empty($ch)) init();  //initialize with the cookie and the csrf token if needed
    curl_setopt($ch, CURLOPT_POST, false);
    //curl thinks PUT is a POST!  What a joke.  LOL.
    
    curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT");
    //well PUT and POST are pretty similar
    curl_setopt($ch, CURLOPT_URL,$base."/sequence/Picklist12345/");
    //if the specified Sequence ID in the JSON below is NOT the SAME as ABOVE,
    //AN ADDITIONAL Sequence will be created!
    $newSequence = <<<JSON
{
     "sequenceid": "Picklist12345",
     "sequencenonce": "Order445-PickedBy-Wilma",
     "steps": [
         {"order":5, "device":"E2FECE:E6C748", "command":"flash", "line1":"Fred Take 4", "line2":"of SKU 567-554", "seconds":300},
         {"order":6, "location": "Aisle3|Row4|Slot2", "command":"flash", "line1":"Take 4", "line2":"of SKU 567-554", "seconds":300}
     ]
}    
    
JSON;
//
//IMPORTANT!!!
//
//The above steps will REPLACE any existing steps in the sequence.
//If you specify a different sequenceid in the JSON than in the endpoint,
//an ADDITIONAL sequence will be created!
//
//IMPORTANT!!!
//
    curl_setopt($ch, CURLOPT_POSTFIELDS, $newSequence);
    $theJSON = curl_exec($ch);    // make the request -- the JSON returned has everything in it
    curl_setopt($ch, CURLOPT_CUSTOMREQUEST, null);
    //better reset this after the call in $ch so we don't mess up our other calls!
    $response = json_decode($theJSON);  // parse the JSON that was returned
    //print_r($response);        //the response is the full-blown edited sequence
                            //with STEPS REPLACED! (They are NOT concatenated with the
    return $response;        //previous steps.)
}
function deleteSequence()  //uses DELETE HTTP request
{
    global $ch;
    global $base;
    if (empty($ch)) init();  //initialize with the cookie and the csrf token if needed
    curl_setopt($ch, CURLOPT_POST, false);
    //curl thinks PUT is a POST!  What a joke.  LOL.
    
    curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "DELETE");
    //well PUT and POST are pretty similar
    curl_setopt($ch, CURLOPT_URL,$base."/sequence/Picklist123456/");
    //if the specified Sequence ID in the JSON below is not the same,
    //AN ADDITIONAL Sequence will be created!
    $theJSON = curl_exec($ch);    // make the request -- the JSON returned has everything in it
    curl_setopt($ch, CURLOPT_CUSTOMREQUEST, null);
    //better reset this after the call in $ch so we don't mess up our other calls!
    $response = json_decode($theJSON);  // parse the JSON that was returned
    //print_r($response);        //You should get a '204' response (success without content)
    return $response;        
}
function launchSequence()
{
    global $ch;
    global $base;
    if (empty($ch)) init();  //initialize with the cookie and the csrf token if needed
    curl_setopt($ch, CURLOPT_POST, false);
    //we are doing a get
    
    curl_setopt($ch, CURLOPT_CUSTOMREQUEST, null);
    
    curl_setopt($ch, CURLOPT_URL,$base."/launchsequence/Picklist123456/");
    //This will start or restart the sequence from where it was left off
    $theJSON = curl_exec($ch);    // make the request -- the JSON returned has everything in it
    $response = json_decode($theJSON);  // parse the JSON that was returned
    //print_r($response);        //You should get a '204' response (success without content)
    return $response;        
}

The Big Block Server supports sequences of steps.  Here’s an example of how to Create, Read, Update, or Delete Sequences using the REST API.

You May Also be Interested in:

Device Limitations

The REST API works for both our Modern Cloud Display Devices and our Classic devices.

Modern Cloud Display Devices devices support five lines both for commands and for static data.  As you can see in the code example we use line 1-5 and static a-e for these lines.  The device display will scale to fit the text that you send it, so if you have a five character string on only one line, it’ll be much larger than five 26-character lines.  Each line supports up to 26 characters.

Classic devices only support two lines of text.  The display is 16 characters wide, but you can send a maximum of 32 characters.  If you send more than 16 characters, the display will scroll back and forth, left to right.  Classic devices require a  bar delimiter ‘|’ to separate lines in a static call, and support both ‘static’ and ‘static2’.  Static is shown after a single button push, and static2 is shown after two button pushes.  Please contact us if you wish to replace your Classic devices with the new Modern devices.

Barcodes, QR Codes, and Icons

You can replace any command or static line of text on a Modern Cloud Display Device with a barcode, QR Code or icon.  As you can see in the example above, if you preface a line with ‘bc’ you will get a barcode.  If you preface a line with ‘qr’ you will get a QR Code.  And if you preface a line with ‘ic’ you will get an icon.  And, of course, you could do all three!

Since Modern devices have a limitation of 26 characters per line of text, barcodes and QR Codes are limited to 23 characters (three are used for the prefix).  Note that bitly links are 22 characters — so you can encode any URL on a device.

Modern devices also support two main types of icons: arrows and hazard signs.

Learn about the different encoding formats for icons.

Click here to add your own text

Click here to add your own text

© Copyright 2024 Voodoo Robotics. All Rights Reserved. Patents Pending. Voodoo Robotics, Voodoo Devices, Big Block Server, and Turbo names and logos are all trademarks of Voodoo Robotics.