Notion4ever - Python tool for export all your content of Notion page using official Notion API

Overview

NOTION4EVER

Notion4ever is a small python tool that allows you to free your content and export it as a collection of markdown and HTML files via the official Notion API.

โœจ Features

  • Export ready to deploy static HTML pages from your Notion.so pages. root_page

  • Supports nice urls.

  • Downloads all your Notion content, which is accessible via API to a raw JSON file.

  • Uses official Notion API (via notion-sdk-py, but you can use curls if you want).

  • Supports arbitrary page hierarchy. breadcrumb

  • Supports galleries and lists gallery

    list

    Note that Notion API does not provide information about the database view yet. That is why notion4ever will render the database as a list if any database entries do not have a cover. Suppose all entries have covers, then it will be displayed as a gallery.

  • Lightweight and responsive.

  • Downloads all your images and files locally (you can turn this off if you prefer to store images\files somewhere else).

๐Ÿ’ป How to run it locally

Just copy or clone the content of this repository and run.

python -m notion4ever -n NOTION_TOKEN -p NOTION_PAGE_ID -bl True

๐Ÿค– How to run it automatically with Github actions

I will demonstrate it on the specific example of my site. Notion page -> Github repository Congratulations ๐Ÿค— !

โœ… Step 1. Create/choose some page in Notion.

  1. We will need the page ID. For example, the page with URL https://fmin.notion.site/Danya-Merkulov-12e3d1659a444678b4e2b6a989a3c625 has the following ID: 12e3d1659a444678b4e2b6a989a3c625.

  2. Also, we will need to create a Notion API token. Go to Notion.so/my-integrations -> Create new integration. Type the name of the integration and press submit. Now you can see your token, which starts with secret_*** under the Internal Integration Token field.

โœ… Step 2. Set up a repository for your static site.

In my case, it is github.com/MerkulovDaniil/merkulovdaniil.github.io/.

  1. You need to specify your Notion settings in a Github action secret. Jump to the Settings -> Secrets -> Actions -> New repository secret and create two secrets: a. NOTION_PAGE_ID b. NOTION_TOKEN

    github_secret

  2. Create and configure the following GitHub action in your repository:

publish.yml
name: Deploy from Notion to Pages

# on: [workflow_dispatch]
on:
  schedule:
    - cron: "0 */12 * * *" 
    
jobs:
  download_old-generate-push:
    runs-on: ubuntu-latest
    
    steps:
        # Download packages
      - name: Submodule Update
        run: |
          wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
          sudo apt install ./google-chrome-stable_current_amd64.deb
          sudo apt-get update
          
      - name: Set up Python
        uses: actions/setup-python@v2
        with:
          python-version: 3.10.0
          
      - name: Download notion4ever
        uses: actions/checkout@v2
        with:
          repository: 'MerkulovDaniil/notion4ever'
          
      - name: Install packages
        run: pip install -r requirements.txt
        
      - name: Download current version of the site
        uses: actions/checkout@v2
        with:
          # HERE, YOU NEED TO PLACE YOUR REPOSITORY
          repository: 'MerkulovDaniil/merkulovdaniil.github.io'
          # TARGET BRANCH
          ref: main
          # THE FOLDER, WHERE NOTION4EVER EXPORTS YOUR CONTENT BY DEFAULT
          path: _site
          
      - name: Run notion4ever
        run: python -m notion4ever
        env:
            # HERE YOU NEED TO PLACE URL OF THE ROOT PAGE. PROBABLY IT IS "https://<username>.github.io"
            SITE_URL: "https://merkulov.top"
            NOTION_TOKEN: ${{secrets.NOTION_TOKEN}}
            NOTION_PAGE_ID: ${{secrets.NOTION_PAGE_ID}}
      
      - name: Deploy to Pages
        uses: JamesIves/[email protected]
        with:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          BRANCH: main
          FOLDER: _site
          COMMIT_MESSAGE: ๐Ÿค– Deployed via notion4ever.

