Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
en:mervis-scada:50-api [2021/04/15 10:43]
m.chlupac
en:mervis-scada:50-api [2025/07/24 08:46] (current)
m.skrivanek [api/v2/get/authenticate]
Line 7: Line 7:
  
 ^Function^Description| ^Function^Description|
 +^api/v2/get/authenticate||
 ^api/checkCredentials|| ^api/checkCredentials||
 ^api/logout|| ^api/logout||
Line 15: Line 16:
 ^api/get/history/specific|| ^api/get/history/specific||
 ^api/set/history|| ^api/set/history||
 +^api/replace/history||
 ^api/get/values|| ^api/get/values||
 ^api/get/alarms|| ^api/get/alarms||
Line 34: Line 36:
 ===== Examples ===== ===== Examples =====
  
-====api/checkCredentials====+====api/v2/get/authenticate==== 
 + 
 +**Request** 
 + 
 +   * URL: /api/v2/get/authenticate?format=json 
 +   * Method: POST 
 + 
 +<code javascript> 
 +{"data":{"cred":{"n":"demo","p":"demo"}}} 
 +</code> 
 + 
 +or with the full name (with the domain and login name) 
 + 
 +<code javascript> 
 +{"data":{"cred":{"d":"GlobalDomain","n":"demo","p":"demo"}}} 
 +</code> 
 + 
 +**Response** 
 + 
 +     * token (string) - Authentication token for calling other API methods. 
 +     * tokenValidFor (TimeSpan) - The duration for which the provided token is valid. This value is not returned if a token wasn't provided or if its validity period isn't configured. Example: "P1D" indicates a validity of 1 day. 
 +     * changePwdBefore (DateTime or null) - If present, this specifies the date and time by which the current password must be changed. This period is determined by the domain's password policies, starting from the last password change. Example: "2026-12-21T13:26:42Z"
 +     * notifyNearingPwdExpirationIn (TimeSpan or null) - If present, this indicates how long before the password expires (refer to changePwdBefore) a notification should be displayed to the user. Example: "P8DT22H16M12S" (meaning just over 8 days). 
 + 
 + 
 + 
 +<code javascript> 
 +
 +    "data":
 +        "ChangePwdBefore": null, 
 +        "ClientType": 2, 
 +        "Domain": "3c73477a-6c95-4939-b047-7bbf902bcef1", 
 +        "DomainName": "GlobalDomain", 
 +        "FullName": "GlobalDomain\\demo", 
 +        "Login": "demo", 
 +        "NotifyNearingPwdExpirationIn": null, 
 +        "Token": "3:93d3c832-0f1b-4cde-a0eb-1fd346f5a9c0", 
 +        "TokenValidFor": "P1D", 
 +        "User": "48141739-5d16-4ca3-8ae1-33e27d9eb22e", 
 +        "Username": "" 
 +    }, 
 +    "result":
 +        "code": 0, 
 +        "codeTxt": null, 
 +        "dataType": null, 
 +        "desc": null 
 +    } 
 +}</code> 
 +====[Deprecated] api/checkCredentials==== 
 + 
 +This is deprecated API method. Use api/v2/get/authenticate instead!
  
 **Request** **Request**
Line 40: Line 92:
    * URL: /api/checkCredentials?format=xml    * URL: /api/checkCredentials?format=xml
    * Method: POST    * Method: POST
 +
  
 <code javascript> <code javascript>
 {"cred":{"n":"demo","p":"demo"}} {"cred":{"n":"demo","p":"demo"}}
 +</code>
 +
 +or with the full name (with an escaped backslash between the domain and login name)
 +
 +<code javascript>
 +{"cred":{"n":"GlobalDomain\\demo","p":"demo"}}
 </code> </code>
  
Line 242: Line 301:
 </code> </code>
  
 +==== api/get/history/specific ====
  
