Here is an example of a python 2.7 script to find a group of sensors, the status of the group and the status of the sensors.
#!/usr/bin/python2.7
import urllib
import urllib2
import json
## Define the app ID and API key variables
appID = 'request app ID via support'
apiKey = 'request API key via support'
## Define the node you want to lookup
nodeName = 'Singapore'
if __name__ == '__main__':
# The API for all sensor groups
url = 'https://api.capenetworks.com/v1/nodes'
headers = { 'x-app-id' : appID, 'x-api-key' : apiKey }
req = urllib2.Request(url,None,headers)
response = urllib2.urlopen(req)
# check if the response was successful
if response.code == 200:
# process the response
result = json.loads(response.read())
nodes = result['payload']['nodes']
for node in nodes:
if nodeName == node['name']:
print node['name'],
print node['state']
sensors = node['state_summary']['sensors']
for sensor in sensors:
print ' '+sensor['name'],
print ' '+sensor['state']
Example Output
Singapore warning
Library good
Computer Lab B good
Computer Lab A warning
Updated 8 months ago