This package provides a simple and crisp way to access the Notion API endpoints, query data and update existing entries.
-
You can install the package via composer:
composer require fiveam-code/laravel-notion-api
-
Get your Notion API access token like explained in their documentation. It's also important to grant access to the integration within your Notion pages, which is described in the developer documentation at Notion as well.
-
For internal Integrations, please add a new entry to your
.env
like the following:NOTION_API_TOKEN="$YOUR_ACCESS_TOKEN"
-
Now you can easily access Notion:
use \Notion; Notion::databases()->find($databaseId);
That's it.
Head over to the Documentation of this package.
use \Notion;
Notion::databases()
->find("a7e5e47d-23ca-463b-9750-eb07ca7115e4");
Notion::pages()
->find("e7e5e47d-23ca-463b-9750-eb07ca7115e4");
// Returns a collection pages and databases of your workspace (included in your integration-token)
Notion::search("My Notion Search")
->query()
->asCollection();
// Queries a specific database and returns a collection of pages (= database entries)
$sortings = new Collection();
$filters = new Collection();
$sortings->add(Sorting::propertySort('Ordered', 'ascending'));
$sortings->add(Sorting::timestampSort('created_time', 'ascending'));
$filters->add(Filter::textFilter('title', ['contains' => 'new']));
// or
$filters->add(Filter::rawFilter('Tags', ['multi_select' => ['contains' => 'great']]));
Notion::database("a7e5e47d-23ca-463b-9750-eb07ca7115e4")
->filterBy($filters) // filters are optional
->sortBy($sortings) // sorts are optional
->limit(5) // limit is optional
->query()
->asCollection();
vendor/bin/pest tests
If you use this package in one of your projects or just want to support our development, consider becoming a Patreon!
Please see CONTRIBUTING for details.
If you discover any security related issues, please email hello@dianaweb.dev instead of using the issue tracker.
The MIT License (MIT). Please see License File for more information.