2.3 KiB
Zotero JS Bridge
A Zotero plugin that exposes Zotero's internal JavaScript API as an HTTP API. This allows an external program to easily call and automate tasks like "Find Full Text", "Export file", reading items, and modifying collections directly from outside Zotero.
Caution
SECURITY WARNING: The
/executeendpoint provided by this plugin allows for the execution of arbitrary JavaScript code within Zotero's internal environment.Because Zotero's HTTP server does not currently provide authentication mechanisms, any application or script running locally on your machine can execute code and access, modify, or delete your Zotero data. This plugin is intended strictly for local development, automation, and specific integrations in trusted environments. Do not expose your local Zotero HTTP port to untrusted networks.
Endpoints
By default, Zotero's built-in HTTP server runs on port 23119. You can make POST requests to the following endpoints:
/zotero-js-bridge/execute
Executes arbitrary JavaScript within Zotero's context.
Request: POST http://127.0.0.1:23119/zotero-js-bridge/execute
Body:
{
"code": "return await Zotero.Items.getAll(1, true, false);"
}
Example Test:
curl -X POST http://127.0.0.1:23119/zotero-js-bridge/execute \\
-H 'Content-Type: application/json' \\
-d '{"code": "return await Zotero.Items.getAll(1, true, false);"}'
/zotero-js-bridge/findPDFsForItems
A specialized endpoint to trigger Zotero's "Find Available PDFs" feature for a specific list of item IDs.
Request: POST http://127.0.0.1:23119/zotero-js-bridge/findPDFsForItems
Body:
{
"itemIds": [123, 124, 125]
}
Example Test:
curl -X POST http://127.0.0.1:23119/zotero-js-bridge/findPDFsForItems \\
-H 'Content-Type: application/json' \\
-d '{"itemIds": [123]}'
Development and Building
To build the project into an installable Zotero add-on (.xpi file), run the following command from the root of this repository:
rm -f zotero-js-bridge.xpi && zip -r zotero-js-bridge.xpi manifest.json bootstrap.js README.md
Then drag and drop the zotero-js-bridge.xpi file into the Zotero Add-ons manager to install it.
manifest.json: Zotero plugin manifest.bootstrap.js: Handles plugin lifecycle and endpoint registration.