Occupancy Data

Occupancy Data API provides a table of raw sensor data. You can use the data to create reports, export to excel, visualize and analyze.


API Token

apiToken: [{"sessionToken":"<SessionToken>"},{"propertyid":"<Building_PropertyID>"}]

SessionToken: 

Use SessionToken upon Authentication to create an apiToken and access VSETA Resources.

Building_PropertyID:

Building_PropertyID permits you to access data from your organization’s subscribed properties.


POST Occupancy Data Table

$.ajax({
    type: "POST",
    dataType: "json",
    contentType : "application/json",
    url: "https://ai.vseta.com/getDataTable/",
    data: apiToken, 
    success: function(tData){
        var tableData = tData;
    },
    failure: function(errMsg) {
        console.log("ERROR: "+ errMsg);
    }
});

POST Occupancy Data Table Columns

$.ajax({
    type: "POST",
    dataType: "json",
    contentType : "application/json",
    url: "https://ai.vseta.com/getDataTableCols/",
    data: apiToken,
    success: function(tColData){
        var tableColData = tColData;
    },
    failure: function(errMsg) {
        console.log("ERROR: "+ errMsg);
    }
});

Complete Example: Occupancy Data

<!-- 

-- =============================================
-- Author:      VSETA Mobile Technologies Inc.
-- Create date: NOV 5th, 2018
-- Description: API Example - Get Raw Occupancy Data
-- Copyright © 2018 VSETA Mobile Technologies and other contributors. All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

1) Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.

2) Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

3) Neither the name of VSETA nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Visit vseta.com/legal for latest VSETA Terms and Conditions.

-- =============================================

-->

<!DOCTYPE html>
<html>
  <head>
    <meta http-equiv="content-type" content="text/html;charset=UTF-8" />
    <meta charset="utf-8" />
    <title>VSETA - Facility Developer API</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, shrink-to-fit=no" />
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-touch-fullscreen" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="default">
    <meta content="" name="description" />
    <meta content="" name="author" />
    
    <!--<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.js"></script>-->
    <script data-require="jquery@*" data-semver="2.1.4" src="https://code.jquery.com/jquery-2.1.4.js"></script>
      
    <link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
    
    <script type="text/javascript">
           
    window.onload = function()
    {

      // fix for windows 8
      if (navigator.appVersion.indexOf("Windows NT 6.2") != -1)
        document.head.innerHTML += '<link rel="stylesheet" type="text/css" href="pages/css/windows.chrome.fix.css" />'
        
        //***** VSETA API ACCESS *****
        
            //Use Developer Account instead of Personal Account to avoid Session Termination.
            var userName = "your_dev_account@domain.com";
            var userCertificate = "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX";

            //Application API Account Key - Do Not Share your ID.
            var accessKeyId = "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX";

            //Add accessKeyId to User Login for Authentication
            var sessionToken = JSON.stringify([{"name":"username","value":userName},{"name":"usercertificate","value":userCertificate},{"name":"accessKeyId","value":accessKeyId}]);

        //************************************
        
         $.ajax({
            type: "POST",
            dataType: "json",
            contentType : "application/json",
            url: "https://ai.vseta.com/auth/",
            data: sessionToken,
            success: function(data){
                
                console.log('Data: ' + JSON.stringify(data));
                
                //Modify the SessionToken parameters according to VSETA API Documentation
                var apiToken = JSON.stringify([{"sessionToken":data[0].SessionToken},{"propertyid":"XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX"},{"accessKeyId":accessKeyId}])
                                        
                //URL: Modify URL according to VSETA API Documentation to access various subscribed Restful APIs.
                //success: Success Returns JSON Array Object if accessKeyId is valid for the called Restful API resource.
                
                /*
                    Notes:
                    
                    Blank Data:
                    
                    At times, You may see blank Room data which is due to no data being available for the given time/date period.
                    This can happen if a Room Sensor is offline for maintenance.
                    
                    Full Column Names:
                    
                    If time is near the begining of the hour and not all Rooms have been updated yet, you may not see all of the column names
                    using this sample code. Store or refernce the Room Names seperately in your code.
                */
                $.ajax({
                    type: "POST",
                    dataType: "json",
                    contentType : "application/json",
                    url: "https://ai.vseta.com/getDataTable/",
                    data: apiToken,
                    success: function(data){
                        console.log('Data: ' + JSON.stringify(data));

                        var html = '<table id="RespData" class="table table-striped">';
                        html += '<tr>';
                        var flag = 0;
                        $.each(data[0], function(index, value){
                            html += '<th>'+index+'</th>';
                        });
                        html += '</tr>';
                         $.each(data, function(index, value){
                             html += '<tr>';
                            $.each(value, function(index2, value2){
                                html += '<td>'+value2+'</td>';
                            });
                            html += '<tr>';
                         });
                         html += '</table>';
                         $('body').html(html);
                    },
                    failure: function(errMsg) {
                        console.log('ERROR: ' + errMsg);
                }
        });
                
            },
            failure: function(errMsg) {
                console.log('ERROR: ' + errMsg);
            }
        });
        
    }
    </script>
    
  </head>
  <body>
    <!-- PUT BODY HERE -->
  </body>
</html>