This script will run every 12 hours, and you can change it. Note that the first run could be slow if your page contains a lot of content, but all the subsequent runs will not download existing files. Congratulations ๐Ÿค— !

๐Ÿ›  How it works

  1. Given your notion token and ID of some page, notion4ever downloads all your content from this page and all nested subpages and saves it in a JSON file, notion_content.json.
  2. Given your raw Notion data, notion4ever structures the page's content and generates file notion_structured.json with markdown content of all pages and relations between them. Markdown parsing is done via modification of notion2md library.
  3. Given structured notion content, notion4ever generates site from jinja templates located in ./_templates directory. All styles are located in ./_sass directory and compiled with libsass-python library. By default, site is located in ./_site directory

๐ŸŒˆ Alternatives

๐Ÿ†“ Free

  • loconotion - Python tool to turn Notion.so pages into lightweight, customizable static websites.
  • NotoCourse - properly configured github actions + structuring for loconotion.
  • notablog - blog-oriented static site generator from Notion database.
  • popsy.co - turns your Notion docs into a site with custom domain.

๐Ÿ’ฐ Paid

  • helpkit.so - turns your Notion docs into a hosted self-service knowledge base.
  • float.so - turns your docs in Notion into online course.
  • super.so - turns your Notion docs into a site.
  • potion.so - turns your Notion docs into a site.

๐Ÿฆ„ Examples

Please, add your sites here if you are using Notion4ever.

Notion public page Notion4ever web page
My personal page My personal page

ToDo

  • Proper documentation.
  • Create pip package.
  • Add parralel files downloading.
  • Add search field.
You might also like...
Cutting-edge GitHub page customization tool

Cutting-edge GitHub page customization tool Want to customize your GitHub user page, but don't know how? Now you can make your profile unique and attr

A small Python app to create Notion pages from Jira issues
A small Python app to create Notion pages from Jira issues

Jira to Notion This little program will capture a Jira issue and create a corresponding Notion subpage. Mac users can fetch the current issue from the

Discord RPC for Notion written in Python

Discord RPC for Notion This is a program that allows you to add your Notion workspace activities to your Discord profile. This project is currently un

Export Statistics for a Telegram Group Chat

Telegram Statistics Export Statistics for a Telegram Group Chat How to Run First, in main repo directory, run the following code to add src to your PY

This is a script to export logs from AWS CloudTrail to a local file.

cloudtrail-export-logs This is a script to export logs from AWS CloudTrail to a local file. Getting Started Prerequisites python 3 boto3 pip Installin

A simple message content sniping Discord bot which you can run yourself! Sniping API pulled from isobot and Arch bot

Discord Snipe Bot This is a bot made with the same message content sniping API from isobot and Arch bot. It's default prefix is -, however you can als

Import Notion Tasks to

Notion-to-Google-Calendar (1 way) Import Notion Tasks to Google Calendar NO MORE UPDATES WILL BE MADE TO THIS REPO. Attention has been put on a 2-way

A simple object model for the Notion SDK.

A simplified object model for the Notion SDK. This is loosely modeled after concepts found in SQLAlchemy.

Token-gate Notion pages

This is a Next.js project bootstrapped with create-next-app. Getting Started First, run the development server: npm run dev # or yarn dev Open http://

