| PagesEndpoint | R Documentation |
Handle all pages operations in the Notion API
Note: Access this endpoint through the client instance, e.g., notion$pages. Not to be instantiated directly.
A list containing the parsed API response.
propertiesPages properties endpoint
new()Initialise pages endpoint.
Not to be called directly, e.g., use notion$pages instead.
PagesEndpoint$new(client)
clientNotion Client instance
create()Create a page
PagesEndpoint$create( parent, properties = NULL, icon = NULL, cover = NULL, content = NULL, children = NULL, markdown = NULL, template = NULL, position = NULL )
parentNamed list (JSON object) (required). The parent under which the new page is created.
propertiesNamed list (JSON object). Key-value pairs representing the page's properties.
iconNamed list (JSON object). The page icon.
coverNamed list (JSON object). The page cover image.
contentList of lists (JSON array). Block objects to append as children to the page.
childrenList of lists (JSON array). Block objects to append as children to the page.
markdownCharacter. Page content as Notion-flavored Markdown. Mutually exclusive with content/children.
templateNamed list (JSON object). A data source template apply to the new page. Cannot be combined with children.
positionNamed list (JSON object). Controls where new blocks are inserted among parent's children. Defaults to end of parent block's children when omitted.
retrieve()Retrieve page properties
PagesEndpoint$retrieve(page_id, filter_properties = NULL)
page_idCharacter (required). The ID for a Notion page.
filter_propertiesCharacter vector. Page property value IDs to include in the response schema. If NULL (default), all properties are returned.
move()Move a page
PagesEndpoint$move(page_id, parent)
page_idCharacter (required). The ID of the page to move.
parentNamed list (JSON object) (required). The new parent location for the page.
update()Update attributes of a Notion page
PagesEndpoint$update( page_id, properties = NULL, icon = NULL, cover = NULL, is_locked = NULL, template = NULL, erase_content = NULL, in_trash = NULL, is_archived = NULL )
page_idCharacter (required). The ID for a Notion page.
propertiesNamed list (JSON object). Key-value pairs representing the page's properties.
iconNamed list (JSON object). The page icon.
coverNamed list (JSON object). The page cover image.
is_lockedBoolean. Whether the page should be locked from editing.
templateNamed list (JSON object). A template to apply to the page.
erase_contentBoolean. Whether to erase all existing content from the page. Irreversible via the API.
in_trashBoolean. Set to TRUE to trash (delete) the page. Set to FALSE to restore the page.
is_archivedBoolean. Deprecated alias for in_trash. Use in_trash
for new integrations.
retrieve_markdown()Retrieve a page as markdown
PagesEndpoint$retrieve_markdown(page_id, include_transcript = NULL)
page_idCharacter (required). The ID of the page (or block) to to retrieve as markdown.
include_transcriptBoolean. Whether to include meeting note transcripts. Defaults to false.
update_markdown()Update a page's content as markdown
PagesEndpoint$update_markdown( page_id, type, update_content = NULL, replace_content = NULL, insert_content = NULL, replace_content_range = NULL )
page_idCharacter (required). The ID of the page to update.
typeCharacter (required). The update command type. One of "update_content", "replace_content", "insert_content" and "replace_content_range". The first two are recommended.
update_contentNamed list (JSON object). Update specific content using search-and-replace operations.
replace_contentNamed list (JSON object). Replace the entire page content with new markdown.
insert_contentNamed list (JSON object). Insert new content into the page.
replace_content_rangeNamed list (JSON object). Replace a range of content in the page.
notion <- notion_client()
# ----- Create a page
notion$pages$create(
list(page_id = "22f33ea0c1e480b99c77d1ab72aedff9"),
list(
title = list(list(
text = list(
content = "Test Page for notionapi"
)
))
)
)
# ----- Retrieve a page
notion$pages$retrieve("34033ea0-c1e4-81c4-afa0-d1ec98de4bec")
# ----- Move page into a database
notion$pages$move(
"34033ea0-c1e4-81c4-afa0-d1ec98de4bec",
list(
data_source_id = "34033ea0-c1e4-8112-bc3a-000bc940aa45"
)
)
# ----- Update a page
notion$pages$update(
"34033ea0-c1e4-81c4-afa0-d1ec98de4bec",
icon = list(
icon = list(
name = "pizza",
color = "blue"
)
)
)
# ----- Use `NA` to send JSON `null` — below removes the page's icon
notion$pages$update(
"34033ea0-c1e4-81c4-afa0-d1ec98de4bec",
icon = NA
)
# ----- Retrieve a page as markdown
notion$pages$retrieve_markdown("34033ea0-c1e4-81c4-afa0-d1ec98de4bec")
# ----- Update/replace a page content
notion$pages$update_markdown(
"34033ea0-c1e4-81c4-afa0-d1ec98de4bec",
"replace_content",
replace_content = list(
new_str = '## Updated Test Heading\nUsed markdown{color="blue"}'
)
)
# ----- Trash a page
notion$pages$update(
"34033ea0-c1e4-81c4-afa0-d1ec98de4bec",
in_trash = TRUE
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.