Automatically tag Zotero items with in_logseq when they are referenced in Logseq pages with the #zotero tag.
- Clone or download this repository
- Copy the
skill/folder to your Claude Code skills directory:cp -r skill ~/.claude/skills/logseq-zotero-sync - Restart Claude Code to load the skill
This tool syncs your Logseq knowledge base with Zotero by:
- Querying Logseq (via CLI) for all pages with #zotero tag and Zotero URL property
- Extracting the Zotero item keys from those URLs
- Checking which items already have the
in_logseqtag in Zotero - Batch tagging only the items that need it
This is idempotent - you can run it multiple times safely. It only tags items that don't already have the tag.
- Logseq Desktop app with its bundled
logseqCLI on your PATH (ships with current Logseq.app; no npm install needed) - Python 3.10+
- Zotero account with API access
-
Clone this repository and
cdinto it:git clone https://github.com/kerim/logseq-zotero-sync.git cd logseq-zotero-sync -
Install Python dependencies:
pip3 install -r requirements.txt
-
Set up credentials (shares credentials with zotero-tag-automation):
If you've already set up zotero-tag-automation, you're done! This script uses the same keychain credentials.
If not, run the included setup script. It stores your Library ID and API key in the macOS Keychain and then makes one read-only call to Zotero to confirm the key works (and warns if it lacks the write access the sync needs):
python setup_credentials.py
You'll need:
- Your Zotero Library ID (find at https://www.zotero.org/settings/keys)
- Your Zotero API Key (create at https://www.zotero.org/settings/keys/new, with "Allow write access")
Run with auto-detected graph:
python sync_logseq_to_zotero.pyOr specify a graph name:
python sync_logseq_to_zotero.py "2025-10-26 Logseq DB"- Add new literature notes to Logseq with #zotero tag and Zotero URL property
- Run this script periodically to sync the
in_logseqtag to Zotero - Use the
in_logseqtag in Zotero to filter/organize your referenced items
==============================================================
Logseq to Zotero Sync
==============================================================
Querying Logseq graph: 2025-10-26 Logseq DB
Found 14 items in Logseq with Zotero URLs
Querying Zotero for items with 'in_logseq' tag...
Found 10 items already tagged with 'in_logseq'
Found 4 items that need tagging:
- AA8CFB7Y
- DUF7Q2B6
- M2QGSQA9
- ZTSWUK3C
Tagging 4 items with 'in_logseq'...
[1/4] ✓ AA8CFB7Y: Here we are together
[2/4] ✓ DUF7Q2B6: Reflections on Orthography in Formosan Languages
[3/4] ✓ M2QGSQA9: Taiwan Archaeology
[4/4] ✓ ZTSWUK3C: Who owns "the culture of the Yellow Emperor"?
==============================================================
Summary:
Successful: 4/4
Failed: 0/4
Tag: in_logseq
==============================================================
- Logseq Query: Uses
logseq query --graph "NAME" --query 'EDN' --output jsonCLI command to find all pages with the Zotero URL property - Extract Keys: Parses the output to extract Zotero item keys (e.g., "M2QGSQA9")
- Batch Check: Queries Zotero API for all items already tagged with
in_logseq - Diff: Compares the two lists to find items that need tagging
- Tag: Only tags items that don't already have the tag
This batch approach is efficient because:
- Only one query to Zotero for existing tags
- Only tags items that need it
- Idempotent - safe to run repeatedly
Credentials are stored securely in macOS Keychain using the service name zotero-tag-automation (shared with the zotero-tag-automation skill).
To view/manage:
- Open Keychain Access.app
- Search for "zotero-tag-automation"
"Graph not found"
- Make sure you're using Logseq Desktop app (not browser)
- Run
logseq graph list --output jsonto see available graphs - Specify the exact graph name as shown in the list
"Credentials not found" (or Zotero returns 403 Invalid key)
- Run
python setup_credentials.pyto store (or replace) your Library ID and API key - A
403 Invalid keyfrom Zotero means the stored key was revoked/regenerated — create a new one and re-run the setup script - Check Keychain Access.app (search "zotero-tag-automation") for the stored credentials
"Command not found: logseq"
- Make sure Logseq Desktop app is installed — the bundled
logseqCLI ships with current Logseq.app - Verify:
logseq --version
- zotero-tag-automation: Tag Zotero items after search results
- logseq-cli skill: Interface with Logseq from Claude Code
See CHANGELOG.md. Current version: 1.1.0.
MIT License