Comments
  • KeyError

    KeyError

    trying to pull an entire workspace, so using the pageid of the workspace page. Always getting "KeyError" as follows:

    2022-02-04 09:29:32,033 INFO: ๐Ÿค– Notion authentification completed successfully. 2022-02-04 09:29:32,034 INFO: ๐Ÿค– Started raw notion content parsing. 2022-02-04 09:29:38,845 INFO: ๐Ÿค– Downloaded raw notion content. Saved at ./notion_content.json 2022-02-04 09:29:38,845 INFO: ๐Ÿค– Started structuring notion data Traceback (most recent call last): File "/opt/homebrew/Cellar/[email protected]/3.9.9/Frameworks/Python.framework/Versions/3.9/lib/python3.9/runpy.py", line 197, in _run_module_as_main return _run_code(code, main_globals, None, File "/opt/homebrew/Cellar/[email protected]/3.9.9/Frameworks/Python.framework/Versions/3.9/lib/python3.9/runpy.py", line 87, in _run_code exec(code, run_globals) File "/Users/techyogi/Desktop/notion4ever/notion4ever/main.py", line 102, in main() File "/Users/techyogi/Desktop/notion4ever/notion4ever/main.py", line 74, in main structured_notion = structuring.structurize_notion_content(raw_notion, File "/Users/techyogi/Desktop/notion4ever/notion4ever/structuring.py", line 495, in structurize_notion_content markdown_parser.parse_markdown(raw_notion, structured_notion) File "/Users/techyogi/Desktop/notion4ever/notion4ever/markdown_parser.py", line 372, in parse_markdown page_md = blocks_convertor(raw_notion[page_id]["blocks"], structured_notion, page_id) File "/Users/techyogi/Desktop/notion4ever/notion4ever/markdown_parser.py", line 139, in blocks_convertor block_md = block_convertor(block,0, structured_notion, page_id) File "/Users/techyogi/Desktop/notion4ever/notion4ever/markdown_parser.py", line 238, in block_convertor block_md = block_convertor(block, depth, structured_notion, page_id) File "/Users/techyogi/Desktop/notion4ever/notion4ever/markdown_parser.py", line 238, in block_convertor block_md = block_convertor(block, depth, structured_notion, page_id) File "/Users/techyogi/Desktop/notion4ever/notion4ever/markdown_parser.py", line 188, in block_convertor title = structured_notion['pages'][block['id']]['title'] KeyError: 'XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX'

    enhancement 
    opened by techyogi 4
Owner
PhD student@Skoltech, IT, Russia merkulov.top
null
A way to export your saved reddit posts to a Notion table.

reddit-saved-to-notion A way to export your saved reddit posts and comments to a Notion table.Uses notion-sdk-py and praw for interacting with Notion

null 19 Sep 12, 2022
Unofficial Python API client for Notion.so

notion-py Unofficial Python 3 client for Notion.so API v3. Object-oriented interface (mapping database tables to Python classes/attributes) Automatic

Jamie Alexandre 3.9k Jan 3, 2023
Notion API Database Python Implementation

Python Notion Database Notion API Database Python Implementation created only by database from the official Notion API. Installing / Getting started p

minwook 78 Dec 19, 2022
Python 3 tools for interacting with Notion API

NotionDB Python 3 tools for interacting with Notion API: API client Relational database wrapper Installation pip install notiondb API client from noti

Viet Hoang 14 Nov 24, 2022
The Bot provide Hadith API and fetch content via api.hadith.sutanlab.id

Bot Hadith-API on Telegram The Bot provide Hadith API and fetch content via api.hadith.sutanlab.id Built With Python Asynchronous HTTP protocol client

xMan 12 Feb 19, 2022
A small repository with convenience functions for working with the Notion API.

Welcome! Within this respository are a few convenience functions to assist with the pulling and pushing of data from the Notion API.

null 10 Jul 9, 2022
Create a roles overview page for all Ansible roles/playbooks in Gitlab

ansible-create-roles-overview Overview The script ./create_roles_overview.py queries a Gitlab API for Ansible roles and playbooks. It will iterate ove

null 2 Oct 11, 2021
Notflix - Notion / Netflix and IMDb to organise your movie dates. Happy Valentine <3 from 0x1za

Welcome to notflix ?? This is a project to help organise shows to watch with my

Mwiza Ed' Simbeye 3 Feb 15, 2022
szrose is an all in one group management bot made for managing your group effectively with some advance security tools & Suit For All Your Needs โค๏ธ

szrose is an all in one group management bot made for managing your group effectively with some advance security tools & Suit For All Your Needs โค๏ธ

szsupunma 93 Jan 7, 2023
A python script fetches all your starred repositories from your GitHub account and clones them to your server so you will never lose important resources

A python script fetches all your starred repositories from your GitHub account and clones them to your server so you will never lose important resources

Ringo Hoffmann 27 Oct 1, 2022