{"id":13660201,"url":"https://github.com/brd6/notion-sdk-php","last_synced_at":"2026-02-23T21:18:15.315Z","repository":{"id":37792384,"uuid":"468870898","full_name":"brd6/notion-sdk-php","owner":"brd6","description":"PHP library for the official Notion API.","archived":false,"fork":false,"pushed_at":"2025-06-26T07:27:33.000Z","size":439,"stargazers_count":59,"open_issues_count":0,"forks_count":5,"subscribers_count":5,"default_branch":"main","last_synced_at":"2025-08-11T11:13:17.866Z","etag":null,"topics":["notion","notion-api","notion-client","notion-sdk","php","sdk"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/brd6.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"brd6"}},"created_at":"2022-03-11T19:10:41.000Z","updated_at":"2025-07-24T21:25:51.000Z","dependencies_parsed_at":"2023-02-18T15:15:48.497Z","dependency_job_id":"e1d4c657-4df2-4275-bbb5-3b200bb11bd9","html_url":"https://github.com/brd6/notion-sdk-php","commit_stats":{"total_commits":158,"total_committers":4,"mean_commits":39.5,"dds":0.08860759493670889,"last_synced_commit":"dd8574e6d263f48dd8347e61c881d5fe06e88e35"},"previous_names":[],"tags_count":19,"template":false,"template_full_name":null,"purl":"pkg:github/brd6/notion-sdk-php","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brd6%2Fnotion-sdk-php","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brd6%2Fnotion-sdk-php/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brd6%2Fnotion-sdk-php/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brd6%2Fnotion-sdk-php/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/brd6","download_url":"https://codeload.github.com/brd6/notion-sdk-php/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brd6%2Fnotion-sdk-php/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":270100556,"owners_count":24527070,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-12T02:00:09.011Z","response_time":80,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["notion","notion-api","notion-client","notion-sdk","php","sdk"],"created_at":"2024-08-02T05:01:18.319Z","updated_at":"2026-02-23T21:18:15.310Z","avatar_url":"https://github.com/brd6.png","language":"PHP","funding_links":["https://github.com/sponsors/brd6"],"categories":["PHP"],"sub_categories":[],"readme":"![brd6/notion-sdk-php](resources/banner.png \"brd6/notion-sdk-php\")\n\n\u003cp align=\"center\"\u003e\n    \u003cstrong\u003eNotion SDK for PHP\u003c/strong\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n    \u003ca href=\"https://github.com/brd6/notion-sdk-php\"\u003e\u003cimg src=\"https://img.shields.io/badge/source-brd6/notion--sdk--php-blue.svg?style=flat-square\" alt=\"Source Code\"\u003e\u003c/a\u003e\n    \u003ca href=\"https://packagist.org/packages/brd6/notion-sdk-php\"\u003e\u003cimg src=\"https://img.shields.io/packagist/v/brd6/notion-sdk-php.svg?style=flat-square\u0026label=release\" alt=\"Download Package\"\u003e\u003c/a\u003e\n    \u003ca href=\"https://php.net\"\u003e\u003cimg src=\"https://img.shields.io/packagist/php-v/brd6/notion-sdk-php.svg?style=flat-square\u0026colorB=%238892BF\" alt=\"PHP Programming Language\"\u003e\u003c/a\u003e\n    \u003ca href=\"https://github.com/brd6/notion-sdk-php/blob/main/LICENSE\"\u003e\u003cimg src=\"https://img.shields.io/packagist/l/brd6/notion-sdk-php.svg?style=flat-square\u0026colorB=darkcyan\" alt=\"Read License\"\u003e\u003c/a\u003e\n    \u003ca href=\"https://github.com/brd6/notion-sdk-php/actions/workflows/continuous-integration.yml\"\u003e\u003cimg src=\"https://img.shields.io/github/actions/workflow/status/brd6/notion-sdk-php/.github/workflows/continuous-integration.yml?branch=main\u0026style=flat-square\u0026logo=github\" alt=\"Build Status\"\u003e\u003c/a\u003e\n\u003c/p\u003e\n\nPHP 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) 🎉\n\n\n## Installation\n\nInstall this package as a dependency using [Composer](https://getcomposer.org).\n\n``` bash\ncomposer require brd6/notion-sdk-php\n```\n\nThis 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)\nand [HTTP client](https://packagist.org/providers/psr/http-client-implementation) they want to use.\n\nIf you just want to get started quickly with symfony http client, run the following command:\n\n```bash\ncomposer require brd6/notion-sdk-php symfony/http-client nyholm/psr7\n```\n\n## Usage\n\n\u003e Use Notion's [Getting Started Guide](https://developers.notion.com/docs/getting-started) to get set up to use Notion's API.\n\nImport and initialize a client using an **integration token** or an OAuth **access token**.\n\n```php\nuse Brd6\\NotionSdkPhp\\Client;\nuse Brd6\\NotionSdkPhp\\ClientOptions;\n\n$options = (new ClientOptions())\n    -\u003esetAuth(getenv('NOTION_TOKEN'));\n\n$notion = new Client($options);\n```\n\nMake a request to any Notion API endpoint.\n\n\u003e See the complete list of endpoints in the [API reference](https://developers.notion.com/reference).\n```php\n$listUsersResponse = $notion-\u003eusers()-\u003elist();\nvar_dump($listUsersResponse-\u003etoArray());\n```\n\n```php\narray (size=4)\n  'has_more' =\u003e boolean false\n  'results' =\u003e\n    array (size=2)\n      0 =\u003e\n        array (size=6)\n          'object' =\u003e string 'user' (length=4)\n          'id' =\u003e string '7f03dda0-a132-49d7-b8b2-29c9ed1b1f0e' (length=36)\n          'type' =\u003e string 'person' (length=6)\n          'name' =\u003e string 'John Doe' (length=8)\n          'avatar_url' =\u003e string 'https://s3-us-west-2.amazonaws.com/public.notion-static.com/521dfe9c-f821-4de8-a0bb-e40ff71283e5/39989484_10217003981481443_4621803518267752448_n.jpg' (length=149)\n          'person' =\u003e\n            array (size=1)\n              ...\n      1 =\u003e\n        array (size=5)\n          'object' =\u003e string 'user' (length=4)\n          'id' =\u003e string '8dee9e49-7369-4a6d-a11f-7db625b2448c' (length=36)\n          'type' =\u003e string 'bot' (length=3)\n          'name' =\u003e string 'MyBot' (length=5)\n          'bot' =\u003e\n            array (size=1)\n              ...\n  'object' =\u003e string 'list' (length=4)\n  'type' =\u003e string 'user' (length=4)\n```\n\nEndpoint parameters are grouped into a single object. You don't need to remember which parameters go in the path, query, or body.\n```php\n$databaseRequest = new DatabaseRequest();\n$databaseRequest-\u003esetFilter([\n    'property' =\u003e 'Landmark',\n    'text' =\u003e [\n        'contains' =\u003e 'Bridge',\n    ],\n]);\n$myPage = $notion-\u003edatabases()-\u003equery('897e5a76-ae52-4b48-9fdf-e71f5945d1af', $databaseRequest)\n```\n\n### Data sources (Notion API 2025-09-03)\n\nIf you use Notion API version `2025-09-03` or newer, the SDK supports data source endpoints via `$notion-\u003edataSources()`, and page creation with `data_source_id` parents. When creating a database with this API version, `databases()-\u003ecreate()` automatically maps `properties` to the required `initial_data_source` payload.\n\n### Handling errors\n\nIf the API returns an unsuccessful response, an `ApiResponseException` will be thrown.\n\nThe 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.\n\n### Client options\n\nThe `Client` supports the following options on initialization. These options can be set on the `ClientOptions` instance.\n\n| Option       | Default value              | Type                              | Description                                                                                                                                        |\n|--------------|----------------------------|-----------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------|\n| `auth`       | `''`                       | `string`                          | Bearer token for authentication. If left undefined, the `auth` parameter should be set on each request.                                            |\n| `timeout`    | `60`                       | `number`                          | Number of seconds to wait before throw a `RequestTimeoutException`                                                                                 |\n| `baseUrl`    | `\"https://api.notion.com\"` | `string`                          | The root URL for sending API requests. This can be changed to test with a mock server.                                                             |\n| `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. |\n\n## Examples\n\nThe `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:\n\n- **[01-intro-to-notion-api](examples/01-intro-to-notion-api/)** - Basic database queries and page creation\n- **[02-parse-text-from-any-block](examples/02-parse-text-from-any-block/)** - Extract text content from all block types\n- **[03-web-form](examples/03-web-form/)** - Web form to Notion page integration\n- **[04-generate-random-data](examples/04-generate-random-data/)** - Populate databases with sample data\n- **[05-notify-on-update](examples/05-notify-on-update/)** - Email notifications for database changes\n- **[06-notion-github-sync](examples/06-notion-github-sync/)** - GitHub issues synchronization\n- **[07-oauth-flow](examples/07-oauth-flow/)** - Complete OAuth 2.0 implementation\n- **[08-data-sources-api-smoke](examples/08-data-sources-api-smoke/)** - Data source integration checks for retrieve/query/search/create/update\n\nEach example is self-contained with its own dependencies, documentation, and setup instructions.\n\n## Contributing\n\nContributions are welcome! To contribute, please familiarize yourself with\n[CONTRIBUTING.md](CONTRIBUTING.md).\n\n\n\n\n\n\n\n## License\n\nThe MIT License (MIT). Please see [LICENSE](LICENSE) for more information.\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbrd6%2Fnotion-sdk-php","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbrd6%2Fnotion-sdk-php","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbrd6%2Fnotion-sdk-php/lists"}