Hi community,
I’m learning to use the /models/instances/query endpoint (with Open Industrial Data, public project) and experiencing some confusion about how cursors and pagination work.
{
"with": {
"cities": {
"nodes": {
"filter": {
"and": [
{
"exists": {
"property": [
"Geography",
"City",
"name"
]
}
}
]
}
}
},
"continents": {
"nodes": {
"filter": {
"and": [
{
"exists": {
"property": [
"Geography",
"Continent",
"name"
]
}
}
]
}
}
}
},
"select": {
"cities": {
"sources": [
{
"source": {
"type": "view",
"space": "Geography",
"externalId": "City",
"version": "1"
},
"properties": [
"continent",
"country",
"name",
"iso2",
"iso3",
"population"
]
}
]
},
"continents": {
"sources": [
{
"source": {
"type": "view",
"space": "Geography",
"externalId": "Continent",
"version": "1"
},
"properties": [
"name"
]
}
]
}
}
}
I built the following query (see above) to fetch cities and continents. I sent the request with no cursors, and got this response: "nextCursor" with both "cities" and "continents", "items" with 100 cities and 6 continents
So, for the next request, I put nextCursor values into the "cursors" field. This time, I only get a nextCursor for cities, and the items are 100 cities and 0 continents.
For the third request, I use the new cursor. And I get 100 more cities, but for continents, I again get the same 6 as in the first request.
Actually I just want to get all cities and continents with the cursors without expecting I might get repeated data.
I want to know:
- Is this the correct usage for pagination with multiple entities?
- Is there a recommended best practice for getting all data when querying multiple collections like this?
Additionally, I tried to use data_modeling.instances.query in the Python SDK, but it seems there’s no auto-pagination and I need to pass cursors manually in each call.
Thanks!
Check the
documentation
Ask the
Community
Take a look
at
Academy
Cognite
Status
Page
Contact
Cognite Support