Retrieve latest data point

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.

Securityoidc-token or oauth2-client-credentials or oauth2-open-industrial-data or oauth2-auth-code
Request
Request Body schema: application/json
required

The list of the queries to perform.

required
Array of QueryWithInternalId (object) or QueryWithExternalId (object) or QueryWithInstanceId (object) (LatestDataBeforeRequest) [ 1 .. 100 ] items

List of latest queries

ignoreUnknownIds
boolean
Default: false

Ignore IDs and external IDs that are not found

Responses
200

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.

400

IDs not found.

post/timeseries/data/latest
Request samples
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)
Response samples
application/json
{
  • "items": [
    • {
      }
    ]
}