Print

Import Notion Data to Google Sheets

In this guide, we’ll walk through how to pull data from the Notion API directly into Google Sheets, using the API Connector add-on for Sheets. We'll first get an API key from Notion, and then set up a request to pull in data to your spreadsheet.

Contents

Before You Begin

Click here to install the API Connector add-on from the Google Marketplace.

Part 1: Get Your Notion Token

  1. Log in to Notion and click Settings & Members on the left side navigation menu
    notion-img1
  2. Click Connections and then Develop or manage integrations
    notion-develop
  3. Click + New Integration
    notion-img3
  4. You'll be prompted to give your integration a name and a logo. These can be anything, but remember what you pick :p. Click Submit.
    notion-img4
  5. You will be presented with an internal token that you can use to make your API requests.
    notion-img5
  6. Scroll to the bottom of the page, make sure Internal integration is selected, and click Save. Congrats, you have your token! Copy it down as we'll use it shortly.
    notion-img6

Part 2: Allow Access for Your Token

By default, the token you've just created doesn't have access to your Notion data until you explicitly share access. To share access, you'll need to add it like this.

  • Navigate to your page or database, and click the click the ••• button on top right.
    notion-open
  • Scroll down to the bottom and click +Add connections
  • In the resulting pop-up, search for and select the integration you created earlier.
    notion-addconnection
  • You'll see a message informing you that your integration will now have access to the page. Click Confirm.

Now your page is available via the API.

Part 3: Example API Requests

Notion provides the following endpoints. Note that some of these requests use GET while others use POST, as this will be important for pagination handling.

HTTP methodEndpoint
GETList all users
GETRetrieve block children
GETRetrieve a comment
GETRetrieve a page property item
POSTQuery a database
POSTSearch

Example - Query Records from a Notion Database

This example shows how to pull records from a Notion database into Sheets.

  1. First, get your Notion database ID. Get your Notion database ID from the URL (or see below for another method). If your URL is https://notion.so/xxxx?v=YYYYY, xxxx is your database ID.
    notion-dbid-url
  2. Open up Google Sheets and click Extensions > API Connector > Open > Create request.
  3. In the request form, enter the following, substituting in your own database ID and API key:
    • Application: Custom
    • Method: POST
    • Request URL: https://api.notion.com/v1/databases/your_database_id/query
    • Headers
      • Authorization: Bearer your_key
      • Notion-Version: 2022-06-28
      • Content-Type: application/json
    • Request body: {}
  4. Create a new tab and click Set current to use that tab as your data destination.
  5. Name your request and click Run. A moment later you'll see database records populate your sheet.
    notion-database

You can search all the databases you have access to with a request like this:

  • Application: Custom
  • Method: POST
  • Request URL: https://api.notion.com/v1/search
  • Headers
    • Authorization: Bearer your_key
    • Notion-Version: 2022-06-28
    • Content-Type: application/json
  • Request body: {"filter":{"value":"database","property":"object"}}

To see available pages, change database to pages in the request body. To see all available entities, enter {} into the request body (but Notion recommends being as specific as possible).

More Example API URLs

For these, you'll need your page ID from the page URL
notion-img9

Substitute in that page ID where it says 11111111

  1. Get metadata about a page
    GET https://api.notion.com/v1/pages/11111111
  2. Get content from a page
    GET https://api.notion.com/v1/blocks/11111111/children

Part 4: Handle Pagination

By default, Notion API limits 100 responses per page as shown in their documentation:
notion-img13

To get more records, use the start_cursor parameter as described. In API Connector you can do this automatically with pagination handling, like this.

  • Pagination type: cursor body
  • Next token parameterstart_cursor
  • Next token pathnext_cursor (this is the column name containing the tokens)
  • Run untilchoose when to stop fetching data
    notion-pagination-cursorbody
Note: the above example is for any of Notion's POST requests. If you're querying one of their GET endpoints, the pagination type will be cursor instead. The next token parameter and path will remain the same either way.

Part 5: API Documentation

Official API documentation: https://developers.notion.com/reference/intro

2 thoughts on “Import Notion Data to Google Sheets”

    • The database URL should have 2 numbers; the first is the database ID and the second is the view ID. Can you try plugging in the first number and see if that resolves the issue? I just updated the article to include a more complete example of getting records from a database.

      Reply

Leave a Comment

Jump To