I’m working with the Notion Public API and I’m having trouble figuring out how to get the URL of a page. I can fetch page properties and some basic metadata 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 or slug for the page. This is particularly important for me because I’m trying to get the URLs for items in a database. Has anyone figured out a way to do this with the available metadata? I’ve looked through the API docs but couldn’t find anything specific about retrieving page URLs. Any help or suggestions would be really appreciated. I’m not sure if I’m missing something obvious or if this is a limitation of the API. Thanks in advance!
As someone who’s been working with Notion’s API for a while now, I can confirm that retrieving the page URL directly isn’t straightforward. However, there’s a workaround that’s been reliable for me.
You can construct the URL using the page ID you receive from the API. The format is ‘https://www.notion.so/’ followed by the page ID, replacing any dashes with hyphens. This works for both standalone pages and database items.
One thing to keep in mind: if you’re dealing with private pages, you’ll need the right permissions to access them via this URL. Also, this method gives you the internal Notion URL, not a public share link.
If you’re looking to automate this process, you could create a simple function to handle the URL construction. This has saved me a lot of time in my projects. Let me know if you need any more specifics on implementation!
I encountered this challenge as well while working on a Notion integration. The solution I found was to construct the URL programmatically using the page ID. The format is ‘https://www.notion.so/’ followed by the page ID, with any dashes replaced by hyphens. This method works reliably for both pages and database items. Keep in mind that for private pages, you’ll need appropriate permissions to access them via the constructed URL. Also, note that this approach generates the web app URL, not the public share link if that’s what you’re after. If you need further assistance with implementation, feel free to ask.
hey tom, i had a similar issue. turns out the url isn’t directly available thru the API. but you can construct it using the page ID. just combine ‘https://www.notion.so/’ with the page ID, replacing dashes with hyphens. hope that helps! lemme know if u need more details