total rebase
[anni] / docs / development / API / differences_in_mastoapi_responses.md
1 # Differences in Mastodon API responses from vanilla Mastodon
2
3 A Pleroma instance can be identified by "<Mastodon version> (compatible; Pleroma <version>)" present in `version` field in response from `/api/v1/instance` and `/api/v2/instance`
4
5 ## Flake IDs
6
7 Pleroma uses 128-bit ids as opposed to Mastodon's 64 bits. However, just like Mastodon's ids, they are lexically sortable strings
8
9 ## Timelines
10
11 Adding the parameter `with_muted=true` to the timeline queries will also return activities by muted (not by blocked!) users.
12
13 Adding the parameter `exclude_visibilities` to the timeline queries will exclude the statuses with the given visibilities. The parameter accepts an array of visibility types (`public`, `unlisted`, `private`, `direct`), e.g., `exclude_visibilities[]=direct&exclude_visibilities[]=private`.
14
15 Adding the parameter `reply_visibility` to the public and home timelines queries will filter replies. Possible values: without parameter (default) shows all replies, `following` - replies directed to you or users you follow, `self` - replies directed to you.
16
17 Adding the parameter `instance=lain.com` to the public timeline will show only statuses originating from `lain.com` (or any remote instance).
18
19 Home, public, hashtag & list timelines accept these parameters:
20
21 - `only_media`: show only statuses with media attached
22 - `local`: show only local statuses
23 - `remote`: show only remote statuses
24
25 ## Statuses
26
27 - `visibility`: has additional possible values `list` and `local` (for local-only statuses)
28
29 Has these additional fields under the `pleroma` object:
30
31 - `local`: true if the post was made on the local instance
32 - `conversation_id`: the ID of the AP context the status is associated with (if any)
33 - `direct_conversation_id`: the ID of the Mastodon direct message conversation the status is associated with (if any)
34 - `in_reply_to_account_acct`: the `acct` property of User entity for replied user (if any)
35 - `content`: a map consisting of alternate representations of the `content` property with the key being its mimetype. Currently, the only alternate representation supported is `text/plain`
36 - `spoiler_text`: a map consisting of alternate representations of the `spoiler_text` property with the key being its mimetype. Currently, the only alternate representation supported is `text/plain`
37 - `expires_at`: a datetime (iso8601) that states when the post will expire (be deleted automatically), or empty if the post won't expire
38 - `thread_muted`: true if the thread the post belongs to is muted
39 - `emoji_reactions`: A list with emoji / reaction maps. The format is `{name: "☕", count: 1, me: true}`. Contains no information about the reacting users, for that use the `/statuses/:id/reactions` endpoint.
40 - `parent_visible`: If the parent of this post is visible to the user or not.
41 - `pinned_at`: a datetime (iso8601) when status was pinned, `null` otherwise.
42 - `quotes_count`: the count of status quotes.
43 - `non_anonymous`: true if the source post specifies the poll results are not anonymous. Currently only implemented by Smithereen.
44 - `bookmark_folder`: the ID of the folder bookmark is stored within (if any).
45
46 The `GET /api/v1/statuses/:id/source` endpoint additionally has the following attributes:
47
48 - `content_type`: The content type of the status source.
49
50 ## Scheduled statuses
51
52 Has these additional fields in `params`:
53
54 - `expires_in`: the number of seconds the posted activity should expire in.
55
56 ## Media Attachments
57
58 Has these additional fields under the `pleroma` object:
59
60 - `mime_type`: mime type of the attachment.
61
62 ### Attachment cap
63
64 Some apps operate under the assumption that no more than 4 attachments can be returned or uploaded. Pleroma however does not enforce any limits on attachment count neither when returning the status object nor when posting.
65
66 ### Limitations
67
68 Pleroma does not process remote images and therefore cannot include fields such as `meta` and `blurhash`. It does not support focal points or aspect ratios. The frontend is expected to handle it.
69
70 ## Bookmarks
71
72 The `GET /api/v1/bookmarks` endpoint accepts optional parameter `folder_id` for bookmark folder ID.
73
74 The `POST /api/v1/statuses/:id/bookmark` endpoint accepts optional parameter `folder_id` for bookmark folder ID.
75
76 ## Accounts
77
78 The `id` parameter can also be the `nickname` of the user. This only works in these endpoints, not the deeper nested ones for following etc.
79
80 - `/api/v1/accounts/:id`
81 - `/api/v1/accounts/:id/statuses`
82
83 `/api/v1/accounts/:id/statuses` endpoint accepts these parameters:
84
85 - `pinned`: include only pinned statuses
86 - `tagged`: with tag
87 - `only_media`: include only statuses with media attached
88 - `with_muted`: include statuses/reactions from muted accounts
89 - `exclude_reblogs`: exclude reblogs
90 - `exclude_replies`: exclude replies
91 - `exclude_visibilities`: exclude visibilities
92
93 Endpoints which accept `with_relationships` parameter:
94
95 - `/api/v1/accounts/:id`
96 - `/api/v1/accounts/:id/followers`
97 - `/api/v1/accounts/:id/following`
98 - `/api/v1/mutes`
99
100 Has these additional fields under the `pleroma` object:
101
102 - `ap_id`: nullable URL string, ActivityPub id of the user
103 - `background_image`: nullable URL string, background image of the user
104 - `tags`: Lists an array of tags for the user
105 - `relationship` (object): Includes fields as documented for Mastodon API https://docs.joinmastodon.org/entities/relationship/
106 - `is_moderator`: boolean, nullable,  true if user is a moderator
107 - `is_admin`: boolean, nullable, true if user is an admin
108 - `confirmation_pending`: boolean, true if a new user account is waiting on email confirmation to be activated
109 - `hide_favorites`: boolean, true when the user has hiding favorites enabled
110 - `hide_followers`: boolean, true when the user has follower hiding enabled
111 - `hide_follows`: boolean, true when the user has follow hiding enabled
112 - `hide_followers_count`: boolean, true when the user has follower stat hiding enabled
113 - `hide_follows_count`: boolean, true when the user has follow stat hiding enabled
114 - `settings_store`: A generic map of settings for frontends. Opaque to the backend. Only returned in `/api/v1/accounts/verify_credentials` and `/api/v1/accounts/update_credentials`
115 - `chat_token`: The token needed for Pleroma shoutbox. Only returned in `/api/v1/accounts/verify_credentials`
116 - `deactivated`: boolean, true when the user is deactivated
117 - `allow_following_move`: boolean, true when the user allows automatically follow moved following accounts
118 - `unread_conversation_count`: The count of unread conversations. Only returned to the account owner.
119 - `unread_notifications_count`: The count of unread notifications. Only returned to the account owner.
120 - `notification_settings`: object, can be absent. See `/api/v1/pleroma/notification_settings` for the parameters/keys returned.
121 - `accepts_chat_messages`: boolean, but can be null if we don't have that information about a user
122 - `favicon`: nullable URL string, Favicon image of the user's instance
123
124 ### Source
125
126 Has these additional fields under the `pleroma` object:
127
128 - `show_role`: boolean, nullable, true when the user wants his role (e.g admin, moderator) to be shown
129 - `no_rich_text` - boolean, nullable, true when html tags are stripped from all statuses requested from the API
130 - `discoverable`: boolean, true when the user allows external services (search bots) etc. to index / list the account (regardless of this setting, user will still appear in regular search results)
131 - `actor_type`: string, the type of this account.
132
133 ## Conversations
134
135 Has an additional field under the `pleroma` object:
136
137 - `recipients`: The list of the recipients of this Conversation. These will be addressed when replying to this conversation.
138
139 ## GET `/api/v1/conversations`
140
141 Accepts additional parameters:
142
143 - `recipients`: Only return conversations with the given recipients (a list of user ids). Usage example: `GET /api/v1/conversations?recipients[]=1&recipients[]=2`
144
145 ## Account Search
146
147 Behavior has changed:
148
149 - `/api/v1/accounts/search`: Does not require authentication
150
151 ## Search (global)
152
153 Unlisted posts are available in search results, they are considered to be public posts that shouldn't be shown in local/federated timeline.
154
155 ## Notifications
156
157 Has these additional fields under the `pleroma` object:
158
159 - `is_seen`: true if the notification was read by the user
160
161 ### Move Notification
162
163 The `type` value is `move`. Has an additional field:
164
165 - `target`: new account
166
167 ### EmojiReact Notification
168
169 The `type` value is `pleroma:emoji_reaction`. Has these fields:
170
171 - `emoji`: The used emoji
172 - `account`: The account of the user who reacted
173 - `status`: The status that was reacted on
174
175 ### ChatMention Notification (not default)
176
177 This notification has to be requested explicitly.
178
179 The `type` value is `pleroma:chat_mention`
180
181 - `account`: The account who sent the message
182 - `chat_message`: The chat message
183
184 ### Report Notification (not default)
185
186 This notification has to be requested explicitly.
187
188 The `type` value is `pleroma:report`
189
190 - `account`: The account who reported
191 - `report`: The report
192
193 ## GET `/api/v1/notifications`
194
195 Accepts additional parameters:
196
197 - `exclude_visibilities`: will exclude the notifications for activities with the given visibilities. The parameter accepts an array of visibility types (`public`, `unlisted`, `private`, `direct`). Usage example: `GET /api/v1/notifications?exclude_visibilities[]=direct&exclude_visibilities[]=private`.
198 - `include_types`: will include the notifications for activities with the given types. The parameter accepts an array of types (`mention`, `follow`, `reblog`, `favourite`, `move`, `pleroma:emoji_reaction`, `pleroma:chat_mention`, `pleroma:report`). Usage example: `GET /api/v1/notifications?include_types[]=mention&include_types[]=reblog`.
199
200 ## DELETE `/api/v1/notifications/destroy_multiple`
201
202 An endpoint to delete multiple statuses by IDs.
203
204 Required parameters:
205
206 - `ids`: array of activity ids
207
208 Usage example: `DELETE /api/v1/notifications/destroy_multiple/?ids[]=1&ids[]=2`.
209
210 Returns on success: 200 OK `{}`
211
212 ## POST `/api/v1/statuses`
213
214 Additional parameters can be added to the JSON body/Form data:
215
216 - `preview`: boolean, if set to `true` the post won't be actually posted, but the status entity would still be rendered back. This could be useful for previewing rich text/custom emoji, for example.
217 - `content_type`: string, contain the MIME type of the status, it is transformed into HTML by the backend. You can get the list of the supported MIME types with the nodeinfo endpoint.
218 - `to`: A list of nicknames (like `lain@soykaf.club` or `lain` on the local server) that will be used to determine who is going to be addressed by this post. Using this will disable the implicit addressing by mentioned names in the `status` body, only the people in the `to` list will be addressed. The normal rules for post visibility are not affected by this and will still apply.
219 - `visibility`: string, besides standard MastoAPI values (`direct`, `private`, `unlisted`, `local` or `public`) it can be used to address a List by setting it to `list:LIST_ID`.
220 - `expires_in`: The number of seconds the posted activity should expire in. When a posted activity expires it will be deleted from the server, and a delete request for it will be federated. This needs to be longer than an hour.
221 - `in_reply_to_conversation_id`: Will reply to a given conversation, addressing only the people who are part of the recipient set of that conversation. Sets the visibility to `direct`.
222
223 ## GET `/api/v1/statuses`
224
225 An endpoint to get multiple statuses by IDs.
226
227 Required parameters:
228
229 - `ids`: array of activity ids
230
231 Usage example: `GET /api/v1/statuses/?ids[]=1&ids[]=2`.
232
233 Returns: array of Status.
234
235 The maximum number of statuses is limited to 100 per request.
236
237 ## PATCH `/api/v1/accounts/update_credentials`
238
239 Additional parameters can be added to the JSON body/Form data:
240
241 - `no_rich_text` - if true, html tags are stripped from all statuses requested from the API
242 - `hide_followers` - if true, user's followers will be hidden
243 - `hide_follows` - if true, user's follows will be hidden
244 - `hide_followers_count` - if true, user's follower count will be hidden
245 - `hide_follows_count` - if true, user's follow count will be hidden
246 - `hide_favorites` - if true, user's favorites timeline will be hidden
247 - `show_role` - if true, user's role (e.g admin, moderator) will be exposed to anyone in the API
248 - `default_scope` - the scope returned under `privacy` key in Source subentity
249 - `pleroma_settings_store` - Opaque user settings to be saved on the backend.
250 - `skip_thread_containment` - if true, skip filtering out broken threads
251 - `allow_following_move` - if true, allows automatically follow moved following accounts
252 - `also_known_as` - array of ActivityPub IDs, needed for following move
253 - `pleroma_background_image` - sets the background image of the user. Can be set to "" (an empty string) to reset.
254 - `discoverable` - if true, external services (search bots) etc. are allowed to index / list the account (regardless of this setting, user will still appear in regular search results).
255 - `actor_type` - the type of this account.
256 - `accepts_chat_messages` - if false, this account will reject all chat messages.
257 - `language` - user's preferred language for receiving emails (digest, confirmation, etc.)
258
259 All images (avatar, banner and background) can be reset to the default by sending an empty string ("") instead of a file.
260
261 ### Pleroma Settings Store
262
263 Pleroma has mechanism that allows frontends to save blobs of json for each user on the backend. This can be used to save frontend-specific settings for a user that the backend does not need to know about.
264
265 The parameter should have a form of `{frontend_name: {...}}`, with `frontend_name` identifying your type of client, e.g. `pleroma_fe`. It will overwrite everything under this property, but will not overwrite other frontend's settings.
266
267 This information is returned in the `/api/v1/accounts/verify_credentials` endpoint.
268
269 ## Authentication
270
271 *Pleroma supports refreshing tokens.*
272
273 ### POST `/oauth/token`
274
275 You can obtain access tokens for a user in a few additional ways.
276
277 #### Refreshing a token
278
279 To obtain a new access token from a refresh token, pass `grant_type=refresh_token` with the following extra parameters:
280
281 - `refresh_token`: The refresh token.
282
283 #### Getting a token with a password
284
285 To obtain a token from a user's password, pass `grant_type=password` with the following extra parameters:
286
287 - `username`: Username to authenticate.
288 - `password`: The user's password.
289
290 #### Response body
291
292 Additional fields are returned in the response:
293
294 - `id`: The primary key of this token in Pleroma's database.
295 - `me` (user tokens only): The ActivityPub ID of the user who owns the token.
296
297 ## Account Registration
298
299 `POST /api/v1/accounts`
300
301 Has these additional parameters (which are the same as in Pleroma-API):
302
303 - `fullname`: optional
304 - `bio`: optional
305 - `captcha_solution`: optional, contains provider-specific captcha solution,
306 - `captcha_token`: optional, contains provider-specific captcha token
307 - `captcha_answer_data`: optional, contains provider-specific captcha data
308 - `token`: invite token required when the registrations aren't public.
309 - `language`: optional, user's preferred language for receiving emails (digest, confirmation, etc.), default to the language set in the `userLanguage` cookies or `Accept-Language` header.
310
311 ## Instance
312
313 `GET /api/v1/instance` has additional fields
314
315 - `max_toot_chars`: The maximum characters per post
316 - `max_media_attachments`: Maximum number of post media attachments
317 - `chat_limit`: The maximum characters per chat message
318 - `description_limit`: The maximum characters per image description
319 - `poll_limits`: The limits of polls
320 - `shout_limit`: The maximum characters per Shoutbox message
321 - `upload_limit`: The maximum upload file size
322 - `avatar_upload_limit`: The same for avatars
323 - `background_upload_limit`: The same for backgrounds
324 - `banner_upload_limit`: The same for banners
325 - `background_image`: A background image that frontends can use
326 - `pleroma.metadata.account_activation_required`: Whether users are required to confirm their emails before signing in
327 - `pleroma.metadata.birthday_required`: Whether users are required to provide their birth day when signing in
328 - `pleroma.metadata.birthday_min_age`: The minimum user age (in days)
329 - `pleroma.metadata.features`: A list of supported features
330 - `pleroma.metadata.federation`: The federation restrictions of this instance
331 - `pleroma.metadata.fields_limits`: A list of values detailing the length and count limitation for various instance-configurable fields.
332 - `pleroma.metadata.post_formats`: A list of the allowed post format types
333 - `pleroma.stats.mau`: Monthly active user count
334 - `pleroma.vapid_public_key`: The public key needed for push messages
335
336 In, `GET /api/v2/instance` Pleroma-specific fields are all moved into `pleroma` object. `max_toot_chars`, `poll_limits` and `upload_limit` are replaced with their MastoAPI counterparts.
337
338 ## Push Subscription
339
340 `POST /api/v1/push/subscription`
341 `PUT /api/v1/push/subscription`
342
343 Permits these additional alert types:
344
345 - pleroma:chat_mention
346 - pleroma:emoji_reaction
347
348 ## Markers
349
350 Has these additional fields under the `pleroma` object:
351
352 - `unread_count`: contains number unread notifications
353
354 ## Streaming
355
356 ### Chats
357
358 There is an additional `user:pleroma_chat` stream. Incoming chat messages will make the current chat be sent to this `user` stream. The `event` of an incoming chat message is `pleroma:chat_update`. The payload is the updated chat with the incoming chat message in the `last_message` field.
359
360 ### Remote timelines
361
362 For viewing remote server timelines, there are `public:remote` and `public:remote:media` streams. Each of these accept a parameter like `?instance=lain.com`.
363
364 ### Follow relationships updates
365
366 Pleroma streams follow relationships updates as `pleroma:follow_relationships_update` events to the `user` stream.
367
368 The message payload consist of:
369
370 - `state`: a relationship state, one of `follow_pending`, `follow_accept` or `follow_reject`.
371
372 - `follower` and `following` maps with following fields:
373   - `id`: user ID
374   - `follower_count`: follower count
375   - `following_count`: following count
376
377 ### Authenticating via `sec-websocket-protocol` header
378
379 Pleroma allows to authenticate via the `sec-websocket-protocol` header, for example, if your access token is `your-access-token`, you can authenticate using the following:
380
381 ```
382 sec-websocket-protocol: your-access-token
383 ```
384
385 ### Authenticating after connection via `pleroma:authenticate` event
386
387 Pleroma allows to authenticate after connection is established, via the `pleroma:authenticate` event. For example, if your access token is `your-access-token`, you can send the following after the connection is established:
388
389 ```
390 {"type": "pleroma:authenticate", "token": "your-access-token"}
391 ```
392
393 ### Response to client-sent events
394
395 Pleroma will respond to client-sent events that it recognizes. Supported event types are:
396
397 - `subscribe`
398 - `unsubscribe`
399 - `pleroma:authenticate`
400
401 The reply will be in the following format:
402
403 ```
404 {
405   "event": "pleroma:respond",
406   "payload": "{\"type\": \"<type of the client-sent event>\", \"result\": \"<result of the action>\", \"error\": \"<error code>\"}"
407 }
408 ```
409
410 Result of the action can be either `success`, `ignored` or `error`. If it is `error`, the `error` property will contain the error code. Otherwise, the `error` property will not be present. Below are some examples:
411
412 ```
413 {
414   "event": "pleroma:respond",
415   "payload": "{\"type\": \"pleroma:authenticate\", \"result\": \"success\"}"
416 }
417
418 {
419   "event": "pleroma:respond",
420   "payload": "{\"type\": \"subscribe\", \"result\": \"ignored\"}"
421 }
422
423 {
424   "event": "pleroma:respond",
425   "payload": "{\"type\": \"unsubscribe\", \"result\": \"error\", \"error\": \"bad_topic\"}"
426 }
427 ```
428
429 If the sent event is not of a type that Pleroma supports, it will not reply.
430
431 ### The `stream` attribute of a server-sent event
432
433 Technically, this is in Mastodon, but its documentation does nothing to specify its format.
434
435 This attribute appears on every event type except `pleroma:respond` and `delete`. It helps clients determine where they should display the new statuses.
436
437 The value of the attribute is an array containing one or two elements. The first element is the type of the stream. The second is the identifier related to that specific stream, if applicable.
438
439 For the following stream types, there is a second element in the array:
440
441 - `list`: The second element is the id of the list, as a string.
442 - `hashtag`: The second element is the name of the hashtag.
443 - `public:remote:media` and `public:remote`: The second element is the domain of the corresponding instance.
444
445 For all other stream types, there is no second element.
446
447 Some examples of valid `stream` values:
448
449 - `["list", "1"]`: List of id 1.
450 - `["hashtag", "mew"]`: The hashtag #mew.
451 - `["user:notifications"]`: Notifications for the current user.
452 - `["user"]`: Home timeline.
453 - `["public:remote", "mew.moe"]`: Public posts from the instance mew.moe .
454
455 ### The unified streaming endpoint
456
457 If you do not specify a stream to connect to when requesting `/api/v1/streaming`, you will enter a connection that subscribes to no streams. After the connection is established, you can authenticate and then subscribe to different streams.
458
459 ### List of supported streams
460
461 Below is a list of supported streams by Pleroma. To make a single-stream WebSocket connection, append the string specified in "Query style" to the streaming endpoint url.
462 To subscribe to a stream after the connection is established, merge the JSON object specified in "Subscribe style" with `{"type": "subscribe"}`. To unsubscribe, merge it with `{"type": "unsubscribe"}`.
463
464 For example, to receive updates on the list 1, you can connect to `/api/v1/streaming/?stream=list&list=1`, or send
465
466 ```
467 {"type": "subscribe", "stream": "list", "list": "1"}
468 ```
469
470 upon establishing the websocket connection.
471
472 To unsubscribe to list 1, send
473
474 ```
475 {"type": "unsubscribe", "stream": "list", "list": "1"}
476 ```
477
478 Note that if you specify a stream that requires a logged-in user in the query string (for example, `user` or `list`), you have to specify the access token when you are trying to establish the connection, i.e. in the query string or via the `sec-websocket-protocol` header.
479
480 - `list`
481   - Query style: `?stream=list&list=<id>`
482   - Subscribe style: `{"stream": "list", "list": "<id>"}`
483 - `public`, `public:local`, `public:media`, `public:local:media`, `user`, `user:pleroma_chat`, `user:notifications`, `direct`
484   - Query style: `?stream=<stream name>`
485   - Subscribe style: `{"stream": "<stream name>"}`
486 - `hashtag`
487   - Query style: `?stream=hashtag&tag=<name>`
488   - Subscribe style: `{"stream": "hashtag", "tag": "<name>"}`
489 - `public:remote`, `public:remote:media`
490   - Query style: `?stream=<stream name>&instance=<instance domain>`
491   - Subscribe style: `{"stream": "<stream name>", "instance": "<instance domain>"}`
492
493 ## User muting and thread muting
494
495 Both user muting and thread muting can be done for only a certain time by adding an `expires_in` parameter to the API calls and giving the expiration time in seconds.
496
497 ## Not implemented
498
499 Pleroma is generally compatible with the Mastodon 2.7.2 API, but some newer features and non-essential features are omitted. These features usually return an HTTP 200 status code, but with an empty response. While they may be added in the future, they are considered low priority.
500
501 ### Suggestions
502
503 *Added in Mastodon 2.4.3*
504
505 - `GET /api/v1/suggestions`: Returns an empty array, `[]`
506
507 ### Trends
508
509 *Added in Mastodon 3.0.0*
510
511 - `GET /api/v1/trends`: Returns an empty array, `[]`
512
513 ### Identity proofs
514
515 *Added in Mastodon 2.8.0*
516
517 - `GET /api/v1/identity_proofs`: Returns an empty array, `[]`
518
519 ### Featured tags
520
521 *Added in Mastodon 3.0.0*
522
523 - `GET /api/v1/featured_tags`: Returns HTTP 404