Download the PHP package pi-space/notion-api-integration without Composer

On this page you can find all versions of the php package pi-space/notion-api-integration. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package notion-api-integration

Laravel Notion Integration


About

The Laravel Notion Integration package is a wrapper for the REST API provided by Notion.so. It allows for easy interaction with your Notion workspace, saving you time and effort.

This package provides an easy and fluent interface for manipulating pages, databases, users, blocks, and more.

Installation

You can install the package via composer:

Usage

Setting Up Notion Workspace

In your .env file, add your Notion token:

To create your first integration, please visit: Notion Create an integration To obtain your secret token, visit Notion API

Handling Notion Databases

Fetching Notion Database by ID

To fetch a Notion database by ID, use the find method of the NotionDatabase class. It will return a NotionDatabase object containing information such as title, description, and all the database properties.

Creating a Notion Database

To create a Notion database, use the NotionDatabase class and set the required parameters such as parent page ID and properties schema.

Updating a Notion Database

To update an existing Notion database, use the NotionDatabase class and specify the database ID and updated properties.

Querying a Database

To query a Notion database and get a list of pages contained within the database, you can apply filters and sorting criteria using the query method.

Handling Notion Pages

Fetching a Page by ID (without the page contents)

Fetching a Page by ID (with the page contents)

Creating a New Notion Page / Notion Database Item

To create a new Notion page or a new item in a Notion database, you can use the NotionPage class and set the required properties and their values.

Creating a New Notion Page / Notion Database Item with Content

Updating a Page Properties

To update the properties of an existing page, create a NotionPage object with the page ID, set the updated properties, and call the update() method.

Deleting a Page

To delete a page, create a NotionPage object with the page ID and call the delete() method.

Handling Notion Blocks

Fetching a Block by ID

To fetch a Notion block by ID, use the find method of the NotionBlock class.

Fetching Block Children

To fetch the children blocks of a Notion block, use the fetchChildren method.

Updating a Block

To update a Notion block, create a new instance of the NotionBlock class, set the updated content, and call the update() method.

Appending Block Children

To append children blocks to a Notion block, use the createChildren method.

Deleting a Block

To delete a Notion block, use the delete method.

Searching

You can perform searches in Notion pages or databases using the NotionSearch class.

Searching in Pages

To search for a specific query in Notion pages, use the inPages method of the NotionSearch class. You can apply sorting criteria using the sorts method.

Searching in Databases

To search for a specific query in Notion databases, use the inDatabases method of the NotionSearch class.

Users

Retrieving All Users

To retrieve all Notion users, use the index method of the NotionUser class.

Retrieving a User by ID

To retrieve a specific Notion user by ID, use the find method of the NotionUser class.

Retrieving Current Bot Info

To retrieve information about the current Notion bot, use the getBot method of the NotionUser class.

Comments

Retrieving All Comments by Page ID / Discussion ID

To retrieve all comments associated with a page or discussion, use the index method of the NotionComment class.

Creating a New Comment

To create a new comment on a page or discussion, use the NotionComment class and set the parent ID and content.

Pagination

Notion API provides paginated responses for certain endpoints. The NotionPaginator class handles pagination for you.

Example with Search Results

Mapping Eloquent Models to Notion Database Items

To map your Laravel Eloquent models to Notion database items, you can use the Notionable trait and implement the mapToNotion method in your model.

Syncing Data between Notion and Eloquent Models

You can sync data between Notion and Eloquent models using the sync:to-notion Artisan command.

Watching a Notion Database

Currently, Notion API does not support webhooks. However, you can use the 'notion:watch' artisan command to watch a Notion database for changes. The command will run every specified interval and check for changes in the notion database. If there are any changes, it will send a post request to your route, so you can handle it accordingly. You can change the interval and the route in the config file.

This is how you can run the command:

Surely, you can use the command in a cron job to run it every specified interval.

Handling Errors

In case of an error, an exception will be thrown with the error message. You can check the exceptions folder or the NotionException class for more information about the exceptions. Please refer to the Notion API documentation for detailed information about the errors.

Testing

To run the package tests, use the following command:

Changelog

Please see the CHANGELOG for more information on what has changed recently.

Contributing

Please

see CONTRIBUTING for details.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

The MIT License (MIT). Please see License File for more information.


All versions of notion-api-integration with dependencies

PHP Build Version
Package Version
Requires php Version ^8.1
guzzlehttp/guzzle Version ^7.7
illuminate/contracts Version ^10.0
spatie/laravel-package-tools Version ^1.14.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package pi-space/notion-api-integration contains the following files

Loading the files please wait ....