Laravel Packages

Notion API for Laravel

Published
Notion API for Laravel image

Notion API for Laravel is a package to effortlessly create Notion integrations with Laravel:

This package provides a simple and crisp way to access the Notion API endpoints, query data, and update existing entries.

The package includes convenient methods to fetch page information, search Notion collection pages and databases in your workspace:

  • Fetch a Notion page
  • Fetch children from a specific block
  • Search all databases and pages
  • Get all pages in a workspace
  • Fetch all databases of a workspace

Here’s some usage examples from the API documentation:

// Returns a specific page
$notion->pages()->find($yourPageId);

// Returns all pages of the workspace
\Notion::search()
        ->onlyPages()
        ->query()
        ->asCollection();

// Returns all databases of the workspace
\Notion::search()
        ->onlyDatabases()
        ->query()
        ->asCollection();

// Fetches all users from this workspace
\Notion::users()
        ->limit(5) // limit is optional
        ->all()
        ->asCollection();

// Retrieves data for a specific user in this workspace
\Notion::users()
        ->find($userId);

More specifically, here are some examples of retrieving properties from a specific page:

// Access properties from a specific page
$page = \Notion::pages()   
               ->find($pageId);

// Returns all properties as collection
$page->getProperties(); 

// Returns specific property by propertyKey
$page->getProperty($propertyKey);

// Returns specific property content by propertyKey (returned type depends on the property-type)
$page->getProperty($propertyKey)->getContent();

// Returns specific property content by propertyKey (array of exact NotionApi-structure is returned)
$page->getProperty($propertyKey)->getRawContent();

// Returns array of propertyKeys (names/titles of properties)
$page->getPropertyKeys();

// Return json-array of all properties
$page->getRawProperties();

Learn More

You can see the source code, get installation instructions, and get installation instructions on GitHub at 5am-code/laravel-notion-api. The official documentation has more code examples and usage details. You can learn more about the Notion API at developers.notion.com.

Paul Redmond photo

Staff writer at Laravel News. Full stack web developer and author.

Sponsored

laravelcloud logo
Laravel Cloud

Easily create and manage your servers and deploy your Laravel applications in seconds.

Visit Laravel Cloud

The latest

View all →
Laravel AI SDK 1.4 Lets Agents Recover From Tool Failures image

Laravel AI SDK 1.4 Lets Agents Recover From Tool Failures

Read article
Laravel Read Replicas: Check if a Replica Has Caught Up image

Laravel Read Replicas: Check if a Replica Has Caught Up

Read article
UUID Request Input and Migration Failure Events in Laravel 13.42 image

UUID Request Input and Migration Failure Events in Laravel 13.42

Read article
Replay Missed Laravel Scheduled Tasks With Schedule Catchup image

Replay Missed Laravel Scheduled Tasks With Schedule Catchup

Read article
Search Polymorphic Relations and Filament Tables With Laravel Searchable image

Search Polymorphic Relations and Filament Tables With Laravel Searchable

Read article
Laravel Rest Api 3.0: Typed Fields, Metrics, and OpenAPI Docs image

Laravel Rest Api 3.0: Typed Fields, Metrics, and OpenAPI Docs

Read article