Notion PHP SDK

Overview

Notion PHP SDK

Latest Version on Packagist Total Downloads


This is an unofficial PHP SDK for the new public Notion API. It's work in progress as we didn't get the change to be included to the private beta.

Installation

You can install the package via composer:

composer require codecycler/notion

Usage

Getting all databases attached to your integration.

use Notion\Notion;

$databaseOptions = new Notion($token)
    ->database()
    ->ids();

Querying a database by id

use Notion\Notion;

$databaseOptions = new Notion($token)
    ->database($databaseId)
    ->query()
    ->get();

Query database by property (WIP)

$database = $client->database('e3161af3-ff12-43c5-9f42-02eea4ab4cbf')
  ->query()
  ->where('Show on website', 'checkbox', 'equals', true)
  ->get();

foreach ($database->pages as $page) {
  $name = $page->name;
  $status = $page->status;
}

Getting a page by id

$page = $client->page('9b0ff081-1af8-4751-92d6-9e07fbd5c20d')->get();

$name           = $page->name;          // Property: 'Name'
$showOnWebsite  = $page->showOnWebsite; // Property: 'Show on website'

Creating a new page in a database

$database = $client->database('e3161af3-ff12-43c5-9f42-02eea4ab4cbf')->get();

$page = $database->newPage();

$page->name = 'New page created with the Notion API';
$page->showOnWebsite = true;

$page->save();

Changelog

Please see 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.

Comments
  • Better support for empty properties

    Better support for empty properties

    Changes

    • Proper support for empty Date, Select, and People properties.
    • The People property now returns an array instead of the name of the first person.
    opened by andreascreten 2
  • fix: init

    fix: init "select" property on set when not isset

    When the select configuration on the Notion page is empty and if we are trying to set a value with your API, we got a warning message:

    PHP Warning: Creating default object from empty value in Notion/Properties/Select.php on line 14

    Adding a isset() condition and setting the select property fix this issue. Please note that this issue may appear on other child classes of PropertyBase.

    opened by Divi 1
  • Fix for body failed validation: body.parent should be defined, instead was undefined.

    Fix for body failed validation: body.parent should be defined, instead was undefined.

    Fixes empty array being passed to the 'Notion\Objects\Page->initProperties' method, causing error from Notion API: body failed validation: body.parent should be defined, instead was undefined.

    opened by cy-josh 1
  • [Bug] Icon on new Pages will not get saved

    [Bug] Icon on new Pages will not get saved

    Currently if you add a new Page to a Database ($notion->database('id')->get()->newPage()) you cannot set the icon. If I do $page->icon = '💬'; and save that page ($page->save();) the icon will not get saved.

    Is this planned for the future?

    opened by riyuk 0
  • Undefined

    Undefined "ray()" function

    Hi, I cannot send a new page request as an undefined function is being used here :

    https://github.com/codecyclernl/notion-php-sdk/blob/965ab2e013dd226fdc955a9dc395efcf22611cb7/src/Notion/Objects/Page.php#L68

    Maybe I'm missing something? Let me know! Thank you.

    opened by p-cauty 1
  • Properties array key generation method change

    Properties array key generation method change

    Proposal: Change key generation method from $this->properties[Str::camel($label)] to this $this->properties[sha1($label)]

    Reason:

    • non-Latin titles are "camelcased" incorrectly
    • some non-letter titles become empty strings (for example: _)
    • thus, different titles have same keys in some cases (for example: _ and __)

    If we generate sha1 from the title - we get the unique array key with a fairly high probability. Now we can refer to properties with their Notion titles: $page->Name, $page->Status, etc. Also, we can refer to properties with space in title $page->{'Show On Website'} and to non-latin properties: $page->{'Дата просмотра'}

    Code style and backward compatibility To follow code style for latin-letter-named properties case and for providing backward compatibility we store camelcased titles as aliases to sha1-keys. So, the $page->showOnWebsite still works the same as $page->{'Show On Website'}

    Testing Although I checked this on my tables, it's better to be tested additionally ;)

    p.s. Added function_exists check for the ray call

    opened by xpundel 0
Releases(0.11.0)
  • 0.11.0(Feb 10, 2022)

    What's Changed

    • Allow installation of illuminate/support 9.x by @jdrieghe in https://github.com/codecyclernl/notion-php-sdk/pull/12

    New Contributors

    • @jdrieghe made their first contribution in https://github.com/codecyclernl/notion-php-sdk/pull/12

    Full Changelog: https://github.com/codecyclernl/notion-php-sdk/compare/0.10.0...0.11.0

    Source code(tar.gz)
    Source code(zip)
  • 0.10.0(Jan 31, 2022)

    What's Changed

    • fix: init "select" property on set when not isset by @Divi in https://github.com/codecyclernl/notion-php-sdk/pull/9
    • Better support for empty properties by @andreascreten in https://github.com/codecyclernl/notion-php-sdk/pull/10

    New Contributors

    • @Divi made their first contribution in https://github.com/codecyclernl/notion-php-sdk/pull/9
    • @andreascreten made their first contribution in https://github.com/codecyclernl/notion-php-sdk/pull/10

    Full Changelog: https://github.com/codecyclernl/notion-php-sdk/compare/0.9.0...0.10.0

    Source code(tar.gz)
    Source code(zip)
  • 0.6.0(May 17, 2021)

  • 0.5.0(May 15, 2021)

