JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 5
  • Score
    100M100P100Q20007F

Package Exports

  • notion2json
  • notion2json/lib/index.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (notion2json) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

notion2json

A library built with Bun and Notion API client to extract and parse data from a Notion database.

NotionQuerier

This class needs a NOTION_API_SECRET environment variable in your project.

Query a database's pages

const querier = new NotionQuerier()

// Query pages sequentially: uses Notion's `next_cursor` after each call
const pages = await querier.queryAllDatabasePages('478cb452-7694-467a-9470-1934dc35ca87')

// Query pages bidirectionally: uses 2 threads, one querying from the oldest created page upward and one from the most recent page downward
const pages = await querier.queryDatabaseBidirectionally('478cb452-7694-467a-9470-1934dc35ca87')

// Query pages by partition: partitions the database based on the creation date and queries all segments concurrently
const pages = await querier.queryAllDatabasePagesByPartition('478cb452-7694-467a-9470-1934dc35ca87', { decreaseRatio: 2, count: 10 })

// Add options to queried pages (uses NotionClient options)
const pages = await querier.queryAllDatabasePages('478cb452-7694-467a-9470-1934dc35ca87', { filter_properties: ['%3BVB%3D', '%3Caie'] })

Retrieve property configurations

const querier = new NotionQuerier()

// Retrieve id, type and related databaseId (for relation properties only) of every propery in the database
const propertyConfigs = await querier.fetchDatabasePropertyConfigs('478cb452-7694-467a-9470-1934dc35ca87')

NotionFormatter

Format database pages

const formatter = new NotionFormatter({ '478cb452-7694-467a-9470-1934dc35ca87': { pages, propertyConfigs } })

// Format all pages in the given database to JSON objects with property ids as keys and property content as values
const formattedPages = formatter.formatDatabase('478cb452-7694-467a-9470-1934dc35ca87')