This document explains how to embed in a Google Sites page a bibliography generated dynamically starting from a Zotero public library. The case of a private library is more complex and is not covered here. This tutorial is based on the official library in [https://www.zotero.org/support/dev/web_api/v3/basics](official documentation).
We cover cases in which embedding does not require javascript code, but just writing a HTTP URL that leverages the API of the Zotero bibliography service. The URL is then embedded into the Google Sites page using the embed button (the one represented by two brackets <>) in the Google Sites graphical user interface. We are using this method to write the bibliography of the https://sites.google.com/view/prin-underlandscape project web site (at draft stage when writing this gist).
The fist operation on our way is to find the User Identifier for the library you want to use. For this purpose:
- log in to your Zotero account and access your web library
- select your username on top of the sceen and the "Settings" label
- select the Feed/API section
- annotate your userID for use in API calls: it is a numeric value. For me it composed of 8 digits but your milage may vary. In this document I use 12345678 as a placeholder for the userID
The URL to download a formatted list of your library is
https://api.zotero.org/users/12345678/items?format=bib
and you can use it in your browser to check the result. Beware that Zotero will not process your bibliography if it contains more than 150 items.
You can now open your Google Site GUI and embed the URL to see the result:
To address the contento of one of your collections you need to find the collection ID, which is a sequence of eight alphanumeric characters. I use AAAAAAAA as a placeholder for the collection ID
You find the collection ID by navigating to the collection with your browser. In the URL box of your browser you now read a URL that terminates with the collection ID:
https://www.zotero.org/user.name/collections/AAAAAAAAA
The URL to download the formatted list of your collection is:
https://api.zotero.org/users/12345678/collections/AAAAAAAA/items?format=bib
You can go and try it as explained above.
If you make use of tags in your bibliography you can use them to include in the formatted bibliography only the items carrying some of them.
To select in your library all the bibliography items with a given tag tag1 you format your URL as follows:
https://api.zotero.org/users/12345678/items?format=bib&tag=tag1
You may run into troubles if you use spaces and other non-ASCII characters, which need to be URL-encoded, a topic which is not covered here.
If you want to restrict to one of your collections the URL is:
https://api.zotero.org/users/12345678/collections/AAAAAAAA/items?format=bib&tag=tag1
If you want to match a combination of several tags the URL for searching in your whole library is:
https://api.zotero.org/users/12345678/collections/AAAAAAAA/items?format=bib&tag=tag1&tag=tag2
Many more options are available to select items: check in the official document mentioned above.
There are several bibliography formats that should be used depending on the discipline and the target audience. You can browse the avaliable styles in Zotero at https://www.zotero.org/styles. You may restrict your search by discipline, or directly input the name of the format.
Once found the desired bibliography style, hover on the link and annotate the last element of the corresponding URL. Depending on the browswer you may see it displayed on the bottom of the browser window, or you may need to copy and paste it elsewhere. The link should be similar to
https://www.zotero.org/styles/acm-siggraph
and in this case the style ID is acm-siggraph. To obtain the bibliography of your whole library formatted according to the ACM SIGGRAPH style you use the following URL:
https://api.zotero.org/users/12345678/items?format=bib&style=acm-siggraph
You can restrict to a collection and/or search by tag according with the examples above
If you are given access to a Library as a member of a group, you need to use a different syntax for the API, after having found the ID of the group you are member of.
To find the ID of your group, browse to the group library and observe the content of the URL box in your browser. It should display a something like:
https://www.zotero.org/groups/5555555/...
where the 5555555 is the placeholder for the group ID.
You can use it in the previous examples by replacing the users/12345678 with groups/5555555. For instance, to embed the content of the whole library of your group the URL is:
https://api.zotero.org/groups/5555555/items?format=bib