Ben Borgers

Reading a Notion table with an API

April 19, 2020

Heads up! This post was written before Notion came out with an official API, and uses a reverse-engineering method that isn’t offically supported. Notion now has an official developer API, so you should use that instead. I no longer maintain Potion, which is used in this article.


I wrote my own reverse-engineered API for Notion, called Potion. The code is open source on GitHub.

Today, we're going to use that API to read a table in Notion.

Getting the table ID

To use the API, we need the ID of the table in Notion that we want to read.

First, make the table public using the Share button in the top right corner:

Then, click the Copy page link button and paste the link somewhere. The long string of characters in the link (but not after the ?) is the Notion document ID:

image

The ID in this example is 2364751436224832ba85e279417ea798.

You'll need to give this ID to the API in order to tell it which table to read from.

Using the Potion API

Now, we'll use Potion to read the table.

The endpoint we want to send a GET request to is:

https://potion-api.now.sh/table?id=NOTION_DOCUMENT_ID

You can click here and see what the response would look like with the example ID we copied earlier, which is the ID for this table.

Here's an example for javascript using fetch, which is built in to the browser:

fetch("https://potion-api.now.sh/table?id=2364751436224832ba85e279417ea798")
  .then((res) => res.json())
  .then((json) => {
    console.log(json);
  });

From here, you can use the data however you'd like. Feel free to use it to populate a website, read data for running a daily script, etc. This opens up a ton of new possibilities!

More blog posts

Subscribe to my newsletter for a monthly round-up of new blog posts and projects I’m working on!

Twitter ↗ RSS feed ↗