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

fetch-notion-page

v0.2.1

Published

A tool to recursively fetch all blocks from a Notion page

Readme

fetch-notion-page

NPM Version

Fetch Notion page contents as JSON or Markdown.

Features

  • 🔄 Recursive block fetching: Recursively fetch all blocks in a page, unlike the raw Notion API
  • 📝 Markdown conversion: Convert Notion pages to clean Markdown format
  • 🖥️ CLI & API: Use as a command-line tool or programatically integrate into your applications

Installation

npm

npm install fetch-notion-page

Usage

[!TIP] Wanna use this as a MCP server? Check out monoread

CLI Usage

# Set your Notion API key
export NOTION_API_KEY="your_api_key_here"

# Fetch a page as JSON
fetch-notion-page <page-url>

# Or fetch a page as Markdown
fetch-notion-page <page-url> --format markdown

# Specify maximum retries for rate limit errors
fetch-notion-page <page-url> --max-retries 3

Programmatic Usage

import { fetchNotionPage, convertPageToMarkdown } from 'fetch-notion-page';

// Fetch a Notion page with all its child blocks
const result = await fetchNotionPage('your-page-id', {
  apiKey: 'your-api-key',
  maxDepth: 10, // Optional: limit recursion depth
  maxRetries: 3 // Optional: maximum retries for rate limit errors (default: 3)
});

if (result.type === 'Success') {
  const pageWithChildren = result.value;

  // Convert to Markdown
  const markdown = convertPageToMarkdown(pageWithChildren);
  console.log(markdown);
} else {
  console.error('Failed to fetch page:', result.error);
}

API Reference

fetchNotionPage(pageId, options)

Recursively fetches a Notion page and all its child blocks.

Parameters:

  • pageId (string): The Notion page ID
  • options (object):
    • apiKey (string): Your Notion integration API key
    • maxDepth (number, optional): Maximum recursion depth (default: 10)
    • maxRetries (number, optional): Maximum number of retries for rate limit errors (default: 3)

Returns:

  • Result<PageWithChildren, FetchNotionPageError>: A result object containing either the page data or error information

convertPageToMarkdown(page)

Converts a fetched page to Markdown format.

Parameters:

  • page (PageWithChildren): The page object returned by fetchNotionPage

Returns:

  • string: The page content in Markdown format

Notion API Setup

  1. Create a new integration at Notion Developers
  2. Copy the Internal Integration Token
  3. Share your pages with the integration:
    • Open the page in Notion
    • Click "Share" → "Add people, emails, or integrations"
    • Select your integration

License

Apache License 2.0