跳到主要内容

Zotero 文献库

收藏0

用 pyzotero 程序化管理 Zotero 文献库:检索条目、新建与更新条目、整理分类与标签、导出引用格式、上传 PDF 附件,支持 Web API 与本地 API。

让 AI 安装

星光尘缘LV2最新版本 0.1.0更新于 2026-11-24下载 0 次

references/cli.md

3.7 KB查看排版效果
1# Command-Line Interface
2
3The pyzotero CLI connects to your **local Zotero installation** (Zotero 7+ for reads, Zotero 10+ for writes) (not the remote Web API). It requires a running Zotero desktop app with local API access enabled:
4
5**Zotero → Settings → Advanced → Allow other applications on this computer to communicate with Zotero**
6
7## Installation
8
9```bash
10uv add "pyzotero[cli]==1.15.2"
11# or run without installing:
12uvx --from "pyzotero[cli]==1.15.2" pyzotero search -q "your query"
13```
14
15## Searching
16
17```bash
18# Search titles and metadata
19pyzotero search -q "machine learning"
20
21# Full-text search (includes PDF content)
22pyzotero search -q "climate change" --fulltext
23
24# Filter by item type
25pyzotero search -q "methodology" --itemtype journalArticle --itemtype book
26
27# Filter by tags (AND logic)
28pyzotero search -q "evolution" --tag "reviewed" --tag "high-priority"
29
30# Search within a collection
31pyzotero search --collection ABC123 -q "test"
32
33# Paginate results
34pyzotero search -q "deep learning" --limit 20 --offset 40
35
36# Output as JSON (for machine processing)
37pyzotero search -q "protein" --json
38```
39
40## Getting Individual Items
41
42```bash
43# Get a single item by key
44pyzotero item ABC123
45
46# Get as JSON
47pyzotero item ABC123 --json
48
49# Get child items (attachments, notes)
50pyzotero children ABC123 --json
51
52# Get multiple items at once (up to 50)
53pyzotero subset ABC123 DEF456 GHI789 --json
54```
55
56## Collections & Tags
57
58```bash
59# List all collections
60pyzotero listcollections
61
62# List all tags
63pyzotero tags
64
65# Tags in a specific collection
66pyzotero tags --collection ABC123
67```
68
69## Full-Text Content
70
71```bash
72# Get full-text content of an attachment
73pyzotero fulltext ABC123
74```
75
76## Item Types
77
78```bash
79# List all available item types
80pyzotero itemtypes
81```
82
83## DOI Index
84
85```bash
86# Get complete DOI-to-key mapping (useful for caching)
87pyzotero doiindex > doi_cache.json
88# Returns JSON: {"10.1038/s41592-024-02233-6": {"key": "ABC123", "doi": "..."}}
89```
90
91## Output Format
92
93By default the CLI outputs human-readable text including title, authors, date, publication, volume, issue, DOI, URL, and PDF attachment paths.
94
95Use `--json` for structured JSON output suitable for piping to other tools.
96
97## Search Behaviour Notes
98
99- Default search covers top-level item titles and metadata fields only
100- `--fulltext` expands search to PDF content; results show parent bibliographic items (not raw attachments)
101- Multiple `--tag` flags use AND logic
102- Multiple `--itemtype` flags use OR logic
103
104## Authorized Local Writes (Zotero 10+)
105
106The CLI also supports local writes in the reviewed 1.15.2 release. These are illustrative commands, not part of the read-only smoke test:
107
108```bash
109# Zotero displays its authorization dialog; choose the scope you intend.
110pyzotero authorize --app-name "Research library tool"
111pyzotero listitemfields journalArticle
112pyzotero createitem items.json --json
113pyzotero createcollection "Review papers" --json
114pyzotero addtocollection COLKEY ITEMKEY --json
115pyzotero removefromcollection COLKEY ITEMKEY --json
116pyzotero movetocollection --from OLDCOLKEY --to NEWCOLKEY ITEMKEY --json
117```
118
119`items.json` contains an editable item object or array of objects. Validate bibliographic metadata before importing. The stored persistent local key and server ID are in `$XDG_CONFIG_HOME/pyzotero/local-api-key.json` (default `~/.config/pyzotero/local-api-key.json`); a Web API key does not authorize these commands. Collection membership commands update one item at a time.
120
121For Semantic Scholar CLI commands (`related`, `citations`, `references`, `s2search`), network access is required; see the limitations in [mcp.md](mcp.md). Sources: [CLI documentation](https://pyzotero.readthedocs.io/en/latest/#command-line-interface), [release CLI source](https://github.com/urschrei/pyzotero/blob/v1.15.2/src/pyzotero/cli.py).

文件内容是平台检查时读出的文本,只供查看。平台不会运行包里的任何脚本或程序。