Get endpoint data incrementally
This API allows retrieving a list of Endpoints incrementally. This enables fast updates of Endpoints without needing to retrieve the full list.
Theory of operation
To obtain a list of Endpoints incrementally, the SequenceNumber field is used. This field is monotonically ascending, meaning that when changes occur in EndpointData, its SequenceNumber field will change to a value higher than any other. This allows retrieving data based on the SequenceNumber in small batches until no more data is obtained, and then continuing periodically to get updates. When the result of this API is an empty list, it means that there are currently no updates.
Typically, an application consuming this API uses the following flow:
- The application starts using a stored SequenceNumber (typically in non-volatile storage). On the first execution, this value is 1.
- The application executes the API using (stored SequenceNumber + 1).
- The application receives a list of Endpoint data, sorted by SequenceNumber.
- If the received list is empty, the application waits a few seconds and returns to step 2.
- If the received list is not empty, the application stores the highest SequenceNumber received.
- The application immediately returns to step 2.
- When there is a new data reading from an Endpoint, its SequenceNumber will immediately change to a value higher than the last received, so its information will be received immediately in the next execution.
| In the flow above, it is assumed that the application always executes the API with the same set of clientID, facilityID, deviceID, and endpointID parameters. If different parameters are desired, the search must start from zero. |
|---|
| For debugging any application using this API, it is recommended to use maxCount = 1, to receive updates one at a time. This parameter can later be changed to a more practical value for production, such as 50. |
|---|
Request
GET /api/v2/endpointData/incremental/{sequenceNumber}?clientID={clientID}&facilityID={facilityID}&deviceID={deviceID}&endpointID={endpointID}&maxCount={maxCount} HTTP/1.1
Host: gear.cloud.studio
Authorization: Bearer {accessToken}Parameters
| Name | Description |
|---|---|
| accessToken | Access token with permissions to read endpoint information. See this page for more information. The access token can also be sent as part of the query string, using the "accessToken" parameter. |
| sequenceNumber | Value of the SequenceNumber field from the last EndpointData received. Use 0 to start from the beginning. |
| clientID | Optional identifier indicating that only EndpointData for the given client should be retrieved. |
| facilityID | Optional identifier indicating that only EndpointData for the given facility should be retrieved. |
| deviceID | Optional identifier indicating that only EndpointData for the given device should be retrieved. |
| endpointID | Optional identifier indicating that only EndpointData for the given endpoint should be retrieved. |
| maxCount | Optional parameter indicating the maximum number of records to include in the result. Values greater than 500 are limited to 500 regardless of the value sent in the request. |
| It is mandatory to include one (and only one) of the parameters "clientID", "facilityID", "deviceID", or "endpointID". |
|---|
Response
The response contains the list of matching EndpointData, as shown in this example:
[
{
"EndpointID": 113653,
"Timestamp_UTC": "2021-10-15T23:01:25",
"Value": 16.93,
"SequenceNumber": 6683852
},
{
"EndpointID": 113653,
"Timestamp_UTC": "2021-10-15T23:11:28",
"Value": 16.97,
"SequenceNumber": 6683864
},
{
"EndpointID": 113653,
"Timestamp_UTC": "2021-10-15T23:41:36",
"Value": 16.93,
"SequenceNumber": 6683874
},
{
"EndpointID": 113653,
"Timestamp_UTC": "2021-10-16T00:01:44",
"Value": 16.99,
"SequenceNumber": 6683887
},
{
"EndpointID": 113653,
"Timestamp_UTC": "2021-10-16T00:11:48",
"Value": 15.93,
"SequenceNumber": 6683900
}
]