-==== [Depricated] api/get/history====+**Request** 
 + 
 +   * URL: /api/get/history/specific?format=json 
 +   * Method: POST 
 +   * You should always use token ("t") instead of simple name and password ("n" and "p"). Non-token call is slower. 
 +   * "dataSpec" - data specification 
 +      MinTimestamp = 0, 
 +      MaxTimestamp = 1, 
 +      FirstLessThanReferenceDateTime = 2, 
 +      FirstLessThanOrEqualThanReferenceTime = 3, 
 +      FirstGreaterThanReferenceDateTime = 4, 
 +      FirstGreaterThanOrEqualThanReferenceTime = 5, 
 +      MaxGoodThroughTime = 6  
 +   * "refTime" [optional] - reference time for dataSpec values 2 to 5 
 + 
 + 
 +<code javascript> 
 +
 + "cred": 
 + { 
 +  "n":"test", 
 +  "p":"test" 
 + }, 
 +  "projId":"b4d96a6d-2b3d-48eb-af30-d11e875ba7ed", 
 +  "offset":0, 
 +  "count":1000, 
 +  "dataSpec":2,  
 +  "refTime":"\/Date(1692788459000)\/", 
 +  "dpIds":["58426e69-46ba-4925-9a5c-d7d65efb9886","f4501a2e-62ed-430e-9346-5e155e730fe3","28e7d087-917a-456a-9d02-96882f572286"
 +
 +</code> 
 + 
 +**Response** 
 + 
 +   * Values 
 +     * v - value 
 +     * ts - timestamp - start of the value validity period 
 +     * gt - goodthrough - end of the value validity period 
 +     * i - interval 
 + 
 +<code javascript> 
 +
 +    "ns":
 +        "r": "http://dev.rcware.eu/serialization/references", 
 +        "n1": "http://dev.rcware.eu/scada/history", 
 +        "n2": "http://dev.rcware.eu/scada/datapoints", 
 +        "n3": "http://dev.rcware.eu/scada/basic-props" 
 +    }, 
 +    "doc":
 +        "n1:getHistorySpecificResult":
 +            "n2:pl":
 +                { 
 +                    "n2:p":
 +                        "n1:hist":
 +                            "@":
 +                                "n1:projId": "b4d96a6d-2b3d-48eb-af30-d11e875ba7ed", 
 +                                "n1:dpId": "58426e69-46ba-4925-9a5c-d7d65efb9886", 
 +                                "n1:propName": "Output", 
 +                                "n1:interval": "00:00:00", 
 +                                "n1:historyState": "", 
 +                                "n1:nextValOfs":
 +                            }, 
 +                            "n1:errMsg": "", 
 +                            "n1:vals":
 +                                { 
 +                                    "n1:hv":
 +                                        "@":
 +                                            "n1:ts": "2023-08-23T11:00:57.7010708Z", 
 +                                            "n1:i": "1.00:00:00" 
 +                                        }, 
 +                                        "n3:v": 12.48 
 +                                    } 
 +                                } 
 +                            ] 
 +                        }, 
 +                        "@":
 +                            "r:type": "b133774d-21ce-42b6-add3-57c012079c55" 
 +                        } 
 +                    } 
 +                }, 
 +                { 
 +                    "n2:p":
 +                        "n1:hist":
 +                            "@":
 +                                "n1:projId": "b4d96a6d-2b3d-48eb-af30-d11e875ba7ed", 
 +                                "n1:dpId": "f4501a2e-62ed-430e-9346-5e155e730fe3", 
 +                                "n1:propName": "Output", 
 +                                "n1:interval": "00:00:00", 
 +                                "n1:historyState": "", 
 +                                "n1:nextValOfs":
 +                            }, 
 +                            "n1:errMsg": "", 
 +                            "n1:vals":
 +                                { 
 +                                    "n1:hv":
 +                                        "@":
 +                                            "n1:ts": "2023-08-23T10:38:43.784Z", 
 +                                            "n1:gt": "2023-08-23T11:18:00.207Z", 
 +                                            "n1:i": "00:00:30" 
 +                                        }, 
 +                                        "n3:v": 5.0 
 +                                    } 
 +                                } 
 +                            ] 
 +                        }, 
 +                        "@":
 +                            "r:type": "b133774d-21ce-42b6-add3-57c012079c55" 
 +                        } 
 +                    } 
 +                }, 
 +                { 
 +                    "n2:p":
 +                        "n1:hist":
 +                            "@":
 +                                "n1:projId": "b4d96a6d-2b3d-48eb-af30-d11e875ba7ed", 
 +                                "n1:dpId": "28e7d087-917a-456a-9d02-96882f572286", 
 +                                "n1:propName": "Output", 
 +                                "n1:interval": "00:00:00", 
 +                                "n1:historyState": "", 
 +                                "n1:nextValOfs":
 +                            }, 
 +                            "n1:errMsg": "", 
 +                            "n1:vals":
 +                                { 
 +                                    "n1:hv":
 +                                        "@":
 +                                            "n1:ts": "2023-08-23T10:38:43.786Z", 
 +                                            "n1:gt": "2023-08-23T11:18:00.207Z", 
 +                                            "n1:i": "00:00:30" 
 +                                        }, 
 +                                        "n3:v": "ZAP" 
 +                                    } 
 +                                } 
 +                            ] 
 +                        }, 
 +                        "@":
 +                            "r:type": "177e726a-3180-4152-bef2-6254e7055e1f" 
 +                        } 
 +                    } 
 +                } 
 +            ], 
 +            "@":
 +                "r:type": "1c4c1ddc-463f-443d-883a-19489cd2e53a" 
 +            } 
 +        } 
 +    } 
 +
 + 
 +</code> 
 + 
 +==== [Deprecated] api/get/history====
  
 **Request** **Request**
