Retrieving page URLs through Notion's Public API

I’m working with the Notion Public API and I’m trying to figure out how to get the URL or slug for a page, specifically for items in a database. When I fetch a page, I can see some basic info like the object type, ID, and timestamps for creation and last edit. But I can’t seem to find a way to get the actual URL. Does anyone know if this is possible with the current API? If so, how can I do it? I’ve looked through the docs but couldn’t find anything clear about this. It would be really helpful for a project I’m working on. Thanks for any tips!

I’ve encountered this issue before when working with Notion’s API. While there’s no direct method to retrieve page URLs, you can construct them programmatically. The format is typically ‘https://www.notion.so/’ followed by the page ID, with hyphens inserted every 4 characters. For example, if your page ID is ‘abcdef1234567890’, the URL would be ‘https://www.notion.so/abcd-ef12-3456-7890’. This approach has worked reliably for me in various projects. Just remember to handle any potential edge cases, like different page types or workspace-specific URLs.

hey there! i’ve messed with the notion api a bit. afaik there’s no direct way to get page urls :confused: but u can kinda hack it by combining the base url with the page id, like ‘https://www.notion.so/’ + page_id. not ideal but it works! hope that helps ur project

I’ve been using Notion’s API for a while now, and I’ve run into this exact problem. It’s frustrating that there’s no straightforward way to get page URLs, but I’ve found a workaround that’s been pretty reliable.

What I do is construct the URL manually using the page ID. The format is ‘https://www.notion.so/’ + page_id.replace(/-/g, ‘’). This removes any hyphens from the ID, which is important because Notion sometimes includes them in the API response but not in the actual URL.

One thing to watch out for: if you’re dealing with pages in shared workspaces, you might need to prepend the workspace ID to the URL. It’s a bit of trial and error, but once you get it set up, it works consistently.

Just keep in mind that this method isn’t officially supported by Notion, so there’s always a small risk it could break with future updates. But for now, it’s the best solution I’ve found.