Picture of the author

Notion Blocks

Fetch Blocks

Fetch Specific Blocks

Specific blocks can be fetched by using their UUID.

If the returned block is one that has a specific implementation in this package, an instance of one of the classes listed on the Supported Blocks page will be returned. If not, an instance of Block::class will be returned instead.

Notion::block($blockId)
       ->retrieve();

Fetch block children

If a block has children (e.g. a page or a list), they can be fetched with the parent UUID. The result can be fetched as a Collection or as JSON.

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

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

Some blocks are not supported by the Notion API and will be ignored. To force the listing of unsupported blocks, the method withUnsupported() can be used.

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

Fetch block children as content

In some cases the content representation of all blocks is preferable. 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();
Previous
Supported Blocks