API description

The following section describes the options provided by the JSON Data Interface with the help of short example requests and responses. The API is equally valid for access via MQTT or via ADS.

Type

Request/Response

Sample of the JSON payload

Reading a variable

Request

{"symbol":"MAIN.nCounter"}

 

Response

{"symbol":"MAIN.nCounter",
"value":42}

Reading a variable and its data type

Request

{"symbol":"MAIN.nCounter",
"datatype":null}

 

Response

{"symbol":"MAIN.nCounter",
"value":42, "datatype":INT}

Simultaneous reading of several variables

Request

[{"symbol": "MAIN.nCounter"},{"symbol":"MAIN.nSecCounter"}]

 

Response

[{"symbol":"MAIN.nCounter","value":42 },{"symbol":"MAIN.nSecCounter, "value":35}]

Reading the TwinCAT symbol info

Request

{"symbols":null}

 

Response

Complete symbol info

Writing a variable

Request

{"symbol":"MAIN.nCounter","value":42}

 

Response

{"symbol":"MAIN.nCounter","value":42}

Writing several variables

Request

[{"symbol":"MAIN.nCounterˮ, "value":42},{"symbol":"MAIN.nSecCounter", "value":35}]

 

Response

[{"symbol":"MAIN.nCounter","value":42},{"symbol":"MAIN.nSecCounter","value":35}]

Method calls, optionally with input and output parameters

Request

{"symbol": "MAIN.fbTester#M_Add","parameter":{ "intA":42, "intB":35}}

 

Response

{"symbol":"MAIN.fbTester#M_Add", "value":77}

 

Response with additional outputs

{"symbol":"MAIN.fbTester#M_Add","value":77,"parameter":{"intC":32, "intD":64}}