Best way to batch sync items children/attachments

81 views
Skip to first unread message

Ahmed A.

unread,
Jan 24, 2025, 3:51:20 AMJan 24
to zotero-dev
So my current first Sync approach is to go through the library items fetching their essential data, identifying numChildren from their meta and putting their parent item keys into list, then reiterating over each item separately looking for what is under it. Is there any more efficient approach especially when it comes to fetching individual items attachments?

Dan Stillman

unread,
Jan 24, 2025, 6:25:17 AMJan 24
> items attachments? --

In case you haven't seen it, we have a dedicated documentation page that
explains how we do syncing:

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

The right approach would depend on your interaction model, but if you're
actually trying to sync a full library, I would strongly recommend using
versioning, not making individual requests for individual items' children.

Ahmed Albialy

unread,
Jan 24, 2025, 10:14:47 AMJan 24
Thanks Dan. I’m already using versioning for updates which works great. Although I wasn’t sure about first sync when ‘since=0’ does the json response include every items’s child? As couldn’t see this and had to go through them individually for that first time sync.


> On 24 Jan 2025, at 03:25, Dan Stillman <[email protected]> wrote:
> --
> You received this message because you are subscribed to a topic in the Google Groups "zotero-dev" group.
> To unsubscribe from this topic, visit https://groups.google.com/d/topic/zotero-dev/wqLhQVmGB3Y/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to [email protected].
> To view this discussion visit https://groups.google.com/d/msgid/zotero-dev/010001949657a294-01286bf6-babb-403a-a31c-f92943b21b7d-000000%40email.amazonses.com.

Dan Stillman

unread,
Jan 24, 2025, 10:26:16 AMJan 24
On 1/24/25 2:14 AM, Ahmed Albialy wrote:
> Thanks Dan. I’m already using versioning for updates which works great. Although I wasn’t sure about first sync when ‘since=0’ does the json response include every items’s child? As couldn’t see this and had to go through them individually for that first time sync.

I'm not sure what you mean by "had to go through them individually". The
syncing process we've documented makes a /top request first to populate
the items list quickly for the user and avoid downloading child items
before top-level items.

But there can be various cases where a collection or item has a
dependency that isn't yet fulfilled (parent/child collection,
parent/child item, related item), so that's something any syncing client
needs to deal with. But that's more about
storing/skipping/retrying/resolving — it doesn't change the basic sync
process.

Ahmed Albialy

unread,
Jan 24, 2025, 10:33:22 AMJan 24

Yes that’s what I meant for parent items and retrieving their children, not available from the /top request.

Thank you.

> On 24 Jan 2025, at 07:26, Dan Stillman <[email protected]> wrote:
> --
> You received this message because you are subscribed to a topic in the Google Groups "zotero-dev" group.
> To unsubscribe from this topic, visit https://groups.google.com/d/topic/zotero-dev/wqLhQVmGB3Y/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to [email protected].
> To view this discussion visit https://groups.google.com/d/msgid/zotero-dev/01000194973447a1-72d6e807-a21f-4a7b-b9a0-5634550e0137-000000%40email.amazonses.com.

Dan Stillman

unread,
Jan 24, 2025, 10:37:03 AMJan 24
On 1/24/25 2:33 AM, Ahmed Albialy wrote:
> Yes that’s what I meant for parent items and retrieving their children, not available from the /top request.

No, but the point is that it makes a /top request followed by a non-/top
request. But you just skip the top-level items when processing the
second request, because those versions will all match the local versions:

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

Our sync process doesn't use `numChildren` or `/children` requests at all.

Ahmed Albialy

unread,
Jan 24, 2025, 10:52:25 AMJan 24
Oh I see them now all without /top filter! I got it wrong from the beginning. Thanks a lot for clarifying

>
> On 24 Jan 2025, at 07:37, Dan Stillman <[email protected]> wrote:
> --
> You received this message because you are subscribed to a topic in the Google Groups "zotero-dev" group.
> To unsubscribe from this topic, visit https://groups.google.com/d/topic/zotero-dev/wqLhQVmGB3Y/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to [email protected].
> To view this discussion visit https://groups.google.com/d/msgid/zotero-dev/01000194973e27bc-471c82af-37cd-4602-a336-e3fbaf2e88cb-000000%40email.amazonses.com.
Reply all
Reply to author
Forward
0 new messages