Skill Tracer
Skills › Scientific Agent Skills › pyzotero › exports.md

exports.md

78 lines · skills/pyzotero/references/exports.md at 5f2bc03

Open on GitHub

Most marks come from matching words in the file, so treat them as pointers.

1# Export Formats
2
3These examples target Pyzotero 1.15.2. Set the format and its parameters together on the read call. Calling `add_parameters(format='bibtex')` and then `top(limit=50)` resets the format to JSON in this release; the result will not have `.entries`.
4

Export Formats

These examples target Pyzotero 1.15.2. Set the format and its parameters together on the read call. Calling add_parameters(format='bibtex') and then top(limit=50) resets the format to JSON in this release; the result will not have .entries.

Raw lines 1 to 4
5## BibTeX
6
7```python
8import bibtexparser
9
10bibtex_db = zot.top(format='bibtex', limit=50)
11# bibtexparser 1.x BibDatabase
12for entry in bibtex_db.entries:
13 print(entry.get('title'), entry.get('author'))
14with open('library.bib', 'w', encoding='utf-8') as f:
15 bibtexparser.dump(bibtex_db, f)
16```
18Use `zot.everything(zot.top(format='bibtex', limit=100))` for a complete paginated remote export. The bibliography reflects Zotero's stored metadata; confirm DOI, author, title, and publication details before citing.

BibTeX

import bibtexparser

bibtex_db = zot.top(format='bibtex', limit=50)
# bibtexparser 1.x BibDatabase
for entry in bibtex_db.entries:
    print(entry.get('title'), entry.get('author'))
with open('library.bib', 'w', encoding='utf-8') as f:
    bibtexparser.dump(bibtex_db, f)

Use zot.everything(zot.top(format='bibtex', limit=100)) for a complete paginated remote export. The bibliography reflects Zotero's stored metadata; confirm DOI, author, title, and publication details before citing.

Raw lines 5 to 19
20## CSL-JSON
22```python
23# Direct CSL export wraps the array in an 'items' member.
24csl_export = zot.items(format='csljson', limit=50)
25csl_items = csl_export['items']
27# Or retain Zotero metadata alongside per-item CSL data
28records = zot.items(format='json', include='data,csljson', limit=50)
29csl_items = [record['csljson'] for record in records]
30```

CSL-JSON

# Direct CSL export wraps the array in an 'items' member.
csl_export = zot.items(format='csljson', limit=50)
csl_items = csl_export['items']

