Using a socket-based protocol to run API commands
When you connect, the API service issues its standard prompt,
>, indicating that it is ready to receive a command.
To connect to the API service, open the connection to the server where the API is currently running by using the port 50000, which is the default port. To change the default socket-based port, set the
api_port system preference. For more information, see Managing system settings.
However, setting the
api_port system preference is not enough for the Windows platform. In order to configure the default socket-based port on Windows, issue the following command:
VAPIService.exe -config -Port <port>, where
<port> is the port on which you want to run the API service.
The default location of the VAPIService.exe file is C:\Program Files (x86)\VaraLogix (or the directory which you specified during the API service installation).
Each completed command returns 0 or more informational lines followed by a status line. The status line starts with a command-complete character (<), followed by a numeric result code and related message. For more information, see API result codes.
For example, you could enter a
login command with a valid user name and password and receive a response as follows:
>login user pass
In this case, the
login command returned a 0 result code and related message indicating success (Ok).
Commands that return information lines issue those lines before the result code. The lines typically consist of an ID code followed by text information, but vary depending on the command issued. For example:
In this example, the
list packages command lists each package defined in the database on one line composed of the unique ID number and name of the package. Most
list commands display data in this format. The unique ID number for each entry can be used by other commands.