Zotero client automation (how to programmatically saving urls in a headless enviornment)

I want to accomplish the following in a headless Linux server.
1). log into zotero.org
2). save reference by url (ignoring if already existed)
3). sync the changes to zotero.org

I prefer to use zotero client over zotero web API https://www.zotero.org/support/dev/web_api/v3/start because I also want to save the snapshot of the urls. And I don't want to flood zotero.org with my large collections of references (I want to check if references already exist before I save them).

It is indeed possible to automate zotero client with javascript https://www.zotero.org/support/dev/client_coding/javascript_api . There is a command line agument `jsconsole`, but this seems to require graphic interface. When I run `zotero --jsconsole`, `Error: no DISPLAY environment variable specified` is reported.

Is it possible to evaluate Javascript code in the headless mode of zotero?
One way I can think of is to create a plugin. But this seems to be too much of a hassle for me. Also how can I automatically install this plugin?

How do I login in the headless zotero? Is there any way to specify my zotero.org API token or change my configuration to use my pre-created token?
  • I'm not sure I fully understand your set-up, but you've seen
    In the Tools → Developer menu, select Run JavaScript. Opening the Error Console, which appears in the same menu, will also be helpful.
    But if you mean whether you can use the Zotero client from the command line without any interaction with the GUI, the answer is no. Something along those lines is planned, but no ETA (and still not sure it'd fulfill your use case).
  • Thanks for your response. What I wanted is exactly running javascript code without any interaction with the GUI. I also want to login from the command line so that I can sync my zotero files in a Linux server.
  • edited May 4, 2023
    But if you mean whether you can use the Zotero client from the command line without any interaction with the GUI, the answer is no. Something along those lines is planned, but no ETA (and still not sure it'd fulfill your use case).
    I use selenium for setup (profile creation and setting prefs) + the abovementioned debug bridge to drive Zotero in an xvfb environment for my test suite. By necessity Zotero will "display" the UI, but my test suite doesn't interact with the UI at all.
Sign In or Register to comment.