Registry / crm-productivity / notion2md

notion2md

JSON →
library2.9.0pypypiunverified

notion2md is a Python CLI tool designed to export Notion pages, databases, and blocks into markdown files. It leverages the Notion API client to fetch content and convert it into a standard markdown format. The current version is 2.9.0, and the project has an active, though irregular, release cadence with recent updates.

pip install notion2md
INSTALL
IMPORT
SIG · NOTION2MD
N
notion2md
crm-productivitypythonv2.9.0
Install
3.3s avg
Import
Disk
35MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v2.9.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.910 runs
installs and imports cleanly · install 0.0s · import 0.000s · 39.3MB
glibc
py 3.103.910 runs
installs and imports cleanly · install 3.3s · import 0.000s · 36MB
35MB installed
● package 35MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

notion_to_markdown
from notion2md.notion_to_md import notion_to_markdown
from notion2md import notion_to_markdown

The primary use case for notion2md is via its command-line interface. This quickstart demonstrates how to export a Notion page by setting the `NOTION_TOKEN` environment variable and executing the `notion2md` command with a page ID and an output directory. Ensure your Notion API token has the necessary read permissions.

import os import subprocess # Set your Notion API token as an environment variable # Ensure the token has read access to the page/database you intend to export. # Example: export NOTION_TOKEN="secret_YOUR_NOTION_TOKEN" # For quick testing, you can set it directly (NOT recommended for production): # os.environ['NOTION_TOKEN'] = 'secret_YOUR_NOTION_TOKEN' # Replace with your actual Notion Page ID NOTION_PAGE_ID = os.environ.get('NOTION_PAGE_ID', 'a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6') if not os.environ.get('NOTION_TOKEN'): print("Error: NOTION_TOKEN environment variable is not set.") print("Please set it (e.g., export NOTION_TOKEN='secret_YOUR_TOKEN')") else: print(f"Attempting to export Notion Page ID: {NOTION_PAGE_ID}...") try: # Example CLI usage: Export a Notion page to a local 'output' directory result = subprocess.run( ['notion2md', NOTION_PAGE_ID, '-o', 'output'], capture_output=True, text=True, check=True ) print("Export successful!") print("STDOUT:", result.stdout) if result.stderr: print("STDERR:", result.stderr) except subprocess.CalledProcessError as e: print(f"Error during export: {e}") print("STDOUT:", e.stdout) print("STDERR:", e.stderr) except FileNotFoundError: print("Error: 'notion2md' command not found. Please ensure the package is installed and in your PATH.")
notion2md --version
Debug
Known issues
breakingVersion 2.0.0 was a complete rewrite of the library, introducing significant breaking changes. Code written for versions prior to 2.0.0 will not be compatible.
fix
Completely uninstall any old versions (`pip uninstall notion2md`) and reinstall (`pip install notion2md`). Review your code and CLI usage against the new documentation, as command-line arguments and internal APIs have changed.
affects: <2.0.0
gotchaThe `NOTION_TOKEN` environment variable must be set correctly, and the associated Notion Integration must have the necessary read permissions for the specific pages or databases you are trying to export.
fix
Verify your Notion API token is correct and set in your environment (e.g., `export NOTION_TOKEN='secret_...'`). In Notion, go to 'Settings & members' -> 'Integrations', find your integration, and ensure it has access to the pages/databases by inviting it to them.
affects: All
gotchanotion2md relies on the Notion API. Changes in the official Notion API or its client libraries (e.g., `notion-client-py`) can lead to unexpected behavior or breakage in notion2md until the library is updated.
fix
If you encounter unexpected errors, check the project's GitHub issues for recent reports and updates. Consider pinning `notion2md` to a specific version if you need stability in production and test updates carefully.
affects: All
gotchaNot all Notion block types are perfectly supported or rendered in markdown. Complex blocks (e.g., sync blocks, advanced tables, some embedded content) might not export as expected or might be omitted.
fix
Test your specific Notion content before relying on the export for complex layouts. Manually review exported markdown files for fidelity and be aware of limitations for certain Notion block types.
affects: All
Upgrade
Version history
2.9.0latest on PyPI · released Jan 10, 2024
Audit
Dependencies

No dependency data recorded yet.

Agent activity
40 hits · last 30 days
node
36
OpenAI (training)
1
Resources
notion2md — pip install notion2md · libregistry