Skip to main content

notion-to-md (Python Version)

This is the Python implementation of nodejs version of notion-to-md, a tool that converts Notion pages into Markdown files.

Installation

Install the package via pip:

pip install notion-to-md-py

Usage

Sync Version

from notion_client import Client
from notion_to_md import NotionToMarkdown


notion = Client(auth="your-auth-token")

n2m = NotionToMarkdown(notion)

# Export a page as a markdown blocks
md_blocks = n2m.page_to_markdown("page-id")

# Convert markdown blocks to string
md_str = n2m.to_markdown_string(md_blocks).get('parent')

# Write to a file
with open("output.md", "w") as f:
    f.write(md_str)

Async Version

import asyncio
from notion_client import AsyncClient
from notion_to_md import NotionToMarkdownAsync


notion = AsyncClient(auth="your-auth-token")

n2m = NotionToMarkdownAsync(notion)

# Export a page as a markdown blocks
md_blocks = asyncio.run(n2m.page_to_markdown("page-id"))

# Convert markdown blocks to string
md_str = n2m.to_markdown_string(md_blocks).get('parent')

# Write to a file
with open("output.md", "w") as f:
    f.write(md_str)

Replace your-auth-token and page-id with the appropriate values from your Notion account.

Authentication with Notion API

  1. Create an integration in your Notion account and get the API key.
  2. Share your database with the integration to allow access.
  3. Retrieve your Database ID and Page ID from the Notion app.

Requirements

  • Python 3.7 or later
  • Notion API key

Limitations

  • The tool relies on the Notion API, and features are limited to what the API supports.
  • Embedding or downloading files other than images is not supported.

Contributing

Contributions are welcome! Feel free to open issues or submit pull requests to improve the functionality or fix bugs.

  1. Fork the repository.
  2. Create a new branch for your feature or bug fix.
  3. Submit a pull request with a clear description of your changes.

License

This project is licensed under the MIT License.

Metadata

Release files for notion-to-md-py 0.1.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for notion-to-md-py 0.1.5
File Size Uploaded
notion_to_md_py-0.1.5.tar.gz 14.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for notion-to-md-py 0.1.5
File Interpreter ABI Platform
notion_to_md_py-0.1.5-py3-none-any.whl Python 3 none any Details

Total release size: 24.8 kB

Release files / notion_to_md_py-0.1.5.tar.gz

Download URL notion_to_md_py-0.1.5.tar.gz
Size 14.3 kB
Tags Source
SHA-256 checksum
How to use checksums
327a35bb2a393e458fbf585b5d0d8bb7c2e2834607ad0b86e7f23a5cc0edc807
BLAKE2b-256 checksum
How to use checksums
ae3bed3750d49dddf15aff5c4f835f9d27741b8f9a8087ad6752e3a87bab0f4d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.4

Release files / notion_to_md_py-0.1.5-py3-none-any.whl

Download URL notion_to_md_py-0.1.5-py3-none-any.whl
Size 10.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ef1fffad8f32ce64d75cc064700080f4ff1f2a034cf158f120fe8e59143ab4e3
BLAKE2b-256 checksum
How to use checksums
9ee9da8e9d7368a72e71985f484b80dc313528df67ef37ebf733c0f33f664a16
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.4

Release history Release notifications | RSS feed

This release

0.1.5 This release

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page