minwook-shin / notion-database

Python bindings for Notion Database API
https://pypi.org/project/notion-database/
GNU Lesser General Public License v3.0
137 stars 12 forks source link

How to get children blocks ? #16

Closed j-barot closed 1 year ago

j-barot commented 1 year ago

Hi, i'm looking to get children blocks of a specific page, i can see i should be able to do it but i don't find a way ^^' Thanks !

minwook-shin commented 1 year ago

hello, @j-barot it doesn't. notion official documentation also you to use the block API instead of page. this package does not support the block API. (But, can create children block!)

ref : https://developers.notion.com/reference/retrieve-a-page

Retrieves a Page object using the ID specified.

Responses contains page properties, not page content. To fetch page content, use the Retrieve block children endpoint.

I will let you know when finished developing feature.

minwook-shin commented 1 year ago
B = Block(integrations_token=NOTION_KEY)
for j in D.result["results"]:
    B.retrieve_block(block_id=j["id"], is_children=True)
    pprint.pprint(B.result)

coming soon, (on 1.1.0 milestone ) :)

minwook-shin commented 1 year ago

@j-barot released version 1.1.0, which add this feature. https://github.com/minwook-shin/notion-database/releases/tag/1.1.0

pip install notion-database==1.1.0

Here an example. https://github.com/minwook-shin/notion-database/blob/main/page_content_example.py

j-barot commented 1 year ago

Wow thanks ! I'll update and using it asap !