| Title: | Client for the 'Notion API' |
|---|---|
| Description: | Enable programmatic interaction with 'Notion' pages, databases, blocks, comments, and users through the 'Notion API' <https://developers.notion.com/>. Provides both synchronous and asynchronous client interfaces for building workflows and automations that integrate with 'Notion' workspaces. Supports all 'Notion API' endpoints including content creation, data retrieval, and workspace management. |
| Authors: | Brenwin Ang [aut, cre, cph] |
| Maintainer: | Brenwin Ang <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 0.2.0 |
| Built: | 2026-05-13 09:27:44 UTC |
| Source: | https://github.com/cran/notionapi |
Handle all block children operations in the Notion API
Note: Access this endpoint through the client instance, e.g., notion$blocks$children. Not to be instantiated directly.
A list containing the parsed API response.
new()
Initialise block children endpoint.
Not to be called directly, e.g., use notion$pages$children instead.
BlocksChildrenEndpoint$new(client)
clientNotion Client instance
list()
Retrieve a block's children
BlocksChildrenEndpoint$list(block_id, start_cursor = NULL, page_size = NULL)
block_idString (required). The ID for a Notion block.
start_cursorCharacter. For pagination. If provided, returns results starting from this cursor. If NULL, returns the first page of results.
page_sizeInteger. Number of items to return per page (1-100). Defaults to 100.
append()
Append block children
BlocksChildrenEndpoint$append(block_id, children, position = NULL)
block_idString (required). The ID for a Notion block.
childrenList of lists (JSON array) (required). Block objects to append as children to the block.
positionNamed list (JSON object). Controls where new blocks are inserted among parent's children. Defaults to end of parent block's children when omitted.
notion <- notion_client() # ----- Append children to a block notion$blocks$children$append( "34033ea0-c1e4-81c4-afa0-d1ec98de4bec", list( list( object = "block", heading_2 = list( rich_text = list(list( text = list(content = "Test Heading") )) ) ) ), position = list(type = "start") ) # ----- Retrieve children of a block notion$blocks$children$list("34033ea0-c1e4-81c4-afa0-d1ec98de4bec") # ----- Iterate through paginated results ## Not run: start_cursor <- NULL has_more <- FALSE resps <- list() i <- 1 while (has_more) { resps[[i]] <- notion$blocks$children$list( "2926b407e3c44b49a1830609abe6744f", start_cursor ) has_more <- resps[[i]][["has_more"]] start_cursor <- resps[[i]][["next_cursor"]] i <- i + 1 } ## End(Not run)notion <- notion_client() # ----- Append children to a block notion$blocks$children$append( "34033ea0-c1e4-81c4-afa0-d1ec98de4bec", list( list( object = "block", heading_2 = list( rich_text = list(list( text = list(content = "Test Heading") )) ) ) ), position = list(type = "start") ) # ----- Retrieve children of a block notion$blocks$children$list("34033ea0-c1e4-81c4-afa0-d1ec98de4bec") # ----- Iterate through paginated results ## Not run: start_cursor <- NULL has_more <- FALSE resps <- list() i <- 1 while (has_more) { resps[[i]] <- notion$blocks$children$list( "2926b407e3c44b49a1830609abe6744f", start_cursor ) has_more <- resps[[i]][["has_more"]] start_cursor <- resps[[i]][["next_cursor"]] i <- i + 1 } ## End(Not run)
Handle all block operations in the Notion API
Note: Access this endpoint through the client instance, e.g., notion$blocks. Not to be instantiated directly.
A list containing the parsed API response.
childrenBlock children endpoint
new()
Initialise block endpoint.
Not to be called directly, e.g., use notion$blocks instead.
BlocksEndpoint$new(client)
clientNotion Client instance
retrieve()
Retrieve a block
BlocksEndpoint$retrieve(block_id)
block_idCharacter (required). The ID for a Notion block.
update()
Update a block
BlocksEndpoint$update(block_id, in_trash = NULL, ...)
block_idCharacter (required). The ID for a Notion block.
in_trashBoolean. Set to TRUE to trash (delete) a block. Set to FALSE to restore a block.
...<dynamic-dots> Block-specific properties to update. Each argument should be named
after a block type (e.g., heading_1, paragraph)
with a named list value containing the block configuration.
delete()
Delete a block
BlocksEndpoint$delete(block_id)
block_idCharacter (required). The ID for a Notion block.
notion <- notion_client() # ----- Retrieve a block notion$blocks$retrieve("34033ea0-c1e4-8123-be95-e77dcc78e47d") # ----- Update a block notion$blocks$update( "34033ea0-c1e4-8123-be95-e77dcc78e47d", heading_2 = list( rich_text = list(list( text = list( content = "Updated Test Heading" ) )) ) ) # ----- Delete a block notion$blocks$delete( "34033ea0-c1e4-8123-be95-e77dcc78e47d" )notion <- notion_client() # ----- Retrieve a block notion$blocks$retrieve("34033ea0-c1e4-8123-be95-e77dcc78e47d") # ----- Update a block notion$blocks$update( "34033ea0-c1e4-8123-be95-e77dcc78e47d", heading_2 = list( rich_text = list(list( text = list( content = "Updated Test Heading" ) )) ) ) # ----- Delete a block notion$blocks$delete( "34033ea0-c1e4-8123-be95-e77dcc78e47d" )
Handle all comments operations in the Notion API
Note: Access this endpoint through the client instance, e.g., notion$comments. Not to be instantiated directly.
A list containing the parsed API response.
new()
Initialise comments endpoint.
Not to be called directly, e.g., use notion$comments instead.
CommentsEndpoint$new(client)
clientNotion Client instance
create()
Create a comment
CommentsEndpoint$create( rich_text, parent = NULL, discussion_id = NULL, attachments = NULL, display_name = NULL )
rich_textList of lists (JSON array) (required). Rich text object(s) representing the content of the comment.
parentList (JSON object). The parent of the comment. This can be a page or a block.
Required if discussion_id is not provided.
discussion_idCharacter. The ID of the discussion to comment on.
Required if parent is not provided.
attachmentsList of lists (JSON array). An array of files to attach to the comment. Maximum of 3 allowed.
display_nameNamed list (JSON object). Display name for the comment.
retrieve()
Retrieve comments for a block
CommentsEndpoint$retrieve(comment_id)
comment_idCharacter (required). The ID of the comment to retrieve.
list()
List comments
CommentsEndpoint$list(block_id, start_cursor = NULL, page_size = NULL)
block_idCharacter (required). The ID for a Notion block or page.
start_cursorCharacter. For pagination. If provided, returns results starting from this cursor. If NULL, returns the first page of results.
page_sizeInteger. Number of items to return per page (1-100). Defaults to 100.
notion <- notion_client() # ----- Create comment notion$comments$create( parent = list( page_id = "34033ea0-c1e4-81c4-afa0-d1ec98de4bec" ), rich_text = list( list( text = list( content = "Hello world!" ) ) ) ) # ----- Retrieve comment notion$comments$retrieve("34033ea0-c1e4-8193-a220-001d29ae83c5") # ----- List un-resolved comments from a page or block notion$comments$list("34033ea0-c1e4-81c4-afa0-d1ec98de4bec")notion <- notion_client() # ----- Create comment notion$comments$create( parent = list( page_id = "34033ea0-c1e4-81c4-afa0-d1ec98de4bec" ), rich_text = list( list( text = list( content = "Hello world!" ) ) ) ) # ----- Retrieve comment notion$comments$retrieve("34033ea0-c1e4-8193-a220-001d29ae83c5") # ----- List un-resolved comments from a page or block notion$comments$list("34033ea0-c1e4-81c4-afa0-d1ec98de4bec")
Handle all custom emojis operations in the Notion API
Note: Access this endpoint through the client instance, e.g., notion$custom_emojis. Not to be instantiated directly.
A list containing the parsed API response.
new()
Initialise custom emojis endpoint.
Not to be called directly, e.g., use notion$custom_emojis instead.
CustomEmojisEndpoint$new(client)
clientNotion Client instance
list()
List custom emojis
CustomEmojisEndpoint$list(start_cursor = NULL, page_size = NULL, name = NULL)
start_cursorCharacter. For pagination. If provided, returns results starting from this cursor. If NULL, returns the first page of results.
page_sizeInteger. Number of items to return per page (1-100). Defaults to 100
nameCharacter. Filters custom emojis by exact name match. Useful for resolving a custom emoji name to its ID.
notion <- notion_client() notion$custom_emojis$list()notion <- notion_client() notion$custom_emojis$list()
Handle all databases operations in the Notion API
Note: Access this endpoint through the client instance, e.g., notion$databases. Not to be instantiated directly.
A list containing the parsed API response.
new()
Initialise databases endpoint.
Not to be called directly, e.g., use notion$databases instead.
DatabasesEndpoint$new(client)
clientNotion Client instance
create()
Create a database
DatabasesEndpoint$create( parent, title = NULL, description = NULL, is_inline = NULL, initial_data_source = NULL, icon = NULL, cover = NULL )
parentNamed list (JSON object) (required). The parent page or workspace where the database will be created.
titleList of lists (JSON array). The title of the database.
descriptionList of lists (JSON array). The description of the database.
is_inlineBoolean. Whether the database should be displayed inline in the parent page. Defaults to false.
initial_data_sourceNamed list (JSON object). Initial data source configuration for the database
iconNamed list (JSON object). The icon for the database.
coverNamed list (JSON object). The cover image for the database.
retrieve()
Retrieve a database
DatabasesEndpoint$retrieve(database_id)
database_idString (required). The ID of a Notion database.
update()
Update a database
DatabasesEndpoint$update( database_id, parent = NULL, title = NULL, description = NULL, is_inline = NULL, icon = NULL, cover = NULL, in_trash = NULL, is_locked = NULL )
database_idString (required). The ID of a Notion database.
parentNamed list (JSON object). The parent page or workspace to move the database to. If not provided, the database will not be moved.
titleList of lists (JSON array). The updated title of the database.
descriptionList of lists (JSON array). The updated description of the database.
is_inlineBoolean. Whether the database should be displayed in the parent page.
iconNamed list (JSON object). The updated icon for the database.
coverNamed list (JSON object). The updated cover image for the database.
in_trashBoolean. Whether the database should be moved to or from the trash.
is_lockedBoolean. Whether the database should be locked from editing.
notion <- notion_client() # ----- Create a database notion$databases$create( list( type = "page_id", page_id = "22f33ea0c1e480b99c77d1ab72aedff9" ), title = list(list( text = list( content = "Test Database" ) )) ) # ----- Retrieve a database notion$databases$retrieve("ffec20ee-1450-4da8-9904-f4babba0e9c0") # ----- Update a database notion$databases$update( "ffec20ee-1450-4da8-9904-f4babba0e9c0", description = list(list( text = list( content = "For testing purposes" ) )), icon = list( icon = list( name = "calendar", color = "gray" ) ) )notion <- notion_client() # ----- Create a database notion$databases$create( list( type = "page_id", page_id = "22f33ea0c1e480b99c77d1ab72aedff9" ), title = list(list( text = list( content = "Test Database" ) )) ) # ----- Retrieve a database notion$databases$retrieve("ffec20ee-1450-4da8-9904-f4babba0e9c0") # ----- Update a database notion$databases$update( "ffec20ee-1450-4da8-9904-f4babba0e9c0", description = list(list( text = list( content = "For testing purposes" ) )), icon = list( icon = list( name = "calendar", color = "gray" ) ) )
Handle all data sources operations in the Notion API
Note: Access this endpoint through the client instance, e.g., notion$datas_ources. Not to be instantiated directly.
A list containing the parsed API response.
new()
Initialise data sources endpoint.
Not to be called directly, e.g., use notion$datasources instead.
DataSourcesEndpoint$new(client)
clientNotion Client instance
create()
Create a data source
DataSourcesEndpoint$create(parent, properties, title = NULL, icon = NULL)
parentNamed list (JSON object) (required). An object specifying the parent of the new data source to be created.
propertiesNamed list (JSON object) (required). Property schema of data source.
titleList of lists (JSON array). Title of data source.
iconNamed list (JSON object). Page icon.
retrieve()
Retrieve a data source
DataSourcesEndpoint$retrieve(data_source_id)
data_source_idCharacter (required). ID of a Notion data source.
list_templates()
List page templates available for a data source
DataSourcesEndpoint$list_templates( data_source_id, name = NULL, start_cursor = NULL, page_size = NULL )
data_source_idCharacter (required). ID of a Notion data source.
nameCharacter. Name to filter templates by.
start_cursorCharacter. For pagination. If provided, returns results starting from this cursor. If NULL, returns the first page of results.
page_sizeInteger. Number of items to return per page (1-100). Defaults to 100
update()
Update a data source
DataSourcesEndpoint$update( data_source_id, title = NULL, icon = NULL, properties = NULL, in_trash = NULL, parent = NULL )
data_source_idCharacter (required). ID of a Notion data source.
titleList of lists (JSON array). Title of data source.
iconNamed list (JSON object). Page icon.'
propertiesNamed list (JSON object). Key-value pairs representing the data source's properties.
in_trashBoolean. Whether the database should be moved to or from the trash.
parentNamed list (JSON object). The parent of the data source, when moving it to a different database.
query()
Query a data source
DataSourcesEndpoint$query( data_source_id, filter_properties = NULL, sorts = NULL, filter = NULL, start_cursor = NULL, page_size = NULL, in_trash = NULL, result_type = NULL )
data_source_idCharacter (required). ID of a Notion data source.
filter_propertiesCharacter vector. Page property value IDs to include in the response schema. If NULL (default), all properties are returned.
sortsList of lists (JSON array). Sort conditions to apply to the query
filterList of lists (JSON array). Filter conditions to apply. to the query
start_cursorCharacter. For pagination. If provided, returns results starting from this cursor. If NULL, returns the first page of results.
page_sizeInteger. Number of items to return per page (1-100). Defaults to 100
in_trashBoolean. If TRUE, trashed pages are included in the results alongside
non-trashed pages. If FALSE or NULL (default), only non-trashed pages are returned.
result_typeCharacter. Filter results by type. Available options are
"page" and "data_source". If NULL (default), all result types are returned.
notion <- notion_client() # ----- Create a data source notion$data_sources$create( list( database_id = "ffec20ee-1450-4da8-9904-f4babba0e9c0" ), properties = list( Title = list( title = no_config() ) ), title = list(list( text = list( content = "Test data source" ) )) ) # ----- Update data source notion$data_sources$update( "34033ea0-c1e4-8112-bc3a-000bc940aa45", properties = list( Status = list( status = list( options = list( list( name = "To do", color = "red" ), list( name = "Done", color = "green" ) ) ) ) ) ) # ----- Retrieve a data source notion$data_sources$retrieve("34033ea0-c1e4-8112-bc3a-000bc940aa45") # ----- List data source templates notion$data_sources$list_templates("34033ea0-c1e4-8112-bc3a-000bc940aa45") # ----- Query a data source notion$data_sources$query( "34033ea0-c1e4-8112-bc3a-000bc940aa45", filter = list( property = "Status", status = list( equals = "To do" ) ) )notion <- notion_client() # ----- Create a data source notion$data_sources$create( list( database_id = "ffec20ee-1450-4da8-9904-f4babba0e9c0" ), properties = list( Title = list( title = no_config() ) ), title = list(list( text = list( content = "Test data source" ) )) ) # ----- Update data source notion$data_sources$update( "34033ea0-c1e4-8112-bc3a-000bc940aa45", properties = list( Status = list( status = list( options = list( list( name = "To do", color = "red" ), list( name = "Done", color = "green" ) ) ) ) ) ) # ----- Retrieve a data source notion$data_sources$retrieve("34033ea0-c1e4-8112-bc3a-000bc940aa45") # ----- List data source templates notion$data_sources$list_templates("34033ea0-c1e4-8112-bc3a-000bc940aa45") # ----- Query a data source notion$data_sources$query( "34033ea0-c1e4-8112-bc3a-000bc940aa45", filter = list( property = "Status", status = list( equals = "To do" ) ) )
Handle all file uploads operations in the Notion API
Note: Access this endpoint through the client instance, e.g., notion$file_uploads. Not to be instantiated directly.
A list containing the parsed API response.
new()
Initialise file uploads endpoint.
Not to be called directly, e.g., use notion$file_uploads instead.
FileUploadsEndpoint$new(client)
clientNotion Client instance
create()
Create a file upload
FileUploadsEndpoint$create( mode = NULL, filename = NULL, content_type = NULL, number_of_parts = NULL, external_url = NULL )
modeCharacter. How the file is being sent. Use "multi_part" for files larger than 20MB. Use "external_url" for files that are temporarily hosted publicly elsewhere. Default is "single_part".
filenameCharacter. Name of the file to be created. Required when mode
is "multi_part". Must include an extension, or have one inferred from
the content_type parameter.
content_typeCharacter. MIME type of the file to be created.
number_of_partsInteger. When mode is "multi_part", the number of parts
you are uploading.
external_urlCharacter. When mode is "external_url", provide the
HTTPS URL of a publicly accessible file to import into your workspace.
send()
Upload a file
FileUploadsEndpoint$send(file_upload_id, file, part_number = NULL)
file_upload_idCharacter (required). Identifier for a Notion file upload object.
fileNamed list (JSON object). The raw binary file contents to upload. Must contain named elements:
filename. Character. The name of the file, including it's extension (e.g., "report.pdf")
data. Raw. The binary contents of the file, as returned by e.g., readBin()
type. Character. Optional. The MIME type of the file (e.g., "application/pdf", "image/png").
If not supplied, the type is inferred from filename by curl::form_file().
Supported file types are listed here.
part_numberCharacter. The current part number when uploading files greater than 20MB in parts. Must be an integer between 1 and 1,000
complete()
Complete a multi-part file upload
FileUploadsEndpoint$complete(file_upload_id)
file_upload_idCharacter (required). Identifier for a Notion file upload object.
retrieve()
Retrieve a file upload
FileUploadsEndpoint$retrieve(file_upload_id)
file_upload_idCharacter (required). Identifier for a Notion file upload object.
list()
List file uploads
FileUploadsEndpoint$list(status = NULL, start_cursor = NULL, page_size = NULL)
statusCharacter. If supplied, the endpoint will return file uploads with the specified status. Available options are "pending", "uploaded", "expired", "failed".
start_cursorCharacter. For pagination. If provided, returns results starting from this cursor. If NULL, returns the first page of results.
page_sizeInteger. Number of items to return per page (1-100). Defaults to 100
notion <- notion_client() # ----- Direct upload (files <= 20MB) # Step 1: Create a File Upload object (resp <- notion$file_uploads$create("single_part")) file_upload_id <- resp[["id"]] # Step 2: Upload file contents #* replace with your file path <- file.path(tempdir(), "test.pdf") writeBin(charToRaw("placeholder"), path) raw <- readBin(path, "raw", file.size(path)) notion$file_uploads$send( file_upload_id, list( filename = basename(path), data = raw ) ) # Retrieve the file upload notion$file_uploads$retrieve(file_upload_id) # ----- Multi-part upload (files > 20MB) # Step 1: Split raw content into parts #* replace with your file raw <- as.raw(rep(65L, 11 * 1024 * 1024)) mid <- ceiling(length(raw) / 2) parts <- list(raw[seq_len(mid)], raw[seq(mid + 1L, length(raw))]) # Step 2: Create a File Upload object (resp <- notion$file_uploads$create( mode = "multi_part", filename = "test-large.txt", number_of_parts = 2L )) file_upload_id <- resp[["id"]] # Step 3: Send each part for (i in seq_along(parts)) { notion$file_uploads$send( file_upload_id, file = list( filename = "test-large.txt", data = parts[[i]] ), part_number = as.character(i) ) } # Step 4: Complete the upload notion$file_uploads$complete( file_upload_id ) # Retrieve the file upload notion$file_uploads$retrieve( file_upload_id ) # ----- Import external files notion$file_uploads$create( "external_url", "dummy.pdf", content_type = "application/pdf", external_url = "https://github.com/brenwin1/notionapi/blob/main/tests/testthat/test.pdf" )notion <- notion_client() # ----- Direct upload (files <= 20MB) # Step 1: Create a File Upload object (resp <- notion$file_uploads$create("single_part")) file_upload_id <- resp[["id"]] # Step 2: Upload file contents #* replace with your file path <- file.path(tempdir(), "test.pdf") writeBin(charToRaw("placeholder"), path) raw <- readBin(path, "raw", file.size(path)) notion$file_uploads$send( file_upload_id, list( filename = basename(path), data = raw ) ) # Retrieve the file upload notion$file_uploads$retrieve(file_upload_id) # ----- Multi-part upload (files > 20MB) # Step 1: Split raw content into parts #* replace with your file raw <- as.raw(rep(65L, 11 * 1024 * 1024)) mid <- ceiling(length(raw) / 2) parts <- list(raw[seq_len(mid)], raw[seq(mid + 1L, length(raw))]) # Step 2: Create a File Upload object (resp <- notion$file_uploads$create( mode = "multi_part", filename = "test-large.txt", number_of_parts = 2L )) file_upload_id <- resp[["id"]] # Step 3: Send each part for (i in seq_along(parts)) { notion$file_uploads$send( file_upload_id, file = list( filename = "test-large.txt", data = parts[[i]] ), part_number = as.character(i) ) } # Step 4: Complete the upload notion$file_uploads$complete( file_upload_id ) # Retrieve the file upload notion$file_uploads$retrieve( file_upload_id ) # ----- Import external files notion$file_uploads$create( "external_url", "dummy.pdf", content_type = "application/pdf", external_url = "https://github.com/brenwin1/notionapi/blob/main/tests/testthat/test.pdf" )
Helper function that creates an empty named list for property configurations that require no additional settings.
Many database properties like text, checkbox and date
do not need configuration settings.
This function returns the empty configuration ({} in JSON)
that these properties expect.
no_config()no_config()
An empty named list that serialises to {} in JSON
notion <- notion_client() # ----- Create a data source notion$data_sources$create( list( database_id = "5f9759b2-ad71-4b66-880f-d0306614227b" ), properties = list( Title = list( title = no_config() ) ), title = list(list( text = list( content = "Test data source" ) )) )notion <- notion_client() # ----- Create a data source notion$data_sources$create( list( database_id = "5f9759b2-ad71-4b66-880f-d0306614227b" ), properties = list( Title = list( title = no_config() ) ), title = list(list( text = list( content = "Test data source" ) )) )
Checks if the NOTION_TOKEN environment variable is set.
notion_token_exists()notion_token_exists()
TRUE if the token exists, FALSE otherwise.
notion_token_exists()notion_token_exists()
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 )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 )
Handle all pages properties operations in the Notion API
Note: Access this endpoint through the client instance, e.g., notion$pages$properties. Not to be instantiated directly.
A list containing the parsed API response.
new()
Initialise pages properties endpoint.
Not to be called directly, e.g., use notion$pages$properties instead.
PagesPropertiesEndpoint$new(client)
clientNotion Client instance
retrieve()
Retrieve a page property item
PagesPropertiesEndpoint$retrieve( page_id, property_id, start_cursor = NULL, page_size = NULL )
page_idCharacter (required). The ID for a Notion page.
property_idCharacter (required). The ID of the property to retrieve.
start_cursorCharacter. For pagination. If provided, returns results starting from this cursor. If NULL, returns the first page of results.
page_sizeInteger. Number of items to return per page (1-100). Defaults to 100.
notion <- notion_client() # ----- Retrieve a page property notion$pages$properties$retrieve( "34033ea0-c1e4-81c4-afa0-d1ec98de4bec", "%60w%5CX" )notion <- notion_client() # ----- Retrieve a page property notion$pages$properties$retrieve( "34033ea0-c1e4-81c4-afa0-d1ec98de4bec", "%60w%5CX" )
Print the result of a Notion API call
## S3 method for class 'notion_response' print(x, ...)## S3 method for class 'notion_response' print(x, ...)
x |
The result object. |
... |
Ignored. |
The JSON result.
Handle all users operations in the Notion API
Note: Access this endpoint through the client instance, e.g., notion$users. Not to be instantiated directly.
A list containing the parsed API response.
new()
Initialise users endpoint.
Not to be called directly, e.g., use notion$users instead.
UsersEndpoint$new(client)
clientNotion Client instance
list()
List all users
UsersEndpoint$list(start_cursor = NULL, page_size = NULL)
start_cursorCharacter. For pagination. If provided, returns results starting from this cursor. If NULL, returns the first page of results.
page_sizeInteger. Number of items to return per page (1-100). Defaults to 100.
retrieve()
Retrieve a user
UsersEndpoint$retrieve(user_id)
user_idCharacter (required). The ID of the user to retrieve.
me()
Retrieve the bot User associated with the API token
UsersEndpoint$me()
notion <- notion_client() # ----- List all users notion$users$list() # ----- Retrieve a user notion$users$retrieve("fda12729-108d-4eb5-bbfb-a8f0886794d1") # ----- Retrieve the bot User associated with the API token notion$users$me()notion <- notion_client() # ----- List all users notion$users$list() # ----- Retrieve a user notion$users$retrieve("fda12729-108d-4eb5-bbfb-a8f0886794d1") # ----- Retrieve the bot User associated with the API token notion$users$me()
Handle all views operations in the Notion API
Note: Access this endpoint through the client instance, e.g., notion$views. Not to be instantiated directly.
A list containing the parsed API response.
queriesViews Queries Endpoint
new()
Initialise views endpoint.
Not to be called directly, e.g., use notion$views instead.
ViewsEndpoint$new(client)
clientNotion Client instance
create()
Create a view
ViewsEndpoint$create( data_source_id, name, type, database_id = NULL, view_id = NULL, filter = NULL, sorts = NULL, quick_filters = NULL, create_database = NULL, configuration = NULL, position = NULL, placement = NULL )
data_source_idCharacter (required). The ID of the data source this view is scoped to.
nameCharacter (required). The name of the view.
typeCharacter (required). The type of view to create.
database_idCharacter. The ID of the database to create a view in.
Mutually exclusive with view_id and create_database
view_idCharacter. The ID of a dashboard view to add this view to
as a widget. Mutually exclusive with database_id and create_database.
filterNamed list (JSON object). Filter to apply to the view.
sortsList of lists (JSON array). Sorts to apply to the view.
quick_filtersNamed list (JSON object). Key-value pairs of quick filters to pin in the view's filter bar.
create_databaseNamed list (JSON object). Create a new linked database
block and add the view to it. Mutually exclusive with database_id and view_id
configurationNamed list (JSON object). View presentation configuration.
positionNamed list (JSON object). Where to place the new view
in the database's view tab bar. Only applicable when database_id is provided.
Defaults to "end" (append).
placementNamed list (JSON object). Where to place the new widget in a dashboard view.
Only applicable when view_id is provided. Defaults to creating a new row at the end.
retrieve()
Retrieve a view
ViewsEndpoint$retrieve(view_id)
view_idID of a Notion view.
update()
Update a view
ViewsEndpoint$update( view_id, name = NULL, filter = NULL, sorts = NULL, quick_filters = NULL, configuration = NULL )
view_idID of a Notion view.
nameCharacter. New name for the view.
filterNamed list (JSON object). Filter to apply to the view.
sortsList of lists (JSON array). Property sorts to apply to the view.
quick_filtersNamed list (JSON object). Key-value pairs of quick filters to add/update.
configurationNamed list (JSON object). View presentation configuration.
delete()
Delete a view
ViewsEndpoint$delete(view_id)
view_idID of a Notion view.
list()
List all views in a database
ViewsEndpoint$list( database_id = NULL, data_source_id = NULL, start_cursor = NULL, page_size = NULL )
database_idCharacter. ID of a Notion database to list views for.
At least one of database_id or data_source_id is required.
data_source_idCharacter. ID of a data source to list all views for,
including linked views across the workspace. At least one of database_id
or data_source_id is required.
start_cursorCharacter. For pagination. If provided, returns results starting from this cursor. If NULL, returns the first page of results.
page_sizeInteger. Number of items to return per page (1-100). Defaults to 100
notion <- notion_client() # ----- Create a view notion$views$create( "34033ea0-c1e4-8112-bc3a-000bc940aa45", "Test view", "table", "ffec20ee-1450-4da8-9904-f4babba0e9c0" ) # ----- Retrieve a view notion$views$retrieve("34033ea0-c1e4-8192-ac14-000cdad096ce") # ----- List views notion$views$list(data_source_id = "34033ea0-c1e4-8112-bc3a-000bc940aa45") # ----- Update a view notion$views$update("34033ea0-c1e4-8192-ac14-000cdad096ce", "Updated view name") # ----- Delete a view notion$views$delete("34033ea0-c1e4-8192-ac14-000cdad096ce")notion <- notion_client() # ----- Create a view notion$views$create( "34033ea0-c1e4-8112-bc3a-000bc940aa45", "Test view", "table", "ffec20ee-1450-4da8-9904-f4babba0e9c0" ) # ----- Retrieve a view notion$views$retrieve("34033ea0-c1e4-8192-ac14-000cdad096ce") # ----- List views notion$views$list(data_source_id = "34033ea0-c1e4-8112-bc3a-000bc940aa45") # ----- Update a view notion$views$update("34033ea0-c1e4-8192-ac14-000cdad096ce", "Updated view name") # ----- Delete a view notion$views$delete("34033ea0-c1e4-8192-ac14-000cdad096ce")
Handle all views queries operations in the Notion API
Note: Access this endpoint through the client instance, e.g., notion$views$queries. Not to be instantiated directly.
A list containing the parsed API response.
new()
Initialise pages properties endpoint.
Not to be called directly, e.g., use notion$views$queries instead.
ViewsQueriesEndpoint$new(client)
clientNotion Client instance
create()
Create a view query
ViewsQueriesEndpoint$create(view_id, page_size = NULL)
view_idCharacter (required). The ID of the view.
page_sizeInteger. Number of items to return per page (1-100). Defaults to 100.
results()
Get view query results
ViewsQueriesEndpoint$results( view_id, query_id, start_cursor = NULL, page_size = NULL )
view_idCharacter (required). The ID of the view.
query_idCharacter (required). The ID of the query.
start_cursorCharacter. For pagination. If provided, returns results starting from this cursor. If NULL, returns the first page of results.
page_sizeInteger. Number of items to return per page (1-100). Defaults to 100
delete()
Delete a view query
ViewsQueriesEndpoint$delete(view_id, query_id)
view_idCharacter (required). The ID of the view.
query_idCharacter (required). The ID of the query.
notion <- notion_client() # ----- Create a view query notion$views$queries$create("34033ea0-c1e4-8192-ac14-000cdad096ce") # ----- Get view query results notion$views$queries$results( "34033ea0-c1e4-8192-ac14-000cdad096ce", "9af03bd1-ed79-4842-a57c-0bc04fb61be2" ) # ----- Delete a view query notion$views$queries$delete( "34033ea0-c1e4-8192-ac14-000cdad096ce", "9af03bd1-ed79-4842-a57c-0bc04fb61be2" )notion <- notion_client() # ----- Create a view query notion$views$queries$create("34033ea0-c1e4-8192-ac14-000cdad096ce") # ----- Get view query results notion$views$queries$results( "34033ea0-c1e4-8192-ac14-000cdad096ce", "9af03bd1-ed79-4842-a57c-0bc04fb61be2" ) # ----- Delete a view query notion$views$queries$delete( "34033ea0-c1e4-8192-ac14-000cdad096ce", "9af03bd1-ed79-4842-a57c-0bc04fb61be2" )