Skip to main content

Generate a roam research like network graph view from your Notion pages.

Project description

Notion Graph View

github github github

Export Notion pages to a Roam-Research like graph view.

📜 Usage

Environment

  • Python >= 3.9

Installing

pip install notion-graph

Notion API Setup

  1. Create a notion internal integration and generate an Internal Integration Token.

    👉 Learn more about authorization

  2. Open one notion page on browser, select "Add connections" and add your integration account.

  3. Find your base Page ID from browser url, for example:

if page url is: https://www.notion.so/yourName/PageTitle-8a4b5ff100d648fb8d39d4bfa756ff3f, 8a4b5ff100da48fb8d39d4bfa756ff3f is the Page ID

Quickly Running

python -m notion_graph -p <Page ID> -t <Integration Token> -o <PNG file path to export>

For instance,

python -m notion_graph -p 856391c93ae64bd1b7ebf699ca0cd861 -t secret_b8p7uLp3j3n95IDgofC9GviXP111Skx6NOt2d20U8e -o ./graph_out.png

graph_out.png would be generated at your specific path.

Importing as a Python Library

You can also import notion_graph as a library.

For instance, drawing your own diagram by matplotlib.

import notion_graph as ng
import networkx as nx
import matplotlib.pyplot as plt

my_ng = ng.NotionGraph(bearer_token="secret_b8p7uLp3j3n95IDgofC9GviXP111Skx6NOt2d20U8e")
graph = my_ng.parse(page_id="856391c93ae64bd1b7ebf699ca0cd861")
# graph is a networkx.classes.graph.Graph object

pos = nx.spring_layout(graph)
labels = nx.get_node_attributes(graph, 'title')
options = {
    "node_size": 50,
    "node_color": "tab:gray",
    "font_size": 10,
    "width": 0.5,
    "with_labels": True,
    "labels": labels
}

nx.draw(graph, pos, **options)
plt.show()
plt.savefig('./graph.png')

Testing Environment

The testing page is Notion-grap-view-demo. You can duplicate the page to your Notion account and run the project to test if everything goes well.

Development Guide

This project's dependencies are managed by PDM.

brew install pdm
pdm install

Running the project by:

pdm run start -p <page_id> -t <notion_token> -o ./graph_out.png

🔗 Supported Link

database page
paragraph ✔️ ✔️
bulleted_list_item ✔️ ✔️
numbered_list_item ✔️ ✔️
to_do ✔️ ✔️
toggle ✔️ ✔️
child_page ✔️ ✔️
child_database ✔️ ✔️
embed
callout ✔️ ✔️
quote ✔️ ✔️
heading_1 ✔️ ✔️
heading_2 ✔️ ✔️
heading_3 ✔️ ✔️
column
column_list
synced_block
link_to_page
table ✔️ ✔️
table_row ✔️ ✔️

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

notion-graph-0.1.0.tar.gz (5.3 kB view details)

Uploaded Source

Built Distribution

notion_graph-0.1.0-py3-none-any.whl (6.5 kB view details)

Uploaded Python 3

File details

Details for the file notion-graph-0.1.0.tar.gz.

File metadata

  • Download URL: notion-graph-0.1.0.tar.gz
  • Upload date:
  • Size: 5.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: pdm/2.4.0 CPython/3.11.1

File hashes

Hashes for notion-graph-0.1.0.tar.gz
Algorithm Hash digest
SHA256 a167eb0d19127ab9b4830ebc1e0b43d3ae94b48f6c6be50b95e4c0b1aa6bc564
MD5 deb415c653861bc2e7090b3e36a92106
BLAKE2b-256 84d3b195d14bea864e32c74a1de26c33022e7dbf7fb472aa055a34f5743432c0

See more details on using hashes here.

File details

Details for the file notion_graph-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for notion_graph-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 450f2cd7e096b2d643cff46c5968dc6b6a4a32498602076acc34c6f8ed76876c
MD5 59e3995892477c22a1f7027f91e05191
BLAKE2b-256 819f1f2b92ffaaca39d5681f25d230d6d71d99df71f699b30f07502e1632e5f7

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