Fork of Pleroma with site-specific changes and feature branches https://git.pleroma.social/pleroma/pleroma
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

pleroma_api.md 19KB

4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549
  1. # Pleroma API
  2. Requests that require it can be authenticated with [an OAuth token](https://tools.ietf.org/html/rfc6749), the `_pleroma_key` cookie, or [HTTP Basic Authentication](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Authorization).
  3. Request parameters can be passed via [query strings](https://en.wikipedia.org/wiki/Query_string) or as [form data](https://www.w3.org/TR/html401/interact/forms.html). Files must be uploaded as `multipart/form-data`.
  4. ## `/api/pleroma/emoji`
  5. ### Lists the custom emoji on that server.
  6. * Method: `GET`
  7. * Authentication: not required
  8. * Params: none
  9. * Response: JSON
  10. * Example response:
  11. ```json
  12. {
  13. "girlpower": {
  14. "tags": [
  15. "Finmoji"
  16. ],
  17. "image_url": "/finmoji/128px/girlpower-128.png"
  18. },
  19. "education": {
  20. "tags": [
  21. "Finmoji"
  22. ],
  23. "image_url": "/finmoji/128px/education-128.png"
  24. },
  25. "finnishlove": {
  26. "tags": [
  27. "Finmoji"
  28. ],
  29. "image_url": "/finmoji/128px/finnishlove-128.png"
  30. }
  31. }
  32. ```
  33. * Note: Same data as Mastodon API’s `/api/v1/custom_emojis` but in a different format
  34. ## `/api/pleroma/follow_import`
  35. ### Imports your follows, for example from a Mastodon CSV file.
  36. * Method: `POST`
  37. * Authentication: required
  38. * Params:
  39. * `list`: STRING or FILE containing a whitespace-separated list of accounts to follow
  40. * Response: HTTP 200 on success, 500 on error
  41. * Note: Users that can't be followed are silently skipped.
  42. ## `/api/pleroma/captcha`
  43. ### Get a new captcha
  44. * Method: `GET`
  45. * Authentication: not required
  46. * Params: none
  47. * Response: Provider specific JSON, the only guaranteed parameter is `type`
  48. * Example response: `{"type": "kocaptcha", "token": "whatever", "url": "https://captcha.kotobank.ch/endpoint"}`
  49. ## `/api/pleroma/delete_account`
  50. ### Delete an account
  51. * Method `POST`
  52. * Authentication: required
  53. * Params:
  54. * `password`: user's password
  55. * Response: JSON. Returns `{"status": "success"}` if the deletion was successful, `{"error": "[error message]"}` otherwise
  56. * Example response: `{"error": "Invalid password."}`
  57. ## `/api/pleroma/disable_account`
  58. ### Disable an account
  59. * Method `POST`
  60. * Authentication: required
  61. * Params:
  62. * `password`: user's password
  63. * Response: JSON. Returns `{"status": "success"}` if the account was successfully disabled, `{"error": "[error message]"}` otherwise
  64. * Example response: `{"error": "Invalid password."}`
  65. ## `/api/pleroma/accounts/mfa`
  66. #### Gets current MFA settings
  67. * method: `GET`
  68. * Authentication: required
  69. * OAuth scope: `read:security`
  70. * Response: JSON. Returns `{"enabled": "false", "totp": false }`
  71. ## `/api/pleroma/accounts/mfa/setup/totp`
  72. #### Pre-setup the MFA/TOTP method
  73. * method: `GET`
  74. * Authentication: required
  75. * OAuth scope: `write:security`
  76. * Response: JSON. Returns `{"key": [secret_key], "provisioning_uri": "[qr code uri]" }` when successful, otherwise returns HTTP 422 `{"error": "error_msg"}`
  77. ## `/api/pleroma/accounts/mfa/confirm/totp`
  78. #### Confirms & enables MFA/TOTP support for user account.
  79. * method: `POST`
  80. * Authentication: required
  81. * OAuth scope: `write:security`
  82. * Params:
  83. * `password`: user's password
  84. * `code`: token from TOTP App
  85. * Response: JSON. Returns `{}` if the enable was successful, HTTP 422 `{"error": "[error message]"}` otherwise
  86. ## `/api/pleroma/accounts/mfa/totp`
  87. #### Disables MFA/TOTP method for user account.
  88. * method: `DELETE`
  89. * Authentication: required
  90. * OAuth scope: `write:security`
  91. * Params:
  92. * `password`: user's password
  93. * Response: JSON. Returns `{}` if the disable was successful, HTTP 422 `{"error": "[error message]"}` otherwise
  94. * Example response: `{"error": "Invalid password."}`
  95. ## `/api/pleroma/accounts/mfa/backup_codes`
  96. #### Generstes backup codes MFA for user account.
  97. * method: `GET`
  98. * Authentication: required
  99. * OAuth scope: `write:security`
  100. * Response: JSON. Returns `{"codes": codes}`when successful, otherwise HTTP 422 `{"error": "[error message]"}`
  101. ## `/api/pleroma/admin/`
  102. See [Admin-API](admin_api.md)
  103. ## `/api/v1/pleroma/notifications/read`
  104. ### Mark notifications as read
  105. * Method `POST`
  106. * Authentication: required
  107. * Params (mutually exclusive):
  108. * `id`: a single notification id to read
  109. * `max_id`: read all notifications up to this id
  110. * Response: Notification entity/Array of Notification entities that were read. In case of `max_id`, only the first 80 read notifications will be returned.
  111. ## `/api/v1/pleroma/accounts/:id/subscribe`
  112. ### Subscribe to receive notifications for all statuses posted by a user
  113. * Method `POST`
  114. * Authentication: required
  115. * Params:
  116. * `id`: account id to subscribe to
  117. * Response: JSON, returns a mastodon relationship object on success, otherwise returns `{"error": "error_msg"}`
  118. * Example response:
  119. ```json
  120. {
  121. "id": "abcdefg",
  122. "following": true,
  123. "followed_by": false,
  124. "blocking": false,
  125. "muting": false,
  126. "muting_notifications": false,
  127. "subscribing": true,
  128. "requested": false,
  129. "domain_blocking": false,
  130. "showing_reblogs": true,
  131. "endorsed": false
  132. }
  133. ```
  134. ## `/api/v1/pleroma/accounts/:id/unsubscribe`
  135. ### Unsubscribe to stop receiving notifications from user statuses
  136. * Method `POST`
  137. * Authentication: required
  138. * Params:
  139. * `id`: account id to unsubscribe from
  140. * Response: JSON, returns a mastodon relationship object on success, otherwise returns `{"error": "error_msg"}`
  141. * Example response:
  142. ```json
  143. {
  144. "id": "abcdefg",
  145. "following": true,
  146. "followed_by": false,
  147. "blocking": false,
  148. "muting": false,
  149. "muting_notifications": false,
  150. "subscribing": false,
  151. "requested": false,
  152. "domain_blocking": false,
  153. "showing_reblogs": true,
  154. "endorsed": false
  155. }
  156. ```
  157. ## `/api/v1/pleroma/accounts/:id/favourites`
  158. ### Returns favorites timeline of any user
  159. * Method `GET`
  160. * Authentication: not required
  161. * Params:
  162. * `id`: the id of the account for whom to return results
  163. * `limit`: optional, the number of records to retrieve
  164. * `since_id`: optional, returns results that are more recent than the specified id
  165. * `max_id`: optional, returns results that are older than the specified id
  166. * Response: JSON, returns a list of Mastodon Status entities on success, otherwise returns `{"error": "error_msg"}`
  167. * Example response:
  168. ```json
  169. [
  170. {
  171. "account": {
  172. "id": "9hptFmUF3ztxYh3Svg",
  173. "url": "https://pleroma.example.org/users/nick2",
  174. "username": "nick2",
  175. ...
  176. },
  177. "application": {"name": "Web", "website": null},
  178. "bookmarked": false,
  179. "card": null,
  180. "content": "This is :moominmamma: note 0",
  181. "created_at": "2019-04-15T15:42:15.000Z",
  182. "emojis": [],
  183. "favourited": false,
  184. "favourites_count": 1,
  185. "id": "9hptFmVJ02khbzYJaS",
  186. "in_reply_to_account_id": null,
  187. "in_reply_to_id": null,
  188. "language": null,
  189. "media_attachments": [],
  190. "mentions": [],
  191. "muted": false,
  192. "pinned": false,
  193. "pleroma": {
  194. "content": {"text/plain": "This is :moominmamma: note 0"},
  195. "conversation_id": 13679,
  196. "local": true,
  197. "spoiler_text": {"text/plain": "2hu"}
  198. },
  199. "reblog": null,
  200. "reblogged": false,
  201. "reblogs_count": 0,
  202. "replies_count": 0,
  203. "sensitive": false,
  204. "spoiler_text": "2hu",
  205. "tags": [{"name": "2hu", "url": "/tag/2hu"}],
  206. "uri": "https://pleroma.example.org/objects/198ed2a1-7912-4482-b559-244a0369e984",
  207. "url": "https://pleroma.example.org/notice/9hptFmVJ02khbzYJaS",
  208. "visibility": "public"
  209. }
  210. ]
  211. ```
  212. ## `/api/v1/pleroma/accounts/update_*`
  213. ### Set and clear account avatar, banner, and background
  214. - PATCH `/api/v1/pleroma/accounts/update_avatar`: Set/clear user avatar image
  215. - PATCH `/api/v1/pleroma/accounts/update_banner`: Set/clear user banner image
  216. - PATCH `/api/v1/pleroma/accounts/update_background`: Set/clear user background image
  217. ## `/api/v1/pleroma/accounts/confirmation_resend`
  218. ### Resend confirmation email
  219. * Method `POST`
  220. * Params:
  221. * `email`: email of that needs to be verified
  222. * Authentication: not required
  223. * Response: 204 No Content
  224. ## `/api/v1/pleroma/mascot`
  225. ### Gets user mascot image
  226. * Method `GET`
  227. * Authentication: required
  228. * Response: JSON. Returns a mastodon media attachment entity.
  229. * Example response:
  230. ```json
  231. {
  232. "id": "abcdefg",
  233. "url": "https://pleroma.example.org/media/abcdefg.png",
  234. "type": "image",
  235. "pleroma": {
  236. "mime_type": "image/png"
  237. }
  238. }
  239. ```
  240. ### Updates user mascot image
  241. * Method `PUT`
  242. * Authentication: required
  243. * Params:
  244. * `file`: Multipart image
  245. * Response: JSON. Returns a mastodon media attachment entity
  246. when successful, otherwise returns HTTP 415 `{"error": "error_msg"}`
  247. * Example response:
  248. ```json
  249. {
  250. "id": "abcdefg",
  251. "url": "https://pleroma.example.org/media/abcdefg.png",
  252. "type": "image",
  253. "pleroma": {
  254. "mime_type": "image/png"
  255. }
  256. }
  257. ```
  258. * Note: Behaves exactly the same as `POST /api/v1/upload`.
  259. Can only accept images - any attempt to upload non-image files will be met with `HTTP 415 Unsupported Media Type`.
  260. ## `/api/pleroma/notification_settings`
  261. ### Updates user notification settings
  262. * Method `PUT`
  263. * Authentication: required
  264. * Params:
  265. * `followers`: BOOLEAN field, receives notifications from followers
  266. * `follows`: BOOLEAN field, receives notifications from people the user follows
  267. * `remote`: BOOLEAN field, receives notifications from people on remote instances
  268. * `local`: BOOLEAN field, receives notifications from people on the local instance
  269. * `privacy_option`: BOOLEAN field. When set to true, it removes the contents of a message from the push notification.
  270. * Response: JSON. Returns `{"status": "success"}` if the update was successful, otherwise returns `{"error": "error_msg"}`
  271. ## `/api/pleroma/healthcheck`
  272. ### Healthcheck endpoint with additional system data.
  273. * Method `GET`
  274. * Authentication: not required
  275. * Params: none
  276. * Response: JSON, statuses (200 - healthy, 503 unhealthy).
  277. * Example response:
  278. ```json
  279. {
  280. "pool_size": 0, # database connection pool
  281. "active": 0, # active processes
  282. "idle": 0, # idle processes
  283. "memory_used": 0.00, # Memory used
  284. "healthy": true, # Instance state
  285. "job_queue_stats": {} # Job queue stats
  286. }
  287. ```
  288. ## `/api/pleroma/change_email`
  289. ### Change account email
  290. * Method `POST`
  291. * Authentication: required
  292. * Params:
  293. * `password`: user's password
  294. * `email`: new email
  295. * Response: JSON. Returns `{"status": "success"}` if the change was successful, `{"error": "[error message]"}` otherwise
  296. * Note: Currently, Mastodon has no API for changing email. If they add it in future it might be incompatible with Pleroma.
  297. # Pleroma Conversations
  298. Pleroma Conversations have the same general structure that Mastodon Conversations have. The behavior differs in the following ways when using these endpoints:
  299. 1. Pleroma Conversations never add or remove recipients, unless explicitly changed by the user.
  300. 2. Pleroma Conversations statuses can be requested by Conversation id.
  301. 3. Pleroma Conversations can be replied to.
  302. Conversations have the additional field `recipients` under the `pleroma` key. This holds a list of all the accounts that will receive a message in this conversation.
  303. The status posting endpoint takes an additional parameter, `in_reply_to_conversation_id`, which, when set, will set the visiblity to direct and address only the people who are the recipients of that Conversation.
  304. ⚠ Conversation IDs can be found in direct messages with the `pleroma.direct_conversation_id` key, do not confuse it with `pleroma.conversation_id`.
  305. ## `GET /api/v1/pleroma/conversations/:id/statuses`
  306. ### Timeline for a given conversation
  307. * Method `GET`
  308. * Authentication: required
  309. * Params: Like other timelines
  310. * Response: JSON, statuses (200 - healthy, 503 unhealthy).
  311. ## `GET /api/v1/pleroma/conversations/:id`
  312. ### The conversation with the given ID.
  313. * Method `GET`
  314. * Authentication: required
  315. * Params: None
  316. * Response: JSON, statuses (200 - healthy, 503 unhealthy).
  317. ## `PATCH /api/v1/pleroma/conversations/:id`
  318. ### Update a conversation. Used to change the set of recipients.
  319. * Method `PATCH`
  320. * Authentication: required
  321. * Params:
  322. * `recipients`: A list of ids of users that should receive posts to this conversation. This will replace the current list of recipients, so submit the full list. The owner of owner of the conversation will always be part of the set of recipients, though.
  323. * Response: JSON, statuses (200 - healthy, 503 unhealthy)
  324. ## `POST /api/v1/pleroma/conversations/read`
  325. ### Marks all user's conversations as read.
  326. * Method `POST`
  327. * Authentication: required
  328. * Params: None
  329. * Response: JSON, returns a list of Mastodon Conversation entities that were marked as read (200 - healthy, 503 unhealthy).
  330. ## `GET /api/pleroma/emoji/packs/import`
  331. ### Imports packs from filesystem
  332. * Method `GET`
  333. * Authentication: required
  334. * Params: None
  335. * Response: JSON, returns a list of imported packs.
  336. ## `GET /api/pleroma/emoji/packs/remote`
  337. ### Make request to another instance for packs list
  338. * Method `GET`
  339. * Authentication: required
  340. * Params:
  341. * `url`: url of the instance to get packs from
  342. * Response: JSON with the pack list, hashmap with pack name and pack contents
  343. ## `POST /api/pleroma/emoji/packs/download`
  344. ### Download pack from another instance
  345. * Method `POST`
  346. * Authentication: required
  347. * Params:
  348. * `url`: url of the instance to download from
  349. * `name`: pack to download from that instance
  350. * `as`: (*optional*) name how to save pack
  351. * Response: JSON, "ok" with 200 status if the pack was downloaded, or 500 if there were
  352. errors downloading the pack
  353. ## `POST /api/pleroma/emoji/packs/:name`
  354. ### Creates an empty pack
  355. * Method `POST`
  356. * Authentication: required
  357. * Params: None
  358. * Response: JSON, "ok" and 200 status or 409 if the pack with that name already exists
  359. ## `PATCH /api/pleroma/emoji/packs/:name`
  360. ### Updates (replaces) pack metadata
  361. * Method `PATCH`
  362. * Authentication: required
  363. * Params:
  364. * `metadata`: metadata to replace the old one
  365. * `license`: Pack license
  366. * `homepage`: Pack home page url
  367. * `description`: Pack description
  368. * `fallback-src`: Fallback url to download pack from
  369. * `fallback-src-sha256`: SHA256 encoded for fallback pack archive
  370. * `share-files`: is pack allowed for sharing (boolean)
  371. * Response: JSON, updated "metadata" section of the pack and 200 status or 400 if there was a
  372. problem with the new metadata (the error is specified in the "error" part of the response JSON)
  373. ## `DELETE /api/pleroma/emoji/packs/:name`
  374. ### Delete a custom emoji pack
  375. * Method `DELETE`
  376. * Authentication: required
  377. * Params: None
  378. * Response: JSON, "ok" and 200 status or 500 if there was an error deleting the pack
  379. ## `POST /api/pleroma/emoji/packs/:name/files`
  380. ### Add new file to the pack
  381. * Method `POST`
  382. * Authentication: required
  383. * Params:
  384. * `file`: file needs to be uploaded with the multipart request or link to remote file.
  385. * `shortcode`: (*optional*) shortcode for new emoji, must be unique for all emoji. If not sended, shortcode will be taken from original filename.
  386. * `filename`: (*optional*) new emoji file name. If not specified will be taken from original filename.
  387. * Response: JSON, list of files for updated pack (hashmap -> shortcode => filename) with status 200, either error status with error message.
  388. ## `PATCH /api/pleroma/emoji/packs/:name/files`
  389. ### Update emoji file from pack
  390. * Method `PATCH`
  391. * Authentication: required
  392. * Params:
  393. * `shortcode`: emoji file shortcode
  394. * `new_shortcode`: new emoji file shortcode
  395. * `new_filename`: new filename for emoji file
  396. * `force`: (*optional*) with true value to overwrite existing emoji with new shortcode
  397. * Response: JSON, list with updated files for updated pack (hashmap -> shortcode => filename) with status 200, either error status with error message.
  398. ## `DELETE /api/pleroma/emoji/packs/:name/files`
  399. ### Delete emoji file from pack
  400. * Method `DELETE`
  401. * Authentication: required
  402. * Params:
  403. * `shortcode`: emoji file shortcode
  404. * Response: JSON, list with updated files for updated pack (hashmap -> shortcode => filename) with status 200, either error status with error message.
  405. ## `GET /api/pleroma/emoji/packs`
  406. ### Lists local custom emoji packs
  407. * Method `GET`
  408. * Authentication: not required
  409. * Params: None
  410. * Response: JSON, "ok" and 200 status and the JSON hashmap of pack name to pack contents
  411. ## `GET /api/pleroma/emoji/packs/:name`
  412. ### Get pack.json for the pack
  413. * Method `GET`
  414. * Authentication: not required
  415. * Params: None
  416. * Response: JSON, pack json with `files` and `pack` keys with 200 status or 404 if the pack does not exist
  417. ## `GET /api/pleroma/emoji/packs/:name/archive`
  418. ### Requests a local pack archive from the instance
  419. * Method `GET`
  420. * Authentication: not required
  421. * Params: None
  422. * Response: the archive of the pack with a 200 status code, 403 if the pack is not set as shared,
  423. 404 if the pack does not exist
  424. ## `GET /api/v1/pleroma/accounts/:id/scrobbles`
  425. ### Requests a list of current and recent Listen activities for an account
  426. * Method `GET`
  427. * Authentication: not required
  428. * Params: None
  429. * Response: An array of media metadata entities.
  430. * Example response:
  431. ```json
  432. [
  433. {
  434. "account": {...},
  435. "id": "1234",
  436. "title": "Some Title",
  437. "artist": "Some Artist",
  438. "album": "Some Album",
  439. "length": 180000,
  440. "created_at": "2019-09-28T12:40:45.000Z"
  441. }
  442. ]
  443. ```
  444. ## `POST /api/v1/pleroma/scrobble`
  445. ### Creates a new Listen activity for an account
  446. * Method `POST`
  447. * Authentication: required
  448. * Params:
  449. * `title`: the title of the media playing
  450. * `album`: the album of the media playing [optional]
  451. * `artist`: the artist of the media playing [optional]
  452. * `length`: the length of the media playing [optional]
  453. * Response: the newly created media metadata entity representing the Listen activity
  454. # Emoji Reactions
  455. Emoji reactions work a lot like favourites do. They make it possible to react to a post with a single emoji character. To detect the presence of this feature, you can check `pleroma_emoji_reactions` entry in the features list of nodeinfo.
  456. ## `PUT /api/v1/pleroma/statuses/:id/reactions/:emoji`
  457. ### React to a post with a unicode emoji
  458. * Method: `PUT`
  459. * Authentication: required
  460. * Params: `emoji`: A single character unicode emoji
  461. * Response: JSON, the status.
  462. ## `DELETE /api/v1/pleroma/statuses/:id/reactions/:emoji`
  463. ### Remove a reaction to a post with a unicode emoji
  464. * Method: `DELETE`
  465. * Authentication: required
  466. * Params: `emoji`: A single character unicode emoji
  467. * Response: JSON, the status.
  468. ## `GET /api/v1/pleroma/statuses/:id/reactions`
  469. ### Get an object of emoji to account mappings with accounts that reacted to the post
  470. * Method: `GET`
  471. * Authentication: optional
  472. * Params: None
  473. * Response: JSON, a list of emoji/account list tuples, sorted by emoji insertion date, in ascending order, e.g, the first emoji in the list is the oldest.
  474. * Example Response:
  475. ```json
  476. [
  477. {"name": "😀", "count": 2, "me": true, "accounts": [{"id" => "xyz.."...}, {"id" => "zyx..."}]},
  478. {"name": "☕", "count": 1, "me": false, "accounts": [{"id" => "abc..."}]}
  479. ]
  480. ```
  481. ## `GET /api/v1/pleroma/statuses/:id/reactions/:emoji`
  482. ### Get an object of emoji to account mappings with accounts that reacted to the post for a specific emoji
  483. * Method: `GET`
  484. * Authentication: optional
  485. * Params: None
  486. * Response: JSON, a list of emoji/account list tuples
  487. * Example Response:
  488. ```json
  489. [
  490. {"name": "😀", "count": 2, "me": true, "accounts": [{"id" => "xyz.."...}, {"id" => "zyx..."}]}
  491. ]
  492. ```