General API structure

The general entry point to the rc_reason_stack’s API is http://<host>/api/, where <host> is the IP address of the host PC that runs the rc_reason_stack combined with the port 8080, i.e. <host-ip>::8080. Accessing this entry point with a web browser lets the user explore and test the full API during run-time using the Swagger UI .

For actual HTTP requests, the current API version is appended to the entry point of the API, i.e., http://<host>/api/v2.

All data sent to and received by the REST-API follows the JavaScript Object Notation (JSON). The API is designed to let the user create, retrieve, modify, and delete so-called resources as listed in Available resources and requests using the HTTP requests below.

Request type Description
GET Access one or more resources and return the result as JSON.
PUT Modify a resource and return the modified resource as JSON.
DELETE Delete a resource.
POST Upload file (e.g., license or firmware image).

Depending on the type and the specific request itself, arguments to HTTP requests can be transmitted as part of the path (URI) to the resource, as query string, as form data, or in the body of the request. The following examples use the command line tool curl, which is available for various operating systems. See https://curl.haxx.se.

  • Get a node’s current status; its name is encoded in the path (URI)

    curl -X GET 'http://<host>/api/v2/pipelines/0/nodes/rc_stereomatching'
    
  • Get values of some of a node’s parameters using a query string

    curl -X GET 'http://<host>/api/v2/pipelines/0/nodes/rc_stereomatching/parameters?name=minconf&name=maxdepth'
    
  • Set a node’s parameter as JSON-encoded text in the body of the request

    curl -X PUT --header 'Content-Type: application/json' -d '[{"name": "mindepth", "value": 0.1}]' 'http://<host>/api/v2/pipelines/0/nodes/rc_stereomatching/parameters'
    

As for the responses to such requests, some common return codes for the rc_reason_stack’s API are:

Status Code Description
200 OK The request was successful; the resource is returned as JSON.
400 Bad Request A required attribute or argument of the API request is missing or invalid.
404 Not Found A resource could not be accessed; e.g., an ID for a resource could not be found.
403 Forbidden Access is (temporarily) forbidden; e.g., some parameters are locked while a GigE Vision application is connected.
429 Too many requests Rate limited due to excessive request frequency.

The following listing shows a sample response to a successful request that accesses information about the rc_stereomatching node’s minconf parameter:

HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: 157

{
    "name": "minconf",
    "min": 0,
    "default": 0,
    "max": 1,
    "value": 0,
    "type": "float64",
    "description": "Minimum confidence"
}

Note

The actual behavior, allowed requests, and specific return codes depend heavily on the specific resource, context, and action. Please refer to the rc_reason_stack’s available resources and to each software module’s parameters and services.

Available resources and requests

The available REST-API resources are structured into the following parts:

  • /nodes
    Access the rc_reason_stack’s global Database modules with their run-time status, parameters, and offered services, for storing data used in all camera pipelines and multiple modules, such as load carriers, grippers and regions of interest.
  • /pipelines/<number>/nodes
    Access the rc_reason_stack’s 3D-camera, detection and configuration software modules of the camera pipeline with the specified number, with their run-time status, parameters, and offered services.
  • /pipelines
    Access to the status and configuration of the camera pipelines.
  • /templates
    Access the object templates on the rc_reason_stack.
  • /cad
    Access the cad elements, e.g. for grippers, on the rc_reason_stack.
  • /presets
    Access the 2D and 3D user-defined presets for zivid cameras.
  • /system
    Access the system state, set network configuration, configure the camera pipeline types, and manage licenses as well as firmware updates.
  • /logs
    Access the log files on the rc_reason_stack.
  • /generic_robot_interface
    Access the job and hec_configs for the Generic Robot Interface on the rc_reason_stack.