A small repository with convenience functions for working with the Notion API.

Overview

Welcome!

Within this respository are a few convenience functions to assist with the pulling and pushing of data from the Notion API. Given your credential file and database you want to access, you can pull back cleanly formatted json tables to lookup by database row_id or field name. For each type of object in the Notion database, I am using pre-defined functions to extract only core information - the field value or the plain text. You can access the raw data by using .raw_data of the NotionData class object. Please note, not every type of field is accounted for in this custom parsing.

Field types which are implemented include:

  • date (takes single input and returns start and end dates formatted in python datetime format for convenience)
  • relation (returns relation IDs which can be passed back through .query_id() to return record information)
  • text (returns plain text value)
  • rich_text (returns plain text value)
  • title (returns plain text value)
  • select (returns plain text value)
  • checkbox (returns True False boolean based on if box was checked)

I do not plan on implementing additional field types at this time - if you need additional functionality please feel free to fork this repo and/or submit a pull request. These scripts are provided without guarantee or warrenty; as of writing this, all scripts have worked for my purposes and I will continue to update the code as I notice data structure changes within my own projects. Please note that any changes to how Notion returns field type data may lead to breakage.

Quickstart:

notion_data = NotionData(DATABASE_ID, INTEGRATION_TOKEN)
notion_data.summary() #quick summary of returned records and structure of first record
notion_data.data #returns the full raw data for custom json parsing
notion_data.fields #returns all fields in database for reference
notion_data.field_types #returns the field types of the fields for custom logic on parsing the json based on elements specific to a type
notion_data.row_ids #unique match-keys that represent a row within a data table

Return all row_id & values for a given field:

notion_data.query_field()['field_name']

Return all record information for a given row_id:

notion_data.query_id()['row_id']

Searching using regex to return all records matching the lookup:

# Returns matching ids & record data
match_pattern = r'testlookup' #appropriate re.match regex string
my_lookup = notion_data.lookup(match_pattern, field)
my_lookup[0] #matching id values
my_lookup[1] #records corresponding to id values

You might also like...
Token-gate Notion pages

This is a Next.js project bootstrapped with create-next-app. Getting Started First, run the development server: npm run dev # or yarn dev Open http://

A script to automate the process of downloading Markdown and CSV backups of Notion
A script to automate the process of downloading Markdown and CSV backups of Notion

Automatic-Notion-Backup A script to automate the process of downloading Markdown and CSV backups of Notion. In addition, the data is processed to remo

Discord RPC for Notion written in Python

Discord RPC for Notion This is a program that allows you to add your Notion workspace activities to your Discord profile. This project is currently un

Notflix - Notion / Netflix and IMDb to organise your movie dates. Happy Valentine <3 from 0x1za
Notflix - Notion / Netflix and IMDb to organise your movie dates. Happy Valentine 3 from 0x1za

Welcome to notflix 👋 This is a project to help organise shows to watch with my

Automatically pulls specified repository whenever a specified file is pushed. Great for working collaboratively when you need to run something locally.

autopull Simple python tool that allows you to automatically pull from a github repository whenever a file with a specified name is uploaded installat

Python API for working with RESQML models

resqpy: Python API for working with RESQML models Introduction resqpy is a pure python package which provides a programming interface (API) for readin

Library for working with QIWI API.

Library for working with QIWI API.

This repository provides a set functions to extract paragraphs from AWS Textract responses.

extract-paragraphs-with-aws-textract Since AWS Textract (the AWS OCR service) does not have a native function to extract paragraphs, this repository p

Exchange indicators & Basic functions for Binance API.
Exchange indicators & Basic functions for Binance API.

binance-ema Exchange indicators & Basic functions for Binance API. This python library has been written to calculate SMA, EMA, MACD etc. functions wit

Owner
null
Notion4ever - Python tool for export all your content of Notion page using official Notion API

NOTION4EVER Notion4ever is a small python tool that allows you to free your cont

null 50 Dec 30, 2022
A small Python app to create Notion pages from Jira issues

Jira to Notion This little program will capture a Jira issue and create a corresponding Notion subpage. Mac users can fetch the current issue from the

Dr. Kerem Koseoglu 12 Oct 27, 2022
A small package to markdownify Notion blocks.

markdownify-notion A small package to markdownify notion blocks. Installation Install this library using pip: $ pip install markdownify-notion Usage

Sergio Sánchez Zavala 2 Oct 29, 2022
For specific function. For my own convenience. Remind owner to share data to another DITO user.

For specific function. For my own convenience. Remind owner to share data to another DITO user.

Meigo 1 Dec 14, 2021
Unofficial Python API client for Notion.so

notion-py Unofficial Python 3 client for Notion.so API v3. Object-oriented interface (mapping database tables to Python classes/attributes) Automatic

Jamie Alexandre 3.9k Jan 3, 2023
Notion API Database Python Implementation

Python Notion Database Notion API Database Python Implementation created only by database from the official Notion API. Installing / Getting started p

minwook 78 Dec 19, 2022
Python 3 tools for interacting with Notion API

NotionDB Python 3 tools for interacting with Notion API: API client Relational database wrapper Installation pip install notiondb API client from noti

Viet Hoang 14 Nov 24, 2022
A way to export your saved reddit posts to a Notion table.

reddit-saved-to-notion A way to export your saved reddit posts and comments to a Notion table.Uses notion-sdk-py and praw for interacting with Notion

null 19 Sep 12, 2022
Import Notion Tasks to

Notion-to-Google-Calendar (1 way) Import Notion Tasks to Google Calendar NO MORE UPDATES WILL BE MADE TO THIS REPO. Attention has been put on a 2-way

null 12 Aug 11, 2022
A simple object model for the Notion SDK.

A simplified object model for the Notion SDK. This is loosely modeled after concepts found in SQLAlchemy.

Jason Heddings 54 Jan 2, 2023