I can get the paginated list of children for a given database with https://api.notion.com/v1/databases/:id/query. But can I get the current number of children anywhere?
Asked
Active
Viewed 619 times
2 Answers
2
The API does not have offer a count of results in the current version of the API (Notion-Version: 2021-05-13).

adlopez15
- 3,449
- 2
- 14
- 19
0
If you want the number of pages (children) in the database, assuming it is javascript.
<!DOCTYPE html>
<html>
<body>
<p>Click the button to create an array, then display its length.</p>
<button onclick="myFunction()">Find Length</button>
<p id="demo"></p>
<script>
function myFunction() {
var data = {
"object": "list",
"results": [{
"object": "page",
"id": "2e01e904-febd-43a0-ad02-8eedb903a82c",
"created_time": "2020-03-17T19:10:04.968Z",
"last_edited_time": "2020-03-17T21:49:37.913Z",
"parent": {
"type": "database_id",
"database_id": "897e5a76-ae52-4b48-9fdf-e71f5945d1af"
},
"archived": false,
"properties": {
"Recipes": {
"id": "Ai`L",
"type": "relation",
"relation": [{
"id": "796659b4-a5d9-4c64-a539-06ac5292779e"
},
{
"id": "79e63318-f85a-4909-aceb-96a724d1021c"
}
]
},
"Cost of next trip": {
"id": "R}wl",
"type": "formula",
"formula": {
"type": "number",
"number": 2
}
},
"Last ordered": {
"id": "UsKi",
"type": "date",
"date": {
"start": "2020-10-07",
"end": null
}
},
"In stock": {
"id": "{>U;",
"type": "checkbox",
"checkbox": false
}
}
},
{
"object": "page",
"id": "2e01e904-febd-43a0-ad02-8eedb903a82c",
"created_time": "2020-03-17T19:10:04.968Z",
"last_edited_time": "2020-03-17T21:49:37.913Z",
"parent": {
"type": "database_id",
"database_id": "897e5a76-ae52-4b48-9fdf-e71f5945d1af"
},
"archived": false,
"properties": {
"Recipes": {
"id": "Ai`L",
"type": "relation",
"relation": [{
"id": "796659b4-a5d9-4c64-a539-06ac5292779e"
},
{
"id": "79e63318-f85a-4909-aceb-96a724d1021c"
}
]
},
"Cost of next trip": {
"id": "R}wl",
"type": "formula",
"formula": {
"type": "number",
"number": 2
}
},
"Last ordered": {
"id": "UsKi",
"type": "date",
"date": {
"start": "2020-10-07",
"end": null
}
},
"In stock": {
"id": "{>U;",
"type": "checkbox",
"checkbox": false
}
}
}
],
"has_more": false,
"next_cursor": null
}
document.getElementById("demo").innerHTML = data.results.length;
}
</script>
</body>
</html>

Quan You
- 117
- 4
-
This way I would have to request everything and then check it in my backend/frontend. The maximum number of results the API sends in the response is 100 per page. For a big database I would have to make multiple requests just to check the length of the list. It seems hugely inefficient. – gorniczy May 21 '21 at 05:10
-
Unfortunately, Notion doesn't have an effortlessly way to return the total item in a database. – Quan You May 21 '21 at 05:48