# Or retain Zotero metadata alongside per-item CSL data
records = zot.items(format='json', include='data,csljson', limit=50)
csl_items = [record['csljson'] for record in records]
Raw lines 20 to 31
32## Bibliography HTML and Citations
34```python
35# Individual references embedded in JSON (also supported by the local API)
36records = zot.items(format='json', include='data,bib', style='apa', limit=50)
37bib_entries = [record['bib'] for record in records]
39records = zot.items(format='json', include='citation', style='apa', limit=50)
40citations = [record['citation'] for record in records]
41```
43For one complete, style-sorted bibliography, use `format='bib'`. It has no sorting or pagination parameters and is limited to 150 matching items. In 1.15.2 its HTML response is returned as **bytes**, not a list of citation strings:
45```python
46html_bytes = zot.collection_items('COLKEY', format='bib', style='apa')
47html = html_bytes.decode('utf-8')
48```
50Pass a valid style identifier from the [Zotero style repository](https://www.zotero.org/styles), such as `apa`, `vancouver`, `ieee`, or `nature`; avoid assuming a renamed style alias still exists. `linkwrap='1'` wraps bibliography URLs in links.

Bibliography HTML and Citations

# Individual references embedded in JSON (also supported by the local API)
records = zot.items(format='json', include='data,bib', style='apa', limit=50)
bib_entries = [record['bib'] for record in records]

records = zot.items(format='json', include='citation', style='apa', limit=50)
citations = [record['citation'] for record in records]

For one complete, style-sorted bibliography, use format='bib'. It has no sorting or pagination parameters and is limited to 150 matching items. In 1.15.2 its HTML response is returned as bytes, not a list of citation strings:

html_bytes = zot.collection_items('COLKEY', format='bib', style='apa')
html = html_bytes.decode('utf-8')

Pass a valid style identifier from the Zotero style repository, such as apa, vancouver, ieee, or nature; avoid assuming a renamed style alias still exists. linkwrap='1' wraps bibliography URLs in links.

Raw lines 32 to 51
52## RIS and Other Exports
54The [API format table](https://www.zotero.org/support/dev/web_api/v3/basics#export_formats) lists `ris`, `biblatex`, `rdf_dc`, `rdf_zotero`, `wikipedia`, and others. Pyzotero 1.15.2 dispatches by response content type. A live direct `format='ris'` response used `application/x-research-info-systems`, which the SDK tried to parse as JSON and failed. Use per-item JSON `include` instead:
56```python
57from pathlib import Path
59records = zot.everything(zot.items(format='json', include='ris', limit=50))
60Path('library.ris').write_text('\n'.join(r['ris'] for r in records), encoding='utf-8')
61```
63JSON records work with `everything()`. Direct exports may return a dict, bytes, or a BibDatabase depending on their content type; do not pass them all through one generic writer. Direct `biblatex` uses the BibTeX parser in this release. Export formats require a limit (except `bib`).
65Legacy `content='ris'`, `content='csljson'`, `content='bib'`, or `content='citation'` forces Atom and returns parsed lists in remote mode. If used, pass `content`, `style`, and `limit` on the **same** call. The local API does not support Atom. Prefer JSON `include` for per-item export data; unlike the SDK's legacy `content` parser, it supports multiple comma-separated members such as `include='data,bib'`.

RIS and Other Exports

The API format table lists ris, biblatex, rdf_dc, rdf_zotero, wikipedia, and others. Pyzotero 1.15.2 dispatches by response content type. A live direct format='ris' response used application/x-research-info-systems, which the SDK tried to parse as JSON and failed. Use per-item JSON include instead:

from pathlib import Path

records = zot.everything(zot.items(format='json', include='ris', limit=50))
Path('library.ris').write_text('\n'.join(r['ris'] for r in records), encoding='utf-8')

JSON records work with everything(). Direct exports may return a dict, bytes, or a BibDatabase depending on their content type; do not pass them all through one generic writer. Direct biblatex uses the BibTeX parser in this release. Export formats require a limit (except bib).

Legacy content='ris', content='csljson', content='bib', or content='citation' forces Atom and returns parsed lists in remote mode. If used, pass content, style, and limit on the same call. The local API does not support Atom. Prefer JSON include for per-item export data; unlike the SDK's legacy content parser, it supports multiple comma-separated members such as include='data,bib'.

Raw lines 52 to 66
Starts an agent dispatches :54
67## Keys and Versions
69```python
70# Omit the SDK limit for these formats, which the remote API does not cap.
71keys_bytes = zot.items(format='keys', limit=None)
72keys = keys_bytes.decode('utf-8').splitlines()
74# Returns a dict, not a list; do not wrap it in everything().
75versions = zot.item_versions() # equivalent to items(format='versions', limit=None)
76```
78Source: [API response formats](https://www.zotero.org/support/dev/web_api/v3/basics#request_parameters), [release response dispatch](https://github.com/urschrei/pyzotero/blob/v1.15.2/src/pyzotero/_decorators.py).

Keys and Versions

# Omit the SDK limit for these formats, which the remote API does not cap.
keys_bytes = zot.items(format='keys', limit=None)
keys = keys_bytes.decode('utf-8').splitlines()

# Returns a dict, not a list; do not wrap it in everything().
versions = zot.item_versions()  # equivalent to items(format='versions', limit=None)

Source: API response formats, release response dispatch.

Raw lines 67 to 78
Starts an agent dispatch :78