Skip to content

sizmailov/zotero-notion-sync

Repository files navigation

Zotero ↔ Notion

Synchronize Zotero with Notion via public APIs.

Here is the assumed workflow:

  1. Add a paper to Zotero
  2. Wait for synchronization
  3. Go to corresponding Notion page and annotate paper

At synchronization sync-zotero-notion:

  • Creates new items in Notion database
  • Creates Zotero note with link to corresponding Notion page
  • Updates Zotero fields in Notion database

👨‍🎓📗 Notion fields — Columns in Notion database that SHOULD BE edited manually.

🤖📕 Zotero fields — Columns in Notion database that MUST NOT be edited by users. Those columns are continuously overwritten with values from Zotero.

How to

Setup

Notion

  1. Create Notion database with Title, Authors, Link, Published at, Zotero 🖥️, Zotero 🌐, Zotero ItemID fields.
  2. Create integration token with read/write permissions
  3. Share database with integration (from top-right conner of database page): Share database with integration

Zotero

  1. Create new group
  2. Create API token with read/write permissions

Sync

  1. Create config.yml and fill with values obtained earlier
notion:
  token: "<...>"
  database_id: "<...>"

zotero:
  token: "<...>"
  group_id: 123456789
  1. Install zotero-notion-sync
pip install git+https://github.com/sizmailov/zotero-notion-sync.git
  1. Synchronize
sync-zotero-notion --config=./config.yml

Development

Set up environment and install dependencies

python3.9 -m venv venv
source venv/bin/activate
pip install -U pip wheel setuptools
pip install pip-tools
pip-sync requirements-dev.txt
pre-commit install

Run linters

# Pre-commit hooks
pre-commit run --all-files

Integration with systemd

  1. Create two files sync-zotero-notion.* in /etc/systemd/system/ using template below.
  2. Activate sync via
sudo systemctl start sync-zotero-notion.timer
sudo systemctl enable sync-zotero-notion.timer
sync-zotero-notion.service
# TODO: replace `<USERNAME>` with actual user name
[Unit]
Description=Sync Notion with Zotero
After=network.target network-online.target

[Service]
User=<USERNAME>
Group=<USERNAME>
Type=simple
ExecStart=/home/<USERNAME>/venv/bin/sync-zotero-notion --config=/home/<USERNAME>/config.yml
sync-zotero-notion.timer
[Unit]
Description=Sync Notion with Zotero

[Timer]
OnUnitInactiveSec=1m
OnBootSec=2m

[Install]
WantedBy=timers.target