Skip to main content

NotionExporter

Description

NotionExporter is a Python class designed to simplify the process of exporting content from Notion. It provides an interface to configure, trigger, and download content exports from Notion. The class supports exporting content in various formats (Markdown, HTML, PDF) and also allows users to choose the scope of the export (current view vs. all content).

Features

  • Export content in Markdown, HTML, or PDF format.
  • Configure the scope of your export: current view or all content.
  • Option to include or exclude files in the export.
  • Flatten the file tree structure upon export.
  • Export multiple pages concurrently for faster processing.
  • Monitor export progress with a progress bar.
  • Automatically unpack zipped export files.

Usage

  1. Download:

    pip install python-notion-exporter
    
  2. Initialization:

    from python_notion_exporter import NotionExporter
    
    if __name__ == "__main__":
        exporter = NotionExporter(
            token_v2="YOUR_NOTION_TOKEN",
            file_token="YOUR_FILE_TOKEN",
            pages={"Page Name": "Page ID"},
            export_directory="path/to/save",
            flatten_export_file_tree=True,
            export_type=ExportType.MARKDOWN,
            current_view_export_type=ViewExportType.CURRENT_VIEW,
            include_files=True,
            recursive=True
        )
        exporter.process()
    

    You will need to get the token_v2 and file_token values from your Notion cookies. The pages dictionary should contain pairs of page_name: page_id for each page you want to export.

Needed Cookies

To export anything from Notion, one needs to authenticate oneself with some Cookies (like a browser would). These cookies are called token_v2 and file_token. They are set on all requests of a logged in user when using the Notion web-app.

How to retrieve the Cookies?

  • Go to notion.so.
  • Log in with your account.
  • Open the developer tools of your browser, open Application > Storage > Cookies (Chrome); Storage tab (Firefox).
  • Copy the value of the Cookies called token_v2 and file_token and paste them somewhere safe.
  • ⚠️ If you don't find file_token, you need to have at least had exported a file manually once.
  • Those cookies have a 1 year validity, so you don't need to do this often.
  1. Process Exports:

    exporter.process()
    

    This will initiate the export, download, and unpacking processes for the pages defined.

Requirements

  • Python 3.6+

For more details or any issues, please raise a ticket or contact the maintainers.

Metadata

Release files for python-notion-exporter 1.0.6

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

Source distribution (sdist)

Source distribution for python-notion-exporter 1.0.6
File Size Uploaded
python_notion_exporter-1.0.6.tar.gz 7.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for python-notion-exporter 1.0.6
File Interpreter ABI Platform
python_notion_exporter-1.0.6-py3-none-any.whl Python 3 none any Details

Total release size: 14.0 kB

Release files / python_notion_exporter-1.0.6.tar.gz

Download URL python_notion_exporter-1.0.6.tar.gz
Size 7.1 kB
Tags Source
SHA-256 checksum
How to use checksums
0a5d11f343569c963b4a4b2da0d1eb40adf7f9204c7f3956c6ad635f47b5a4ec
BLAKE2b-256 checksum
How to use checksums
7f377bbaeeaeb958f970bb3d2d2b95490547028b53465e086652cf88d00429cb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.18

Release files / python_notion_exporter-1.0.6-py3-none-any.whl

Download URL python_notion_exporter-1.0.6-py3-none-any.whl
Size 7.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c049acf1b8906fa2ef994821e945f35be3e4a9c856e5abfb06a126749378d7cc
BLAKE2b-256 checksum
How to use checksums
5dd84a27731234db615139caab472dad7e0d65e68a9a92604d57bb7aa34f1a92
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.18

Release history Release notifications | RSS feed

This release

1.0.6 This release

2 release files

1.0.5

2 release files

1.0.4

2 release files

1.0.2

2 release files

1.0.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