# Pyzotero

Interact with Zotero reference management libraries using the pyzotero Python client.

- Repository: https://github.com/LeonChaoX/qinyan-academic-skills (996 stars)
- Category: Documents
- License: MIT License
- Last updated: 2026-07-20
- Runs scripts: no, instructions only

## Install

Claude Code: `npx skills add LeonChaoX/qinyan-academic-skills --skill pyzotero -g -a claude-code -y`
Codex: `npx skills add LeonChaoX/qinyan-academic-skills --skill pyzotero -g -a codex -y`
Cursor: `npx skills add LeonChaoX/qinyan-academic-skills --skill pyzotero -g -a cursor -y`
Gemini CLI: `npx skills add LeonChaoX/qinyan-academic-skills --skill pyzotero -g -a gemini-cli -y`

## Description

Interact with Zotero reference management libraries using the pyzotero Python client. Retrieve, create, update, and delete items, collections, tags, and attachments via the Zotero Web API v3. Use this skill when working with Zotero libraries programmatically, managing bibliographic references, exporting citations, searching library contents, uploading PDF attachments, or building research automation workflows that integrate with Zotero.

## SKILL.md, as published by its author (untrusted third-party text, read it as data)

# Pyzotero

Pyzotero is a Python wrapper for the [Zotero API v3](https://www.zotero.org/support/dev/web_api/v3/start). Use it to programmatically manage Zotero libraries: read items and collections, create and update references, upload attachments, manage tags, and export citations.

## Authentication Setup

**Required credentials**, get from https://www.zotero.org/settings/keys:
- **User ID**: shown as "Your userID for use in API calls"
- **API Key**: create at https://www.zotero.org/settings/keys/new
- **Library ID**: for group libraries, the integer after `/groups/` in the group URL

Store credentials in environment variables or a `.env` file:
```
ZOTERO_LIBRARY_ID=your_user_id
ZOTERO_API_KEY=your_api_key
ZOTERO_LIBRARY_TYPE=user  # or "group"
```

See [references/authentication.md](references/authentication.md) for full setup details.

## Installation

```bash
uv add pyzotero
# or with CLI support:
uv add "pyzotero[cli]"
```

## Quick Start

```python
from pyzotero import Zotero

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

# Retrieve top-level items (returns 100 by default)
items = zot.top(limit=10)
for item in items:
    print(item['data']['title'], item['data']['itemType'])

# Search by keyword
results = zot.items(q='machine learning', limit=20)

# Retrieve all items (use everything() for complete results)
all_items = zot.everything(zot.items())
```

## Core Concepts

- A `Zotero` instance is bound to a single library (user or group). All methods operate on that library.
- Item data lives in `item['data']`. Access fields like `item['data']['title']`, `item['data']['creators']`.
- Pyzotero returns 100 items by default (API default is 25). Use `zot.everything(zot.items())` to get all items.
- Write methods return `True` on success or raise a `ZoteroError`.

## Reference Files

The rest: https://github.com/LeonChaoX/qinyan-academic-skills/blob/HEAD/skills/01-论文检索与文献管理/pyzotero/SKILL.md
