available for beta testing: local HTTP API for the desktop app

360 views
Skip to first unread message

Dan Stillman

unread,
Jun 15, 2024, 6:32:08 AMJun 15
to zoter...@googlegroups.com
In Zotero 7 beta 88, we've introduced a new local HTTP API for accessing Zotero data, based on the Zotero web API.

This is a near-complete read-only implementation of the web API, and it should be a drop-in replacement for the web API for many local tools. In fact, it's so complete that we were able to run a local copy of the Zotero web library against the Zotero desktop app. (Due to browser restrictions, it's not possible to follow links to file:// URLs for attachments, but they can be used directly by external tools.) Of course, this should also be a much better option for tools that currently read the SQLite database directly or that require third-party plugins for access to data.

See the comment at the top of server_localAPI.js for additional details. Of particular note, since this runs locally, pagination isn't required, and the API can provide the actual results of saved searches, which the web API itself can't currently do.

There are still some bugs that we'll be fixing in upcoming versions, and we plan to add additional functionality (write support, additional actions, possibly the ability to run arbitrary JS) going forward.

To try out the API, make sure you're running beta 88 or later and enable "Allow other applications on this computer to communicate with Zotero" from the Advanced pane of the Zotero settings. You can then run curl 'http://localhost:23119/api/users/0/items?limit=10&sort=dateAdded' to see your 10 most recent items.

You can post to this list with general questions about the API or if you can't get something working. If you're pretty sure you found a bug with the API, please open an issue in https://github.com/zotero/zotero. (For all non-technical questions, please continue to post to the Zotero Forums.)

We hope this opens up a new era of local integration with Zotero, and we're excited to see what people build!

- Dan

Sebastian Karcher

unread,
Jun 15, 2024, 7:25:30 AMJun 15
to zoter...@googlegroups.com
So cool! Is this going to remain read only or will there eventually be a read& write option? 
Sebastian 

Sent from my phone

--
You received this message because you are subscribed to the Google Groups "zotero-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to zotero-dev+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/zotero-dev/010001901b744a75-dfb26bd3-ea61-4fe5-b2e6-1762bd5772dc-000000%40email.amazonses.com.

Dan Stillman

unread,
Jun 15, 2024, 5:49:10 PMJun 15
to zoter...@googlegroups.com
On 6/15/24 7:25 AM, Sebastian Karcher wrote:
> So cool! Is this going to remain read only or will there eventually be
> a read& write option?

We're planning to add write support in some form, but we haven't worked
through all the details there, and it may be tricky to make that fully
compatible with existing clients. (E.g., writing to the web API usually
involves the concept of library versions, but those are set centrally by
the dataserver and can't be increased by the desktop app.)

Stephan Hügel

unread,
Jun 17, 2024, 4:47:50 PMJun 17
to zotero-dev
Looks like someone is already trying this with Pyzotero. I won't have much time to work on it over the next couple of months, but encourage anyone using it to open issues / pull requests as appropriate: https://github.com/urschrei/pyzotero/issueshttps://github.com/urschrei/pyzotero/pulls

gjsu...@gmail.com

unread,
Jun 21, 2024, 9:43:18 AMJun 21
to zotero-dev
I am trying to access the local Api  but I get this error:

CURL error: Failed to connect to localhost port 23119: Connection refused.

Any ideas how I can fix this?

Dan Stillman

unread,
Jun 21, 2024, 2:41:37 PMJun 21
to zoter...@googlegroups.com
On 6/21/24 9:43 AM, gjsu...@gmail.com wrote:
> I am trying to access the local Api  but I get this error:
>
> CURL error: Failed to connect to localhost port 23119: Connection refused.
>
> Any ideas how I can fix this?

That would be a more general problem not specific to this API — the
server is also used for the Zotero Connector, for example. This could be
caused by the BBT plugin or security software on your system.

See https://www.zotero.org/support/kb/connector_zotero_unavailable, and
post to the Zotero Forums if you're still having trouble

Emiliano Heyns

unread,
Jun 22, 2024, 12:16:31 PMJun 22
to zotero-dev
Which in turn seems to have been caused by BBT calling await Zotero.Translators.init(). I still don't know why that call locks up, or why it locking up affects the web server, but by calling it directly after await Zotero.initializationPromise instead of later in the startup process, the problem seems to have gone away.
Reply all
Reply to author
Forward
0 new messages