urschrei / pyzotero

Pyzotero: a Python client for the Zotero API
https://pyzotero.readthedocs.org
Other
908 stars 99 forks source link

zlib.collection_items: only retrieving first 25 items #50

Closed silviaegt closed 9 years ago

silviaegt commented 9 years ago

hey Stephan, thank you so much for pyzotero! I wish I could fix problems myself and contribute but I am just a rookie so the best I can do is to report this issue. So, unfortunately, I have not been able to get all my collections' items, which are 76, but rather just 25 (which is exactly the same amount of items shown per page in Zotero, do you think this has anything to do with it?)

Here's what I did:

zlib = zotero.Zotero('1677289','user','4g5SrCY6IUW1x6LPUfXrzVGe') # My own user ID / api key
items = zlib.collection_items('THA7JMA5') # My collection: https://www.zotero.org/silviaegt/items/collectionKey/THA7JMA5
itemlist = []
for item in items:
    itemlist.append(item['data']['title'])
print(len(itemlist))

And here's my complete code for further reference

urschrei commented 9 years ago

Hi Silvia, The Read API calls return the first 25 items by default. You can work around this by using e.g. zlib.everything(zlib.collection_items('THA7JMA5')). You could also set the limit parameter on the API call: zlib.collection_items('THA7JMA5', limit=100).

Hope this helps.

silviaegt commented 9 years ago

Thank you so much @urschrei! Both things worked perfectly. As a note for future users it might be useful for them to know that attachments count as independent nodes/items. It was thanks to zlib.everything() that I realized my collection was not 76 items long -- as it appears in my Zotero collection -- but double so long (152) because each bibliographic reference had an html attachment.