All responses from Notion are structured in a certain way, in order to ease the use of the API. Every result is either an
EntityCollection or an
Entity. Additionally, you can always look at the raw result from the Notion API.
Entity is a single result from Notion. This can be a
Entity has some base functions to access basic information.
# This can be any of the entities $entity = new Entity(); # Retrieve the ID of the Notion resources $id = $entity->getId(); # Retrieve the type of the Notion resource $objectType = $entity->getObjectType(); # Retrieve the raw result of the Notion API $rawResponse = $entity->getRawResponse(); # Get the response structure as a JSON array $entityAsJsonArray = $entity->toArray();
Some entities have properties like
This is the case for
While time properties are always
DateTime::class instances, the
last_edited_by properties are always
The following methods are available within timestampable entities.
$entity->getCreatedTime(); $entity->getLastEditedTime(); $entity->getCreatedBy(); $entity->getLastEditedBy();
Entities with a Parent
Some entities have a parent property, like
Both an id and the type of the parent are available as
string. The type can be either a
The following methods are available within entities with a parent.
Some entities can be archived, like
The following methods are available within archivable entities.
EntityCollection is a collection of results from Notion. This can be a
UserCollectionetc. Mostly these are results of search queries, database queries or retrieving content of
EntityCollection has functions to access basic information.
# This can be any of the above mentioned EntityCollections $entityCollection = new EntityCollection(); # Get all results as a `Illuminate\Support\Collection` $collectionResult = $entityCollection->asCollection(); # Get all results as JSON string $jsonResult = $entityCollection->asJson(); # Check if there are more results available within the query (pagination) $hasMoreEntries = $entityCollection->hasMoreEntries(); # Get the next cursor for the next page of results (`FiveamCode\LaravelNotionApi\Query\StartCursor`) $startCursor = $entityCollection->nextCursor(); # Get the raw result of the next cursor (as string) $rawNextCursor = $entityCollection->nextCursorRaw(); # Retrieve the raw result of the Notion API $entityCollection->getRawResponse();