Skip to main content

A package to convert Notion content into Markdown format

Project description

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

notion_to_md_py-0.1.5.tar.gz (14.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

notion_to_md_py-0.1.5-py3-none-any.whl (10.5 kB view details)

Uploaded Python 3

File details

Details for the file notion_to_md_py-0.1.5.tar.gz.

File metadata

  • Download URL: notion_to_md_py-0.1.5.tar.gz
  • Upload date:
  • Size: 14.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.4

File hashes

Hashes for notion_to_md_py-0.1.5.tar.gz
Algorithm Hash digest
SHA256 327a35bb2a393e458fbf585b5d0d8bb7c2e2834607ad0b86e7f23a5cc0edc807
MD5 977bb9be272fb405633922e2c355b82a
BLAKE2b-256 ae3bed3750d49dddf15aff5c4f835f9d27741b8f9a8087ad6752e3a87bab0f4d

See more details on using hashes here.

File details

Details for the file notion_to_md_py-0.1.5-py3-none-any.whl.

File metadata

File hashes

Hashes for notion_to_md_py-0.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 ef1fffad8f32ce64d75cc064700080f4ff1f2a034cf158f120fe8e59143ab4e3
MD5 dc28371ee8e50bb36fdb917bc8c4c2db
BLAKE2b-256 9ee9da8e9d7368a72e71985f484b80dc313528df67ef37ebf733c0f33f664a16

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page