zlt / laravel-notion-viewer
Get Notion blocks with Laravel
v0.0.2
2022-12-10 15:06 UTC
Requires
- php: ^8.1
- illuminate/http: ^8.0|^9.0
- illuminate/support: ^8.0|^9.0
This package is auto-updated.
Last update: 2025-01-10 19:21:04 UTC
README
This is a server side package for getting Notion page and blocks.
In order to render notion blocks in your application, please consider using npm package notion-viewer-client.
Table Of Contents
Prerequisites
Requirements are:
"illuminate/support": "^8.0|^9.0",
"php": "^8.1",
"illuminate/http": "^8.0|^9.0"
You need to provide API key for getting Notion API.
If you don't know how to get API key, please consult this documentation.
Installation
- Install package via composer
composer require laravel-notion-viewer
- Publish config file
php artisan vendor:publish --tag=laravel-notion-viewer
The following routes will be auto registered.
/laravel-notion-viewer/data/{id} /laravel-notion-viewer/link-preview
Config file will be
'API_KEY' => env('NOTION_API_KEY'), 'API_VERSION' => env('NOTION_API_VERSION'), // default '2022-06-28' 'cache' => [ // If you want to cache the response, set this to true 'enabled' => false, // specify cache time in seconds 'time' => 60, ]
Usage
use Zlt\LaravelNotionViewer\Notion\Client;
-
Getting Notion Page
Client::getPage('page-id');
-
Getting Blocks
Client::getBlocks('block-id');
-
Getting Notion Page With Blocks
Client::getPageWithBlocks('page-id');
-
Getting Recursive Blocks
Some blocks have children blocks. In order to get all children blocks, use this method.
Client::getRecursiveBlocks('block-id');
-
Getting Page with Recursive Blocks
Client::getPageWithRecursiveBlocks('page-id');
TroubleShooting
-
object_not_found error
If you get
object_not_found
error, please check if you have given your integration access to your Notion Page. See here.
Support me
If you want to support me, buy me a coffee via Binance.
TODO
- Add Tests
- Add more features to cover all Notion API endpoints