An application programming interface (or API) is a set of instructions and protocols for accessing functionality in software. Since the release of their operating systems in mid-2010*, our CR1000, CR3000, and CR800 dataloggers have supported the use of a web-based API. This API enables experienced computer programmers to create custom web applications for datalogger management, control, and data display.
The datalogger web API employs basic access authentication to provide a measure of secure access to a datalogger on the web. There are four levels of access: all access denied, all access allowed, read-only, and control. Different commands in the web API require different levels of access. User access is assigned using a file named .csipasswd that resides on the datalogger's CPU. Depending upon the settings in the .csipasswd file, a user can be challenged with a user name and password request when accessing the datalogger or initiating control.
The available commands in the web API allow the programmer to create a full-featured, web-based application. The Browse Symbols and DataQuery commands allow a web client to query a datalogger for its table information and request data. SetValueEx is used to set a value in the datalogger, thus enabling control. There are also commands to check and set the datalogger's clock and query and manage files on the datalogger's file system. Results of the commands are returned in HTML, JSON, or XML.
So, what if you're not a programmer? You may still find the web API useful for quickly viewing a data table in a browser or setting a variable in a datalogger using a browser. A command is typed into the browser's URL field, and the result is returned in the browser window. For example, to display a table with the three most recent values from a variable named TCTemp_Max in a table called OneMin, the command line would be (without line breaks):
http://192.168.4.14/?command=dataquery
&uri=dl:onemin.TCTemp_Max&format=html
&mode=most-recent&p1=3
As a result, the following would be displayed in the browser window:
Documentation on the web API can be found in the CRBasic help files. To use the web API, the datalogger must be connected to the Internet (e.g., using an NL115, NL120, NL200, or cellular IP).
The web API opens up exciting possibilities for our dataloggers:
Campbell Scientific is busy leveraging the capabilities provided by the web API into its other applications. Look for new features in RTMC Pro and our PC-based web server to be announced soon!
* CR1000 OS 20, CR3000 OS 13, and CR800 OS11
We're now on Facebook!
Stay informed with our latest updates by following Campbell Scientific Australia.