View Source ThinNotionApi.Blocks (thin_notion_api v1.0.1)
This module contains functions to interact and modify Notion blocks.
A block object represents content within Notion. Blocks can be text, lists, media, and more.
Link to this section Summary
Functions
Creates and appends new children blocks to the parent block_id specified.
Sets a Block object, including page blocks, to archived: true using the ID specified. Note: in the Notion UI application, this moves the block to the "Trash" where it can still be accessed and restored.
Retrieves a Block object using the ID specified.
Returns a paginated array of child block objects contained in the block using the ID specified. In order to receive a complete representation of a block, you may need to recursively retrieve the block children of child blocks.
Updates the content for the specified block_id based on the block type. Supported fields based on the block object type (see Block object for available fields and the expected input for each field).
Link to this section Functions
@spec append_block_children(String.t(), [map()]) :: ThinNotionApi.Types.Response.t()
Creates and appends new children blocks to the parent block_id specified.
Returns a paginated list of newly created first level children block objects.
examples
Examples:
iex> ThinNotionApi.Blocks.append_block_children("c4c027f4ea7c41c5908d63a7f5a9c32c", [%{
object: "block",
type: "paragraph",
paragraph: %{
text: [%{
type: "text",
text: %{
content: "Testing for append_block_children",
}
}]
}
}])
{:ok, %{...}}
@spec delete_block(String.t()) :: ThinNotionApi.Types.Response.t()
Sets a Block object, including page blocks, to archived: true using the ID specified. Note: in the Notion UI application, this moves the block to the "Trash" where it can still be accessed and restored.
To restore the block with the API, use the Update a block or Update page respectively.
examples
Examples:
iex> ThinNotionApi.Blocks.delete_block("9b4a624d5a18482ab2187e54166edda7")
{:ok, %{...}}
@spec retrieve_block(String.t()) :: ThinNotionApi.Types.Response.t()
Retrieves a Block object using the ID specified.
examples
Examples:
iex> ThinNotionApi.Blocks.retrieve_block(block_id)
{:ok, %{...}}
@spec retrieve_block_children( String.t(), %{start_cursor: String.t(), page_size: integer()} | %{} ) :: ThinNotionApi.Types.Response.t()
Returns a paginated array of child block objects contained in the block using the ID specified. In order to receive a complete representation of a block, you may need to recursively retrieve the block children of child blocks.
🚧 Returns only the first level of children for the specified block. See block objects for more detail on determining if that block has nested children.
The response may contain fewer than page_size of results.
See Pagination for details about how to use a cursor to iterate through the list.
examples
Examples:
iex> ThinNotionApi.Blocks.retrieve_block_children("9b4a624d5a18482ab2187e54166edda7")
{:ok, %{...}}
@spec update_block(String.t(), %{archived: boolean()} | map()) :: ThinNotionApi.Types.Response.t()
Updates the content for the specified block_id based on the block type. Supported fields based on the block object type (see Block object for available fields and the expected input for each field).
Note: The update replaces the entire value for a given field. If a field is omitted (ex: omitting checked when updating a to_do block), the value will not be changed.
examples
Examples:
iex> ThinNotionApi.Blocks.update_block("c4c027f4ea7c41c5908d63a7f5a9c32c", %{
paragraph: %{
text: [%{
type: "text",
text: %{
content: "Hello DOGE!",
}
}],
}
})
{:ok, %{...}}