notion-to-md-py


Namenotion-to-md-py JSON
Version 0.1.3 PyPI version JSON
download
home_pagehttps://github.com/SwordAndTea/notion-to-md-py
SummaryA package to convert Notion content into Markdown format
upload_time2025-09-04 20:49:34
maintainerNone
docs_urlNone
authorWei Xiang
requires_python>=3.7
licenseNone
keywords notion markdown converter python
VCS
bugtrack_url
requirements notion-client setuptools httpx pytablewriter pytest pytest-asyncio pytest-cov
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # notion-to-md (Python Version)

This is the **Python implementation** of nodejs version of [notion-to-md](https://github.com/souvikinator/notion-to-md), 
a tool that converts Notion pages into Markdown files.

## Installation

Install the package via pip:

```bash
pip install notion-to-md-py
```

## Usage

### Sync Version

```python
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
```python
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](LICENSE).

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/SwordAndTea/notion-to-md-py",
    "name": "notion-to-md-py",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.7",
    "maintainer_email": null,
    "keywords": "notion markdown converter python",
    "author": "Wei Xiang",
    "author_email": "xiangweiqaz@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/66/ab/0830f4e7bfd372f54c5278e916ee31d0d6cc1987770a02f09133383d0495/notion_to_md_py-0.1.3.tar.gz",
    "platform": null,
    "description": "# notion-to-md (Python Version)\n\nThis is the **Python implementation** of nodejs version of [notion-to-md](https://github.com/souvikinator/notion-to-md), \na tool that converts Notion pages into Markdown files.\n\n## Installation\n\nInstall the package via pip:\n\n```bash\npip install notion-to-md-py\n```\n\n## Usage\n\n### Sync Version\n\n```python\nfrom notion_client import Client\nfrom notion_to_md import NotionToMarkdown\n\n\nnotion = Client(auth=\"your-auth-token\")\n\nn2m = NotionToMarkdown(notion)\n\n# Export a page as a markdown blocks\nmd_blocks = n2m.page_to_markdown(\"page-id\")\n\n# Convert markdown blocks to string\nmd_str = n2m.to_markdown_string(md_blocks).get('parent')\n\n# Write to a file\nwith open(\"output.md\", \"w\") as f:\n    f.write(md_str)\n```\n\n### Async Version\n```python\nimport asyncio\nfrom notion_client import AsyncClient\nfrom notion_to_md import NotionToMarkdownAsync\n\n\nnotion = AsyncClient(auth=\"your-auth-token\")\n\nn2m = NotionToMarkdownAsync(notion)\n\n# Export a page as a markdown blocks\nmd_blocks = asyncio.run(n2m.page_to_markdown(\"page-id\"))\n\n# Convert markdown blocks to string\nmd_str = n2m.to_markdown_string(md_blocks).get('parent')\n\n# Write to a file\nwith open(\"output.md\", \"w\") as f:\n    f.write(md_str)\n```\n\nReplace `your-auth-token` and `page-id` with the appropriate values from your Notion account.\n\n## Authentication with Notion API\n\n1. Create an integration in your Notion account and get the `API key`.\n2. Share your database with the integration to allow access.\n3. Retrieve your `Database ID` and `Page ID` from the Notion app.\n\n\n## Requirements\n\n- Python 3.7 or later\n- Notion API key\n\n## Limitations\n\n- The tool relies on the Notion API, and features are limited to what the API supports.\n- Embedding or downloading files other than images is not supported.\n\n## Contributing\n\nContributions are welcome! Feel free to open issues or submit pull requests to improve the functionality or fix bugs.\n\n1. Fork the repository.\n2. Create a new branch for your feature or bug fix.\n3. Submit a pull request with a clear description of your changes.\n\n## License\n\nThis project is licensed under the [MIT License](LICENSE).\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "A package to convert Notion content into Markdown format",
    "version": "0.1.3",
    "project_urls": {
        "Bug Tracker": "https://github.com/SwordAndTea/notion-to-md-py/issues",
        "Homepage": "https://github.com/SwordAndTea/notion-to-md-py",
        "Source Code": "https://github.com/SwordAndTea/notion-to-md-py"
    },
    "split_keywords": [
        "notion",
        "markdown",
        "converter",
        "python"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "c263a41e32e9dc87d475982baa8f77ea05c637425a92c5e364995e868d1da871",
                "md5": "429b9efbd29178d64ce97ac7d8a3268a",
                "sha256": "a6b85a462acc45c5cb03ce88465de29054cdba263a0c811f30861dcfd7c38548"
            },
            "downloads": -1,
            "filename": "notion_to_md_py-0.1.3-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "429b9efbd29178d64ce97ac7d8a3268a",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7",
            "size": 11999,
            "upload_time": "2025-09-04T20:49:33",
            "upload_time_iso_8601": "2025-09-04T20:49:33.569251Z",
            "url": "https://files.pythonhosted.org/packages/c2/63/a41e32e9dc87d475982baa8f77ea05c637425a92c5e364995e868d1da871/notion_to_md_py-0.1.3-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "66ab0830f4e7bfd372f54c5278e916ee31d0d6cc1987770a02f09133383d0495",
                "md5": "bdafb6874f07b7328e48beba20bd0ee9",
                "sha256": "2852fac44b0e1caab67106b54efc8eb25bca9f309a82a938798491a6f8683ddb"
            },
            "downloads": -1,
            "filename": "notion_to_md_py-0.1.3.tar.gz",
            "has_sig": false,
            "md5_digest": "bdafb6874f07b7328e48beba20bd0ee9",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7",
            "size": 11255,
            "upload_time": "2025-09-04T20:49:34",
            "upload_time_iso_8601": "2025-09-04T20:49:34.326941Z",
            "url": "https://files.pythonhosted.org/packages/66/ab/0830f4e7bfd372f54c5278e916ee31d0d6cc1987770a02f09133383d0495/notion_to_md_py-0.1.3.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-09-04 20:49:34",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "SwordAndTea",
    "github_project": "notion-to-md-py",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [
        {
            "name": "notion-client",
            "specs": [
                [
                    "~=",
                    "2.3.0"
                ]
            ]
        },
        {
            "name": "setuptools",
            "specs": [
                [
                    "~=",
                    "75.8.0"
                ]
            ]
        },
        {
            "name": "httpx",
            "specs": [
                [
                    "~=",
                    "0.28.1"
                ]
            ]
        },
        {
            "name": "pytablewriter",
            "specs": [
                [
                    "~=",
                    "1.2.1"
                ]
            ]
        },
        {
            "name": "pytest",
            "specs": [
                [
                    "~=",
                    "8.3.4"
                ]
            ]
        },
        {
            "name": "pytest-asyncio",
            "specs": [
                [
                    "~=",
                    "0.25.2"
                ]
            ]
        },
        {
            "name": "pytest-cov",
            "specs": [
                [
                    "~=",
                    "6.0.0"
                ]
            ]
        }
    ],
    "lcname": "notion-to-md-py"
}
        
Elapsed time: 2.75102s