Fetching BibTeX entry from DOI

Posted by Matthieu R Bloch on April 08, 2020

This is another of my hacks to quickly add references to my BibTeX files using Alfred.

Zotero translate server

I am not a fan of Mendeley, Zotero, and other online tools to maintain a bibliography. I am a bit old school and I prefer to keep my own clean bib file and using JabRef to navigate it. I started using JabRef when it was in version 1.3, and itโ€™s stood the test of time.

All that said, Zotero provides a pretty neat server at zbib.org to quickly get BibTeX from a doi or a title. They also provide a translate server that you can run locally on your machine to query.

Installing the Zotero translate server is pretty straightforward

git clone --recurse-submodules https://github.com/zotero/translation-server
cd translation-server
npm install
npm start

Linking to Alfred

Once your server is running, you can use Alfred to access it easily. My workflow is a simple wrapper around the following bash script, which uses the DOI to return a formatted BibTeX entry.

JsonOutput=`curl -d $1 -H 'Content-Type: text/plain'`
BibTeXOutput=`curl -d "$JsonOutput" -H 'Content-Type: application/json' ''`
echo -n $BibTeXOutput

The proof is again in the pudding.