Blocks-Endpoint Examples

Fetching Blocks

You can fetch the children of every block and page - which as childrens - in Notion.

Just use the following

# Fetches children from a specific block as a Collection
\Notion::block($blockId)
       ->limit(5) // limit is optional
       ->children()
       ->asCollection();


If you need to send fetched data over to the client side or process it otherwise, you can fetch data as JSON.

# Fetches children from a specific block as JSON
\Notion::block($blockId)
       ->children()
       ->asJson();


So called unsupported_blocks (Notion API Docs) are ignored by default.

Include unsupported blocks with ->withUnsupported().

# Fetches children from a specific block as JSON
\Notion::block($blockId)
       ->children()
       ->withUnsupported()
       ->asCollection();


In some cases just the content representation of all blocks is needed.

It is possible to only get the blocks' content with ->asTextCollection().

# Fetches children from a specific block as a Collection of their content
\Notion::block($blockId)
       ->children()
       ->asTextCollection();

Block Types

Here all currently possible block classes are listed.


All supported and recognized blocks will be returned as...

BulletedListItem::class

ChildPage::class

HeadingOne::class

HeadingTwo::class

HeadingThree::class

NumberedListItem::class

Paragraph::class

TextBlock::class

ToDo::class

Toggle::class


All unsupported or unrecognized blocks will be returned as...

Block::class