pyzotero: Driving Zotero Web API v3 Library Operations with Agent Skills

Preface

When writing papers, conducting reviews, or maintaining a group’s literature library, it is often necessary to perform batch retrieval, create entries, modify metadata, and aggregate/collate citations for export in Zotero. While manual clicking on the client can complete these tasks, automating them requires referring to the invocation methods of Zotero Web API v3 and pyzotero, as well as handling pagination, credentials, and error returns. Encapsulating these conventions into an Agent Skill allows a conversational Agent to read and write the library via a unified process, rather than piecing together API snippets from scratch each time.

Below is an introduction to pyzotero (coordinate @org-02qudk26/pyzotero-zh) on SkillHub, what it can do, how to install it, and the credentials and typical code paths.

What is this

pyzotero is a skill specification for programming scenarios: it guides the Agent to use the pyzotero Python client to interact with the user’s library or group library via the Zotero Web API v3. The capability boundaries given on the SkillHub page include retrieval, creation, update, and deletion of Items and Collections; the SKILL.md within the skill package also covers reference chapters for tags, attachments, citation export, full text, and CLI for the Agent to consult as needed.

  • Publisher: ZhiYu Tech (SkillHub category dev-programming, source enterprise)
  • Current Version: 1.0.0
  • Tags: requires_api_key=true (Requires Zotero API key and User/Library ID)
  • Official Entry: SkillHub Skill Page / API Coordinate

The skill body is based on the generic SKILL.md format; the underlying library is marked by skill metadata as maintained by K-Dense Inc. (MIT License), aligned with the official Zotero API documentation.

Core Functions

Combined with the SkillHub introduction and skill documentation, verifiable capabilities include:

  1. Read Library: Top-level items, keyword search, collection and tag queries; supports methods like everything() to handle default pagination limits.
  2. Write Library: Create, update, delete items; CRUD for collections (see reference file paths like references/collections.md).
  3. Attachments and Export: Upload attachments, export modes like BibTeX / CSL-JSON (explained in separate files within the skill’s references/).
  4. Authentication and Local Read-Only: Environment variables or .env store ZOTERO_LIBRARY_ID, ZOTERO_API_KEY, ZOTERO_LIBRARY_TYPE; optional local=True mode for local read-only (no API key required).
  5. Operations Conventions: Return True on successful write, raise ZoteroError on failure; item fields are located in item['data'].

The skill allows the Agent to use tools such as Read, Write, Edit, and Bash, facilitating the execution of uv add pyzotero and running short scripts for verification in real projects.

Installation and Activation

1. Install SkillHub CLI (if not already installed)

command -v skillhub && skillhub --version

If not installed, follow the SkillHub installation instructions to perform a full installation:

curl -fsSL https://skillhub-1388575217.cos.ap-guangzhou.myqcloud.com/install/install.sh | bash

2. Install the skill into the current Agent’s skills directory

When installing, you must use --dir to point to the skills directory recognized by the current environment; otherwise, the default ./skills/ may not be loaded by the Agent. The SkillHub skill page requires installation of:

@org-02qudk26/pyzotero-zh

Cursor example:

skillhub install @org-02qudk26/pyzotero-zh --dir ~/.cursor/skills/

Claude Code:

skillhub install @org-02qudk26/pyzotero-zh --dir ~/.claude/skills/

Codex (Choose either user-level or project-level based on your current workspace convention):

skillhub install @org-02qudk26/pyzotero-zh --dir ~/.codex/skills/
# or project: --dir <project>/.agents/skills/

For other Agents (Windsurf, Gemini CLI, etc.), the default directories are in the fourth section of the same installation document; if the path on your machine cannot be verified, refer to that document.

3. Python dependencies (when executing pyzotero code)

The skill documentation recommends using uv to install the library:

uv add pyzotero
# If you need command line subcommands:
uv add "pyzotero[cli]"

4. Zotero credentials

Obtain the User ID from Zotero Key Settings and generate an API Key on the Create Key page. For group libraries, the library ID is the number after /groups/ in the group URL.

ZOTERO_LIBRARY_ID=your_user_id
ZOTERO_API_KEY=your_api_key
ZOTERO_LIBRARY_TYPE=user   # Fill 'group' for group libraries

Do not write the key into the version control repository; the skill documentation also emphasizes reading credentials from environment variables.

Typical Usage

The following snippets are from the skill’s SKILL.md quick start and common patterns, which can be reproduced directly after configuring the credentials.

Initialize and retrieve items:

from pyzotero import Zotero

zot = Zotero(library_id='123456', library_type='user', api_key='ABC1234XYZ')

items = zot.top(limit=10)
for item in items:
    print(item['data']['title'], item['data']['itemType'])

results = zot.items(q='machine learning', limit=20)
all_items = zot.everything(zot.items())

Update an existing item:

item = zot.item('ITEMKEY')
item['data']['title'] = 'New Title'
zot.update_item(item)

Create a journal article from a template and write it to the library:

template = zot.item_template('journalArticle')
template['title'] = 'My Paper'
template['creators'][0] = {
    'creatorType': 'author',
    'firstName': 'Jane',
    'lastName': 'Doe',
}
zot.create_items([template])

Export BibTeX:

zot.add_parameters(format='bibtex')
bibtex = zot.top(limit=50)
print(bibtex.entries)

In an Agent session, a safer approach is to let the model first consult tables like references/search-params.md and references/write-api.md inside the skill to select the correct interface, and then execute Bash to run the script, rather than guessing all parameters at once.

Suitable Scenarios and Notes

Who is this for

  • Developers and research groups who already use Zotero for literature management but wish to use Python or Agents for batch imports, collection organization, and citation export.
  • Teams that need to call the Zotero API in CI or internal network scripts but wish to have a fixed “API map” on the conversational side.

Limitations and Notes

  • SkillHub marks requires_api_key=true: without a valid key, remote library writes are impossible; local read-only libraries can use local=True, but it cannot replace cloud sync writes.
  • The API has small default pagination limits, and pyzotero also has a default limit on the number of items; for large batch synchronization, use everything() or the pagination generators in the documentation to avoid missing data.
  • Skill statistics (SkillHub page): Rating 100000, Downloads 869 times — this only reflects the popularity on the store side and does not represent compatibility with your library size or network environment; please verify destructive operations like deletion and update in a test library before going live.
  • Write operations that fail will throw a ZoteroError; automated processes should check return values and avoid testing deletions on production libraries without backups.

The skill comes with three types of illustrative scenarios in the README (batch import and collections, conditional BibTeX export, credentials read from environment variables and handling attachment uploads), which can serve as a starting point for productized workflows, but you still need to perform your own acceptance testing based on your library structure and API limits.

Conclusion

pyzotero organizes the Zotero Web API v3 and pyzotero’s authentication, read/write, collection, and export conventions into a format readable by Agents, reducing the cost of looking up documentation temporarily each time. If you are already using SkillHub in Cursor, Claude Code, or Codex, you can install @org-02qudk26/pyzotero-zh using the commands above and pre-configure the Zotero API key.

羽毛球分组比赛记分
小程序二维码

欢迎使用《羽毛球分组比赛记分》微信小程序

Xiaoye