npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

notion-schema

v0.3.3

Published

Simple wrapper for @notionhq/client to parse Notion databases entries to follow a simple defined schema

Readme

Notion Schema

Simple wrapper for @notionhq/client to parse Notion databases entries to follow a simple defined schema

Make sure your integration is added to all pages you want it to have access to!

Notion Integrations

Examples

import { NotionSchemaClass, Field, PropField } from "notion-schema";

const schema = new NotionSchemaClass("<API_SECRET>")

let entries = await schema.entries("<DATABASE_ID>", [
  Field("id"),
  PropField("Name", "title"),
  Field("icon"),
  PropField("text", "desc"),
  PropField("number"),
  PropField("relations", "children", {
    schema: [
        Field("id"),
        PropField("title"),
    ]
  })
])

/*
entries: {
  id: string;
  title: string;
  icon: string; // URL to icon, parses emojis to twemoji CDN
  desc: string;
  number: string;
  children: { id: string; title: string; }[]
}
*/

API

Field & PropField

  • These are for defining a row on a schema
  • The different is Field is a field on the page and PropField is a field under properties (according to the NotionAPI)
Field(
  <source_property_key>, // string | Key of source
  <destination_property_key>, // ?string | Key of resulting schema
  <opts>, // ?SchemaRowOpts | Options (consult SchemaRowOpts)
): SchemaRow // Generated automatically from function

PropField(
  <source_property_key>, // string | Key of source, usually the name of property on Notion's front-end
  <destination_property_key>, // ?string | Key of resulting schema
  <opts>, // ?SchemaRowOpts | Options (consult SchemaRowOpts)
): SchemaRow // Generated automatically from function

NotionSchemaClass

  • the simple class for getting the entries of a Notion database

SchemaRowOpts

interface SchemaRowOpts {
  transformer?: (params: {[index: string]: any}) => any, // For raw editing of property object (consult Notion API to understand returned objects here)
  flag?: string; // Different overrides for props (consult the flag Reference)
  schema?: SchemaRow[] // For specifying the schema of the pages under a relation (SchemaRow is the result of the Field & PropField functions)

  client?: Client; // Sometimes passed thru internally for using the same client, will be overwritten if set
}

EntriesOpts

interface EntriesOpts {
  validate?: (database: DatabaseObjectResponse) => Promise<boolean>; // Promise function that returns a bool that determines whether to continue the function after getting the database OR return null not further process.
}

flag Reference

Flags are put in place to do simple overrides of property values without having to use opts.transformers.

They are based on the property type...

  • date
    • "start" (default): Return the start datetime as a Date object
    • "end": Return the end datetime as a Date object
  • multi_select, select, & status
    • "name": Return the name field of the property
    • "color": Return the color field of the property
  • formula
    • if formula results in date, the date flags are used
  • relation & rollup
    • flags are passthru to the pages that are retrieved from the relation

And that's about it! This package is very weird but it allows me to kind of use Notion as a sort of CMS for my portfolio site, but I'll put this up here for everyone just in case someone else has a use for this