Overview

I prototyped an app using Zotero’s API and Streamlit.

https://nakamura196-zotero.streamlit.app/

This article is a memo on developing this app.

Streamlit

The following article was very helpful.

https://qiita.com/sypn/items/80962d84126be4092d3c

Zotero’s API

Zotero’s API is described at the following page.

https://www.zotero.org/support/dev/web_api/v3/start

This time, I used the following library introduced on the above page.

https://github.com/urschrei/pyzotero

To use the API, you need to obtain a personal library ID and an API key, which could be obtained by following the Quickstart steps in the README.

Below is the screen when issuing an API key.

Development with Streamlit

The source code is available at the following repository.

https://github.com/nakamura196/zotero_streamlit

Sensitive Information

It appears that sensitive information should be stored in a file called /.streamlit/secrets.toml. Don’t forget to add it to .gitignore.

[llaziipobbitrr_eaakrrreoyyy]__=it"dyx=px"exx="x"xu"ser"

It could then be called as follows.

defillarniipeibbittrr_u_aakrzrrenoyyyt__zeit=ordytopse(=etr).o:s=s.teZ.scostrte.eecstrresoec[(tr"lsezi[tob"strz[eao"rrtzoyeo"_rt]ioe[d"r",]oa["pl"]iil[_bi"krbleariyrab"yrr]_yat_ryiypd_e"t,]ypaep"i]_key)

Retrieving the Collection List from the Zotero Library

The following code was used to retrieve the collection list from the Zotero library.

deff"c#cre"ooet"lGltcleluhReter_eccncttttoriiicliotoolenlnlevse_lcelet=aicicnstoozdtinloosltk=n(e.e_zccy[loto{itil("s)olInt:neDac)mlteiif"sor:tnosmcf(or)eloalmcehcZtocitooelnrl[oe'cdltaiitboarn'a]r[y'n"a"m"e'],"key":collection['data']['key']}forcollectionincollections]

Retrieving Items Within a Collection

Items within a collection could be retrieved with the following. Processing to skip items where itemType is attachment has been added.

#deCfoncitevrfrxeeycran:ettorir}rpsretetoetteb_tewft.tidcumsouEeubfors'"""rrxrrl(ln=ticdncrnizl=itraieoooep[teettpprpgtcdz{lmaeedt(dr,t.oeTt"m.if.aiDt'yo:Do"Dpcoa.:prianFahontcesintatyl_aoi""taaialiFlt::eiFslFdedrlemtrerac:aemi"[eaedattmc[t,'mm:maiet'edseteo(idm"a(o(tn)oa[.tir)o_nt'jafoli_ado'woDdi'ai]isaa)t]tn.t)dt:e[a(geam''femiFst]"t[tr(i[{('eact'c'dmmolirdaseleteatl'eatafe]mte'rc,To']otyr,[mip['oe'"icn'f"to_]i)eli,rmldsTe)tycNptaeim'oe]n':]!}={e{"}ca"rt)etaatcohrm[e'nlta"s]tName']}"forcreatorinitem['data'].get('creators',[])),

Meta Tag Configuration

Page settings such as the title could be configured as follows.

#stP.asgepp##m}etaae_gglincpeeanuoa__yi_'''ngtiotiGRAfeicuiteebi_totaetpogcln=lmouuoe="_sHrtrn="ws=et'af"🧊ii{l:tiZ"ddpaigo,ee'"o(t"b:bAne,auprr"gpo_h'st:dxtteap'vStshete:tlr=/toe"/ppaegsmmxi:elpt/niah/tt#nug"d#biu,Ie.tsc#dMchio"eoun#nS,tmbgea/.Tdtnc[ii#taoZtslakmlpaSgatelyemneaotsuardyuerkoietstaa]sdit1m(ptdi9uhlioen6rtanbg/atywasz1petiro9sdhdwt6:eeiie//intrznbihowrt_twtoiasewhwadtr.esldrozeie_obrstastrtimteotaolrrwatnieosbeata.el/mort"lrom,igtetientxui'lpsseaosnpuAbdtePaeisIrdo'n,asndStreamlit"

Deployment

It was easy to deploy to Streamlit Community Cloud from the “Deploy” button in the upper right of the development screen.

At that time, by adding the information written in /.streamlit/secrets.toml in the Advanced settings, sensitive information could also be used on the server.

Summary

Using Streamlit, I was able to easily create a web app.

I hope this serves as a helpful reference for using the Zotero API and more.