0

I have a DB with 106 entries and I can't seem to access the first 6 entries. I tried adding start_cursor and page_size keys to my request but they don't seem to have any effect. If I add them as ints the request gets rejected so I'm adding them as strings - not sure if this is the issue (I also tried converting to bytes). Whatever I do, it seems to return the last 100 results.

import requests
_url = 'https://api.notion.com/v1/databases/xxxxx/query'
_header = {
    'Authorization': _auth,
    'Content-Type': 'application/json',
    'Notion-Version': '2021-08-16',
    'page_size': '3',
    'start_cursor': '0'}
_result = requests.post(_url, headers=_header)

Any idea how I can get all the results, or change my request to get the first six results?

ninhenzo64
  • 702
  • 1
  • 9
  • 23

2 Answers2

0

As it said in the documentation, you can retrieve no more than 100 items per one request, but you can send many consecutive requests. You need to grab the property next_cursor from the response to the previous request and then pass it as a parameter start_cursor in your next request. While the has_more property is True, you can get more and more items.

0

I was adding the data wrong - it needs to be added like this:

_data = {'start_cursor': _next_cursor}
requests.post(_url, headers=self.to_header(), data=json.dumps(_data))
ninhenzo64
  • 702
  • 1
  • 9
  • 23