File tree Expand file tree Collapse file tree 1 file changed +48
-0
lines changed Expand file tree Collapse file tree 1 file changed +48
-0
lines changed Original file line number Diff line number Diff line change @@ -34,6 +34,54 @@ NOTION_API_TOKEN="$YOUR_ACCESS_TOKEN"
3434
3535Head over to the [ Documentation] ( https://www.notion.so/5amcode/Working-Examples-813998dab4244158b51ea3b25b420c60 ) of this package in Notion.
3636
37+ ### 🔥 Code Examples to jumpstart your Notion API Project
38+
39+ #### Basic Setup
40+ ``` php
41+ use FiveamCode\LaravelNotionApi\Notion;
42+ use Illuminate\Support\Collection;
43+ use FiveamCode\LaravelNotionApi\Query\Sorting;
44+ use FiveamCode\LaravelNotionApi\Query\Filter;
45+
46+ // Setup basic API connection
47+ $notion = new Notion();
48+ $notion->v1();
49+ ```
50+
51+ #### Fetch Page Information
52+ ``` php
53+ // Returns a specific page
54+ $notion->pages()->find($yourPageId);
55+ ```
56+
57+ #### Query Database
58+ ``` php
59+ // Queries a specific database and returns a collection of pages (= database entries)
60+ $sortings = new Collection();
61+ $filters = new Collection();
62+
63+ $sortings
64+ ->add(Sorting::propertySort("Ordered", "ascending"));
65+ $sortings
66+ ->add(Sorting::timestampSort("created_time", "ascending"));
67+
68+ $filters
69+ ->add(Filter::textFilter("title", ["contains" => "new"]));
70+ // or
71+ $filters
72+ ->add(Filter::rawFilter("Tags", ["multi_select" => ["contains" => "great"]]));
73+
74+ $notion
75+ ->database($yourDatabaseId)
76+ ->filterBy($filters) // filters are optional
77+ ->sortBy($sortings) // sorts are optional
78+ ->limit(5) // limit is optional
79+ ->query();
80+ ```
81+
82+
83+
84+
3785### Testing
3886
3987``` bash
You can’t perform that action at this time.
0 commit comments