JSPM

  • Created
  • Published
  • Downloads 41
  • Score
    100M100P100Q61702F
  • License MIT

A simple wrapper for the Notion API

Package Exports

  • notion-api-wrapper
  • notion-api-wrapper/dist/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 (notion-api-wrapper) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Notion API Wrapper

Example

  1. Create new integration at https://www.notion.so/my-integrations

  2. Give the integration permissions to read a database

  3. Add the integration token to your .env file

NOTION_API_KEY="secret_0000000000000000000000000000000000000000000"
NOTION_DATABASE_ID="00000000000000000000000000000000"
  1. Query the database, for example:
const databaseId = process.env.NOTION_DATABASE_ID ?? "";
if (!databaseId) throw new Error("Invalid database id");
const data = queryDatabaseFull(databaseId);
console.log(await data)

You can also use the FilterBuilder to create filters that will be used in the query. For example:

const filterA: Filter = {
  property: 'Done',
  checkbox: {
    equals: true,
  },
};

const filterB: Filter = {
  property: 'Tags',
  multi_select: {
    contains: 'A',
  },
};

const filterC: Filter = {
  property: 'Tags',
  multi_select: {
    contains: 'B',
  },
};

const myFilter: Filter = new FilterBuilder()
  .addFilter(filterA)
  .addFilter(
    new FilterBuilder().addFilter(filterB).addFilter(filterC).build('OR')
  )
  .build('AND');

const data = queryDatabaseFull(databaseId, myFilter);