| BlocksChildrenEndpoint | R Documentation |
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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.