| notion_client | R Documentation |
Main client for interacting with Notion API. This R6 class provides access to all Notion API endpoints through organised sub-objects.
notion_client(): Create a synchronous client (blocks until requests complete)
async_notion_client(): Create an asynchronous client (non-blocking)
Both clients provide identical interfaces, with the async client inheriting all methods from synchronous client.
The only difference is that async methods return promises instead of results directly.
notion_client(
auth = NULL,
base_url = getOption("notionapi.base_url"),
version = getOption("notionapi.version"),
timeout = 60000
)
async_notion_client(
auth = NULL,
base_url = getOption("notionapi.base_url"),
version = getOption("notionapi.version"),
timeout = 60000
)
A Notion API client instance
auth: Authentication token. Defaults to NOTION_TOKEN environment variable
base_url: Base URL for Notion API (defaults to getOption("notionapi.base_url"))
version: Notion API version (defaults to getOption("notionapi.version"))
timeout: Timeout for requests in milliseconds (defaults to 60000, or 60 seconds)
blocks: Blocks endpoint object (BlocksEndpoint)
blocks$children: Blocks children endpoint object (BlocksChildrenEndpoint)
pages: Pages endpoint object (PagesEndpoint)
pages$properties: Pages properties endpoint object (PagesPropertiesEndpoint)
databases: Databases endpoint object (DatabasesEndpoint)
data_sources: Data sources endpoint object (DataSourcesEndpoint)
views: Views endpoint object (ViewsEndpoint)
views$queries: Views queries endpoint object (ViewsQueriesEndpoint)
file_uploads: File uploads endpoint object (FileUploadsEndpoint)
comments: Comments endpoint object (CommentsEndpoint)
search: Search endpoint (see NotionClient$search() method below)
users: Users endpoint object (UsersEndpoint)
custom_emojis: Custom emojis endpoint object (CustomEmojisEndpoint)
base_urlBase URL for Notion API
versionNotion API version
blocksBlocks endpoint object
pagesPages endpoint object
databasesDatabases endpoint object
data_sourcesData sources endpoint object
viewsViews endpoint object
file_uploadsFile uploads endpoint object
commentsComments endpoint object
usersUsers endpoint object
custom_emojisCustom emojis endpoint object
new()Initialise Notion Client
NotionClient$new(
auth = NULL,
base_url = getOption("notionapi.base_url"),
version = getOption("notionapi.version"),
timeout = 60000
)authAuthentication token. Uses NOTION_TOKEN environment variable by default.
base_urlCharacter. Base URL for Notion API.
versionCharacter. Notion API version.
timeoutNumeric. Number of milliseconds to wait before timing out a request.
request()Create a base httr2 request object for the Notion API.
This method is primarily for advanced users who want to make custom API calls or for debugging purposes. Most users should use the endpoint methods instead.
NotionClient$request()
httr2 request object
print()Print basic details of Notion Client
NotionClient$print()
search()Search all parent or child pages and databases shared with an integration
NotionClient$search( sort = NULL, query = NULL, start_cursor = NULL, page_size = NULL, filter = NULL )
sortNamed list (JSON object). Sort condition to apply to the search results.
queryCharacter. The search query string.
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.
filterList (JSON object). Filter condition to apply to the search results.
notionapi::NotionClient -> AsyncNotionClient
new()Initialise Async Notion Client
AsyncNotionClient$new(
auth = NULL,
base_url = getOption("notionapi.base_url"),
version = getOption("notionapi.version"),
timeout = 60000
)authAuthentication token. Uses NOTION_TOKEN environment variable by default.
base_urlCharacter. Base URL for Notion API.
versionCharacter. Notion API version.
timeoutNumeric. Number of milliseconds to wait before timing out a request.
request()Create a base httr2 request object for the Notion API.
This method is primarily for advanced users who want to make custom API calls or for debugging purposes. Most users should use the endpoint methods instead.
AsyncNotionClient$request()
httr2 request object
print()Print basic details of Notion Client
AsyncNotionClient$print()
# ----- Create a Notion client with default configuration
notion <- notion_client()
# ----- Search for pages and databases
notion$search(
query = "Test Page for notionapi",
page_size = 1,
filter = list(
property = "object",
value = "page"
),
sort = list(
timestamp = "last_edited_time",
direction = "descending"
)
)
# ----- Async client
## Not run:
library(promises)
async_notion <- async_notion_client()
# Start multiple requests simultaneously (non-blocking)
p1 <- async_notion$search(
query = "Testing",
page_size = 1
)
p2 <- async_notion$users$me()
# Returns a promise object, not particularly useful on its own
p1
p2
# Use promise chaining functions to process results as they complete
p1 %...>%
print()
p2 %...>%
print()
# See the [promises package documentation](https://rstudio.github.io/promises/)
# for more information on working with promises
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.