How to Use REST Tool



Concept Definitions

REST API

Definition: REST API is an architectural style for application programming interfaces (APIs) that uses HTTP requests to access and use data. The data can be manipulated using GET, PUT, POST, and DELETE operations, corresponding to read, update, create, and delete actions related to resources.

Operations:

  • GET: Retrieve resources.
  • PUT: Change or update the state of a resource, which can be an object, file, or block.
  • POST: Create a new resource.
  • DELETE: Remove a resource.


HTTP Protocol-related Explanations

Request Header: The request header is metadata used to describe an HTTP request in the HTTP protocol. It is a part of the request information sent from the client to the server, containing relevant configurations and requirements from the client.

Request Body: The request body is a part of the HTTP protocol used to transmit data sent by the client to the server. It is an optional component of an HTTP request and is used to pass parameters, content, or data required for the request. The request body typically appears in methods such as POST and PUT, used to send client data to the server. It can contain various types of data, such as form data, JSON data, or files. The specific data type is specified by the Content-Type field in the request header.

Response Header: The response header is metadata used to describe the server's response in the HTTP protocol. It is a part of the response information sent from the server to the client, containing relevant configurations and a description of the response content.

Response Body: The response body is a part of the HTTP protocol used to transmit data from the server to the client. It is a component of an HTTP response and contains the actual response content from the server. The response body typically appears in successful responses from the server, such as 200 OK. It can contain various types of data, such as HTML pages, JSON data, or files. The specific data type is specified by the Content-Type field in the response header.




Step 1: Download and Install

The software is available in two installation modes: Total Control Embedded Version and Standalone Installation Version.

Embedded Version:

  • For the embedded version, simply download the latest Total Control software from the official website: Download
  • After installation, click the "Script" button on the main interface to open the script window. In the script list, locate the "REST Tool" button, and click to open the REST Tool for usage.



Installation Version:

  • For the installation version, please download the REST Tool directly from the official website: Download
  • After installation, open the REST Tool using the shortcut icon on your desktop.





Step 2: Login

1. Obtain the account information for Total Control, including the service address, account, and password.

a. Account and password.


b. Service address (format: http://IP:port), where IP is the IP address of the computer where Total Control is installed, and the port can be found in the Total Control system settings.


2. Enter the account information obtained from step 1 (including service address, account, and password) on the login interface to log in.




Step 3 : Official API Testing

1. When the software is opened for the first time, it will initialize the official API list, or you can manually load the official API list (as shown below).


2. Choose one or more devices from the device list (the "Device List" will only be displayed after a successful account login), or leave it unselected to default to the main control device.


3. Select an API data, click the run button to test directly. You can freely modify various parameters such as request method, request URL, query parameters, request headers, etc.





Step 4: Custom API Testing

1. Click the "Add" button to add a new API or directory. There are two places where you can perform the addition operation, as shown below.


2. Fill in the necessary parameters in the pop-up window. After saving successfully, you can view the currently added API data in the left API list.


3. Choose one or more devices from the device list (the "Device List" will only be displayed after a successful account login), or leave it unselected to default to the main control device.


4. Select the newly added or compiled API data, fill in the necessary parameters (refer to the official API help: [link]), and then click the run button to perform the test.




Step 5: Example Code Usage

This tool supports the automatic or manual generation of example code in JavaScript, Java, and Python languages to demonstrate how to call the Total Control REST API. To generate example code for an API request:

1. Choose the API request for which you want to generate example code.


2. In the API request input section, there is an item labeled "Example Code." Switch to this section to view example code in JavaScript, Java, and Python languages.


3. If you want to compile and run the generated code, follow the specific instructions for each language's compilation environment:

  • Running JavaScript Code: Open the Total Control software, copy the generated JavaScript code, and run it directly in the Total Control script terminal.
  • Running Java Code: Copy the generated code to a compiler that can run Java code, such as Eclipse IDE for Java, IntelliJ IDEA, Visual Studio Code, etc.
  • Running Python Code: Copy the generated code to a compiler that can run Python code, such as PyCharm IDE, IDLE, IPython, Spyder, etc.




Special Instructions

1. What to do if the account login fails?

  • a. Simply restart the Total Control software.
  • b. Modify the API service port in the Total Control system settings, then restart Total Control.
  • c. Delete the current connection object from the connection list in Total Control's system settings, then log in to REST Tool again.
  • d. Modify the account information in Total Control, then restart Total Control, and log in again using the new account.


2. What to do if REST Tool built-in version cannot open, displays a white screen, or loads slowly?

The built-in version may have compatibility issues. Since Total Control's browser plugin uses the IE browser kernel, it is related to the installed version of IE on the operating system. If the IE version is lower than 10, compatibility issues may arise, such as API request failures, inability to log in, or failure to initialize official APIs. If you encounter such issues, upgrade the IE version. Alternatively, the built-in version provides the following three functions, copy the addresses and use them in other browsers: