How I reverse-engineer Notion JS SDK for Flask

Source: Ali Abdaal

Everyone loves Notion. Writing in Notion is an ultimate pleasure if you have an eye for simple but elegant design. However, what you type in Notion stays in Notion, unless you make it as a public link.

In May 2021, Notion has released its first API with an SDK for Javascript. The use case is simple, one can fetch pages, databases and users with the new API without the need of a scraper. Now, this raises an inspiration : what if we can use Notion as a CMS for our websites without the need of creating an admin panel?

I created a minimal application in Flask for testing this idea. For implementation, I checked out Notion’s official JS SDK and tested reverse-engineering in Flask. The template file barely contains anything: just a layout to contain Notion documents and stylesheet. The pages can be iterated within single variable rule for routing :

For a simple demonstration, I create a main page which has redirects to other pages in Notion.

Same page with all links is parsed as:

For being able to use the integration, first the user should obtain integration token from Settings -> Integrations. Second, the pages should be enabled for integration from page “Share” menu.

The API itself is well documented, however, since it is still in beta version, it doesn’t support all the fancy blocks we love in Notion.



Official JS SDK:

I talk to myself all the time.