PHPackages                             brd6/notion-sdk-php - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. brd6/notion-sdk-php

ActiveLibrary[API Development](/categories/api)

brd6/notion-sdk-php
===================

Notion SDK for PHP

1.8.2(1mo ago)5918.0k—8.5%6MITPHPPHP ^7.4 || ^8CI passing

Since Apr 7Pushed 1mo ago4 watchersCompare

[ Source](https://github.com/brd6/notion-sdk-php)[ Packagist](https://packagist.org/packages/brd6/notion-sdk-php)[ GitHub Sponsors](https://github.com/brd6)[ RSS](/packages/brd6-notion-sdk-php/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (10)Dependencies (50)Versions (43)Used By (0)

[![brd6/notion-sdk-php](resources/banner.png "brd6/notion-sdk-php")](resources/banner.png)

 **Notion SDK for PHP**

 [![Source Code](https://camo.githubusercontent.com/4d529ca71b0155c259e103f5a6b1de4e6d67d69ecc6485447395e77ebff101d8/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f736f757263652d627264362f6e6f74696f6e2d2d73646b2d2d7068702d626c75652e7376673f7374796c653d666c61742d737175617265)](https://github.com/brd6/notion-sdk-php) [![Download Package](https://camo.githubusercontent.com/82c46b137b8e15b7002c109ff0561bab63acec44e2bce5b01d0827db0b1ddc4e/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f627264362f6e6f74696f6e2d73646b2d7068702e7376673f7374796c653d666c61742d737175617265266c6162656c3d72656c65617365)](https://packagist.org/packages/brd6/notion-sdk-php) [![PHP Programming Language](https://camo.githubusercontent.com/b25db9c4889b9ce1a1c819fd19477591e8a63673e59d70f847c10198587d6687/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f627264362f6e6f74696f6e2d73646b2d7068702e7376673f7374796c653d666c61742d73717561726526636f6c6f72423d253233383839324246)](https://php.net) [![Read License](https://camo.githubusercontent.com/952a600892cf75a65c5116a6e282128613aaa925e3093c2e6ab0b4787755b24c/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f627264362f6e6f74696f6e2d73646b2d7068702e7376673f7374796c653d666c61742d73717561726526636f6c6f72423d6461726b6379616e)](https://github.com/brd6/notion-sdk-php/blob/main/LICENSE) [![Build Status](https://camo.githubusercontent.com/709583c1addc0775ba6d42261ef0d0e1f786381f6f20970e3965a632275db3ef/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f627264362f6e6f74696f6e2d73646b2d7068702f2e6769746875622f776f726b666c6f77732f636f6e74696e756f75732d696e746567726174696f6e2e796d6c3f6272616e63683d6d61696e267374796c653d666c61742d737175617265266c6f676f3d676974687562)](https://github.com/brd6/notion-sdk-php/actions/workflows/continuous-integration.yml)

PHP version of the official [NOTION API](https://developers.notion.com). It works the same way as the reference [JavaScript SDK](https://github.com/makenotion/notion-sdk-js) 🎉

Installation
------------

[](#installation)

Install this package as a dependency using [Composer](https://getcomposer.org).

```
composer require brd6/notion-sdk-php
```

This package `(brd6/notion-sdk-php)` is not tied to any specific library such as Guzzle or Buzz that sends HTTP messages. Instead, it uses the [PSR-18](https://www.php-fig.org/psr/psr-18/) client abstraction to let users choose whichever [PSR-7 implementation](https://packagist.org/providers/psr/http-message-implementation)and [HTTP client](https://packagist.org/providers/psr/http-client-implementation) they want to use.

If you just want to get started quickly with symfony http client, run the following command:

```
composer require brd6/notion-sdk-php symfony/http-client nyholm/psr7
```

Usage
-----

[](#usage)

> Use Notion's [Getting Started Guide](https://developers.notion.com/docs/getting-started) to get set up to use Notion's API.

Import and initialize a client using an **integration token** or an OAuth **access token**.

```
use Brd6\NotionSdkPhp\Client;
use Brd6\NotionSdkPhp\ClientOptions;

$options = (new ClientOptions())
    ->setAuth(getenv('NOTION_TOKEN'));

$notion = new Client($options);
```

Make a request to any Notion API endpoint.

> See the complete list of endpoints in the [API reference](https://developers.notion.com/reference).

```
$listUsersResponse = $notion->users()->list();
var_dump($listUsersResponse->toArray());
```

```
array (size=4)
  'has_more' => boolean false
  'results' =>
    array (size=2)
      0 =>
        array (size=6)
          'object' => string 'user' (length=4)
          'id' => string '7f03dda0-a132-49d7-b8b2-29c9ed1b1f0e' (length=36)
          'type' => string 'person' (length=6)
          'name' => string 'John Doe' (length=8)
          'avatar_url' => string 'https://s3-us-west-2.amazonaws.com/public.notion-static.com/521dfe9c-f821-4de8-a0bb-e40ff71283e5/39989484_10217003981481443_4621803518267752448_n.jpg' (length=149)
          'person' =>
            array (size=1)
              ...
      1 =>
        array (size=5)
          'object' => string 'user' (length=4)
          'id' => string '8dee9e49-7369-4a6d-a11f-7db625b2448c' (length=36)
          'type' => string 'bot' (length=3)
          'name' => string 'MyBot' (length=5)
          'bot' =>
            array (size=1)
              ...
  'object' => string 'list' (length=4)
  'type' => string 'user' (length=4)
```

Endpoint parameters are grouped into a single object. You don't need to remember which parameters go in the path, query, or body.

```
$databaseRequest = new DatabaseRequest();
$databaseRequest->setFilter([
    'property' => 'Landmark',
    'text' => [
        'contains' => 'Bridge',
    ],
]);
$myPage = $notion->databases()->query('897e5a76-ae52-4b48-9fdf-e71f5945d1af', $databaseRequest)
```

### Data sources (Notion API 2025-09-03)

[](#data-sources-notion-api-2025-09-03)

If you use Notion API version `2025-09-03` or newer, the SDK supports data source endpoints via `$notion->dataSources()`, and page creation with `data_source_id` parents. When creating a database with this API version, `databases()->create()` automatically maps `properties` to the required `initial_data_source` payload.

### Handling errors

[](#handling-errors)

If the API returns an unsuccessful response, an `ApiResponseException` will be thrown.

The error contains properties from the response, and the most helpful is `code`. You can compare `code` to the values in the `NotionErrorCodeConstant` object to avoid misspelling error codes.

### Client options

[](#client-options)

The `Client` supports the following options on initialization. These options can be set on the `ClientOptions` instance.

OptionDefault valueTypeDescription`auth``''``string`Bearer token for authentication. If left undefined, the `auth` parameter should be set on each request.`timeout``60``number`Number of seconds to wait before throw a `RequestTimeoutException``baseUrl``"https://api.notion.com"``string`The root URL for sending API requests. This can be changed to test with a mock server.`httpClient`Default Http Client`Psr\Http\Client\ClientInterface`The Http Client used to make request on the Notion API. This can be change to customize the base Http Client or replace with a mocked Http Client.Examples
--------

[](#examples)

The `examples/` directory contains a comprehensive set of usage examples that demonstrate how to use the SDK for various tasks, from basic API calls to complex integrations:

- **[01-intro-to-notion-api](examples/01-intro-to-notion-api/)** - Basic database queries and page creation
- **[02-parse-text-from-any-block](examples/02-parse-text-from-any-block/)** - Extract text content from all block types
- **[03-web-form](examples/03-web-form/)** - Web form to Notion page integration
- **[04-generate-random-data](examples/04-generate-random-data/)** - Populate databases with sample data
- **[05-notify-on-update](examples/05-notify-on-update/)** - Email notifications for database changes
- **[06-notion-github-sync](examples/06-notion-github-sync/)** - GitHub issues synchronization
- **[07-oauth-flow](examples/07-oauth-flow/)** - Complete OAuth 2.0 implementation
- **[08-data-sources-api-smoke](examples/08-data-sources-api-smoke/)** - Data source integration checks for retrieve/query/search/create/update

Each example is self-contained with its own dependencies, documentation, and setup instructions.

Contributing
------------

[](#contributing)

Contributions are welcome! To contribute, please familiarize yourself with [CONTRIBUTING.md](CONTRIBUTING.md).

License
-------

[](#license)

The MIT License (MIT). Please see [LICENSE](LICENSE) for more information.

###  Health Score

56

—

FairBetter than 98% of packages

Maintenance90

Actively maintained with recent releases

Popularity41

Moderate usage in the ecosystem

Community16

Small or concentrated contributor base

Maturity61

Established project with proven stability

 Bus Factor1

Top contributor holds 87.2% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~51 days

Recently: every ~38 days

Total

29

Last Release

52d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/f007c1c65f0c50524a653493449ebf36a777c9decd9b7603eaa3ceb4fcebb2c2?d=identicon)[brd6](/maintainers/brd6)

---

Top Contributors

[![brd6](https://avatars.githubusercontent.com/u/15201127?v=4)](https://github.com/brd6 "brd6 (212 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (28 commits)")[![MisterDuval](https://avatars.githubusercontent.com/u/66914?v=4)](https://github.com/MisterDuval "MisterDuval (2 commits)")[![rodrigoprimo](https://avatars.githubusercontent.com/u/77215?v=4)](https://github.com/rodrigoprimo "rodrigoprimo (1 commits)")

---

Tags

notionnotion-apinotion-clientnotion-sdkphpsdkphpnotionnotion-apinotion-sdknotion-client

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan, Psalm

Type Coverage Yes

### Embed Badge

![Health badge](/badges/brd6-notion-sdk-php/health.svg)

```
[![Health](https://phpackages.com/badges/brd6-notion-sdk-php/health.svg)](https://phpackages.com/packages/brd6-notion-sdk-php)
```

###  Alternatives

[openai-php/client

OpenAI PHP is a supercharged PHP API client that allows you to interact with the Open AI API

5.8k22.6M232](/packages/openai-php-client)[sylius/sylius

E-Commerce platform for PHP, based on Symfony framework.

8.4k5.6M651](/packages/sylius-sylius)[phpro/http-tools

HTTP tools for developing more consistent HTTP implementations.

28137.8k](/packages/phpro-http-tools)[theodo-group/llphant

LLPhant is a library to help you build Generative AI applications.

1.5k311.5k5](/packages/theodo-group-llphant)[mozex/anthropic-php

Anthropic PHP is a supercharged community-maintained PHP API client that allows you to interact with Anthropic API.

46365.1k13](/packages/mozex-anthropic-php)[darthsoup/php-whmcs-api

WHMCS API client for PHP

2317.3k4](/packages/darthsoup-php-whmcs-api)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
