How to retrieve page identifiers from Notion for external commenting system

I’m building a commenting feature for my investment analysis blog that runs on Notion. The goal is to let visitors leave feedback on my posts regardless of whether they have Notion accounts or not.

My plan involves using Angular for the frontend and Firebase as the backend database. I want to store comments in a Firebase collection where each document uses the Notion page identifier as its key. This approach would allow me to display only relevant comments for each specific analysis post.

For instance, when someone visits my January 15th market review, they should only see comments related to that particular entry.

The challenge I’m facing is figuring out how to extract the page identifier from Notion or alternatively get the database information to derive the page identifier. Is there a method to programmatically access these identifiers so I can use them as document keys in my Firebase setup?

Hit the Notion API with a database query - you’ll get all page objects with their IDs back. Way easier than manual URL parsing. I did this for my crypto blog and it works perfectly. Store the page ID as your Firebase document key like you planned. Pro tip: cache the Notion data so you’re not hitting their API every page load.

The page ID is right there in the Notion URL - it’s that 32-character string at the end. You can grab this through the Notion API when you fetch page or database info. I’d set up a simple script that pulls all pages from your database via the API. You’ll get back the page IDs plus stuff like titles and creation dates, then just map those to your Firebase docs. One heads up though - if you’re thinking bigger picture, consider building a middleware service that syncs Notion and Firebase whenever you publish new posts. Way better than extracting IDs every time someone loads a page.

I built something like this last year for my portfolio. Don’t just extract page IDs from URLs - use Notion’s database query endpoint to grab all your blog posts at once. You’ll get the page IDs plus useful metadata like publication status and last edited time. I set up a background job that syncs new posts with Firebase periodically instead of doing it real-time, which worked much better. One nice thing about Notion page IDs is they don’t change even if you rename posts or move them around, so they’re perfect as keys for your comment system. Just handle the edge case where someone deletes a post from Notion but comments still exist in Firebase.

This topic was automatically closed 4 days after the last reply. New replies are no longer allowed.