Retrieves the latest data point in one or more time series. Note that the latest data point in a time series is the one with the highest timestamp, which is not necessarily the one that was ingested most recently.
The list of the queries to perform.
A list of responses. Each response contains a list with the most recent data point or an empty list if no data points are found.
IDs not found.
res = client.time_series.data.retrieve_latest(id=1)[0] res = client.time_series.data.retrieve_latest(id=1, before="2d-ago")[0] res = client.time_series.data.retrieve_latest(id=1, target_unit="temperature:deg_f")[0] res = client.time_series.data.retrieve_latest(id=1, target_unit_system="Imperial")[0] from cognite.client.data_classes import LatestDatapointQuery res = client.time_series.data.retrieve_latest(id=LatestDatapointQuery(id=1, before=60_000))[0] res = client.time_series.data.retrieve_latest(external_id=["abc", "def"]) latest_abc = res[0][0] latest_def = res[1][0] from datetime import datetime, timezone id_queries = [ 123, LatestDatapointQuery(id=456, before="1w-ago"), LatestDatapointQuery(id=789, before=datetime(2018,1,1, tzinfo=timezone.utc)), LatestDatapointQuery(id=987, target_unit="temperature:deg_f")] ext_id_queries = [ "foo", LatestDatapointQuery(external_id="abc", before="3h-ago", target_unit_system="Imperial"), LatestDatapointQuery(external_id="def", include_status=True), LatestDatapointQuery(external_id="ghi", treat_uncertain_as_bad=False), LatestDatapointQuery(external_id="jkl", include_status=True, ignore_bad_datapoints=False)] res = client.time_series.data.retrieve_latest( id=id_queries, external_id=ext_id_queries)
{- "items": [
- {
- "id": 1,
- "externalId": "string",
- "instanceId": {
- "space": "string",
- "externalId": "string"
}, - "isString": true,
- "isStep": true,
- "unit": "string",
- "unitExternalId": "string",
- "nextCursor": "string",
- "datapoints": [
- {
- "timestamp": 1638795554528,
- "value": 0,
- "status": {
- "code": 0,
- "symbol": "string"
}
}
]
}
]
}