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
The Notion API requires an access token and a Notion integration, the Notion documentation explains how this works. It's important to grant access to the integration within your Notion account to enable the API access.
Add your Notion API token to your .env
file:
NOTION_API_TOKEN="$YOUR_ACCESS_TOKEN"
Head over to the Documentation of this package.
use FiveamCode\LaravelNotionApi\Notion;
use Illuminate\Support\Collection;
use FiveamCode\LaravelNotionApi\Query\Sorting;
use FiveamCode\LaravelNotionApi\Query\Filter;
// Setup basic API connection
$notion = new Notion();
$notion->v1();
// Returns a specific page
$notion->pages()->find($yourPageId);
// 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($yourDatabaseId)
->filterBy($filters) // filters are optional
->sortBy($sortings) // sorts are optional
->limit(5) // limit is optional
->query();
vendor/bin/phpunit tests
Please see CHANGELOG for more information what has changed recently.
Please see CONTRIBUTING for details.
If you discover any security related issues, please email [email protected] instead of using the issue tracker.
The MIT License (MIT). Please see License File for more information.
This package was generated using the Laravel Package Boilerplate.