Notion API for Laravel is a package to effortlessly create Notion integrations with Laravel:
This package provides a simple and crisp way to access the Notion API endpoints, query data, and update existing entries.
The package includes convenient methods to fetch page information, search Notion collection pages and databases in your workspace:
- Fetch a Notion page
- Fetch children from a specific block
- Search all databases and pages
- Get all pages in a workspace
- Fetch all databases of a workspace
Here’s some usage examples from the API documentation:
1// Returns a specific page 2$notion->pages()->find($yourPageId); 3 4// Returns all pages of the workspace 5\Notion::search() 6 ->onlyPages() 7 ->query() 8 ->asCollection(); 9 10// Returns all databases of the workspace11\Notion::search()12 ->onlyDatabases()13 ->query()14 ->asCollection();15 16// Fetches all users from this workspace17\Notion::users()18 ->limit(5) // limit is optional19 ->all()20 ->asCollection();21 22// Retrieves data for a specific user in this workspace23\Notion::users()24 ->find($userId);
More specifically, here are some examples of retrieving properties from a specific page:
1// Access properties from a specific page 2$page = \Notion::pages() 3 ->find($pageId); 4 5// Returns all properties as collection 6$page->getProperties(); 7 8// Returns specific property by propertyKey 9$page->getProperty($propertyKey);10 11// Returns specific property content by propertyKey (returned type depends on the property-type)12$page->getProperty($propertyKey)->getContent();13 14// Returns specific property content by propertyKey (array of exact NotionApi-structure is returned)15$page->getProperty($propertyKey)->getRawContent();16 17// Returns array of propertyKeys (names/titles of properties)18$page->getPropertyKeys();19 20// Return json-array of all properties21$page->getRawProperties();
0 comments:
Post a Comment
Thanks