Solved

Fetching latest timeseries datapoint - API Quota?

  • 24 August 2023
  • 5 replies
  • 82 views

We’re in development of an API retrieving the latest values from timeseries from CDF using the C# SDK. Initially we set the code to look 200 days back (‘200d-ago’). Now, this stopped working all of a sudden this week. My first reaction was to go event further back (‘365d-ago’), but what works is using an even shorter timespan (‘30d-ago’).

So question is - are we limited by a quota or have there been changes limiting this functionality lately?

icon

Best answer by matiasholte 4 September 2023, 10:50

View original

5 replies

Userlevel 2

Hi
I’m not familiar with the C# SDK, which method are you using?

As for retrieving the latest value of a time series, I would use the /timeseries/data/latest endpoint:
https://api-docs.cognite.com/20230101/tag/Time-series/operation/getLatest

That method takes a single parameter, before, and you’ll get the latest data point that is before before. There is no start parameter, we will search back to the beginning of time if necessary.

So in your case, I would expect that what works is to use “now” as the time stamp (or leave it blank). I’m assuming you’re not ingesting data points into the future, if you do, you will have to specify an absolute timestamp in ms since epoch.

If you’re limited by a quota, we will return a 429 response code, but you need to use a very heavy script for that to trigger.

None of this functionality has changed lately, but as I said, I’m not familiar with the C# SDK, and I don’t know how it translates into API calls. There might be some bugs in the SDK that I’m not aware of.

Userlevel 3

Hi @Anders Nygaard, did the above help you?

@Carin Meems well, we do 1500+ requests for latests values in quick succession. I find  no easy way of finding assets by metadata, grabbing properties from the corresponding timeseries and retrieving the latest values without making hundreds and thousands of queries to the APIs. It’s plausible we hit the quota...

Userlevel 2

Hi Anders!
The /data/latest endpoint can query for 100 time series at a time, which may help somewhat. If you still hit the quota and receive 429, the best practice is to add some delays between each request.

We do also have a brand new functionality, which may help your use case, namely subscriptions.
With subscriptions, you can ask for recent changes to up to 10.000 time series at a time. We also have a filter subscription, where you will get updates to all time series that matches a search filter.

The functionality is still in beta, hence the conservative limit of 10k time series, and as far as I know, only the python SDK supports it at the moment.

If you have any questions, feel free to ask!

Userlevel 2

See also the subscriptions group on cognite hub https://hub.cognite.com/groups/time-series-subscriptions-early-adopter-247

Reply