Potion

A functional, easy to use Python wrapper of Notion Api.

Install

pip install notion-potion

Usage

Quick Start

Authentication

from potion import Request, NotionHeader

token = ''

nh = NotionHeader(authorization=token)
req = Request(nh.headers)

Create an integration follow this official tutorial to get token.

A ‘retrieve’ example. (Full code can be found here)

from potion.api import *

print(req.get(url=database_retrieve('1bb0f79b87584afe8609d6e248285cfb')))

And a ‘update’ example. (Full code)

from potion.api import *
from potion.objects import *

property_list = [
    sche.AnySchema('+1', args=Null),  # delete property
    sche.URL('Photo'),  # update property type of `Photo`
    sche.MultiSelect('Store availability', [  # update Options of MultiSelect perproty `Store availability`
        sche.Option('Duc Loi Market'),
        sche.Option('Rainbow Grocery'),
        sche.Option('Gus\'s Community Market'),
        sche.Option('The Good Life Grocery', color='orange'),
    ])
]
properties = Properties(*property_list)

# Create Database object
data = Database(properties=properties)

# Commit update operation
print(data)
print(req.patch(url=database_update('1bb0f79b87584afe8609d6e248285cfb'),
                data=data))

Basic Example

Here lists examples reimplemented by potion from official shell examples

Database

Pages

Blocks

Users

Search

Api

See api.md for details.

Development & Contribute

git clone https://github.com/sailist/potion
python setup

Any issue and pr is welcome.

TODOs

  • Some uncommon used Object, like Filter, Emoji, File, etc..(While, you can implement your idea without this Object by pass dict as args.)
  • Parse json responses recurrsive into notion objects.

Related

GitHub

View Github