Introduction
Getting started
Installation
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 Notions docs 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.
For simplicity and clearity the Internal Integration
approach is used throughout the documentation. However, every functionality can be used with the Public Integration
approach, described below.
Public Integration (OAuth)
For public Integrations, please use Laravel Socialite to authenticate Notion users and retrieve their access-token.
In order to access a user's Notion Workspace, you can hand over the access-tokens like the following:
# init Notion instance with api-token
$notion = new Notion($apiToken);
# example: find a database by id
$notion->databases()->find($databaseId);
Upgrading from older Versions
If your project depends on one of the older versions, please refer to the Upgrade Guide . If you currently have a version below v0.8, please refer to the changelog of our previous documentation at 5amco.de/docs and the current before updating the dependency.
Support us
Support us on Patreon!
If you like our package and you want to see further/faster development, consider becoming a Patreon .