| Title: | R Wrapper for 'Notion' API |
|---|---|
| Description: | Provides functions to query databases and notes in 'Notion', using the official REST API. To learn more about the functionality of the 'Notion' API, see <https://developers.notion.com/>. |
| Authors: | Eduardo Flores [aut, cre] |
| Maintainer: | Eduardo Flores <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 0.0.9 |
| Built: | 2026-06-08 07:59:58 UTC |
| Source: | https://github.com/eflores89/notionr |
Id refers to a page id, content should be only text.
addBlockH1(secret, id, content, toggle = FALSE)addBlockH1(secret, id, content, toggle = FALSE)
secret |
API token |
id |
Page id where block will be appended |
content |
content to append as H1 |
toggle |
defaults to FALSE. If TRUE, will create an H1 Toggle. |
list
Id refers to a page id, content should be only text.
addBlockH2(secret, id, content, toggle = FALSE)addBlockH2(secret, id, content, toggle = FALSE)
secret |
API token |
id |
Page id where block will be appended |
content |
content to append as H2 |
toggle |
defaults to FALSE. If TRUE, will create an H1 Toggle. |
list
Id refers to a page id, content should be only text. HTML will export to text.
addBlockParagraph(secret, id, content)addBlockParagraph(secret, id, content)
secret |
API token |
id |
Page id where block will be appended |
content |
content to append |
list
Archive's a notion page.
archivePage(secret, id)archivePage(secret, id)
secret |
Notion API token |
id |
page id |
list of response
list
Eduardo Flores
Silent Return
createNotionPage(secret, parent_id, title_property, title = "untitled")createNotionPage(secret, parent_id, title_property, title = "untitled")
secret |
API token |
parent_id |
database id where page will be created or page under which it will nest |
title_property |
name of the title property |
title |
title of the new page |
list
Eduardo Flores
Deletes a block
deleteBlock(secret, id)deleteBlock(secret, id)
secret |
Notion API token |
id |
block id |
list of response
list
Eduardo Flores
Helps you build a database filter call with human-readable intuition. You must finish (if using pipes) with notion_filter().
Adds a checkbox filter condition.
notion_filter(., sort = NULL) notion_or(...) add_checkbox_filter(property, equals = TRUE) add_select_filter(property, equals) add_relation_id_filter(property, equals)notion_filter(., sort = NULL) notion_or(...) add_checkbox_filter(property, equals = TRUE) add_select_filter(property, equals) add_relation_id_filter(property, equals)
. |
List of filter conditions |
sort |
List of sort conditions. NULL by default. |
... |
A combination of filters |
property |
name or id of property (column) in database |
equals |
TRUE (default) or FALSE condition to meet in checkbox. Equals (contains) for select filter. |
Still WIP, only a few operators are currently available.
list
list
Eduardo Flores
## Not run: # to create an OR filter on two checkbox columns with id's "tus" and "YiIx"... my_query <- notion_or(add_checkbox_filter("tus", TRUE), add_checkbox_filter("YiIx", FALSE)) %>% notion_filter() ## End(Not run) # add a condition where checkbox should be checked add_checkbox_filter("id_column") # add a condition where checkbox should NOT be checked add_checkbox_filter("id_column", FALSE)## Not run: # to create an OR filter on two checkbox columns with id's "tus" and "YiIx"... my_query <- notion_or(add_checkbox_filter("tus", TRUE), add_checkbox_filter("YiIx", FALSE)) %>% notion_filter() ## End(Not run) # add a condition where checkbox should be checked add_checkbox_filter("id_column") # add a condition where checkbox should NOT be checked add_checkbox_filter("id_column", FALSE)
Query API with a block ID and retrieve JSON format (for now)
getBlock(secret, id)getBlock(secret, id)
secret |
Notion API token |
id |
Notion block ID. |
JSON
Eduardo Flores
For a given column in a database field, creates a vector of all entries. See parameters for options.
getMultiSelectValues( column, strip_string = "\\|", no_na = TRUE, only_unique = TRUE, show_progress = TRUE )getMultiSelectValues( column, strip_string = "\\|", no_na = TRUE, only_unique = TRUE, show_progress = TRUE )
column |
vector of column in data.frame (usually, after using getNotionDatabase, in form db$column_name ) |
strip_string |
String by which we should strip >1 selects in a single database row. Defaults to "|", as this is the default behaviour in getNotionDatabase(). |
no_na |
Strip all NA's? Defaults to TRUE. |
only_unique |
Export only unique values in vector? Defaults to TRUE. |
show_progress |
Print the count of values? Defaults to TRUE. |
does NOT call API.
vector
Eduardo Flores
Query a database in Notion with desired filters and get a database as a data.frame in R or download the entire database (all pages).
getNotionDatabase( secret, database, filters = NULL, show_progress = FALSE, all_pages = TRUE, cover_icon = FALSE )getNotionDatabase( secret, database, filters = NULL, show_progress = FALSE, all_pages = TRUE, cover_icon = FALSE )
secret |
Notion API token |
database |
Notion database ID. Use normalizeChromaPageIds if using directly from browser. |
filters |
A list built with filter operators (see filters) to query database. If NULL will query everything. |
show_progress |
show prints of progress? |
all_pages |
download all pages (loop thru paginations)? |
cover_icon |
also include cover and icon metadata? |
This is actually a POST request as per Notions API: https://developers.notion.com/reference/post-database-query
data.frame
Eduardo Flores
Retrieve a database's metadata as referenced in Notion API: https://developers.notion.com/reference/get-database
getNotionDatabaseMetadata(secret, database, raw = FALSE)getNotionDatabaseMetadata(secret, database, raw = FALSE)
secret |
Notion API token |
database |
Notion database ID |
raw |
if TRUE will not flatten into a data.frame |
data.frame
Eduardo Flores
## Not run: my_db <- "database_id" my_secret <- "NOTION API Secret" my_db_data <- get_database_metadata(secret = my_secret, database = my_db) ## End(Not run)## Not run: my_db <- "database_id" my_secret <- "NOTION API Secret" my_db_data <- get_database_metadata(secret = my_secret, database = my_db) ## End(Not run)
Gets a Notion Page
getNotionPage(secret, id)getNotionPage(secret, id)
secret |
Notion API token |
id |
page id |
list
Eduardo Flores
Retrieves all children blocks (contents) of a Notion page and returns them as a list.
getNotionPageContents(secret, id, show_progress = FALSE, all_pages = TRUE)getNotionPageContents(secret, id, show_progress = FALSE, all_pages = TRUE)
secret |
Notion API token |
id |
Notion page ID (or any block ID that supports children). Use normalizeChromePageIds if using directly from browser. |
show_progress |
show prints of progress? |
all_pages |
download all pages (loop thru paginations)? |
This calls the Notion API endpoint GET /v1/blocks/id/children.
Only the first level of children is returned per call. If a child block itself has children
(i.e., has_children = TRUE), you would need to call this function again with that
block's ID to retrieve its nested children.
See: https://developers.notion.com/reference/get-block-children
list of block objects (children of the page)
Eduardo Flores
## Not run: my_secret <- "secret_xxxx" page_id <- "your-page-id" contents <- getNotionPageContents(secret = my_secret, id = page_id) ## End(Not run)## Not run: my_secret <- "secret_xxxx" page_id <- "your-page-id" contents <- getNotionPageContents(secret = my_secret, id = page_id) ## End(Not run)
Is the database output empty ?
isEmptyNotionDatabaseExport(dataframe)isEmptyNotionDatabaseExport(dataframe)
dataframe |
The database output |
vector
Returns a page id from a copy-paste page id in browser
normalizeChromePageIds(x)normalizeChromePageIds(x)
x |
page id in format: 1f4c70197b0e4589902d371adc1dbd9a |
character
Eduardo Flores
Id refers to a page in a database, and should be normalized using normalizeChromeId().
updateCheckbox(secret, id, property_name, value = TRUE)updateCheckbox(secret, id, property_name, value = TRUE)
secret |
API token |
id |
Page id to be updated |
property_name |
name of property to update (should be a checkbox type property) |
value |
value to update. Use R bollean object. Defaults to TRUE. |
list
Id refers to a page in a database, and should be normalized using normalizeChromeId().
updateDate(secret, id, property_name, value)updateDate(secret, id, property_name, value)
secret |
API token |
id |
Page id to be updated |
property_name |
name of property to update (should be a date type property) |
value |
value to update |
list
Id refers to a page in a database, and should be normalized using normalizeChromeId().
updateEmoji(secret, id, emoji)updateEmoji(secret, id, emoji)
secret |
API token |
id |
Page id to be updated |
emoji |
emoji to update to |
list
Id refers to a page in a database, and should be normalized using normalizeChromeId().
updateMultiSelect(secret, id, property_name, value)updateMultiSelect(secret, id, property_name, value)
secret |
API token |
id |
Page id to be updated |
property_name |
name of property to update (should be a multiselect type property) |
value |
value(s) to update. Could be 1 value or multiple, created with c(). |
This will rewrite whatever is already in the property. It will NOT append another select.
list
Id refers to a page in a database, and should be normalized using normalizeChromeId().
updateNumber(secret, id, property_name, value)updateNumber(secret, id, property_name, value)
secret |
API token |
id |
Page id to be updated |
property_name |
name of property to update (should be a number type property) |
value |
value to update |
list
Updates a page cover to the url specified
updatePageCover(secret, id, cover_url)updatePageCover(secret, id, cover_url)
secret |
Notion API token |
id |
page id to be updated |
cover_url |
url of cover to be update |
list of response
list
Eduardo Flores
Id refers to a page in a database, and should be normalized using normalizeChromeId().
updateRelationship(secret, id, property_name, value)updateRelationship(secret, id, property_name, value)
secret |
API token |
id |
Page id to be updated |
property_name |
name of property to update (should be a relationship type property) |
value |
value to update (should be a unique page id) |
list
Id refers to a page in a database, and should be normalized using normalizeChromeId().
updateSelect(secret, id, property_name, value)updateSelect(secret, id, property_name, value)
secret |
API token |
id |
Page id to be updated |
property_name |
name of property to update (should be a select type property) |
value |
value to update |
list
Id refers to a page in a database, and should be normalized using normalizeChromeId().
updateText(secret, id, property_name, value)updateText(secret, id, property_name, value)
secret |
API token |
id |
Page id to be updated |
property_name |
name of property to update (should be a text type property) |
value |
value to update |
list
Id refers to a page in a database, and should be normalized using normalizeChromeId().
updateTitle(secret, id, property_name, value)updateTitle(secret, id, property_name, value)
secret |
API token |
id |
Page id to be updated |
property_name |
name of property to update (should be the title property of database) |
value |
value to update |
list
Id refers to a page in a database, and should be normalized using normalizeChromeId().
updateURL(secret, id, property_name, value)updateURL(secret, id, property_name, value)
secret |
API token |
id |
Page id to be updated |
property_name |
name of property to update (should be a URL type property) |
value |
value to update |
list