May I ask how do I put in the start time, end time, frequency filters? Thanks!
May I ask how do I put in the start time, end time, frequency filters? Thanks!
Hi Guangyi ,
The Stream GetRecorded action takes in starttime and endtime parameter.
If you'd like to 'sample' data from the recorded values, then please try Stream GetInterpolated instead.
Please also note that there is a bulk version of streams, streamset if you'd like a multiple datapulls at once.
Hi (Missing Content),
I found the Time Strings page, but I'm still having trouble passing the dates I'd like to request. For example, if I want to request data from 1/1/23-2/1/23, what would the datetime format be?
Thanks (Missing Content), I got the call to work however I've run into another issue where the response only contains eight days worth of data instead of the requested month's worth. Do you happen to know why this would be? I've already verified that the tag contains all of the data I'm calling for.
(Missing Content) I've verified the data via the Excel add-in (pulls the whole month) and also plotting it in PI Vision. I'm unsure which piwebapi controller I'm querying.
(Missing Content) Apologies, thought you meant something else. My controller/endpoint is the same (/streams/[WebId]/recorded). The data for the tag I'm calling is already structured how I need it, I'm just running into this roadblock for some reason as far as automation goes. Could it be a server configuration for the API?
Hi Mike Rugh ,
I imagine you could put one as:
startTime=Jan 1 2023&endTime=Feb 1 2023.
Typically it's good to insert the year with 4 digits.
I'll need more detail to understand your issue. May I ask how you verified your data? and which piwebapi controller did you query data from?
Mike Rugh , The piwebapi controller can be found from the URL you are querying.
In the case above, it's /streams/<WebIDs>/recorded.
Excel(PI DataLink) functions could also be broken further into getting Sampled(interpolated) data and compressed(recorded) data.
maxCount parameter limits API to return only 1k rows, data points back.
You could try modifying this param.
/streams/webid/recorded?start&end&maxCount=xxxxx
Thanks (Missing Content) , now I have one more issue to solve... using the boundary params/types. I'm requesting two tags, one returns data at 10 minute intervals and the other at 1 minute intervals.
If I pass 01/01/2023 00:00:00 to 02/01/2023 00:00:00 for example, the data start point will be 01/01/2023 00:00:00 + one interval, and the end point will be 02/01/2023 00:00:00. I need that whole range shifted back one interval so the start is 00:00:00 and the end is 00:00:00 - 1 interval. Can I do that with the boundary param?
(Missing Content) Thanks, it was a problem on my end, didn't realize I was passing milliseconds too. One more thing, on DST (11/5/23) it's only passing the 24 hours when I'm expecting 25 (I validated with PI Data Link, which has 25 hours). Trying to figure out if that's a me problem or an API problem. My guess is the API will populate the JSON object with the 01:xx timestamps, and then repopulate them with the newest values because it would be a duplicate key:value pair.
Sure, I'm expecting to see operating hour 01 to be repeated. Please see the calls and responses below:
PI Data Link Query:
=PICompDat("PI_TAG","11/01/2023","12/01/2023",1,"","inside")
PI Data Link Response Snippet:
05-Nov-23 00:00:00 28.2246418 05-Nov-23 00:10:00 -144.0289612 05-Nov-23 00:20:00 19.67341805 05-Nov-23 00:30:00 -49.99599457 05-Nov-23 00:40:00 102.5537949 05-Nov-23 00:50:00 109.2017746 05-Nov-23 01:00:00 92.88484192 05-Nov-23 01:10:00 137.7048187 05-Nov-23 01:20:00 147.2772827 05-Nov-23 01:30:00 61.2579155 05-Nov-23 01:40:00 15.768363 05-Nov-23 01:50:00 119.312355 05-Nov-23 01:00:00 73.52394104 05-Nov-23 01:10:00 107.8926926 05-Nov-23 01:20:00 137.6197815 05-Nov-23 01:30:00 90.47686768 05-Nov-23 01:40:00 14.6219759 05-Nov-23 01:50:00 66.63463593 05-Nov-23 02:00:00 29.79430008
Python call:
response = session.get(f"{base_url}streams/{web_id}/recorded", params=params)
params = {
"startTime": start_time, (passed as 11/01/2023 00:00:00.00
"endTime": end_time, (passed as 12/01/2023 00:00:00.00
"maxCount": '50000',
"timezone": 'UTC-08',
"includeFilteredValues": 'false',
}
JSON Response Snippet:
{'Timestamp': '2023-11-05T08:00:00Z', 'Value': 92.88484, 'UnitsAbbreviation': '', 'Good': True, 'Questionable': False, 'Substituted': False, 'Annotated': False},
{'Timestamp': '2023-11-05T08:10:00Z', 'Value': 137.704819, 'UnitsAbbreviation': '', 'Good': True, 'Questionable': False, 'Substituted': False, 'Annotated': False},
{'Timestamp': '2023-11-05T08:20:00Z', 'Value': 147.277283, 'UnitsAbbreviation': '', 'Good': True, 'Questionable': False, 'Substituted': False, 'Annotated': False},
{'Timestamp': '2023-11-05T08:30:00Z', 'Value': 61.2579155, 'UnitsAbbreviation': '', 'Good': True, 'Questionable': False, 'Substituted': False, 'Annotated': False},
{'Timestamp': '2023-11-05T08:40:00Z', 'Value': 15.768363, 'UnitsAbbreviation': '', 'Good': True, 'Questionable': False, 'Substituted': False, 'Annotated': False},
{'Timestamp': '2023-11-05T08:50:00Z', 'Value': 119.312355, 'UnitsAbbreviation': '', 'Good': True, 'Questionable': False, 'Substituted': False, 'Annotated': False},
{'Timestamp': '2023-11-05T09:00:00Z', 'Value': 73.52394, 'UnitsAbbreviation': '', 'Good': True, 'Questionable': False, 'Substituted': False, 'Annotated': False},
{'Timestamp': '2023-11-05T09:10:00Z', 'Value': 107.892693, 'UnitsAbbreviation': '', 'Good': True, 'Questionable': False, 'Substituted': False, 'Annotated': False},
{'Timestamp': '2023-11-05T09:20:00Z', 'Value': 137.619781, 'UnitsAbbreviation': '', 'Good': True, 'Questionable': False, 'Substituted': False, 'Annotated': False},
{'Timestamp': '2023-11-05T09:30:00Z', 'Value': 90.47687, 'UnitsAbbreviation': '', 'Good': True, 'Questionable': False, 'Substituted': False, 'Annotated': False},
{'Timestamp': '2023-11-05T09:40:00Z', 'Value': 14.6219759, 'UnitsAbbreviation': '', 'Good': True, 'Questionable': False, 'Substituted': False, 'Annotated': False},
{'Timestamp': '2023-11-05T09:50:00Z', 'Value': 66.6346359, 'UnitsAbbreviation': '', 'Good': True, 'Questionable': False, 'Substituted': False, 'Annotated': False},
{'Timestamp': '2023-11-05T10:00:00Z', 'Value': 29.7943, 'UnitsAbbreviation': '', 'Good': True, 'Questionable': False, 'Substituted': False, 'Annotated': False},
Sure, I'm expecting to see operating hour 01 to be repeated. Please see the calls and responses below:
PI Data Link Query:
=PICompDat("PI_TAG","11/01/2023","12/01/2023",1,"","inside")
PI Data Link Response Snippet:
05-Nov-23 00:00:00 28.2246418 05-Nov-23 00:10:00 -144.0289612 05-Nov-23 00:20:00 19.67341805 05-Nov-23 00:30:00 -49.99599457 05-Nov-23 00:40:00 102.5537949 05-Nov-23 00:50:00 109.2017746 05-Nov-23 01:00:00 92.88484192 05-Nov-23 01:10:00 137.7048187 05-Nov-23 01:20:00 147.2772827 05-Nov-23 01:30:00 61.2579155 05-Nov-23 01:40:00 15.768363 05-Nov-23 01:50:00 119.312355 05-Nov-23 01:00:00 73.52394104 05-Nov-23 01:10:00 107.8926926 05-Nov-23 01:20:00 137.6197815 05-Nov-23 01:30:00 90.47686768 05-Nov-23 01:40:00 14.6219759 05-Nov-23 01:50:00 66.63463593 05-Nov-23 02:00:00 29.79430008
Python call:
response = session.get(f"{base_url}streams/{web_id}/recorded", params=params)
params = {
"startTime": start_time, (passed as 11/01/2023 00:00:00.00
"endTime": end_time, (passed as 12/01/2023 00:00:00.00
"maxCount": '50000',
"timezone": 'UTC-08',
"includeFilteredValues": 'false',
}
JSON Response Snippet:
{'Timestamp': '2023-11-05T08:00:00Z', 'Value': 92.88484, 'UnitsAbbreviation': '', 'Good': True, 'Questionable': False, 'Substituted': False, 'Annotated': False},
{'Timestamp': '2023-11-05T08:10:00Z', 'Value': 137.704819, 'UnitsAbbreviation': '', 'Good': True, 'Questionable': False, 'Substituted': False, 'Annotated': False},
{'Timestamp': '2023-11-05T08:20:00Z', 'Value': 147.277283, 'UnitsAbbreviation': '', 'Good': True, 'Questionable': False, 'Substituted': False, 'Annotated': False},
{'Timestamp': '2023-11-05T08:30:00Z', 'Value': 61.2579155, 'UnitsAbbreviation': '', 'Good': True, 'Questionable': False, 'Substituted': False, 'Annotated': False},
{'Timestamp': '2023-11-05T08:40:00Z', 'Value': 15.768363, 'UnitsAbbreviation': '', 'Good': True, 'Questionable': False, 'Substituted': False, 'Annotated': False},
{'Timestamp': '2023-11-05T08:50:00Z', 'Value': 119.312355, 'UnitsAbbreviation': '', 'Good': True, 'Questionable': False, 'Substituted': False, 'Annotated': False},
{'Timestamp': '2023-11-05T09:00:00Z', 'Value': 73.52394, 'UnitsAbbreviation': '', 'Good': True, 'Questionable': False, 'Substituted': False, 'Annotated': False},
{'Timestamp': '2023-11-05T09:10:00Z', 'Value': 107.892693, 'UnitsAbbreviation': '', 'Good': True, 'Questionable': False, 'Substituted': False, 'Annotated': False},
{'Timestamp': '2023-11-05T09:20:00Z', 'Value': 137.619781, 'UnitsAbbreviation': '', 'Good': True, 'Questionable': False, 'Substituted': False, 'Annotated': False},
{'Timestamp': '2023-11-05T09:30:00Z', 'Value': 90.47687, 'UnitsAbbreviation': '', 'Good': True, 'Questionable': False, 'Substituted': False, 'Annotated': False},
{'Timestamp': '2023-11-05T09:40:00Z', 'Value': 14.6219759, 'UnitsAbbreviation': '', 'Good': True, 'Questionable': False, 'Substituted': False, 'Annotated': False},
{'Timestamp': '2023-11-05T09:50:00Z', 'Value': 66.6346359, 'UnitsAbbreviation': '', 'Good': True, 'Questionable': False, 'Substituted': False, 'Annotated': False},
{'Timestamp': '2023-11-05T10:00:00Z', 'Value': 29.7943, 'UnitsAbbreviation': '', 'Good': True, 'Questionable': False, 'Substituted': False, 'Annotated': False},