PHPackages                             jensvandewiel/laravel-notion-api - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. jensvandewiel/laravel-notion-api

ActiveLibrary[API Development](/categories/api)

jensvandewiel/laravel-notion-api
================================

Laravel Wrapper for the Notion API

v0.3.0(1mo ago)0134MITPHPPHP ^8.0

Since Dec 9Pushed 1mo agoCompare

[ Source](https://github.com/JensvandeWiel/laravel-notion-api)[ Packagist](https://packagist.org/packages/jensvandewiel/laravel-notion-api)[ Docs](https://github.com/JensvandeWiel/laravel-notion-api)[ Patreon](https://www.patreon.com/5amcode)[ RSS](/packages/jensvandewiel-laravel-notion-api/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (10)Dependencies (12)Versions (11)Used By (0)

Laravel Notion API Package
==========================

[](#laravel-notion-api-package)

This package provides an elegant and comprehensive interface for interacting with the Notion API within Laravel applications. It allows you to query, create, update, and manage Notion pages, databases, blocks, comments, users, and more, with a fluent and intuitive API.

> **Note**: This package is a fork maintained for stability and bug fixes on-demand. Updates and improvements are applied as needed, and tests are currently not fully correct. For the latest features, consider the original package.

Installation
------------

[](#installation)

The package is compatible with Laravel 12+. Support is only provided for Laravel 12 and above. The minimum PHP requirement is 8.0.

1. Install the package via Composer:

    ```
    composer require jensvandewiel/laravel-notion-api
    ```
2. Obtain your Notion API access token by following the instructions in the Notion developer documentation at .
3. Add the token to your application's .env file:

    ```
    NOTION_API_TOKEN=your_access_token_here
    ```
4. Publish the configuration file (optional, for customization):

    ```
    php artisan vendor:publish --provider="Jensvandewiel\LaravelNotionApi\LaravelNotionApiServiceProvider"
    ```

Configuration
-------------

[](#configuration)

The package uses the NOTION\_API\_TOKEN environment variable for authentication. You can customize the API version and other settings in the published config file.

Basic Usage
-----------

[](#basic-usage)

Access Notion endpoints through the Notion facade:

```
use Jensvandewiel\LaravelNotionApi\Notion;

$notion = new Notion(env('NOTION_API_TOKEN'));
```

Or use the facade:

```
use Notion;

Notion::pages()->find('page_id');
```

Entities
--------

[](#entities)

The package provides several entity classes that represent Notion objects:

- Page: Represents a Notion page
- Database: Represents a Notion database
- DataSource: Represents a Notion data source
- Block: Represents a Notion block
- User: Represents a Notion user
- Comment: Represents a Notion comment
- FileUpload: Represents a file upload
- Token: Represents an OAuth token
- NotionParent: Represents parent relationships

Each entity provides methods to access and manipulate its properties.

Pages
-----

[](#pages)

### Retrieving a Page

[](#retrieving-a-page)

To retrieve a page by its ID:

```
$page = Notion::pages()->find('page_id');
```

This returns a Page entity with all its properties and content.

### Creating a Page in a Database

[](#creating-a-page-in-a-database)

To create a new page in a database:

```
$page = new Page();
$page->setTitle('Name', 'My New Page');
$page->setText('Description', 'This is a description');

$createdPage = Notion::pages()->createInDatabase('database_id', $page);
```

### Creating a Page as a Child of Another Page

[](#creating-a-page-as-a-child-of-another-page)

```
$page = new Page();
$page->setTitle('Name', 'My New Page');

$createdPage = Notion::pages()->createInPage('parent_page_id', $page);
```

### Updating a Page

[](#updating-a-page)

To update an existing page:

```
$page = Notion::pages()->find('page_id');
$page->setTitle('Name', 'Updated Title');
$page->setText('Description', 'Updated description');

$updatedPage = Notion::pages()->update($page);
```

### Archiving a Page

[](#archiving-a-page)

```
Notion::pages()->archive('page_id');
```

### Moving a Page

[](#moving-a-page)

```
Notion::pages()->move('page_id', ['parent' => ['page_id' => 'new_parent_id']]);
```

Databases
---------

[](#databases)

### Retrieving a Database

[](#retrieving-a-database)

```
$database = Notion::databases()->find('database_id');
```

### Creating a Database

[](#creating-a-database)

```
$database = new Database();
// Set properties...

$createdDatabase = Notion::databases()->create($database);
```

### Updating a Database

[](#updating-a-database)

```
$database = Notion::databases()->find('database_id');
// Modify properties...

$updatedDatabase = Notion::databases()->update($database);
```

### Querying a Database

[](#querying-a-database)

```
$query = Notion::databases()->query('database_id');
$pages = $query->filter(['property' => 'Name', 'text' => ['contains' => 'search term']])->get();
```

Blocks
------

[](#blocks)

### Retrieving Block Children

[](#retrieving-block-children)

```
$blocks = Notion::blocks()->getChildren('block_id');
```

### Appending Block Children

[](#appending-block-children)

```
$blocks = [
    ['type' => 'paragraph', 'paragraph' => ['rich_text' => [['type' => 'text', 'text' => ['content' => 'New paragraph']]]]]
];

Notion::blocks()->appendChildren('block_id', $blocks);
```

### Updating a Block

[](#updating-a-block)

```
Notion::blocks()->update('block_id', ['type' => 'paragraph', 'paragraph' => ['rich_text' => [['type' => 'text', 'text' => ['content' => 'Updated content']]]]);
```

### Deleting a Block

[](#deleting-a-block)

```
Notion::blocks()->delete('block_id');
```

Comments
--------

[](#comments)

### Creating a Comment

[](#creating-a-comment)

```
Notion::comments()->create('page_id', 'Comment text');
```

### Retrieving Comments

[](#retrieving-comments)

```
$comments = Notion::comments()->list('page_id');
```

Users
-----

[](#users)

### Retrieving Users

[](#retrieving-users)

```
$users = Notion::users()->list();
```

### Retrieving a Specific User

[](#retrieving-a-specific-user)

```
$user = Notion::users()->find('user_id');
```

Search
------

[](#search)

### Searching

[](#searching)

```
$results = Notion::search('query')->query()->asCollection();
```

File Uploads
------------

[](#file-uploads)

### Creating a File Upload

[](#creating-a-file-upload)

```
$upload = Notion::fileUploads()->create('file_name', 'file_type');
```

### Sending a File Upload

[](#sending-a-file-upload)

```
Notion::fileUploads()->send($upload->getId(), $fileContent);
```

### Completing a File Upload

[](#completing-a-file-upload)

```
Notion::fileUploads()->complete($upload->getId());
```

Property Types
--------------

[](#property-types)

The package supports all Notion property types:

- Title: setTitle('property\_name', 'text')
- Rich Text: setText('property\_name', 'text')
- Number: setNumber('property\_name', 123.45)
- Select: setSelect('property\_name', 'option\_name')
- Multi-Select: setMultiSelect('property\_name', \['option1', 'option2'\])
- Date: setDate('property\_name', $startDate, $endDate)
- People: setPeople('property\_name', \['user\_id1', 'user\_id2'\])
- Files: (handled via file uploads)
- Checkbox: setCheckbox('property\_name', true)
- URL: setUrl('property\_name', '')
- Email: setEmail('property\_name', '')
- Phone Number: setPhoneNumber('property\_name', '123-456-7890')
- Relation: setRelation('property\_name', \['page\_id1', 'page\_id2'\])
- Place: setPlace('property\_name', 'Location Name', 12.34, 56.78, 'Address')

Filtering and Sorting
---------------------

[](#filtering-and-sorting)

When querying databases, you can apply filters and sorting:

```
$query = Notion::databases()->query('database_id');
$query->filter([
    'property' => 'Name',
    'text' => ['contains' => 'search']
]);
$query->sort([
    'property' => 'Created',
    'direction' => 'descending'
]);
$results = $query->get();
```

Error Handling
--------------

[](#error-handling)

The package throws NotionException for API errors. Always wrap your calls in try-catch blocks:

```
try {
    $page = Notion::pages()->find('page_id');
} catch (NotionException $e) {
    // Handle error
}
```

Advanced Usage
--------------

[](#advanced-usage)

### Working with Rich Text

[](#working-with-rich-text)

Rich text is handled automatically for title and text properties. For more complex rich text manipulation, use the RichText entity.

### Custom Property Types

[](#custom-property-types)

For unsupported property types, you can extend the Property class and implement the Modifiable interface.

### Batch Operations

[](#batch-operations)

For bulk operations, collect multiple requests and execute them in sequence.

Contributing
------------

[](#contributing)

Contributions are welcome. Please ensure all tests pass and follow the existing code style.

License
-------

[](#license)

This package is open-sourced software licensed under the MIT license.

###  Health Score

40

—

FairBetter than 88% of packages

Maintenance90

Actively maintained with recent releases

Popularity14

Limited adoption so far

Community15

Small or concentrated contributor base

Maturity36

Early-stage or recently created project

 Bus Factor1

Top contributor holds 51.1% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~12 days

Recently: every ~27 days

Total

10

Last Release

47d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/dcce384af05f4c246e9aea8232d5d7c0e1a52579444305cddde92b1a8edd1a1c?d=identicon)[JensvandeWiel](/maintainers/JensvandeWiel)

---

Top Contributors

[![johguentner](https://avatars.githubusercontent.com/u/3506359?v=4)](https://github.com/johguentner "johguentner (241 commits)")[![mechelon](https://avatars.githubusercontent.com/u/26432041?v=4)](https://github.com/mechelon "mechelon (186 commits)")[![JensvandeWiel](https://avatars.githubusercontent.com/u/85284773?v=4)](https://github.com/JensvandeWiel "JensvandeWiel (23 commits)")[![danielh-official](https://avatars.githubusercontent.com/u/49914607?v=4)](https://github.com/danielh-official "danielh-official (5 commits)")[![Gummibeer](https://avatars.githubusercontent.com/u/6187884?v=4)](https://github.com/Gummibeer "Gummibeer (5 commits)")[![laravel-shift](https://avatars.githubusercontent.com/u/15991828?v=4)](https://github.com/laravel-shift "laravel-shift (5 commits)")[![blessingefkt](https://avatars.githubusercontent.com/u/887992?v=4)](https://github.com/blessingefkt "blessingefkt (1 commits)")[![treonde-user](https://avatars.githubusercontent.com/u/70837064?v=4)](https://github.com/treonde-user "treonde-user (1 commits)")[![farez](https://avatars.githubusercontent.com/u/39633?v=4)](https://github.com/farez "farez (1 commits)")[![mpociot](https://avatars.githubusercontent.com/u/804684?v=4)](https://github.com/mpociot "mpociot (1 commits)")[![osbre](https://avatars.githubusercontent.com/u/23292709?v=4)](https://github.com/osbre "osbre (1 commits)")[![richardhj](https://avatars.githubusercontent.com/u/1284725?v=4)](https://github.com/richardhj "richardhj (1 commits)")[![sschlein](https://avatars.githubusercontent.com/u/2911113?v=4)](https://github.com/sschlein "sschlein (1 commits)")

---

Tags

laravelApi Wrappernotionfiveam-codelaravel-notion-apinotion-api

###  Code Quality

TestsPest

### Embed Badge

![Health badge](/badges/jensvandewiel-laravel-notion-api/health.svg)

```
[![Health](https://phpackages.com/badges/jensvandewiel-laravel-notion-api/health.svg)](https://phpackages.com/packages/jensvandewiel-laravel-notion-api)
```

###  Alternatives

[fiveam-code/laravel-notion-api

Laravel Wrapper for the Notion API

435224.4k1](/packages/fiveam-code-laravel-notion-api)[irazasyed/telegram-bot-sdk

The Unofficial Telegram Bot API PHP SDK

3.3k4.5M84](/packages/irazasyed-telegram-bot-sdk)[dcblogdev/laravel-microsoft-graph

A Laravel Microsoft Graph API (Office365) package

168285.5k1](/packages/dcblogdev-laravel-microsoft-graph)[vluzrmos/slack-api

Wrapper for Slack.com WEB API.

102589.1k3](/packages/vluzrmos-slack-api)[marcreichel/igdb-laravel

A Laravel wrapper for version 4 of the IGDB API (Apicalypse) including webhook handling

115146.6k1](/packages/marcreichel-igdb-laravel)[smodav/mpesa

M-Pesa API implementation

16363.7k1](/packages/smodav-mpesa)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
