K-Dense-AI/scientific-agent-skills / skills/pyzotero
pyzotero
VerifiedManages Zotero reference libraries using the pyzotero Python client: retrieves, creates, updates, and deletes items, collections, tags, and attachments via the Zotero Web API v3 or local API. Applies 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.
| File | Kind | Size |
|---|---|---|
| SKILL.md | skill md | 7.8 KB |
| references/authentication.md | markdown | 5.1 KB |
| references/cli.md | markdown | 3.7 KB |
| references/collections.md | markdown | 3.8 KB |
| references/error-handling.md | markdown | 3.9 KB |
| references/exports.md | markdown | 3.9 KB |
| references/files-attachments.md | markdown | 4.3 KB |
| references/full-text.md | markdown | 2.4 KB |
| references/mcp.md | markdown | 6.1 KB |
| references/pagination.md | markdown | 2.4 KB |
| references/read-api.md | markdown | 4.3 KB |
| references/saved-searches.md | markdown | 3.6 KB |
| references/search-params.md | markdown | 3.7 KB |
| references/tags.md | markdown | 2.6 KB |
| references/write-api.md | markdown | 5.6 KB |
references/files-attachments.md
View on GitHub# Files & Attachments
## Downloading Files
```python
# Get raw binary content of an attachment
raw = zot.file('ATTACHMENTKEY')
with open('paper.pdf', 'wb') as f:
f.write(raw)
# Convenient wrapper: dump file to disk
# Uses stored filename, saves to current directory
zot.dump('ATTACHMENTKEY')
# Dump to a specific path and filename
zot.dump('ATTACHMENTKEY', 'renamed_paper.pdf', 'papers')
# Create the directory first. Returns None on success, not a path.
```
`dump()` uses the provided filename or stored attachment filename. For responses classified as HTML snapshots, 1.15.2 appends `.zip` to that name; ZIP/EPUB handling can return an archive member. Verify the saved bytes and type instead of assuming every snapshot is a ZIP or is named with its key. Remote `/file` downloads require stored, synced files and appropriate permissions; linked files are not uploaded to Zotero storage.
## Finding Attachments
```python
# Get child items (attachments, notes) of a parent item
children = zot.children('PARENTKEY')
attachments = [c for c in children if c['data']['itemType'] == 'attachment']
# Get the attachment key
for att in attachments:
key = att['data']['key']
filename = att['data'].get('filename') # absent on linked URLs
content_type = att['data']['contentType']
link_mode = att['data']['linkMode'] # 'imported_file', 'linked_file', 'imported_url', 'linked_url'
```
## Uploading Attachments
**Note**: Upstream still labels attachment helpers beta. The simple/both helpers below require the remote API; local uploads need a manually built attachment dict and Zotero 10+ authorization (see [authentication.md](authentication.md)).
```python
# Simple upload: one or more files by path
result = zot.attachment_simple(['/path/to/paper.pdf', '/path/to/notes.docx'])
# Upload as child items of a parent
result = zot.attachment_simple(['/path/to/paper.pdf'], parentid='PARENTKEY')
# Upload with custom filenames: list of (name, path) tuples
result = zot.attachment_both([
('Paper 2024.pdf', '/path/to/paper.pdf'),
('Supplementary.pdf', '/path/to/supp.pdf'),
], parentid='PARENTKEY')
# Upload files to existing attachment items
result = zot.upload_attachments(attachment_items, basedir='/path/to/files/')
# Existing entries need editable attachment dicts with key + version;
# filename resolves on disk relative to basedir. Do not set parentid for existing items.
if result['failure']:
raise RuntimeError(result['failure'])
```
Upload result structure:
```python
{
'success': [attachment_item1, ...],
'failure': [attachment_item2, ...],
'unchanged': [attachment_item3, ...]
}
```
## Attachment Templates
```python
# Get template for a file attachment
template = zot.item_template('attachment', linkmode='imported_file')
# linkmode options: 'imported_file', 'linked_file', 'imported_url', 'linked_url'
# Available link modes
modes = zot.item_attachment_link_modes()
```
## Downloading All PDFs from a Collection
```python
import os
collection_key = 'COLKEY'
output_dir = '/path/to/output/'
os.makedirs(output_dir, exist_ok=True)
items = zot.everything(zot.collection_items_top(collection_key))
for item in items:
# A top-level item can itself be a standalone attachment.
children = ([item] if item['data']['itemType'] == 'attachment' else
zot.everything(zot.children(item['data']['key'])))
for child in children:
if child['data']['itemType'] == 'attachment' and \
child['data'].get('contentType') == 'application/pdf' and \
child['data'].get('linkMode') in {'imported_file', 'imported_url'}:
try:
# Key-based filenames prevent collisions between identically named PDFs.
zot.dump(child['key'], filename=f"{child['key']}.pdf", path=output_dir)
except Exception as e:
print(f"Failed to download {child['data']['key']}: {e}")
```
Upload results are distinct from `create_items()` results: lists under `success`, `failure`, and `unchanged`. Returned successful entries carry the current `version`; creation failures may include an `error` dict. The SDK manages file authorization, upload, and registration through `/items/{key}/file`, including MD5 preconditions and the storage URL returned by Zotero. A completed metadata create alone does not prove the file uploaded. See [official upload protocol](https://www.zotero.org/support/dev/web_api/v3/file_upload).
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| canvas-designanthropics/skillsCreate beautiful visual art in .png and .pdf documents using design philosophy. You should use this skill when the user asks to create a poster, piece of art, design, or other static piece. Create original visual designs, never copying existing artists' work to avoid copyright violations. | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |
| docxanthropics/skillsUse this skill whenever the user wants to create, read, edit, or manipulate Word documents (.docx files) or Word templates (.dotx files). Triggers include: any mention of 'Word doc', 'word document', '.docx', '.dotx', or requests to produce professional documents with formatting like tables of contents, headings, page numbers, or letterheads. Also use when extracting or reorganizing content from .docx or .dotx files, inserting or replacing images in documents, performing find-and-replace in Word files, working with tracked changes or comments, or converting content into a polished Word document. If the user asks for a 'report', 'memo', 'letter', 'template', or similar deliverable as a Word or .docx file, use this skill. Do NOT use for PDFs, spreadsheets, Google Docs, or general coding tasks unrelated to document generation. | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |
| pdfanthropics/skillsUse this skill whenever the user wants to do anything with PDF files. This includes reading or extracting text/tables from PDFs, combining or merging multiple PDFs into one, splitting PDFs apart, rotating pages, adding watermarks, creating new PDFs, filling PDF forms, encrypting/decrypting PDFs, extracting images, and OCR on scanned PDFs to make them searchable. If the user mentions a .pdf file or asks to produce one, use this skill. | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |
| pptxanthropics/skillsUse this skill any time a .pptx or .potx file is involved in any way — as input, output, or both. This includes: creating slide decks, pitch decks, or presentations; reading, parsing, or extracting text from any .pptx or .potx file (even if the extracted content will be used elsewhere, like in an email or summary); editing, modifying, or updating existing presentations; combining or splitting slide files; working with templates (.potx), layouts, speaker notes, or comments. Trigger whenever the user mentions "deck," "slides," "presentation," or references a .pptx or .potx filename, regardless of what they plan to do with the content afterward. If a .pptx or .potx file needs to be opened, created, or touched, use this skill. | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |