Use Watchlist to query for multiple datapoint History
-
I was hoping someone might be able to suggest the most efficient way to accomplish the following -
A customer has multiple datapoints across multiple datasources. These are identified by a customerId tag tied to each datapoint. I would like to retrieve the last 10 days of readings for all of the datapoints associated with any given customerId via the API.
What is the best way to accomplish this? Is this a two step process or can this be accomplished by a single API call?
Possibly using the customerId tag to create a watchlist, but how can I query a watchlist for 10 day history?
When viewing the watchlist using developers tools I see it looping through the points associated with the list to retrieve the value, how would one accomplish this via the API?Thank you
-
@wingnut2-0 said in Use Watchlist to query for multiple datapoint History:
What is the best way to accomplish this? Is this a two step process or can this be accomplished by a single API call?
You need to query for the data points first and then query for the point values. Use the v2 point values end point for getting values for multiple points at once. Use the POST request instead of GET as you will probably have issues with the URL being to long if you use the GET variant.
We are actually looking at making a single endpoint where you can just get point values using a query on tags etc so stay tuned.
-
Thanks Jared. I am looking forward to the single endpoint.
I am attempting this using POST /v2/point-values/multiple-arrays/time-period with the body below, but I receive a response code of 400 and response header message of "error". Is there any additional documentation outside of swagger?
{ "xids": [ "DP_value_a", "DP_value_b" ], "dateTimeFormat": "", "timezone": "", "limit": 0, "simplifyTolerance": 0, "simplifyTarget": 0, "fields": [ "" ], "from": { "offset": { "totalSeconds": 0, "id": "", "rules": { "transitions": [ { "offsetBefore": "ZoneOffset", "offsetAfter": "ZoneOffset", "dateTimeBefore": { "monthValue": 0, "dayOfYear": 0, "dayOfWeek": "", "month": "", "dayOfMonth": 0, "year": 0, "nano": 0, "hour": 0, "minute": 0, "second": 0, "chronology": { "calendarType": "", "id": "" } }, "instant": { "epochSecond": 0, "nano": 0 }, "gap": false, "overlap": false, "dateTimeAfter": { "monthValue": 0, "dayOfYear": 0, "dayOfWeek": "", "month": "", "dayOfMonth": 0, "year": 0, "nano": 0, "hour": 0, "minute": 0, "second": 0, "chronology": { "calendarType": "", "id": "" } }, "duration": { "seconds": 0, "units": [ { "dateBased": false, "durationEstimated": false, "duration": "Duration", "timeBased": false } ], "negative": false, "zero": false, "nano": 0 } } ], "transitionRules": [ { "month": "", "timeDefinition": "", "standardOffset": "ZoneOffset", "offsetBefore": "ZoneOffset", "offsetAfter": "ZoneOffset", "dayOfMonthIndicator": 0, "localTime": { "hour": "", "minute": "", "second": "", "nano": 0 }, "midnightEndOfDay": false, "dayOfWeek": "" } ], "fixedOffset": false } }, "zone": { "rules": { "transitions": [ { "offsetBefore": { "totalSeconds": 0, "id": "", "rules": "ZoneRules" }, "offsetAfter": { "totalSeconds": 0, "id": "", "rules": "ZoneRules" }, "dateTimeBefore": { "monthValue": 0, "dayOfYear": 0, "dayOfWeek": "", "month": "", "dayOfMonth": 0, "year": 0, "nano": 0, "hour": 0, "minute": 0, "second": 0, "chronology": { "calendarType": "", "id": "" } }, "instant": { "epochSecond": 0, "nano": 0 }, "gap": false, "overlap": false, "dateTimeAfter": { "monthValue": 0, "dayOfYear": 0, "dayOfWeek": "", "month": "", "dayOfMonth": 0, "year": 0, "nano": 0, "hour": 0, "minute": 0, "second": 0, "chronology": { "calendarType": "", "id": "" } }, "duration": { "seconds": 0, "units": [ { "dateBased": false, "durationEstimated": false, "duration": "Duration", "timeBased": false } ], "negative": false, "zero": false, "nano": 0 } } ], "transitionRules": [ { "month": "", "timeDefinition": "", "standardOffset": { "totalSeconds": 0, "id": "", "rules": "ZoneRules" }, "offsetBefore": { "totalSeconds": 0, "id": "", "rules": "ZoneRules" }, "offsetAfter": { "totalSeconds": 0, "id": "", "rules": "ZoneRules" }, "dayOfMonthIndicator": 0, "localTime": { "hour": "", "minute": "", "second": "", "nano": 0 }, "midnightEndOfDay": false, "dayOfWeek": "" } ], "fixedOffset": false }, "id": "" }, "monthValue": 6, "dayOfYear": 0, "dayOfWeek": "", "month": "", "dayOfMonth": 10, "year": 2018, "nano": 0, "hour": 0, "minute": 0, "second": 0, "chronology": { "calendarType": "", "id": "" } }, "to": { "offset": { "totalSeconds": 0, "id": "", "rules": { "transitions": [ { "offsetBefore": "ZoneOffset", "offsetAfter": "ZoneOffset", "dateTimeBefore": { "monthValue": 0, "dayOfYear": 0, "dayOfWeek": "", "month": "", "dayOfMonth": 0, "year": 0, "nano": 0, "hour": 0, "minute": 0, "second": 0, "chronology": { "calendarType": "", "id": "" } }, "instant": { "epochSecond": 0, "nano": 0 }, "gap": false, "overlap": false, "dateTimeAfter": { "monthValue": 0, "dayOfYear": 0, "dayOfWeek": "", "month": "", "dayOfMonth": 0, "year": 0, "nano": 0, "hour": 0, "minute": 0, "second": 0, "chronology": { "calendarType": "", "id": "" } }, "duration": { "seconds": 0, "units": [ { "dateBased": false, "durationEstimated": false, "duration": "Duration", "timeBased": false } ], "negative": false, "zero": false, "nano": 0 } } ], "transitionRules": [ { "month": "", "timeDefinition": "", "standardOffset": "ZoneOffset", "offsetBefore": "ZoneOffset", "offsetAfter": "ZoneOffset", "dayOfMonthIndicator": 0, "localTime": { "hour": "", "minute": "", "second": "", "nano": 0 }, "midnightEndOfDay": false, "dayOfWeek": "" } ], "fixedOffset": false } }, "zone": { "rules": { "transitions": [ { "offsetBefore": { "totalSeconds": 0, "id": "", "rules": "ZoneRules" }, "offsetAfter": { "totalSeconds": 0, "id": "", "rules": "ZoneRules" }, "dateTimeBefore": { "monthValue": 0, "dayOfYear": 0, "dayOfWeek": "", "month": "", "dayOfMonth": 0, "year": 0, "nano": 0, "hour": 0, "minute": 0, "second": 0, "chronology": { "calendarType": "", "id": "" } }, "instant": { "epochSecond": 0, "nano": 0 }, "gap": false, "overlap": false, "dateTimeAfter": { "monthValue": 0, "dayOfYear": 0, "dayOfWeek": "", "month": "", "dayOfMonth": 0, "year": 0, "nano": 0, "hour": 0, "minute": 0, "second": 0, "chronology": { "calendarType": "", "id": "" } }, "duration": { "seconds": 0, "units": [ { "dateBased": false, "durationEstimated": false, "duration": "Duration", "timeBased": false } ], "negative": false, "zero": false, "nano": 0 } } ], "transitionRules": [ { "month": "", "timeDefinition": "", "standardOffset": { "totalSeconds": 0, "id": "", "rules": "ZoneRules" }, "offsetBefore": { "totalSeconds": 0, "id": "", "rules": "ZoneRules" }, "offsetAfter": { "totalSeconds": 0, "id": "", "rules": "ZoneRules" }, "dayOfMonthIndicator": 0, "localTime": { "hour": "", "minute": "", "second": "", "nano": 0 }, "midnightEndOfDay": false, "dayOfWeek": "" } ], "fixedOffset": false }, "id": "" }, "monthValue": 6, "dayOfYear": 0, "dayOfWeek": "", "month": "", "dayOfMonth": 15, "year": 2018, "nano": 0, "hour": 0, "minute": 0, "second": 0, "chronology": { "calendarType": "", "id": "" } }, "bookend": false, "useCache": "" }
-
@Wingnut2-0 sorry, swagger led you astray with that one..
It should look like this. You can play around with it by opening up the new watch list page, click the download button then watch the requests in developer tools.
{ "dateTimeFormat":"yyyy-MM-dd'T'HH:mm:ss.SSSXXX", "from":"2018-06-19T15:34:26.804Z", "to":"2018-06-19T16:34:26.805Z", "bookend":true, "timezone":"America/Los_Angeles", "fields":[ "XID", "DATA_SOURCE_NAME", "DEVICE_NAME", "NAME", "TIMESTAMP", "VALUE", "RENDERED" ], "xids":[ "binary", "DP_253536", "multistate", "temperature", "voltage", "zero_to_hundred" ] }
-
Wow, that is certainly much easier to deal with.
When you say the "new watch list page" are you referring to :8080/ui/watch-list/ , or creating a new watch list via the builder 8080/ui/administration/watch-list-builder/?
-
@wingnut2-0 said in Use Watchlist to query for multiple datapoint History:
are you referring to :8080/ui/watch-list/
Yes.