The Python as the easiest programming language is used in the examples on this page. These examples should run as a standalone program unlike the examples described in administrator guidance. Install Python to run.
Although the SDK is designed to be used in applications, all of its functions work from a browser. Moreover, the SDK comments suggest additional functions that may be called. All you have to do is copy the example to the address bar. Try out all the functions using a browser!
The SDK functions require either an SDK password or a session ID. Use your password instead of "123" in the examples.
/login lets you receive a session ID if you have a password. For most of the SDK functions, it does not matter if you pass a session ID or directly pass a password. Only functions for getting events change their behavior: given a password, they return all recent events; given a session ID, then return only new events.
/objects allows you to get an object tree, find objects within the server, for example all channels.
import urllib, re, ssl
s = urllib.urlopen("https://127.0.0.1:8080/objects/?password=12345", context=ssl._create_unverified_context()).read()
for x in s.replace("\n", "").split("{"):
m = re.search('"name"\s*\:\s*"(.*?)".*Channel', x)
if not m: continue
print m.group(1) The example removes all newline characters ("\n") from the string, uses a delimiter ("{") to split the result into a list of strings, and searches each of them for "name" : "NAME" ... Channel using a regular expression. If an instance is found, NAME is printed.
/objects/id.object lets you examine the state of an object. You can view an object's possible states in the rule editor and class description.
/objects/id.object/method?param1=val1¶m2=val2 lets you call a method on an object. You can find an object's identifier in the object tree. You can find the names of methods and parameters in the rule editor or class description.
/classes/id.class lets you view the states of objects of a given class as well as available methods, including the names and types of parameters.
/settings/folder/field allows you to read and write settings. The settings in the server are divided into folders that contain fields of one of three types: integer, real, string. The names of the folders and fields can be viewed by pressing F4 in the admin interface. This mode allows you to view and edit settings, bypassing dialogs. This mode allows you to experiment with how the system behaves when certain settings are modified.
If the field name is omitted in the request, the SDK will return a list of available fields and subfolders.
/events lets you get system events. In the response, "timestamp" uses UNIX time in microseconds. You can view the possible event types in the rule editor. The "origin" field contains the object's identifier. You can get the object's name and other properties from the object tree. Some events contain additional fields. For example, the "Connected to %1 under %2" event contains two fields: "server_address" and "under_username".
import urllib, re
s = urllib.urlopen("https://localhost:8080/login?password=123").read()
sid = re.search('"sid"\s*:\s*"(.*?)"', s).group(1)
print "my session: %s" % sid
while 1:
s = urllib.urlopen("https://127.0.0.1:8085/events?sid=%s" % sid).read()
print s This example receives and prints events as they come in.
/pos_events lets you get POS events in a similar manner. The event format is exactly the same as ActivePOS events in scripts.
/lpr_events lets you get AutoTRASSIR events in a similar manner. The event format is exactly the same as AutoTRASSIR events in scripts.

