Reputation: 635
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.
Upvotes: 33
Views: 78887
Reputation: 59
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
Upvotes: 4
Reputation: 71
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)
Upvotes: 5
Reputation: 3793
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:
Upvotes: 60
Reputation: 9
...notion.so/?v=<some id or hash ...>
The former some id or hash is the Database ID.
Upvotes: -3
Reputation: 7351
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.
Upvotes: 15