Pagination with Notion API and PowerShell

As I have written in this Post Work with NOTION API and PowerShell – TechGuy, I recently started with Notion as my central Planning and Note Tool. So I immediately reached a lot of ToDos in my Database.

As you can read in this Notion Documentation Pagination (, the Result Size is always 100 for each API Query. So as I have more than 100 Tasks in my Database, I had to deal with the Paging in Notion API and my PowerShell Script.

The Notion PowerShell Script

So, Notion sends “has_more” and “next_cursor” when the query returns more than 100 Results. So See the Script on how we deal with that.

$NotionAPIKey="Your Secret"
$DatabaseID="Your Database ID"

$Notionheaders = @{
    "Authorization"  = "Bearer $($NotionAPIKey)"
    "Content-type"   = "application/json"
    "Notion-Version" = "2021-08-16"

$Cursor = $False
$AllNotionTasks = @()

do {
    if (!($Cursor)) {
        $Result = Invoke-RestMethod -Uri "$DatabaseID/query" -Method Post -Headers $Notionheaders
    else {
        $JsonBody = @"
        $Result = Invoke-RestMethod -Uri "$DatabaseID/query" -Method Post -Headers $Notionheaders -Body $JsonBody
    if ($Result.has_more) { $Cursor = $Result.next_cursor }

    $AllNotionTasks += $Result
} until (!($Result.has_more))




All Notion examples can be found in my GitHub Repo: Seidlm/NOTION-PowerShell: PowerShell Scripts to work with NOTION (

Michael Seidl, aka Techguy
au2mate, everything

1 thought on “Pagination with Notion API and PowerShell”

  1. Pingback: Add a Page to a Notion Database with PowerShell - TechGuy

Leave a Comment

Your email address will not be published. Required fields are marked *