Skip to main content

Export and download Notion pages asynchronously

Project description

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.

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

python_notion_exporter-1.0.4.tar.gz (5.6 kB view details)

Uploaded Source

Built Distribution

python_notion_exporter-1.0.4-py3-none-any.whl (5.3 kB view details)

Uploaded Python 3

File details

Details for the file python_notion_exporter-1.0.4.tar.gz.

File metadata

File hashes

Hashes for python_notion_exporter-1.0.4.tar.gz
Algorithm Hash digest
SHA256 601ba1e071e39f485200d667037147e266ac4b5c198fdf7eb8fe9ffe27477a25
MD5 05ce533d55eccaf6491cfbb5336c5f9b
BLAKE2b-256 b603e5d596a1020763447b761fb70a43ae4111437aa722688d235d0910e33f9f

See more details on using hashes here.

File details

Details for the file python_notion_exporter-1.0.4-py3-none-any.whl.

File metadata

File hashes

Hashes for python_notion_exporter-1.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 97c54b573a464d6b5f761489ef0e72e77b6bc49beb022569453af4e231fa70d1
MD5 f55ee17e7e2be63aef3ce6c6ec6a8d93
BLAKE2b-256 1abda60d1d49fe91def43bb1881a5a39f1343e9c921bd7c29105ce62671a3fc0

See more details on using hashes here.

Supported by

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