Blocks-Endpoint Examples

Fetching Block

You can fetch specific blocks with the following statement:

# Fetches the content and information of a specific block
\Notion::block($blockId)
       ->retrieve();

If the returned block is a supported block from the NotionApi, you will receive one of the following classes: BulletedListItem::class, ChildPage::class, HeadingOne::class, HeadingTwo::class, HeadingThree::class, NumberedListItem::class, Paragraph::class, TextBlock::class, ToDo::class, Toggle::class, Image::class, Embed::class, File::class, Video::class, Pdf::class,

Otherwise you will receive the Block::class.

Fetching Block Children

You can fetch the children of every block and page.

Just use the following statement:

# 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 clientside 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 (NotionAPI 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

Image::class

Embed::class

File::class

Video::class

Pdf::class


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

Block::class