API 3: Get items for certain tag

89 views
Skip to first unread message

Stephen Margheim

unread,
Aug 20, 2014, 5:23:43 PM8/20/14
to zoter...@googlegroups.com
<p>In the past, using <code>pyzotero</code>, it was possible to get formatted references for all items that had some specific tag. This method used the general URL scheme: <code>/{t}/{u}/tags/{ta}/items</code>. In the API version 3, I cannot replicate this functionality. I can get the number of items for a tag, but not the actual items themselves (specifically, a CSL-formatted version of the items). Is this functionality deprecated? Or has the method merely changed? Any help is greatly appreciated.</p>

<p>stephen</p>

Dan Stillman

unread,
Aug 20, 2014, 5:37:31 PM8/20/14
to zoter...@googlegroups.com
On 8/20/14 11:23 PM, Stephen Margheim wrote:
> <p>In the past, using <code>pyzotero</code>, it was possible to get
> formatted references for all items that had some specific tag. This
> method used the general URL scheme: <code>/{t}/{u}/tags/{ta}/items</code>.

That was removed, though I think a long time ago in v2. Use the 'tag'
query parameter.

https://www.zotero.org/support/dev/web_api/v3/basics#searching

Stephan Hügel

unread,
Aug 20, 2014, 5:45:22 PM8/20/14
to zoter...@googlegroups.com
Are you asking about Pyzotero (I'm the maintainer), or about the API v3 functionality in general?
If it's about Pyzotero, you'll be able to use the API v3-compatible version when I release it sometime in September (or you can test it now by checking out the api_v3 branch from Github and installing it). You'd be using the search functionality (https://www.zotero.org/support/dev/web_api/v3/basics#search_syntax) to retrieve items relating to a tag. For example, if you wanted to retrieve the last five top-level-items tagged "Beckett", the call would be zot.top(tag='Beckett", limit=5). If you wanted your results CSL-formatted, you'd additionally specify e.g. style='chicago'.

Stephen Margheim

unread,
Aug 20, 2014, 5:52:31 PM8/20/14
to zoter...@googlegroups.com
Ah. Ok. That makes sense. I am still, however, not getting it to work. 

If I get all of my tags (https://api.zotero.org/users/[user_id]/tags), one of them is “Semantics” (seen as 'tag': 'Semantics' in the JSON response). If, however, I search for items with that tag (https://api.zotero.org/users/[user_id]/items?tag=Semantics), I get an empty list. The JSON response for all tags tells me that there is one item with this tag, so why the empty result? Have I malformed the URL?

Stephen Margheim

unread,
Aug 20, 2014, 5:54:46 PM8/20/14
to zoter...@googlegroups.com
I was asking about API v3 in general. I have the api_v3 branch already on my machine, and had tested it with my old code to get formatted items for a tag (tag_items method), but it failed. But, tbh, I'm working on a project that greatly underuses pyzotero, so I've been working on a more circumscribed version of things for myself. 

Stephen Margheim

unread,
Aug 20, 2014, 5:55:51 PM8/20/14
to zoter...@googlegroups.com
But, that solution now has things working perfect in pyzotero api_v3. Thank you. That helps alot.


On Wednesday, August 20, 2014 5:45:22 PM UTC-4, Stephan Hügel wrote:

Stephen Margheim

unread,
Aug 20, 2014, 5:59:51 PM8/20/14
to zoter...@googlegroups.com
You might want to change the logic of `tag_items` however. As it is, doesn't seem to work.


On Wednesday, August 20, 2014 5:45:22 PM UTC-4, Stephan Hügel wrote:
Reply all
Reply to author
Forward
0 new messages