Databases-Endpoint Examples

Fetch database information

This endpoint provides all structural information about a database.

Get properties, title, icon, cover image, etc.

# Returns a single database
$database = \Notion::databases()
                ->find($databaseId);

# Get database title
$database->getTitle();

# Get property-information of the database
$database->getProperties();

# Get all keys of the properties (property-names)
$database->getPropertyKeys();

# Get database icon and icon-type (emoji, file, external)
$database->getIcon();
$database->getIconType();

# Get database cover and cover-type (file, external)
$database->getCover();
$database->getCoverType();

# Get database url (within Notion)
$database->getUrl();

Fetch all Databases

# This endpoint is not recommended by Notion anymore but is working nevertheless. 
# Use the search endpoint instead.

# Returns all databases of the workspace that were explicitly granted access.
\Notion::databases()
        ->all()
        ->asCollection();

{warning} Watch out:
This endpoint is no longer recommended by Notion and can be removed anytime.
Use ✨ Search instead.