Need suggestion for getting item's note using API

48 views
Skip to first unread message

Shebaz Multani

unread,
Oct 5, 2021, 12:02:50 PM10/5/21
to zotero-dev
Hello,

Basically, I am storing all items note in the database one by one using PHP script. First, I make a top level API call to get all top level item's key (/items/top ), after that, I loop all top level item's key and make multiple child item API call to get notes of the respective top level item (/items//children).

But here problem is that if I get 50+ items in top level API call I have to make another 50 children API to get notes and that is technically very time consuming. For the possible solutions, I have check official Zotero API documentation ( https://www.zotero.org/support/dev/web_api/v3/basics) but didn't get any worthy solution for it.

So, I want to know is there a way to get item notes inside top level API call? Or in the alternative is there a way I can pass multiple top level item keys in child item API call?

Thanks in Advance.

Dan Stillman

unread,
Oct 5, 2021, 12:13:39 PM10/5/21
to zoter...@googlegroups.com
If you're getting all items anyway, you don't need to use /top — you can just do non-top requests to retrieve all items, including notes, and store them in your database.

You could also use ?itemType=note to retrieve just all notes.

Shebaz Multani

unread,
Oct 6, 2021, 2:39:29 AM10/6/21
to zotero-dev
Hello  Dan Stillman, 

Thanks for your response, yes we can use it but the problem here is when we use API without top items ( <userOrGroupPrefix>/items/?itemType=note ) it returns us lots of child items and some of the parent item keys received from them don't event exists in the Zotero library. So, it will store junk of data extra data in the database which is useless. But is it possible to get notes in the top item API call(<userOrGroupPrefix>/items/top)? OR  get the child items of specific multiple top items(<userOrGroupPrefix>/items/<itemKey>/children). 

Thank You.

Dan Stillman

unread,
Nov 15, 2021, 5:22:57 AM11/15/21
to zoter...@googlegroups.com
On 10/6/21 2:39 AM, Shebaz Multani wrote:
> Thanks for your response, yes we can use it but the problem here is
> when we use API without top items (
> <userOrGroupPrefix>/items/?itemType=note ) it returns us lots of child
> items and some of the parent item keys received from them don't event
> exists in the Zotero library. So, it will store junk of data extra
> data in the database which is useless

This sounds like some sort of misunderstanding. itemType=note returns
notes, not random child items, and the API doesn't return items that
don't exist in the library. If there's a specific response you think is
wrong, we'd need a specific example (without an API key).

> But is it possible to get notes in the top item API
> call(<userOrGroupPrefix>/items/top)?

Child notes, no, because the request is literally a request for
top-level items, and child notes aren't top-level items.

> OR  get the child items of specific multiple top
> items(<userOrGroupPrefix>/items/<itemKey>/children)

No, and if you need enough child items where this is an issue, you
should just be storing all items and pulling updates efficiently using
versioned (?since=) requests:

https://www.zotero.org/support/dev/web_api/v3/syncing#version_numbers

And just to clarify, since someone from your team wrote to us off-list,
many things use the Zotero API and also display notes, including the
Zotero apps and the Zotero web library, so I assure you there's a better
way to do what you're trying to do.
Reply all
Reply to author
Forward
0 new messages