Reference Expansion from Official MD 5.1.0 API #39
md-y
announced in
Announcements
Replies: 1 comment
-
(I also have no idea how the discussions tab is meant to work so tell me if anything is wrong) |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Version 5.1.0 of the official API announced that relationships (such as authors and artists for manga) can now be given alongside the base call for an object. This means the Relationship class will be mostly replaced by the actual data in addition to other async 'get' functions. This may require refactoring your code, but it will also decrease the required amount of API calls.
I am busy this weekend, so there will be no changes until next week, but the new version (5.2.0) will see this implemented alongside basic browser support and any PRs.
Official Patch Notes:
https://discord.com/channels/403905762268545024/839817812012826644/852681202259591219
Reference Expansion 🚀 is a feature of certain endpoints where relationships of a resource are expanded with their attributes, which reduces the amount of requests that need to be sent to the API to retrieve a complete set of data.
It works by appending a list of includes to the query with the type names from the relationships. If an endpoint supports this feature is indicated by the presence of the optional includes parameter.
Example
To fetch a specific manga with author, artist and cover_art expanded, you can send the following request: GET /manga/f9c33607-9180-4ba6-b85c-e4b5faee7192?includes[]=author&includes[]=artist&includes[]=cover_art. You will now find the objects attributes inside the returned relationships array.
Note
Your current user needs *.view permission on each type of reference you want to expand. Guests have most of these permissions and for logged-in user accounts you can check GET /auth/check to list all permissions you have been granted. For example, to be able to expand cover_art, you need to have been granted the cover.view permission, for author and artist types you need the author.view permission and so on.
If a reference can't be expanded, the request will still succeed and no error indication will be visible.
Beta Was this translation helpful? Give feedback.
All reactions