25

I have been using notion to track my habits and my finances. Now I want to get the data from the database using the Notion API. But the notion API requires Database ID and I can't seem to find it.

5 Answers 5

45

The official documentation is probably outdated or at least not working for UK users.


If your URL looks like below, then <long_hash_1> is the database ID and <long_hash_2> is the view ID.

https://www.notion.so/<long_hash_1>?v=<long_hash_2>
                                  

You must add your integration to the database!

Click the 3 dots, under Connections, there is an Add connections button.


If you still haven't found your URL, you can get it from either the web client or an APP client:

  • If you are using the web client, go to the database view (e.g. board view), and the URL is can be found in your browser's address bar.
  • If you are using APP client, go to the database view (e.g. board view), and click/tap the share button. Copy the invite link (lower bottom corner as in Windows APP) and the link is your URL.
2
  • 2
    share button did the trick for me! thanks
    – mike.f
    Dec 14, 2021 at 23:07
  • The docs should update itself with this. Feb 5 at 11:35
15

If this is just for yourself, you can get the database ID from the URL of the page:

  • If you're using the Notion desktop app, click on the Share button once again and select Copy link. Paste and navigate to this URL in your browser. You may need to log into the Notion workspace if you haven't already. Follow the instructions for the browser in the next bullet.

  • If you're using Notion in a browser and viewing the database as a full page, the database ID is the part of the URL after your workspace name and the slash (acme/) and before the question mark (?). The ID is 32 characters long, containing numbers and letters. Copy the ID and paste it somewhere you can easily find later.

https://www.notion.so/myworkspace/a8aec43384f447ed84390e8e42c2e089?v=...
                                  |--------- Database ID --------|

If you are creating an integration for others, you can use the Search endpoint to get all databases your integration has access to. There is also a List databases endpoint, but apparently this is deprecated.

4
  • 1
    hmm I'm not able to arrive at https://www.notion.so/<myworkspace>/a8aec43384f447ed84390e8e42c2e089?v=.. in my broswer. It always just goes to a page Jun 16, 2021 at 11:50
  • I understand it now; database is really just a page with /table Jun 19, 2021 at 20:18
  • so it's not really the database of a workspace containing all its pages ha.. Jun 19, 2021 at 20:20
  • I only have an url shaped like : https://www.notion.so/<some id or hash...>?v=<some id or hash ...>
    – imrok
    Jul 8, 2021 at 6:58
3

Since I was stuck here for a good [redacted] length of time, I will the clarification that if your URL looks like:

https://www.notion.so/<workspace>/pamela-writings-fa1d12278d9e42d8b50e281a41fdd645

Then you do not need a database ID because this is a page not a database. So you would want the pageId.

I mistakenly though that "everything is a database".

Using the above url example, the page Id would be fa1d12278d9e42d8b50e281a41fdd645

Usage Example:


def readPage(pageId, headers):
    readUrl = f"https://api.notion.com/v1/pages/{pageId}"
    res = requests.get(readUrl, headers=headers)
    print(res.status_code)
        
readPage(pageId, headers)
2

Open your database as full-page in your browser and copy the URL. Paste the URL in a notepad to extract the database ID from there.

https://www.notion.so/fer6ff3d5fcs3dff1d2134349192cc?v=4rf43545...
                     |---------Database ID----------|

The random string between / and ?v is your database ID.

If you are looking for a complete guide read Notion databases using notion API

1
  • Very nice guide. Thanks for sharing @hrishikesh-pathak
    – AlexStack
    May 11 at 16:41
-2

...notion.so/?v=<some id or hash ...>

The former some id or hash is the Database ID.

1
  • 2
    Please provide additional details in your answer. As it's currently written, it's hard to understand your solution.
    – Community Bot
    Sep 9, 2021 at 8:23

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.