Line 364: Line 574:
   </vals>   </vals>
 </setHistoryRequest></code> </setHistoryRequest></code>
 +
 +**Response**
 +
 +   * 200 OK
 +
 +====api/replace/history====
 +
 +**Request**
 +
 +   * URL: /api/replace/history?format=xml
 +   * Method: POST
 +   * Content-Type: text/xml
 +
 +Attribute **i** sets **interval** ([[https://en.wikipedia.org/wiki/ISO_8601#Time_intervals|ISO 8601]]) in which the next value should be expected to be saved into a database.
 +
 +Even though there could be used name and password in **cred** - you should always use **token** to get the best performance.
 +
 +All date and time values are supposed to be in UTC.
 +
 +<code xml>
 +<?xml version="1.0" encoding="UTF-8"?>
 +<replaceHistoryRequest xmlns="http://dev.rcware.eu/scada/history" 
 +xmlns:n2="http://dev.rcware.eu/auth" 
 +xmlns:n1="http://dev.rcware.eu/scada/basic-props" 
 +projId="5abf8ca0-94ba-48df-8d3c-7ebe87a12fd0" 
 +dpId="e86dba6d-1250-4e7f-aafb-84fd28324710"
 +from="2020-03-15T11:00:00+00:00"
 +to="2020-03-18T11:00:00+00:00">
 +  <n2:cred t="xxxxx"/><!-- token should be used here -->
 +  <vals>
 +    <hv ts="2020-03-15T11:00:00+00:00" i="P1D">
 +      <n1:v>2.7</n1:v>
 +    </hv>
 +    <hv ts="2020-03-16T11:00:00+00:00" i="P1D">
 +      <n1:v>3.0</n1:v>
 +    </hv>
 +    <hv ts="2020-03-17T11:00:00+00:00" i="P1D">
 +      <n1:v>2.0</n1:v>
 +    </hv>
 +    <hv ts="2020-03-18T11:00:00+00:00" i="P1D">
 +      <n1:v>2.3</n1:v>
 +    </hv>
 +  </vals>
 +</replaceHistoryRequest></code>
  
 **Response** **Response**
Line 396: Line 650:
   </actionDefs>   </actionDefs>
 </executeActionsRequest></code> </executeActionsRequest></code>
 +
 +**Response**
 +
 +<code xml><?xml version="1.0" encoding="utf-8"?>
 +<executeActionsResponse xmlns:r="http://dev.rcware.eu/serialization/references" code="Ok" message="OK" xmlns="http://dev.rcware.eu/scada/error-reporting" /></code>
 +
 +====api/set/values====
 +
 +**Request**
 +
 +   * URL: /api/set/values?format=xml
 +   * Method: POST
 +   * Content-Type: text/xml
 +
 +<code xml>
 +<?xml version="1.0" encoding="UTF-8"?>
 +<setValuesRequest xmlns:r="http://dev.rcware.eu/serialization/references" xmlns="http://dev.rcware.eu/scada/datapoints" xmlns:n2="http://dev.rcware.eu/auth" xmlns:n1="http://dev.rcware.eu/scada/comm-props" >
 +   <n2:cred n="demo" p="demo"/>
 +        <values projId="1b2623be-eaa4-4e29-8596-c66dd85d5643">
 +            <dps>
 +                <d id="07d538d9-9f4b-46ca-ba4d-13b13b5302ff">
 +                    <props>
 +                        <p n="Source" t="2024-02-23T09:58:00Z" r:type="1c104bdf-ffcb-4c90-b491-e4781a91ef09">
 +                            <n1:v>23</n1:v>
 +                        </p>
 +                    </props>
 +                </d>
 +            </dps>
 +        </values>
 +</setValuesRequest></code>
  
 **Response** **Response**
Line 573: Line 857:
  </dps>  </dps>
 </getProjectByPartsResult></code> </getProjectByPartsResult></code>
 +
 +====api/get/projects====
 +
 +To get the list of projects.
 +
 +**Request**
 +
 +   * URL: /api/get/projects?format=xml
 +   * Method: POST
 +
 +<code javascript>
 +{
 + "cred":
 + {
 + "n":"xxx",
 + "p":"xxx"
 + },
 + "offset":0,
 + "count":250
 +}
 +</code>
 +
 +**Response**
 +
 +<code xml><?xml version="1.0" encoding="utf-8"?>
 +<?xml version="1.0" encoding="utf-8"?>
 +<getProjectsResult xmlns:r="http://dev.rcware.eu/serialization/references" xmlns:n1="http://dev.rcware.eu/loc" xmlns:n2="http://dev.rcware.eu/scada/notifications" xmlns:n3="http://dev.rcware.eu/scada/schemas" xmlns:n4="http://dev.rcware.eu/projectMetadata" dataVersion="638761649652581521" xmlns="http://dev.rcware.eu/scada/projects">
 +    <projects>
 +        <project id="00000000-3333-0000-0000-000001000001" name="P0001" domain="PP_Domain_0001" tz="Europe/Prague">
 +            <loc>
 +                <n1:gps lat="0" lon="0" />
 +            </loc>
 +            <mdi>
 +                <mi n2:moduleInstantiated="true" r:type="073d1b6c-24f5-435a-a5bd-1d54e04b0d06" r:def="1" />
 +                <mi n3:totalAllowedSchemasCount="1" n3:totalSchemasCount="1" r:type="aa8818ce-d47d-41ff-9be5-3de9f34d7ebf" />
 +            </mdi>
 +        </project>
 +        <project id="03cd3dd9-e170-4799-bc26-17ac0eccf780" name="aaa" domain="DomainTes1" tz="Europe/Prague">
 +            <mdi>
 +                <mi r:ref="1" r:type="073d1b6c-24f5-435a-a5bd-1d54e04b0d06" />
 +                <mi r:type="1fe100d2-2dbe-4737-bb10-7cf2a19123b2">
 +                    <n3:schemas />
 +                    <n3:schemaGroups />
 +                    <n3:slideShow />
 +                </mi>
 +            </mdi>
 +        </project>
 +    </projects>
 +</getProjectsResult>
 +</code>
 ===== Matlab Client ===== ===== Matlab Client =====
 ==== General notes client function parameters ==== ==== General notes client function parameters ====
  • © Energocentrum Plus, s.r.o. 2017 - 2025