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.4.tar.gz (11.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.4-py3-none-any.whl (12.0 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for notion_to_md_py-0.1.4.tar.gz
Algorithm Hash digest
SHA256 11b53cf1d903a48f66bdc6b4e3a0941d61fc4aae1eccffab60f0f1eb684130d7
MD5 8674729dfade2d4d76e4754d98026b63
BLAKE2b-256 cdfcb5c89f669a5216e3e7a19806f06327eac6f7340410a8388bc2b861b2d47d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for notion_to_md_py-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 3db73e55f04f02845273816de33ea5de7c8eb7e72136372ff75075ea0b552462
MD5 1b367ccf55b8a2ad7e54b60e3c851d0e
BLAKE2b-256 a3eba8f26a12ced1949288a8946c259243a8d1721d31414b26a101aba1fc91ea

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