You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[](https://packagist.org/packages/fiveam-code/laravel-notion-api)
This package provides a simple and crisp way to access the Notion API endpoints, query data and update existing entries.
14
11
12
+
15
13
## Installation
16
14
17
-
You can install the package via composer:
15
+
1.You can install the package via composer:
18
16
19
-
```bash
20
-
composer require fiveam-code/laravel-notion-api
21
-
```
17
+
```bash
18
+
composer require fiveam-code/laravel-notion-api
19
+
```
22
20
23
-
### Authorization
24
21
25
-
The Notion API requires an access token and a Notion integration, [the Notion documentation](https://developers.notion.com/docs/getting-started#before-we-begin) explains how this works. It's important to grant access to the integration within your Notion account to enable the API access.
22
+
2. Get your Notion API access token like explained in [their documentation](https://developers.notion.com/). It's also
23
+
important to grant access to the integration within your Notion pages, which is described in the developer documentation at Notion as well.
26
24
27
-
Add your Notion API token to your `.env` file:
25
+
3. For internal Integrations, please add a new entry to your `.env` like the following:
26
+
27
+
```bash
28
+
NOTION_API_TOKEN="$YOUR_ACCESS_TOKEN"
29
+
```
30
+
4. Now you can easily access Notion:
31
+
```php
32
+
use \Notion;
33
+
34
+
Notion::databases()->find($databaseId);
35
+
```
36
+
37
+
That's it.
28
38
29
-
```
30
-
NOTION_API_TOKEN="$YOUR_ACCESS_TOKEN"
31
-
```
32
39
33
40
## Usage
34
41
35
-
Head over to the [Documentation](https://5amco.de/docs) of this package.
42
+
Head over to the [Documentation](https://notionforlaravel.com) of this package.
36
43
37
-
### 🔥 Code Examples to jumpstart your Notion API Project
44
+
### 🔥 Code Examples to jumpstart your next Notion API Project
38
45
39
-
#### Basic Setup (+ example)
46
+
#### Fetch a Notion Database (through a Facade)
40
47
```php
41
-
use FiveamCode\LaravelNotionApi\Notion;
48
+
use \Notion;
42
49
43
-
# Access through Facade (token has to be set in .env)
44
-
\Notion::databases()->find($databaseId);
45
-
46
-
# Custom instantiation (necessary if you want to access more than one NotionApi integration)
47
-
$notion = new Notion($apiToken, $apiVersion); // version-default is 'v1'
48
-
$notion->databases()->find($databaseId);
50
+
Notion::databases()
51
+
->find("a7e5e47d-23ca-463b-9750-eb07ca7115e4");
49
52
```
50
53
51
-
#### Fetch Page Information
54
+
#### Fetch a Notion Page
52
55
```php
53
-
// Returns a specific page
54
-
\Notion::pages()->find($yourPageId);
56
+
Notion::pages()
57
+
->find("e7e5e47d-23ca-463b-9750-eb07ca7115e4");
55
58
```
56
59
57
60
#### Search
58
61
```php
59
62
// Returns a collection pages and databases of your workspace (included in your integration-token)
@@ -107,19 +106,16 @@ Please see [CONTRIBUTING](CONTRIBUTING.md) for details.
107
106
108
107
If you discover any security related issues, please email hello@dianaweb.dev instead of using the issue tracker.
109
108
110
-
## Used By
111
-
112
-
- Julien Nahum created [notionforms.io](https://notionforms.io) with [laravel-notion-api](https://github.com/5am-code/laravel-notion-api), which allows you to easily create custom forms, based on your selected database within notion.
113
-
-[GitHub Notion Sync](https://githubnotionsync.com/), a service by [Beyond Code](https://beyondco.de) to sync the issues of multiple GitHub repositories into a Notion database
114
-
-[Notion Invoice](https://notioninvoice.com/), the first premium invoicing solution for freelancers and businesses that use Notion. Create beautiful PDF invoices from your Notion data.
115
-
116
-
Using this package in your project? Open a PR to add it in this section!
0 commit comments