@texonom/cli
v1.5.8
Published
Texonom CLI which has ability to export data from Notion.so
Readme
Texonom Notion CLI
Command line interface for exporting Notion data. It wraps the @texonom/nclient library and converts pages or entire workspaces to Markdown.
Features
- Export a single page or an entire workspace
- Output raw Notion data or rendered Markdown
- Handles rate limits and supports auth tokens
Install
pnpm i @texonom/cliUsage
Export
# export block, collection, collection_view and notion_user for each folder
pnpm tsx src/main.ts export --rawProgrammatic use
import { NotionExporter } from '@texonom/cli'
const exporter = new NotionExporter({ page: pageId })
const recordMap = await exporter.notion.getPage(pageId)
const md = await exporter.pageToMarkdown(parsePageId(pageId), recordMap)// also works with page URLs thanks to nutils
import { parsePageId } from '@texonom/nutils'
const exporter = new NotionExporter({ page })
const recordMap = await exporter.notion.getPage(page)
const md = await exporter.pageToMarkdown(parsePageId(page), recordMap)Example workflow
# 1. Fetch raw data from Notion
pnpm tsx src/main.ts export -p 04089c8ae3534bf79512fc495944b321 --raw -r -f
# 2. Transform raw data to markdown (requires token if data is private)
export NOTION_TOKEN=
pnpm tsx src/main.ts export -p 04089c8ae3534bf79512fc495944b321 -r -l -t $NOTION_TOKEN -u
# 3. Retry without token if you hit rate limits
pnpm tsx src/main.ts export -p 04089c8ae3534bf79512fc495944b321 -r -l -uIf you encounter memory errors:
NODE_OPTIONS="--max-old-space-size=16384" tsx ...Export a single page
pnpm tsx src/main.ts export -p 04089c8ae3534bf79512fc495944b321API
Exports:
NotionExportCommandCLI entryNotionExporterclassgetBlockLink(blockId, recordMap)loadRaw(folder)loadJson(folder, file)generateTreemaps(folder, pageTree)computeStats(pageTree)writeStats(file, stats)
Difference from React Notion X
The original project focuses on rendering. This CLI adds a straightforward way to download and convert Notion content from the terminal.
