5

I would like to ask if there is a way to easily get the number of pages in the database?

Since I didn't find any endpoint for that, I came up with this not very nice solution:

  let count = 0
  let hasMore = true
  let nextCursor = undefined

  while (hasMore) {
    const result: QueryDatabaseResponse = await notion.databases.query({
      database_id: databaseId,
      start_cursor: nextCursor ?? undefined,
    })
    count += result.results.length
    hasMore = result.has_more
    nextCursor = result.next_cursor
  }

Did I miss something in the documentation?

  • 1
    I've been looking for this too, but haven't been able to come across anything in their documentation or elsewhere. I doubt it currently exists. – Alex MacArthur Aug 10 '22 at 03:09

0 Answers0