Docs
Notion Downloader
Notion Downloader
The Notion Downloader package documentation.
Features
- Backup your Notion pages and databases
- Cache your downloads
- Convert Notion content to Markdown
- Flexible naming and layout strategies
- Download assets
- Images
- Files
- Videos
- Audio
- PDFs
- Continuous pulling with revalidation
Installation
npm install notion-downloader
Usage
- Create a configuration file named
downloader.config.cjs
in your project root:
import { Config } from "notion-downloader"
const config: Config = {
conversion: {
outputPaths: {
markdown: "./content/",
assets: "./public/assets/",
},
markdownPrefixes: {
all: "",
image: "/assets/",
},
statusPropertyName: "Status",
statusPropertyValue: "Publish",
pageLinkHasExtension: false,
slugProperty: "slug",
},
rootDbAsFolder: true,
rootObjectType: "database",
rootId: "c974ccd9c70c4abd8a5bd4f5a294e5dd",
cache: {
cleanCache: false,
cacheStrategy: "cache",
},
logLevel: "debug",
revalidatePeriod: -1,
}
export default config
- Run the downloader:
npx notion-downloader pull --notion-token "your-notion-token"
Configuration Options
The NotionPullOptions
object supports the following options:
notionToken
: Your Notion API token (required)rootId
: The ID of the root page or database to start downloading from (required)rootObjectType
: The type of the root object ("page", "database", or "auto")rootDbAsFolder
: Treat the root database as a folder (default: false)cache
: Caching optionsrevalidatePeriod
: Period for revalidating content (in milliseconds)logLevel
: Logging level (default: "info")conversion
: Conversion options
Conversion Options
The conversion
object allows you to customize how Notion content is converted:
skip
: Skip conversion (default: false)overwrite
: Overwrite existing files (default: false)slugProperty
: Custom property to use as slugstatusPropertyName
: Property name for filtering (default: "Status")statusPropertyValue
: Property value for filtering (default: "Done")pageLinkHasExtension
: Include file extension in page links (default: true)outputPaths
: Output paths for different file typesmarkdownPrefixes
: Prefixes for markdown fileslayoutStrategy
: File layout strategynamingStrategy
: File naming strategy
Advanced Configuration
For more advanced configuration options, refer to the schema.ts
file:
This file defines the schema for all configuration options, including enums for asset types, layout strategies, and naming strategies.