Package Data | |
---|---|
Maintainer Username: | 5amcode |
Maintainer Contact: | hello@dianaweb.dev (Diana Scharf) |
Package Create Date: | 2021-05-14 |
Package Last Update: | 2024-07-02 |
Home Page: | https://notionforlaravel.com |
Language: | PHP |
License: | MIT |
Last Refreshed: | 2024-11-23 03:13:16 |
Package Statistics | |
---|---|
Total Downloads: | 97,585 |
Monthly Downloads: | 5,127 |
Daily Downloads: | 159 |
Total Stars: | 411 |
Total Watchers: | 10 |
Total Forks: | 50 |
Total Open Issues: | 9 |
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;
# Access through Facade (token has to be set in .env)
\Notion::databases()->find($databaseId);
# Custom instantiation (necessary if you want to access more than one NotionApi integration)
$notion = new Notion($apiToken, $apiVersion); // version-default is 'v1'
$notion->databases()->find($databaseId);
// Returns a specific page
\Notion::pages()->find($yourPageId);
// Returns a collection pages and databases of your workspace (included in your integration-token)
\Notion::search($searchText)
->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($yourDatabaseId)
->filterBy($filters) // filters are optional
->sortBy($sortings) // sorts are optional
->limit(5) // limit is optional
->query()
->asCollection();
vendor/bin/phpunit 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.
Using this package in your project? Open a PR to add it in this section!
The MIT License (MIT). Please see License File for more information.