0

I have a workspace with 2 databases shared with my integration, basically it works and I get 200 OK code.

That's the function I have, the headers contain the authentication token:

def listDatabases(self):
    r = requests.get('https://api.notion.com/v1/databases', headers=self.headers)
    if r.status_code == 200:
        return r.json()
    else:
        return r.reason

And this is the result:

enter image description here

mkrieger1
  • 19,194
  • 5
  • 54
  • 65
bustrama
  • 61
  • 1
  • 9
  • 1
    What exactly is your question about this? – mkrieger1 May 18 '21 at 09:31
  • I'm suppose to get 2 databases as results, but I get nothing @mkrieger1 – bustrama May 18 '21 at 09:50
  • On Notion API support page, they said to ask here anything related to the API with the 'notion-api' tag – bustrama May 18 '21 at 09:57
  • 1
    Are you 100% sure, you created an integration and shared the databases with those integrations ? https://developers.notion.com/docs/getting-started#share-a-database-with-your-integration And if you have shared it, then double check that the headers are correct, ie. the notion token and version you are using in headers. – nilshah98 May 18 '21 at 14:50
  • 100% sure the headers are correct, I'm also using the Get Database and it's working great – bustrama May 18 '21 at 15:07

2 Answers2

4

I think maybe those database permissions held by integration are inherited from the parent page.

From Notion API Reference (List databases):

Search pages for more details

This endpoint is no longer recommended, use search instead. This endpoint will only return explicitly shared pages, while search will also return child pages within explicitly shared pages.

An easy way to verify is to confirm if "based on xxx" is included under integration in the share option on the database page (not its parent page or inline database). if was, then that database will not return in "list databases" endpoint.

Yukina
  • 109
  • 4
  • I made a page for testing with 2 databases, I shared this page with the integration so it's included – bustrama May 19 '21 at 13:30
  • Please explicitly share those databases one by one, and Notion has no longer recommended to use this endpoint – Yukina May 19 '21 at 15:58
0

I believe it's because you are not sending the database id in the url https://api.notion.com/v1/databases/**database_id**

if you don't specify the database_id it will take the first database which I assume is without any records.

  • I'm using List Databases, not the get method, according to the documentation it suppose to list all databases shared with the authenticated integration. So I don't need any database_id [reference(]https://developers.notion.com/reference/get-databases) – bustrama May 18 '21 at 15:47