pyzotero

Manage Zotero libraries programmatically via the Zotero Web API v3 using Python.

Updated Oct 7, 2022
One-click install
npx skills add https://github.com/tamagusko/linux-cfg --skill pyzotero-tamagusko
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: pyzotero
Source: https://github.com/tamagusko/linux-cfg/tree/main/dotfiles/claude/skills/pyzotero
Command: npx skills add https://github.com/tamagusko/linux-cfg --skill pyzotero-tamagusko

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires pyzotero, and includes references (resource) components.

What problem does it solve? Manually organizing bibliographic references, collections, tags, and PDF attachments in Zotero does not scale for research automation. This Skill provides complete guidance for using the pyzotero Python client to read, create, update, and delete Zotero library content programmatically through the Zotero Web API v3. ## Core Features & Use Cases - Full CRUD on Libraries: Retrieve, create, update, and delete items, collections, tags, and saved searches in user or group libraries. - Search & Export: Run keyword and full-text searches with filters, then export results as BibTeX, CSL-JSON, RIS, or formatted bibliographies in any CSL style. - Attachment Management: Download PDFs, upload file attachments to parent items, and retrieve or set full-text indexed content. - Use Case: A researcher needs to download every PDF from a "Machine Learning Papers" collection and export the collection as a .bib file for a LaTeX manuscript. This Skill provides the exact pyzotero calls to iterate the collection, dump attachments, and write the BibTeX output. ## Quick Start Ask the AI to use the pyzotero skill to connect to your Zotero library with your API credentials and list the ten most recently added items with their titles and types.

Frequently Asked Questions about pyzotero

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I use pyzotero to access my Zotero library in Python?

Create a Zotero instance with your library ID, library type ('user' or 'group'), and API key from zotero.org/settings/keys. Then call methods like zot.items() or zot.top() to retrieve references, using zot.everything() to fetch all results.

How do I export Zotero items to BibTeX with Python?

Call zot.add_parameters(format='bibtex') before a read call such as zot.top(limit=50). The result is a bibtexparser BibDatabase object whose entries can be written to a .bib file with bibtexparser.dump().

Can pyzotero work without an API key?

Yes, local mode connects to a running Zotero desktop app without an API key by passing local=True when creating the Zotero instance. Local mode is read-only, so write operations like creating or updating items are not supported.

How do I download PDF attachments from a Zotero collection?

Iterate items with zot.collection_items(), fetch each item's children with zot.children(), filter for attachments with contentType 'application/pdf', and save each file using zot.dump() with the attachment key and output path.

Why does pyzotero raise TooManyRequests or PreConditionFailed errors?

TooManyRequests means the Zotero API rate limit was hit; retry with exponential backoff. PreConditionFailed indicates a version conflict from optimistic locking, so re-fetch the item and apply your changes to the fresh copy before updating.

What are the limits of the Zotero API when using pyzotero?

Read calls return at most 100 items per request, and write batches are limited to 50 items per call. Saved search results cannot be retrieved via the API, only their metadata, and attachment upload methods are still in beta.