Owner
Codecycler
Codecycler
Shopware PHP SDK is a simple SDK implementation of Shopware 6 APIs

Shopware PHP SDK is a simple SDK implementation of Shopware 6 APIs. It helps to access the API in an object-oriented way.

Thuong Le 77 Dec 19, 2022
Zoho CRM API SDK is a wrapper to Zoho CRM APIs. By using this sdk, user can build the application with ease

Archival Notice: This SDK is archived. You can continue to use it, but no new features or support requests will be accepted. For the new version, refe

null 81 Nov 4, 2022
The 1Password Connect PHP SDK provides your PHP applications access to the 1Password Connect API hosted on your infrastructure and leverage the power of 1Password Secrets Automation

1Password Connect PHP SDK The 1Password Connect PHP SDK provides your PHP applications access to the 1Password Connect API hosted on your infrastructu

Michelangelo van Dam 12 Dec 26, 2022
Facebook SDK for PHP (v6) - allows you to access the Facebook Platform from your PHP app

Facebook SDK for PHP (v6) This repository contains the open source PHP SDK that allows you to access the Facebook Platform from your PHP app. Installa

null 0 Aug 10, 2022
Unofficial Firebase Admin SDK for PHP

Firebase Admin PHP SDK Table of Contents Overview Installation Documentation Support License Overview Firebase provides the tools and infrastructure y

kreait 1.9k Jan 3, 2023
爱发电非官方简易 PHP SDK

afdian-php-sdk 爱发电非官方简易 PHP SDK by Akkariin 这是一个简单的 SDK,可以用于查询爱发电的订单和赞助者信息 Installation 将项目 clone 到本地即可 git clone https://github.com/ZeroDream-CN/afdi

ZeroDream-CN 17 Nov 7, 2022
AWS Cognito package using the AWS SDK for PHP/Laravel

Laravel Package to manage Web and API authentication with AWS Cognito AWS Cognito package using the AWS SDK for PHP This package provides a simple way

EllaiSys 74 Nov 15, 2022
PHP SDK to interact with the Casper Network nodes via RPC

casper-php-sdk PHP SDK to interact with Casper Network nodes via RPC Install composer require make-software/casper-php-sdk Examples RPC Client: $node

MAKE Technology LLC 7 May 8, 2022
A Laravel 5+ (and 4) service provider for the AWS SDK for PHP

AWS Service Provider for Laravel 5/6/7/8 This is a simple Laravel service provider for making it easy to include the official AWS SDK for PHP in your

Amazon Web Services 1.5k Dec 28, 2022
SDK of the LINE Login API for PHP

LINE Login for PHP SDK of the LINE Login API for PHP Documentation See the official API documentation for more information. Installation Use the packa

null 4 Sep 15, 2022
PHP SDK - Flexie CRM fiskalizimi solution

PHP SDK - Flexie CRM fiskalizimi solution Fiskalizimi PHP SDK allows you to talk and generate your e-invoices programmatically from your own solution

Flexie CRM 3 Dec 30, 2021
PHP Digital Green Certificate SDK

Digital Green Certificate SDK PHP Indice Contesto Installazione Uso Licenza Dettaglio licenza Contesto Attenzione, questo repository è derivato dalle

null 13 Jun 20, 2022
Esse SDK em PHP foi desenvolvido no intuito de tornar mais prático a integração com nossa API.

Sobre Beedoo SDK Acessar documentação completa da Beedoo API. A API é organizada seguindo a arquitetura REST, boas práticas, convenções e padrões como

Beedoo Edtech 5 Dec 2, 2021
A PHP SDK for accessing the OpenAI GPT-3 API

OpenAI GPT-3 Api Client in PHP Installation You can install the package via composer: composer require orhanerday/open-ai Usage use Orhanerday\OpenAi\

Orhan erday 462 Jan 2, 2023
The Facebook SDK for PHP provides a native interface to the Graph API and Facebook Login

Facebook SDK for PHP (v5) This repository contains the open source PHP SDK that allows you to access the Facebook Platform from your PHP app. Installa

Meta Archive 3.1k Dec 30, 2022
PHP SDK for the Sellix Developers API (developers.sellix.io)

PHP SDK for the Sellix Developers API (developers.sellix.io). Quickly get started and create products, payments and more using PHP.

Sellix 7 Nov 23, 2022
Alibaba Cloud SDK for PHP

English | 简体中文 Alibaba Cloud SDK for PHP Alibaba Cloud SDK for PHP is a development kit that supports quick access to products, dependency on Alibaba

Alibaba Cloud 493 Dec 16, 2022
Aliyun OSS SDK for PHP

Alibaba Cloud OSS SDK for PHP README of Chinese Overview Alibaba Cloud Object Storage Service (OSS) is a cloud storage service provided by Alibaba Clo

Alibaba Cloud 939 Dec 29, 2022
Qiniu Resource (Cloud) Storage SDK for PHP

Qiniu Cloud SDK for PHP 安装 推荐使用 composer 进行安装。可以使用 composer.json 声明依赖,或者运行下面的命令。SDK 包已经放到这里 qiniu/php-sdk 。 $ composer require qiniu/php-sdk 直接下载安装,SD

Qiniu Cloud 804 Dec 19, 2022