7

I'm trying to get all the pages of my Notion workspace but the search method returns an empty response while there is pages on my personal workspace.

Code :

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

const notion = new Client({
  auth: '<hidden>',
  logLevel: LogLevel.DEBUG
})

const databasesQuery = await notion.search({})
console.log(databasesQuery)

Output

@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 }
Xstoudi
  • 112
  • 6

3 Answers3

20

sorry for the late reply but I just ran into the same issue.

I think it's because you haven't shared any pages with your integration. As far as I know from my own testing you have to share each page with your integration for the search request to work, even if it's your own notion workspace :/

Matias
  • 231
  • 2
  • 3
5

I've just spent 5 hours on this. Matias answer is correct, but as for the new UI in notion, this is no longer available via the "Share" button, but instead you can find the "Share integration" under the three dot icon, as described here

Gomez
  • 81
  • 1
  • 5
3

Here is the latest way to do it

Go to the 3 dots on your page -> connections -> add connection -> select your connection and/or integration