Empty results when using Notion API to retrieve workspace content

I’m having trouble fetching content from my Notion workspace using their API. When I try to retrieve all pages and databases, the API call completes successfully but returns no results even though my workspace has multiple pages.

My implementation:

import { Client, LogLevel } from '@notionhq/client'

const notionClient = new Client({
  auth: 'secret_token_here',
  logLevel: LogLevel.DEBUG
})

const workspaceContent = await notionClient.search({})
console.log(workspaceContent)

API Response:

@notionhq/client info: request start { method: 'post', path: 'search' }
@notionhq/client info: request success { method: 'post', path: 'search' }
{ object: 'list', results: [], next_cursor: null, has_more: false }

The request appears to work fine but the results array stays empty. Has anyone encountered this issue before?

I hit this exact problem a few months ago - drove me nuts for hours. It’s definitely your integration permissions, not the code. When you create a Notion integration, you have to manually share each page or database with it. The integration can’t see anything in your workspace by default, even your own stuff. Go to whatever page you want to access, hit the three dots, click “Add connections”, and add your integration. You’ll need to do this for every top-level page or database you want the API to find. Once I did this, my search results showed up instantly with the same code you’re using.

That’s how Notion’s security works. Your integration token only sees resources you’ve explicitly shared with it - it doesn’t get your personal workspace permissions automatically. Even though you created the integration, it’s treated as a separate entity that needs its own access grants. Go check your integration settings in the workspace and make sure you’ve connected it to the specific pages or databases you’re trying to pull. The search endpoint won’t return anything your integration can’t access, which is why you’re getting empty results even though authentication worked. I made this exact mistake when I started using their API last year.

yeah, i had this too! u gotta share each page with the integration in Notion. just go to the page, hit share, and add your integration there. if you skip this step, the API will return empty results even if the call is successful.