<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>
{'fraction_non_alphanumeric': 0.109979633401222, 'fraction_numerical': 0.025118805159538356, 'mean_word_length': 5.806004618937644, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 15, 'https://': 10, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '109849', 'license': 'MIT', 'n_tokens_mistral': 997, 'n_tokens_neox': 933, 'n_words': 296, 'path': 'Zotero_Example.ipynb', 'repo_name': 'colbrydi/CMSE_PyZotero_Tools', 'size': '2968'}