NotionClient: Notion API client

notion_clientR Documentation

Notion API client

Description

Main client for interacting with Notion API. This R6 class provides access to all Notion API endpoints through organised sub-objects.

Client Types

  • 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.

Usage

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
)

Value

A Notion API client instance

Configuration fields

  • 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)

Endpoints

  • 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)

Public fields

base_url

Base URL for Notion API

version

Notion API version

blocks

Blocks endpoint object

pages

Pages endpoint object

databases

Databases endpoint object

data_sources

Data sources endpoint object

views

Views endpoint object

file_uploads

File uploads endpoint object

comments

Comments endpoint object

users

Users endpoint object

custom_emojis

Custom emojis endpoint object

Methods

Public methods


Method new()

Initialise Notion Client

Usage
NotionClient$new(
  auth = NULL,
  base_url = getOption("notionapi.base_url"),
  version = getOption("notionapi.version"),
  timeout = 60000
)
Arguments
auth

Authentication token. Uses NOTION_TOKEN environment variable by default.

base_url

Character. Base URL for Notion API.

version

Character. Notion API version.

timeout

Numeric. Number of milliseconds to wait before timing out a request.


Method 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.

Usage
NotionClient$request()
Returns

httr2 request object


Method print()

Print basic details of Notion Client

Usage
NotionClient$print()

Method search()

Search all parent or child pages and databases shared with an integration

Usage
NotionClient$search(
  sort = NULL,
  query = NULL,
  start_cursor = NULL,
  page_size = NULL,
  filter = NULL
)
Arguments
sort

Named list (JSON object). Sort condition to apply to the search results.

query

Character. The search query string.

start_cursor

Character. For pagination. If provided, returns results starting from this cursor. If NULL, returns the first page of results.

page_size

Integer. Number of items to return per page (1-100). Defaults to 100.

filter

List (JSON object). Filter condition to apply to the search results.

Details

Endpoint documentation

Super class

notionapi::NotionClient -> AsyncNotionClient

Methods

Public methods

Inherited methods

Method new()

Initialise Async Notion Client

Usage
AsyncNotionClient$new(
  auth = NULL,
  base_url = getOption("notionapi.base_url"),
  version = getOption("notionapi.version"),
  timeout = 60000
)
Arguments
auth

Authentication token. Uses NOTION_TOKEN environment variable by default.

base_url

Character. Base URL for Notion API.

version

Character. Notion API version.

timeout

Numeric. Number of milliseconds to wait before timing out a request.


Method 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.

Usage
AsyncNotionClient$request()
Returns

httr2 request object


Method print()

Print basic details of Notion Client

Usage
AsyncNotionClient$print()

See Also

Notion API documentation

Examples


# ----- 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)


notionapi documentation built on April 13, 2026, 9:07 a.m.