Picture of the author

Effortless Notion Integrations with Laravel

This package provides a simple and crisp way to access the Notion API endpoints, query data and update existing entries.

Notion::database("8284f3ff77e24d4a939d19459e4d6bdc")
->filterBy($filter)
->sortBy($sort)
->limit(5)
->query()
->asCollection();

Introduction

Getting started

Installation

  1. You can install the package via composer:

    composer require fiveam-code/laravel-notion-api
    
  2. 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.

  3. For internal Integrations, please add a new entry to your .env like the following:

    NOTION_API_TOKEN="$YOUR_ACCESS_TOKEN"
    
  4. 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 .