Skip to main content
Seasoned ⭐️⭐️⭐️
Aug 15, 2023 5:15 PM UTC
Solved

Parallelize restAPI calls with pagination

Hello, I am trying to use “Filter time series” or “List time series” endpoints. However, because of 1000 limit, I need to parallelize these calls as I would like to retrieve thousands of timeseries. The challenge I am facing is the pagination used in these endpoints which is based on id of timeseries. Is there a way to use index as pagination? 

Expert ⭐️⭐️⭐️⭐️
Aug 18, 2023 4:39 AM UTC

@Diana Chimnaz Johan 

client: CogniteClient = ...

print(f"Max Workers: {client.config.max_workers}") #ensure you have workers >1 :)

timeseries = client.time_series.list(limit=None) #not making use of the workers

timeseries = client.time_series.list(partitions=10, limit=None) #will leverage the workers and run in parallel

-Jason

5 replies

Glen Sykes
Expert ⭐️⭐️⭐️⭐️
Expert ⭐️⭐️⭐️⭐️
Aug 16, 2023 7:35 AM UTC

Hi Diana, have you tried using the parallel retrieval method, using the /partition parameters?

Read here for more information 

 

Glen | Cognite Product Management
Seasoned ⭐️⭐️⭐️
Aug 16, 2023 2:18 PM UTC

Hi Glen, thank you for getting back to me. Can you tell me more about the parallel retrieval method? It sounds like you may have shared a link, but I do not see it. 

Glen Sykes
Expert ⭐️⭐️⭐️⭐️
Expert ⭐️⭐️⭐️⭐️
Aug 16, 2023 8:16 PM UTC

Hi Diane, sorry about that.  Hopefully this link works!

https://developer.cognite.com/dev/concepts/pagination/

Glen | Cognite Product Management
Expert ⭐️⭐️⭐️⭐️
Aug 18, 2023 4:39 AM UTC

@Diana Chimnaz Johan 

client: CogniteClient = ...

print(f"Max Workers: {client.config.max_workers}") #ensure you have workers >1 :)

timeseries = client.time_series.list(limit=None) #not making use of the workers

timeseries = client.time_series.list(partitions=10, limit=None) #will leverage the workers and run in parallel

-Jason

Expert ⭐️⭐️⭐️⭐️
Aug 23, 2023 7:40 AM UTC

@Diana Chimnaz Johan did the above help you?