API v4 Upgrade Guide
This document outlines the main changes between API v3 (Lemmy 0.19) and API v4 (Lemmy 1.0). You can use the following resources to adapt the new API:
- Official API docs (including OpenAPI spec)
- Browse voyager.lemmy.ml, and use the browser console to see which API requests are made
- Look at the relevant pull requests for a given feature in lemmy-ui (eg notifications)
Note that this document only covers changes to existing features, not new features. If any breaking changes are missing, please make a pull request to this file. If you have any questions, use the development chat on matrix or /c/lemmy-support.
Rename account endpoints
Various endpoints have been renamed, especially those under /api/v3/user have been moved to /api/v4/account/auth.
/api/v3/user/registerto/api/v4/account/auth/register/api/v3/user/loginto/api/v4/account/auth/login/api/v3/user/logoutto/api/v4/account/auth/logout- …
/api/v4/sitedoesn’t havemy_useranymore, this is now available atGET /api/v4/account
https://github.com/LemmyNet/lemmy/pull/5216
Combined endpoints
There are various places in the UI where different types of data are shown together, for example posts and comments in the user profile. Until 0.19 these were queried separately, to display the (last 20 posts) and (last 20 comments). For 1.0 Dessalines implemented combined queries, so that the new endpoint /api/v4/person/content returns the last 20 (posts and comments). See the issue and linked pull requests for more details.
The combined endpoints are:
GET /api/v4/person/contentGET /api/v4/account/inboxGET /api/v4/account/savedGET /api/v4/modlogGET /api/v4/report/list
Image endpoints
Uploading or deleting avatars, icons and banners is done through separate endpoints now. With this change it is possible to disable image uploads, while still allowing changes to avatars etc.
The endpoints for image upload and proxying have been moved to GET /api/v4/image/{filename} and GET /api/v4/image/proxy respectively.
https://github.com/LemmyNet/lemmy/pull/5260
Cursor Pagination
Instead of a page parameter, API v4 uses cursors for pagination. To make it simple, a cursor is a string which encodes the id of the last item on the current page. When going to the next page, the client sends the next_page cursor as page_cursor, and the API sends back items which come after this one. This way users don’t lose their place in the feed, but continue exactly where they left off.
Notifications Rewrite
With API v3 notification functionality was spread across various different endpoints. Now all is available under a single endpoint /api/v4/account/notification/list. Notifications also include modlog entries affecting the current user.
Post Time Range Filter
The previous sorts TopHour, TopDay etc are gone and replaced Top sort. Instead there is now a separate parameter time_range_seconds which accepts arbitrary time values and works with all sort types.
Other Breaking Changes
- Rename actor_id columns to ap_id
- Removing local_user.show_scores column, since its now on the local_user_vote_display_mode table.
- Move custom emojis and tagline views to separate endpoints
- Remove pointless block_views
- Changing list_logins to return a ListLoginsResponse object.
- Remove pointless local_user_id from LocalUserVoteDisplayMode
- Remove enable nsfw