Announcements

Official announcements and news from MangaBaka

Dedicated library sync API

opened by Jippi (admin) 4 weeks, 2 days

:wave: hello friends,

We just launched a new dedicated API to sync library status faster and more efficiently - check out the [API documentation](https://mangabaka.org/pages/31) for more information

> [!NOTE] > Use the library changes feed when your app keeps a local copy of someone's MangaBaka library. Read the library once, save the returned cursor, and fetch only changes on later visits or scheduled syncs. The feed includes removals, list changes, and list membership, so you can update your copy without downloading and comparing the whole library every time.

### Why do we need a new API for this?

Easy of use, efficiency and correctness.

#### Easy of use and efficiency

Before this API the only way to check if a library needed to be synchronized was to request all of the data and then compare it to your local state - if a user library have 15.000 series, well, then you needed to do 150 `/my/library` API requests to get all the data. You would need to do this _every_ time you wanted to check for updates to the library.

Now you can do a one-time full scan via `GET /v2/my/library/changes?limit=1000 ` (so 15 requests) and then save the `cursor` value in your local app state. Next time you just just request `GET /v2/my/library/changes?limit=1000&cursor=${OLD_CURSOR_VALUE}` and you get all the changes since the initial sync. If there are less than 1000 changes, then that single request is all you needed to make.

#### Correctness

Our API also tracks removals/deletes - both series and lists - so you don't need to do your own "absent" cleanup when applying changes. We also properly track changes like "this series is now in different lists" or "this list was renamed"

### Apps with many users

If a MangaBaka OAuth app has many users and need to keep all of them in sync from a backend server, the new `GET /v2/my/apps/{clientId}/library/changes` endpoint makes this a breeze.

Instead of polling _every_ user for _all_ of their library pages with the old system, you can now use `GET /v2/my/apps/{clientId}/library/changes` to find _users_ that need to be synced since your last `sync`.

We keep track of the last sync cursor automatically on your behalf (you can do your own if you prefer, [the documentation has more details on this](https://mangabaka.org/pages/api/31-library-sync-api#sync-many-oauth-users-efficiently))

For each user returned by `GET /v2/my/apps/{clientId}/library/changes` you request that users `GET /v2/my/library/changes?limit=1000&cursor=${cursor}` endpoint with their OAuth token - thats it.

A simple loop that can run every couple of minutes of

1. Get users with changes since last check-in 2. Sync each user returned in (1) 3. Sleep 5minutes 4. go to (1)

### Next steps

Head over to the [dedicated documentation for the new API](https://mangabaka.org/pages/31) and check it out.

Feel free to offer feedback here on the forum or on Discord if you have any.

Comments

Loading comments...