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
- Create an integration in your Notion account and get the
API key. - Share your database with the integration to allow access.
- Retrieve your
Database IDandPage IDfrom 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.
- Fork the repository.
- Create a new branch for your feature or bug fix.
- 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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file notion_to_md_py-0.1.2.tar.gz.
File metadata
- Download URL: notion_to_md_py-0.1.2.tar.gz
- Upload date:
- Size: 11.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6b9ecbae87bf358011631bf64d3345ffb560697de69cec1ed28fb35b78cf4f1c
|
|
| MD5 |
5b082bf30a62217faa378b196358d4f3
|
|
| BLAKE2b-256 |
06ea81ec3936a5e0180630d919da8ab2e183a1d1e385ab42c29f779e5a30fb8b
|
File details
Details for the file notion_to_md_py-0.1.2-py3-none-any.whl.
File metadata
- Download URL: notion_to_md_py-0.1.2-py3-none-any.whl
- Upload date:
- Size: 12.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3238359d232bb7649eb8d0717cb0ec5d795a3370ee313c784e65c5ebb5268a15
|
|
| MD5 |
f82628f0c167cf0892e7794293e29aee
|
|
| BLAKE2b-256 |
75e681b42dc54583f6addab751ef51aaf1afdcd9c592fedd3b0769673fb97d59
|