zettelkasten.zotero¶
zettelkasten.zotero ¶
Zotero integration: Web API v3 client + local-install reader.
Two access paths:
- Web API (
search/get_item/get_annotations) — metadata and annotations over the network, configured via ZOTERO_USER_ID and ZOTERO_API_KEY env vars, or a gitignoredsecrets/zotero_apifile (env vars win). Cannot easily return file contents. - Local install (
fetch_pdf) — reads the desktop Zotero data directory (~/Zoteroby default, override with ZOTERO_DATA_DIR) to resolve an item to its on-disk PDF, extract its text, and pull saved highlights/notes. No API key needed and works offline.
search ¶
Search user's library items by title/creator.
Returns a list of items with key, title, authors, year, itemType, DOI.
Source code in zettelkasten/zotero.py
get_item ¶
Get full metadata for a single item by Zotero key.
Source code in zettelkasten/zotero.py
get_annotations ¶
Get PDF annotations (highlights, notes) for an item's children.
Source code in zettelkasten/zotero.py
fetch_pdf ¶
fetch_pdf(key: str, include_text: bool = True, include_annotations: bool = True, max_chars: int = 200000, full: bool = False) -> dict[str, Any]
Fetch a paper's full-text PDF from the local Zotero install.
Resolves a Zotero item key to its PDF attachment on disk and returns the absolute path plus (optionally) the extracted text and saved annotations.
When full is set the WHOLE document is extracted (ignoring max_chars
for the returned/cached text) and the result carries page_offsets and a
chapter outline so a caller can cache the complete book and address a
later chapter. full bypasses the bounded LRU parse cache (that cache is
keyed on the char cap and serves the Papers/Inspect prefix view).
Source code in zettelkasten/zotero.py
find_item ¶
Resolve a work to an EXISTING Zotero item key, or report it's not there.
Checks whether a paper already lives in the user's Zotero library by matching
its DOI (preferred) or title. Prefers the local install (zotero.sqlite,
consistent with :func:fetch_pdf's PDF source) and falls back to the Web API
when there's no local database. year is accepted for future tie-breaking
but unused today.
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
One of three dicts: |
dict[str, Any]
|
found; |
dict[str, Any]
|
or |
dict[str, Any]
|
Web API credentials, so membership cannot be determined. |
Source code in zettelkasten/zotero.py
list_collections ¶
List the library's collections (folders), local-first with Web fallback.
Gives an agent a way to BROWSE the library structure — the themes/folders a
user actually organizes their papers into — instead of only guessing at
keyword searches. Prefers the local install (offline, no rate limits, same
source as :func:fetch_pdf) and falls back to the Web API.
Source code in zettelkasten/zotero.py
list_items ¶
List the papers in a collection (or the whole library), local-first.
collection accepts a collection KEY (preferred, stable) or its NAME
(case-insensitive); empty lists the most recently added top-level items
across the whole library. Returns search-shaped summaries (key, title,
authors, year, itemType, DOI) ready to feed to :func:fetch_pdf.