MyNixOS website logo
Description

Client for the 'Notion API'.

Enable programmatic interaction with 'Notion' pages, databases, blocks, comments, and users through the 'Notion API' <https://developers.notion.com/>. Provides both synchronous and asynchronous client interfaces for building workflows and automations that integrate with 'Notion' workspaces. Supports all 'Notion API' endpoints including content creation, data retrieval, and workspace management.

notionapi notionapi website

R-CMD-check Codecov testcoverage

notionapi is an R client library for Notion API, enabling users to programmatically interact with their Notion workspaces. The package provides complete API coverage for managing pages and databases, managing content blocks, handling comments and retrieving user information.

The package is designed to mirror the Official Notion JavaScript Client, using R6 classes to provide a familiar object-oriented interface and consistent API structure.

Installation

Install the package from CRAN:

install.packages("notionapi")

Or install the development version from GitHub:

pak::pak("brenwin1/notionapi")

Authentication

To initialise the Notion client, you need a Notion integration token.

  1. Create an integration in your Notion workspace following these instructions.

  2. Copy the integration token from your integration settings.

  3. Set the token as an environment variable:

usethis::edit_r_environ()
# add NOTION_TOKEN=<your_integration_token>
  1. Share pages/databases with your integration in Notion.

  2. Restart your R session to load the environment variable.

Usage

Use notion_client() or async_notion_client() to create a client instance for accessing the API endpoints:

The client organises methods into logical endpoint groups like pages, databases, and blocks. Each method maps directly to an endpoint, with parameters available as function arguments.

See the Notion API reference for complete endpoint documentation.

library(notionapi)

# Create a Notion client instance
notion <- notion_client()

# Access the users endpoint to list all users in your Notion workspace
resp <- notion$users$list()
resp
#> {
#>   "object": "list",
#>   "results": [
#>     {
#>       "object": "user",
#>       "id": "fda12729-108d-4eb5-bbfb-a8f0886794d1",
#>       "name": "Brenwin",
#>       "avatar_url": {},
#>       "type": "person",
#>       "person": {}
#>     },
#>     {
#>       "object": "user",
#>       "id": "6b786605-e456-4237-9c61-5efaff23c081",
#>       "name": "brenwin-internal",
#>       "avatar_url": {},
#>       "type": "bot",
#>       "bot": {
#>         "owner": {
#>           "type": "workspace",
#>           "workspace": true
#>         },
#>         "workspace_name": "Brenwin's Notion",
#>         "workspace_limits": {
#>           "max_file_upload_size_in_bytes": 5368709120
#>         }
#>       }
#>     }
#>   ],
#>   "next_cursor": {},
#>   "has_more": false,
#>   "type": "user",
#>   "user": {},
#>   "request_id": "7ecade3d-9ad8-4a02-bd8d-9aee421e18c6"
#> }

API responses are automatically converted from JSON to R lists.

# Extract specific fields from the response (list subsetting)
vapply(resp$results, "[[", "", "type")
#> [1] "person" "bot"

Serialisation

R data structures are automatically converted to the JSON format expected by the Notion API:

  • lists → JSON object
  • list of lists → JSON array

Examples are provided throughout the reference documentation. See CommentsEndpoint create() method for an example.

Pagination

See Pagination section in Notion API documentation for supported endpoints and implementation details.

Pagination parameters (page_size and start_cursor) are exposed as function arguments.

For an example, see BlocksChildrenEndpoint retrieve() method.

Metadata

Version

0.1.0

License

Unknown

Platforms (76)

    Darwin
    FreeBSD
    Genode
    GHCJS
    Linux
    MMIXware
    NetBSD
    none
    OpenBSD
    Redox
    Solaris
    WASI
    Windows
Show all
  • aarch64-darwin
  • aarch64-freebsd
  • aarch64-genode
  • aarch64-linux
  • aarch64-netbsd
  • aarch64-none
  • aarch64-windows
  • aarch64_be-none
  • arm-none
  • armv5tel-linux
  • armv6l-linux
  • armv6l-netbsd
  • armv6l-none
  • armv7a-linux
  • armv7a-netbsd
  • armv7l-linux
  • armv7l-netbsd
  • avr-none
  • i686-cygwin
  • i686-freebsd
  • i686-genode
  • i686-linux
  • i686-netbsd
  • i686-none
  • i686-openbsd
  • i686-windows
  • javascript-ghcjs
  • loongarch64-linux
  • m68k-linux
  • m68k-netbsd
  • m68k-none
  • microblaze-linux
  • microblaze-none
  • microblazeel-linux
  • microblazeel-none
  • mips-linux
  • mips-none
  • mips64-linux
  • mips64-none
  • mips64el-linux
  • mipsel-linux
  • mipsel-netbsd
  • mmix-mmixware
  • msp430-none
  • or1k-none
  • powerpc-linux
  • powerpc-netbsd
  • powerpc-none
  • powerpc64-linux
  • powerpc64le-linux
  • powerpcle-none
  • riscv32-linux
  • riscv32-netbsd
  • riscv32-none
  • riscv64-linux
  • riscv64-netbsd
  • riscv64-none
  • rx-none
  • s390-linux
  • s390-none
  • s390x-linux
  • s390x-none
  • vc4-none
  • wasm32-wasi
  • wasm64-wasi
  • x86_64-cygwin
  • x86_64-darwin
  • x86_64-freebsd
  • x86_64-genode
  • x86_64-linux
  • x86_64-netbsd
  • x86_64-none
  • x86_64-openbsd
  • x86_64-redox
  • x86_64-solaris
  • x86_64-windows