Notion API in 5 Minutes: How to Read Notion Databases in Python
Key Takeaways
This video demonstrates how to read from Notion databases in Python using the Notion API, covering authentication, database creation, and data retrieval.
Full Transcript
foreign welcome to another video in this video we're learning how we can read from notion databases all the code that we have now has been written in our previous three tutorials where we learned how to authenticate write and read from into an ocean databases so if you haven't checked those out definitely do so let's get started I'm going to set the five minute timer and Jump Right In first things first let's create a database we're going to create an inline database and we're going to call this website Analytics great let's change the rows a little bit or the columns uh we'll call this user ID we'll call this event and then we'll change the type to a select field and we'll add one more date column and we'll just call that date that that's perfect all right so let's add a couple rows I'm going to use my handy bash uid function here to add a couple IDs you would think that when these events come in they'll come in as uuids we're going to create a visitor event and a sign up event and we're just going to put some dates in here so whatever shows up is great and then we're going to delete this last row excellent so next thing you need to do is get your notion database ID so we're going to come in and copy the link we're going to create a new variable notion database ID equals and when you paste this link your ID is going to be the first uuid after the slash so we're going to grab that and jump into our code so first thing we want to do is read the information from our database so let's go ahead and do that we'll call this DB info equals client.databases.retrieve excellent yeah so GitHub copilot knows exactly what we want here if you're not using GitHub copilot definitely hop on the AI train it is here it's here to stay Engineers using it are going to be better off let's write to reuse our right dict to file as Json function and let's go ahead and see the output of this function so let's check out our DB info.json let's prettify this and as you can see we have all the information from our website analytics minus our actual rows so this is just giving metadata about the database itself so let's go ahead and learn how to read the rows the first thing we need is a function that will help us safely get nested properties from complex objects so I'm just going to paste this function and this will be you know all the code all the information you need to get this running will be in the description but basically this allows us to run functions like this to get information out all right so let's go ahead and get our rows DB rows perfect equals client databases query and now that we have our rows we can write our rows to a dictionary and now we're going to Loop through our rows for row and DB rows results let's get rid of the prints let's get rid of the ID we want our user ID we want our event and then let's create one more we want our date right we will put these all in a list we'll call these simple rows it will append all these items and then after we do this we're going to dump out our simple rows to a Json file we're going to comment this code up for now so that we can see the structure of the database row so let's go ahead and run this and look at DB rows format and as you can see we have this results key value pair that's an array which contains properties in each one of these properties we have a nested selection of keys that we need to access which is why we imported that safe git method so let's go ahead and run properties.event select dot name this is how we're going to obtain our event so let's go ahead and uncomment this code and repeat for each type so let's go ahead and paste that in so that's how we get our event and let's go ahead and continue we're running out of time here so it's going to be properties dot date.date.start let's paste that in our date one more let's run properties dot user id.title dot zero dot plain text just as we're running out of time let's go ahead and paste that in and let's run and see what we get all right so let's look at our simple rows.json file that was created let's pretty print and as you can see guys we have our rows as Json so as you can see each row aligns with a row in our database thanks so much for tuning in I hope this video was helpful if I went too fast feel free to stop at any point all the code all the links are going to be in the description we just learned how to read from the ocean databases five minutes so I'll see you guys in the next video where we learn how to write to notion databases peace
Original Description
Grab the source code: https://danisler.com/dev/notion-in-5-minutes
✅ Not sure how to get started? Watch the auth, write, and read videos here.
Notion Authenticate: https://youtu.be/KyllgpvQFuI
Notion Write: https://youtu.be/KENSTonsiEc
Notion Read: https://youtu.be/GSPpYqBgIko
💻 Documentation
Get the code: https://danisler.com/dev/notion-in-5-minutes
Notion Developer Documentation: https://developers.notion.com/
Python Library: https://github.com/ramnes/notion-sdk-py
🗣 Convert your notion pages to lifelike speech: https://subvolver.com
⏳ Manage your time your way: https://timeva.app
#️⃣ Hashtags
#notion #notionapi #api
Watch on YouTube ↗
(saves to browser)
Sign in to unlock AI tutor explanation · ⚡30
Playlist
Uploads from IndyDevDan · IndyDevDan · 33 of 60
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
▶
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
Senior developer codes ENTIRE electron app in 30 days (not for beginners)
IndyDevDan
How I code custom components with vue.js, electron and GitHub Copilot (ASMR)
IndyDevDan
Coding a progress bar using vue.js, progressbar.js, pinia, and electron
IndyDevDan
Vue + Electron settings menu and switch component wrapper (GitHub Copilot FTW)
IndyDevDan
Zen mode, Hot keys, and circle progress bar in vue.js
IndyDevDan
Coding picker components in vue.js for TIMEVA customizability.
IndyDevDan
Coding a micro mode progress bar in vue.js on the balcony like a proper digital nomad.
IndyDevDan
How to use dynamic css variables to create custom color themes for Timeva.
IndyDevDan
Building a minimal account page for my electron + vue.js app
IndyDevDan
This is the final devlog
IndyDevDan
How to build and launch your next app in 30 days
IndyDevDan
Learn Pinia in 10 MINUTES (Vue.js 3)
IndyDevDan
Learn Tailwind CSS by making a Cheatsheet | (30 Key CSS Properties)
IndyDevDan
GitHub Copilot being hella useful when coding Electron + Vue.js app
IndyDevDan
Vue Animations in 3 Lines of Code. (VueUse Motion)
IndyDevDan
How to use VCCode Macros for Insane Developer Productivity (5x, 10x, 25x, 100x gains)
IndyDevDan
Is It Hype? Senior Engineer Learns GraphQL, Rages and Complains About Docs (RAW TAKE - Part 1)
IndyDevDan
Is it Hype? Learn GraphQL by building an Express + GraphQL App (Part 2)
IndyDevDan
So you have an idea for an app. What's next? (3 Actions You Can Take Now)
IndyDevDan
Coding Vue.js Components, Hooks, and Pinia State for Timeva v2
IndyDevDan
Coding Pomodoro Chaining (Vue.js, Electron, Pinia)
IndyDevDan
Programming Pomodoro Chaining PART 2 (Vue 3 Hooks Have Changed Me)
IndyDevDan
Chill Vue.js 3 Coding (Pom Chaining Part 3)
IndyDevDan
Senior Engineer Codes New App Feature With Vue.js, Copilot, Electron and TS.
IndyDevDan
Is It Hype? Github Copilot (The Future of Programming)
IndyDevDan
Achieving Balance as Engineers who want more from life (Raw Discussion)
IndyDevDan
Indie Hackers Most Important Resource: RUNWAY
IndyDevDan
Timeva V2 - Customizable Productivity Timer For The Digital Age
IndyDevDan
Notion API In 5 Minutes: Authentication (Python)
IndyDevDan
Notion API in 5 Minutes: Write (Python)
IndyDevDan
Notion API in 5 Minutes: Read (Python | Copilot)
IndyDevDan
The AI Wave: 3 Years 3 Predictions 3 Actions (ChatGPT will be a Joke)
IndyDevDan
Notion API in 5 Minutes: How to Read Notion Databases in Python
IndyDevDan
Notion API In 5 Minutes - Database Write (Add new rows in Python)
IndyDevDan
Automate Everything: Using The Notion API to automate tweets. Let’s Code
IndyDevDan
Going Serverless: Using Vercel Functions for our Notion Twitter App
IndyDevDan
Serverless Cron Jobs: Automatically Run Your Serverless Functions With QStash And Vercel
IndyDevDan
Let’s Break The Internet: ChatGPT API + Notion Infinite Tweet Generator
IndyDevDan
Survive the AI age: Managing AI generated content with Notion, Python, Vercel, and Cron.
IndyDevDan
The AI Engineer: The Future of Programming
IndyDevDan
Master Disruption: How Top AI Engineers Will Dominate the GPT-X Era
IndyDevDan
FFmpeg, GPT-4 & WhisperX: Convert Horizontal Videos to Vertical (97% AI)
IndyDevDan
Why Use LangChain? A Blunt Overview for Advanced Engineers
IndyDevDan
Nuxt + Vercel KV: Coding an AI Agent Network MVP (flow state devLog)
IndyDevDan
Build VueJS Components While You Sleep: First LLM Agent Network (V2)
IndyDevDan
My Top 6 Modern Vue.js VSCode Snippets
IndyDevDan
useComposable - Vue.js Composable Generator (GCP + Serverless + LLM)
IndyDevDan
Let's Get Fired: Using AI Coding Assistant AIDER to do my Engineering Job
IndyDevDan
Writing code without coding - Browser TTS with AIDER (ASMR DEVLOG)
IndyDevDan
Learn Anything With AI: HTMX - FLASK - AIDER (asmr devlog)
IndyDevDan
Advanced Prompt Engineering Techniques for FRONT-END Engineers
IndyDevDan
I'm DONE writing tests - using AI copilot AIDER to AUTOMATE testing.
IndyDevDan
pip install YOUR-PACKAGE: Building your first python with Poetry, AIDER, and ChatGPT
IndyDevDan
Git + AI = DIFFBRO: AI Coding the future of code reviews (python, aider, gpt-4)
IndyDevDan
AI Devlog: Coding an AI powered, Code Review, CLI tool | Python, Aider, ChatGPT
IndyDevDan
Introducing DIFFBRO - Your AI powered PEER REVIEWS in one command
IndyDevDan
ONE Word Prompts - 3 INSTANTLY useful Prompt Engineering Techniques
IndyDevDan
The Javascript Ecosystem Killer: Using Bun, to Learn Bun (with AIDER)
IndyDevDan
"With this prompt, I learned Pytest in 12 minutes" - Learn ANYTHING with LLMs
IndyDevDan
Prompt Engineering an ENTIRE codebase: Postgres Data Analytics AI Agent
IndyDevDan
More on: Data Literacy
View skill →Related AI Lessons
⚡
⚡
⚡
⚡
Applying Scalability in Backend (CodeBuddy)
Medium · LLM
Why Every Backend Developer Should Learn Nginx Before Going to Production
Medium · DevOps
Connecting Frontend to Backend: A Backend Engineer’s Reality Check
Medium · Programming
Build Secure Authentication System Using Access and Refresh Tokens
Medium · Python
🎓
Tutor Explanation
DeepCamp AI