GithubHelp home page GithubHelp logo

mpociot / laravel-notion-api Goto Github PK

View Code? Open in Web Editor NEW

This project forked from 5am-code/laravel-notion-api

3.0 2.0 0.0 113 KB

Effortless Notion integrations with Laravel

Home Page: https://5amco.de/

License: MIT License

PHP 100.00%

laravel-notion-api's Introduction

Laravel Notion API

Effortless Notion integrations with Laravel

Latest Version on Packagist Total Downloads

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

Installation

You can install the package via composer:

composer require fiveam-code/laravel-notion-api

Authorization

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"

Usage

Head over to the Documentation of this package.

🔥 Code Examples to jumpstart your Notion API Project

Basic Setup

use FiveamCode\LaravelNotionApi\Notion;
use Illuminate\Support\Collection;
use FiveamCode\LaravelNotionApi\Query\Sorting;
use FiveamCode\LaravelNotionApi\Query\Filter;

// Setup basic API connection
$notion = new Notion();
$notion->v1();

Fetch Page Information

// Returns a specific page
$notion->pages()->find($yourPageId);

Query Database

// 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(); 

Testing

vendor/bin/phpunit tests

Changelog

Please see CHANGELOG for more information what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security

If you discover any security related issues, please email [email protected] instead of using the issue tracker.

Credits

License

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

Laravel Package Boilerplate

This package was generated using the Laravel Package Boilerplate.

laravel-notion-api's People

Contributors

johguentner avatar mechelon avatar sschlein avatar

Stargazers

Hugo Epinosa avatar Junior Fernandes avatar Ty Noryan avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.