<jupyter_start><jupyter_text>Accessing Zotero Via the APIWe want to write scripts which allow us to generate formated bibliographies from our Zotero database which can be found here.[CMSEatMSU Zotero Group](https://www.zotero.org/groups/2465063/cmseatmsu)  API overviewI was reading the [Zotero API instructions](https://www.zotero.org/support/dev/web_api/v3/basicssearch_syntax) and learned a lot. I created the following video as a quick explaination<jupyter_code>from IPython.display import YouTubeVideo
YouTubeVideo("fsSTeVz8lfc",width="100%",cc_load_policy=True)<jupyter_output><empty_output><jupyter_text>Everything starts with the Basic URL.Basic URL this does nothing interesting:https://api.zotero.org We can build off the basic URL by adding in the groups (or user) keyword and their number. For example here is the basic URL with the CMSEatMSU group added.  This produces just the group information:https://api.zotero.org/groups/2465063 We can dig a little deeper and see the collections (and their Keys)inside the groups as follows:https://api.zotero.org/groups/2465063/collections If we know a collection key (ex <KEY>) then we can see the items in the collection:https://api.zotero.org/groups/2465063/collections/MPY3BTV3/items What I want is to generated formatted data the format=bib is parameter is the trick. We can add in a parameter by using the "```?```" charicter and then our ```parameter=value```.  Unfortunatly this only works with up to 150 entries:https://api.zotero.org/groups/2465063/collections/MPY3BTV3/items?format=bib I can use multiple parameters by seperating them with the "```&```" symbol.  This one uses linkwrap set to 1 to include clickable links in the output:https://api.zotero.org/groups/2465063/collections/MPY3BTV3/items?format=bib&linkwrap=1 There are a few special formats like "coins" and "bibtex" which we may also want to investigate:https://api.zotero.org/groups/2465063/collections/MPY3BTV3/items?format=coins  Using Pyzotero[PyZotero gitrepo](https://github.com/urschrei/pyzotero)<jupyter_code>#pip install --user pyzotero
# CMSEatMSU info
library_id = 2465063
library_type = 'group'
api_key = '<KEY>'
from pyzotero import zotero
zot = zotero.Zotero(library_id = library_id, library_type = library_type, api_key = api_key)
items = zot.top()

# we've retrieved the latest five top-level items in our library
# we can print each item's item type and ID
# for item in items:
#     print('Item: %s | Key: %s' % (item['data']['itemType'], item['data']['key']))<jupyter_output><empty_output><jupyter_text>Read all collections (Zotero Folders) and identify publications for each collection<jupyter_code>for folder in zot.collections():
    print(folder['data']['name'], folder['data']['key'])
    for item in zot.collection_items(folder['data']['key']):
        print('* Item: %s | Key: %s' % (item['data'],['itemType']))
dir(zotero.Zotero)
zotero.mimetypes?
dir(zotero)<jupyter_output><empty_output>
StarcoderdataJupyterStructuredCleanDedup