Notion API guide

Learn how to use the Notion API, and when it’s easier to sync Notion with other tools automatically using Whalesync, no coding required.
Over 100 million people use Notion to take notes, organize files, project management and many other tasks. Here at Whalesync, we use Notion to manage content, including syncing it to Webflow to publish blog posts like this one.
I’ve been a Notion power user for years, but surprisingly, I’d never explored Notion’s API, until I stumbled across a tutorial on creating Notion pages using Python. I was fascinated, and I also gave it a try myself.
Once I got the hang of it, I decided to write this mini guide to walk you through how to use Notion’s API. We'll explore what the API is, why it's useful, and how to get started.
What is an API?
An API (Application Programming Interface) is like a bridge that allows different applications to communicate with each other. Think of it as a translator that enables apps to exchange information without requiring you to manually transfer data from one platform to another.
Let’s say you get a message in Slack and want to create a task in Notion. Normally, you’d copy and paste the details manually. With an API, you can create that task automatically.
What is the Notion API?
The Notion API gives you programmatic access to your Notion workspace. You can connect Notion to external tools, automate repetitive tasks, and build fully customized workflows, whether it's syncing data or managing databases.
Notion’s API provides endpoints for major functions. An endpoint is a specific part of an API that performs a certain action, like retrieving a database, creating a page, or updating a block. Think of endpoints as different "doors" you can knock on to request specific information or make changes in your Notion workspace.
Using these endpoints, the Notion API allows you to:
- Query, create and update databases
- Retrieve, create, update, and archive pages
- Manage content blocks (retrieving, updating, deleting)
- Append child blocks to parent blocks
- List users and retrieving user information
- Create and retrieve comments
In short, it turns your Notion workspace into a highly customizable system.
Why should you use the Notion API?
Using the Notion API allows you to create a custom Notion experience, with the following advantages:
Increases your efficiency
The Notion API eliminates the need for repetitive manual tasks. Instead of manually copying and pasting information from one place to another, you can set up automated processes to handle these tasks for you. This allows you to focus on more important work.
Improves your workflow
With Notion’s API, you can connect tools that don't have a native integration with Notion. With the API, you can create a more cohesive workspace where all your data and processes are interconnected and easily accessible.
Offers greater flexibility
By allowing you to directly interact with Notion’s backend, you can design workflows and processes tailored specifically to your needs, which will enhance your overall experience.
Reduces errors
With an API, you minimize the likelihood of mistakes occurring when moving data between applications.
Teaches valuable skills
Learning how to use the Notion API helps you understand how systems and workflows are built. Even if you’re not a developer, understanding how APIs work can be a valuable skill, allowing you to design more efficient processes and expand your knowledge of how applications interact.
Understanding how APIs work will be especially valuable for your vibe coding projects.
What can you do with Notion’s API?
Almost anything you can do manually in Notion, you can automate it with code. But here are some practical examples:
- Automate task management: Automatically create and update tasks in your Notion database without manually inputting information.
- Organize information: Sync external data sources with your Notion databases for a centralized information hub.
- Build custom workflows: Design processes that enhance your productivity by integrating Notion with other systems you use daily.
- Create dynamic dashboards: Use the Notion API to pull real-time data into your Notion workspace, providing a powerful way to visualize and interact with your information.
How to use the Notion API
Let’s walk through how to connect to Notion's API and start interacting with your database. We need to set up an integration, find the right database information, and retrieve the database contents with a simple Python script.
If you've never come across Python before, don't worry. You can use an LLM like ChatGPT or Grok to generate the Python script for you.
If you’re more of a visual learner, check out this video tutorial here:
Step 1: Create a Notion integration
First, you’ll need to create an integration that will authorize your access to the Notion workspace.
Visit developers.notion.com and click "View my integrations" in the top-right corner.

Click "New Integration"

Give your integration a name (e.g., Sample Integration) and select the workspace you want it to access. Make sure you set the integration type to Internal.

Once saved, you’ll be given an Internal Integration Token, this is like a password. Copy it and store it securely. You’ll need it whenever you make requests to Notion’s servers

Step 2: Grant access to your integration
Next, you’ll need to give your integration permission to access the specific database you want to work with.
Open the database you want to connect to and then click the three-dot menu at the top right (not on a page, but on the database itself).

As you can see, I want to connect to a database called ‘Python Basics’ (very fitting!)
Next, select connections and then search for the name of the integration you just created. Remember that we named the integration ‘Sample Integration’. Click to add it and confirm access.

Step 3: Find your Notion database ID
To make API requests, you need the unique database ID.
Open your database in Notion and click "copy link".

Paste the link somewhere (like in a notes app). You’ll see a URL that looks like this:
https://www.notion.so/yourworkspace/abcd1234efgh5678ijkl9012mnop3456?v=1234abcd
Your database ID is the long string after /yourworkspace/ and before ?v=....
In this example, the database ID would be:
abcd1234efgh5678ijkl9012mnop3456
You’ll need this to tell Notion which database you’re working with.
Step 4: Write a simple Python script
Now it’s time to connect everything using a short Python script. You also need the Notion client library.
Here’s a simple script to connect to Notion and retrieve database content:

What this script does:
- Authenticates with Notion’s servers using your integration token.
- Retrieves your database’s title.
- Lists out the pages inside the database.
You’ll see the database name and a list of page IDs printed to your terminal.
Now that you know how to retrieve your Notion database data with Python, you’re ready to move on to more powerful automations. You can start building dynamic workflows, like automatically updating page icons based on a "Status" property (e.g., changing a page icon to ✅ when a task is marked "Completed") or syncing data between different tools.
Notion API or Whalesync?
Notion’s API is great for building custom automations, like updating page icons based on a status, triggering actions when certain conditions are met (such as sending a Slack message when a project moves to "in review"), or even integrating AI models (like OpenAI’s CHatGPT) directly into your databases.
However, when it comes to syncing data between Notion and other tools, like Webflow, Airtable, or Supabase, setting up and maintaining custom scripts with the Notion API is complicated and will require significant technical expertise (sorry, vibe coders!)
Instead of writing Python scripts, managing authentication tokens, and troubleshooting API errors. Sync data between Notion and other apps with Whalesync. In just a few clicks, you can create reliable two-way syncs that automatically keeps your data up to date across tools.
In short:
- Use the Notion API when you want to customize how things work inside Notion itself.
- Use Whalesync when you want to sync Notion to other tools in your toolstack.
import os, requests, time
# Create directory
os.makedirs("ABA_509_2024_PDFs", exist_ok=True)
# API endpoint
url = "https://backend.abarequireddisclosures.org/api/AnnualQuestionnaire/GenerateIndividualDisclosure509Report"
# Loop through possible school IDs
for school_id in range(1, 205):
params = {"schoolId": school_id, "year": 2024}
try:
res = requests.get(url, params=params, timeout=10)
if res.status_code == 200 and res.headers["Content-Type"] == "application/pdf":
with open(f"ABA_509_2024_PDFs/ABA_509_2024_School_{school_id}.pdf", "wb") as f:
f.write(res.content)
print(f"Downloaded School {school_id}")
else:
print(f"Skipped School {school_id}")
time.sleep(0.5)
except:
print(f"Error with School {school_id}")
Subscribe for more
Stay up to date with the latest no-code data news, strategies, and insights sent straight to your inbox!