2019-12-07 05:09:59 +00:00
# Lemmy API
2020-02-06 16:26:11 +00:00
2020-09-15 19:26:47 +00:00
*Note: this may lag behind the actual API endpoints [here ](../src/api ). The API should be considered unstable and may change any time.*
2019-05-15 16:04:05 +00:00
2019-11-06 18:57:51 +00:00
<!-- toc -->
- [Data types ](#data-types )
2020-10-15 17:56:16 +00:00
* [Lemmy types ](#lemmy-types )
* [Lower-level types ](#lower-level-types )
2019-11-06 18:57:51 +00:00
- [Basic usage ](#basic-usage )
2020-01-19 18:31:37 +00:00
* [WebSocket ](#websocket )
+ [Testing with Websocat ](#testing-with-websocat )
+ [Testing with the WebSocket JavaScript API ](#testing-with-the-websocket-javascript-api )
* [HTTP ](#http )
+ [Testing with Curl ](#testing-with-curl )
- [Get Example ](#get-example )
- [Post Example ](#post-example )
2019-11-06 18:57:51 +00:00
- [Rate limits ](#rate-limits )
- [Errors ](#errors )
- [API documentation ](#api-documentation )
* [Sort Types ](#sort-types )
2020-07-21 14:15:17 +00:00
* [Undoing actions ](#undoing-actions )
2020-01-19 18:31:37 +00:00
* [Websocket vs HTTP ](#websocket-vs-http )
2019-11-06 18:57:51 +00:00
* [User / Authentication / Admin actions ](#user--authentication--admin-actions )
+ [Login ](#login )
- [Request ](#request )
- [Response ](#response )
2020-01-19 18:31:37 +00:00
- [HTTP ](#http-1 )
2019-11-06 18:57:51 +00:00
+ [Register ](#register )
- [Request ](#request-1 )
- [Response ](#response-1 )
2020-01-19 18:31:37 +00:00
- [HTTP ](#http-2 )
2020-09-15 19:26:47 +00:00
+ [Get Captcha ](#get-captcha )
2019-11-06 18:57:51 +00:00
- [Request ](#request-2 )
- [Response ](#response-2 )
2020-01-19 18:31:37 +00:00
- [HTTP ](#http-3 )
2020-09-15 19:26:47 +00:00
+ [Get User Details ](#get-user-details )
2019-11-06 18:57:51 +00:00
- [Request ](#request-3 )
- [Response ](#response-3 )
2020-01-19 18:31:37 +00:00
- [HTTP ](#http-4 )
2020-09-15 19:26:47 +00:00
+ [Save User Settings ](#save-user-settings )
2019-11-06 18:57:51 +00:00
- [Request ](#request-4 )
- [Response ](#response-4 )
2020-01-19 18:31:37 +00:00
- [HTTP ](#http-5 )
2020-09-15 19:26:47 +00:00
+ [Get Replies / Inbox ](#get-replies--inbox )
2019-11-06 18:57:51 +00:00
- [Request ](#request-5 )
- [Response ](#response-5 )
2020-01-19 18:31:37 +00:00
- [HTTP ](#http-6 )
2020-09-15 19:26:47 +00:00
+ [Get User Mentions ](#get-user-mentions )
2019-11-06 18:57:51 +00:00
- [Request ](#request-6 )
- [Response ](#response-6 )
2020-01-19 18:31:37 +00:00
- [HTTP ](#http-7 )
2020-09-15 19:26:47 +00:00
+ [Mark User Mention as read ](#mark-user-mention-as-read )
2019-11-06 18:57:51 +00:00
- [Request ](#request-7 )
- [Response ](#response-7 )
2020-01-19 18:31:37 +00:00
- [HTTP ](#http-8 )
2020-09-15 19:26:47 +00:00
+ [Get Private Messages ](#get-private-messages )
2019-11-06 18:57:51 +00:00
- [Request ](#request-8 )
- [Response ](#response-8 )
2020-01-19 18:31:37 +00:00
- [HTTP ](#http-9 )
2020-09-15 19:26:47 +00:00
+ [Create Private Message ](#create-private-message )
2019-11-06 18:57:51 +00:00
- [Request ](#request-9 )
- [Response ](#response-9 )
2020-01-19 18:31:37 +00:00
- [HTTP ](#http-10 )
2020-09-15 19:26:47 +00:00
+ [Edit Private Message ](#edit-private-message )
2019-11-06 18:57:51 +00:00
- [Request ](#request-10 )
- [Response ](#response-10 )
2020-01-19 18:31:37 +00:00
- [HTTP ](#http-11 )
2020-09-15 19:26:47 +00:00
+ [Delete Private Message ](#delete-private-message )
2019-11-06 18:57:51 +00:00
- [Request ](#request-11 )
- [Response ](#response-11 )
2020-01-19 18:31:37 +00:00
- [HTTP ](#http-12 )
2020-09-15 19:26:47 +00:00
+ [Mark Private Message as Read ](#mark-private-message-as-read )
2019-11-06 18:57:51 +00:00
- [Request ](#request-12 )
- [Response ](#response-12 )
2020-01-19 18:31:37 +00:00
- [HTTP ](#http-13 )
2020-09-15 19:26:47 +00:00
+ [Mark All As Read ](#mark-all-as-read )
2019-11-06 18:57:51 +00:00
- [Request ](#request-13 )
- [Response ](#response-13 )
2020-01-19 18:31:37 +00:00
- [HTTP ](#http-14 )
2020-09-15 19:26:47 +00:00
+ [Delete Account ](#delete-account )
2019-11-06 18:57:51 +00:00
- [Request ](#request-14 )
- [Response ](#response-14 )
2020-01-19 18:31:37 +00:00
- [HTTP ](#http-15 )
2020-09-15 19:26:47 +00:00
+ [Add admin ](#add-admin )
2019-11-06 18:57:51 +00:00
- [Request ](#request-15 )
- [Response ](#response-15 )
2020-01-19 18:31:37 +00:00
- [HTTP ](#http-16 )
2020-09-15 19:26:47 +00:00
+ [Ban user ](#ban-user )
2019-11-06 18:57:51 +00:00
- [Request ](#request-16 )
- [Response ](#response-16 )
2020-01-19 18:31:37 +00:00
- [HTTP ](#http-17 )
2020-09-15 19:26:47 +00:00
+ [User Join ](#user-join )
2019-11-06 18:57:51 +00:00
- [Request ](#request-17 )
- [Response ](#response-17 )
2020-01-19 18:31:37 +00:00
- [HTTP ](#http-18 )
2020-09-15 19:26:47 +00:00
* [Site ](#site )
+ [List Categories ](#list-categories )
2019-11-06 18:57:51 +00:00
- [Request ](#request-18 )
- [Response ](#response-18 )
2020-01-19 18:31:37 +00:00
- [HTTP ](#http-19 )
2020-09-15 19:26:47 +00:00
+ [Search ](#search )
2019-11-06 18:57:51 +00:00
- [Request ](#request-19 )
- [Response ](#response-19 )
2020-01-19 18:31:37 +00:00
- [HTTP ](#http-20 )
2020-09-15 19:26:47 +00:00
+ [Get Modlog ](#get-modlog )
2019-11-06 18:57:51 +00:00
- [Request ](#request-20 )
- [Response ](#response-20 )
2020-01-19 18:31:37 +00:00
- [HTTP ](#http-21 )
2020-09-15 19:26:47 +00:00
+ [Create Site ](#create-site )
2019-11-06 18:57:51 +00:00
- [Request ](#request-21 )
- [Response ](#response-21 )
2020-01-19 18:31:37 +00:00
- [HTTP ](#http-22 )
2020-09-15 19:26:47 +00:00
+ [Edit Site ](#edit-site )
2019-11-06 18:57:51 +00:00
- [Request ](#request-22 )
- [Response ](#response-22 )
2020-01-19 18:31:37 +00:00
- [HTTP ](#http-23 )
2020-09-15 19:26:47 +00:00
+ [Get Site ](#get-site )
2019-11-06 18:57:51 +00:00
- [Request ](#request-23 )
- [Response ](#response-23 )
2020-01-19 18:31:37 +00:00
- [HTTP ](#http-24 )
2020-09-15 19:26:47 +00:00
+ [Transfer Site ](#transfer-site )
2019-11-06 18:57:51 +00:00
- [Request ](#request-24 )
- [Response ](#response-24 )
2020-01-19 18:31:37 +00:00
- [HTTP ](#http-25 )
2020-09-15 19:26:47 +00:00
+ [Get Site Config ](#get-site-config )
2019-11-06 18:57:51 +00:00
- [Request ](#request-25 )
- [Response ](#response-25 )
2020-01-19 18:31:37 +00:00
- [HTTP ](#http-26 )
2020-09-15 19:26:47 +00:00
+ [Save Site Config ](#save-site-config )
2019-11-06 18:57:51 +00:00
- [Request ](#request-26 )
- [Response ](#response-26 )
2020-01-19 18:31:37 +00:00
- [HTTP ](#http-27 )
2020-09-15 19:26:47 +00:00
* [Community ](#community )
+ [Get Community ](#get-community )
2019-11-06 18:57:51 +00:00
- [Request ](#request-27 )
- [Response ](#response-27 )
2020-01-19 18:31:37 +00:00
- [HTTP ](#http-28 )
2020-09-15 19:26:47 +00:00
+ [Create Community ](#create-community )
2019-11-06 18:57:51 +00:00
- [Request ](#request-28 )
- [Response ](#response-28 )
2020-01-19 18:31:37 +00:00
- [HTTP ](#http-29 )
2020-09-15 19:26:47 +00:00
+ [List Communities ](#list-communities )
2019-11-06 18:57:51 +00:00
- [Request ](#request-29 )
- [Response ](#response-29 )
2020-01-19 18:31:37 +00:00
- [HTTP ](#http-30 )
2020-09-15 19:26:47 +00:00
+ [Ban from Community ](#ban-from-community )
2019-11-06 18:57:51 +00:00
- [Request ](#request-30 )
- [Response ](#response-30 )
2020-01-19 18:31:37 +00:00
- [HTTP ](#http-31 )
2020-09-15 19:26:47 +00:00
+ [Add Mod to Community ](#add-mod-to-community )
2019-11-06 18:57:51 +00:00
- [Request ](#request-31 )
- [Response ](#response-31 )
2020-01-19 18:31:37 +00:00
- [HTTP ](#http-32 )
2020-09-15 19:26:47 +00:00
+ [Edit Community ](#edit-community )
2019-11-06 18:57:51 +00:00
- [Request ](#request-32 )
- [Response ](#response-32 )
2020-01-19 18:31:37 +00:00
- [HTTP ](#http-33 )
2020-09-15 19:26:47 +00:00
+ [Delete Community ](#delete-community )
2019-11-06 18:57:51 +00:00
- [Request ](#request-33 )
- [Response ](#response-33 )
2020-01-19 18:31:37 +00:00
- [HTTP ](#http-34 )
2020-09-15 19:26:47 +00:00
+ [Remove Community ](#remove-community )
2019-11-06 18:57:51 +00:00
- [Request ](#request-34 )
- [Response ](#response-34 )
2020-01-19 18:31:37 +00:00
- [HTTP ](#http-35 )
2020-09-15 19:26:47 +00:00
+ [Follow Community ](#follow-community )
2019-11-23 00:39:53 +00:00
- [Request ](#request-35 )
- [Response ](#response-35 )
2020-01-19 18:31:37 +00:00
- [HTTP ](#http-36 )
2020-09-15 19:26:47 +00:00
+ [Get Followed Communities ](#get-followed-communities )
2020-01-19 18:31:37 +00:00
- [Request ](#request-36 )
- [Response ](#response-36 )
- [HTTP ](#http-37 )
2020-09-15 19:26:47 +00:00
+ [Transfer Community ](#transfer-community )
2020-04-10 20:55:57 +00:00
- [Request ](#request-37 )
- [Response ](#response-37 )
- [HTTP ](#http-38 )
2020-09-15 19:26:47 +00:00
+ [Community Join ](#community-join )
2020-04-10 20:55:57 +00:00
- [Request ](#request-38 )
- [Response ](#response-38 )
- [HTTP ](#http-39 )
2020-09-15 19:26:47 +00:00
* [Post ](#post )
+ [Create Post ](#create-post )
2020-07-21 14:15:17 +00:00
- [Request ](#request-39 )
- [Response ](#response-39 )
- [HTTP ](#http-40 )
2020-09-15 19:26:47 +00:00
+ [Get Post ](#get-post )
2020-07-21 14:15:17 +00:00
- [Request ](#request-40 )
- [Response ](#response-40 )
- [HTTP ](#http-41 )
2020-09-15 19:26:47 +00:00
+ [Get Posts ](#get-posts )
2020-07-21 14:15:17 +00:00
- [Request ](#request-41 )
- [Response ](#response-41 )
- [HTTP ](#http-42 )
2020-09-15 19:26:47 +00:00
+ [Create Post Like ](#create-post-like )
2020-07-21 14:15:17 +00:00
- [Request ](#request-42 )
- [Response ](#response-42 )
- [HTTP ](#http-43 )
2020-09-15 19:26:47 +00:00
+ [Edit Post ](#edit-post )
2020-07-21 14:15:17 +00:00
- [Request ](#request-43 )
- [Response ](#response-43 )
- [HTTP ](#http-44 )
2020-09-15 19:26:47 +00:00
+ [Delete Post ](#delete-post )
2020-07-21 14:15:17 +00:00
- [Request ](#request-44 )
- [Response ](#response-44 )
- [HTTP ](#http-45 )
2020-09-15 19:26:47 +00:00
+ [Remove Post ](#remove-post )
2020-07-21 14:15:17 +00:00
- [Request ](#request-45 )
- [Response ](#response-45 )
- [HTTP ](#http-46 )
2020-09-15 19:26:47 +00:00
+ [Lock Post ](#lock-post )
2020-07-21 14:15:17 +00:00
- [Request ](#request-46 )
- [Response ](#response-46 )
- [HTTP ](#http-47 )
2020-09-15 19:26:47 +00:00
+ [Sticky Post ](#sticky-post )
2020-07-21 14:15:17 +00:00
- [Request ](#request-47 )
- [Response ](#response-47 )
- [HTTP ](#http-48 )
2020-09-15 19:26:47 +00:00
+ [Save Post ](#save-post )
2020-07-21 14:15:17 +00:00
- [Request ](#request-48 )
- [Response ](#response-48 )
- [HTTP ](#http-49 )
2020-09-15 19:26:47 +00:00
+ [Post Join ](#post-join )
2020-07-21 14:15:17 +00:00
- [Request ](#request-49 )
- [Response ](#response-49 )
- [HTTP ](#http-50 )
2020-09-15 19:26:47 +00:00
* [Comment ](#comment )
+ [Create Comment ](#create-comment )
2020-07-21 14:15:17 +00:00
- [Request ](#request-50 )
- [Response ](#response-50 )
- [HTTP ](#http-51 )
2020-09-15 19:26:47 +00:00
+ [Edit Comment ](#edit-comment )
2020-07-21 14:15:17 +00:00
- [Request ](#request-51 )
- [Response ](#response-51 )
- [HTTP ](#http-52 )
2020-09-15 19:26:47 +00:00
+ [Delete Comment ](#delete-comment )
2020-07-21 14:15:17 +00:00
- [Request ](#request-52 )
- [Response ](#response-52 )
- [HTTP ](#http-53 )
2020-09-15 19:26:47 +00:00
+ [Remove Comment ](#remove-comment )
- [Request ](#request-53 )
- [Response ](#response-53 )
- [HTTP ](#http-54 )
+ [Get Comments ](#get-comments )
- [Request ](#request-54 )
- [Response ](#response-54 )
- [HTTP ](#http-55 )
+ [Mark Comment as Read ](#mark-comment-as-read )
- [Request ](#request-55 )
- [Response ](#response-55 )
- [HTTP ](#http-56 )
+ [Save Comment ](#save-comment )
- [Request ](#request-56 )
- [Response ](#response-56 )
- [HTTP ](#http-57 )
+ [Create Comment Like ](#create-comment-like )
- [Request ](#request-57 )
- [Response ](#response-57 )
- [HTTP ](#http-58 )
2019-12-07 05:09:59 +00:00
* [RSS / Atom feeds ](#rss--atom-feeds )
+ [All ](#all )
+ [Community ](#community-1 )
+ [User ](#user )
2020-10-26 11:07:23 +00:00
* [Images ](#images )
+ [Get ](#get )
+ [Create ](#create )
- [Request ](#request-58 )
- [Response ](#response-58 )
+ [Delete ](#delete )
2019-11-06 18:57:51 +00:00
<!-- tocstop -->
2019-09-07 14:22:01 +00:00
## Data types
2019-09-07 15:18:52 +00:00
2020-10-15 17:56:16 +00:00
### Lemmy types
The fields for objects like Users, Comments, Communities, and Posts, are in the [lemmy_db ](https://github.com/LemmyNet/lemmy/tree/main/lemmy_db/src ) folder, with the suffix `_view` . The main types are:
- [CommentView ](https://github.com/LemmyNet/lemmy/blob/main/lemmy_db/src/comment_view.rs )
- [CommunityView ](https://github.com/LemmyNet/lemmy/blob/main/lemmy_db/src/community_view.rs )
- [PostView ](https://github.com/LemmyNet/lemmy/blob/main/lemmy_db/src/post_view.rs )
- [UserView ](https://github.com/LemmyNet/lemmy/blob/main/lemmy_db/src/user_view.rs )
- [PrivateMessageView ](https://github.com/LemmyNet/lemmy/blob/main/lemmy_db/src/private_message_view.rs )
- [UserMentionView ](https://github.com/LemmyNet/lemmy/blob/main/lemmy_db/src/user_mention_view.rs )
- [SiteView ](https://github.com/LemmyNet/lemmy/blob/main/lemmy_db/src/site_view.rs )
- [Category ](https://github.com/LemmyNet/lemmy/blob/main/lemmy_db/src/category.rs )
- [Moderator Views ](https://github.com/LemmyNet/lemmy/blob/main/lemmy_db/src/moderator_views.rs )
The requests and responses, although copied below, are most up to date in [lemmy_structs ](https://github.com/LemmyNet/lemmy/tree/main/lemmy_structs/src ).
### Lower-level types
2019-09-07 14:22:01 +00:00
- `i16` , `i32` and `i64` are respectively [16-bit ](https://en.wikipedia.org/wiki/16-bit ), [32-bit ](https://en.wikipedia.org/wiki/32-bit ) and [64-bit ](https://en.wikipedia.org/wiki/64-bit_computing ) integers.
- < code > Option< ***SomeType***></ code > designates an option which may be omitted in requests and not be present in responses. It will be of type ** *SomeType***.
- < code > Vec< ***SomeType***></ code > is a list which contains objects of type ** *SomeType***.
- `chrono::NaiveDateTime` is a timestamp string in [ISO 8601 ](https://en.wikipedia.org/wiki/ISO_8601 ) format. Timestamps will be UTC.
2019-05-15 16:04:05 +00:00
2019-09-07 14:22:01 +00:00
## Basic usage
2019-09-07 15:18:52 +00:00
2019-09-07 14:22:01 +00:00
Request and response strings are in [JSON format ](https://www.json.org ).
2019-05-15 16:04:05 +00:00
2020-01-19 18:31:37 +00:00
### WebSocket
2019-09-07 15:18:52 +00:00
2019-09-07 14:22:01 +00:00
Connect to < code > ws://***host***/api/v1/ws< / code > to get started.
If the ** *`host`*** supports secure connections, you can use < code > wss://***host***/api/v1/ws</ code > .
2019-05-15 16:04:05 +00:00
2020-09-15 19:26:47 +00:00
To receive websocket messages, you must join a room / context. The three available are:
- [UserJoin ](#user-join ). Receives replies, private messages, etc.
- [PostJoin ](#post-join ). Receives new comments on a post.
- [CommunityJoin ](#community-join ). Receives front page / community posts.
2020-01-19 18:31:37 +00:00
#### Testing with Websocat
2019-11-06 18:57:51 +00:00
[Websocat link ](https://github.com/vi/websocat )
2019-05-15 18:48:01 +00:00
`websocat ws://127.0.0.1:8536/api/v1/ws -nt`
2019-05-15 16:04:05 +00:00
A simple test command:
`{"op": "ListCategories"}`
2020-01-19 18:31:37 +00:00
#### Testing with the WebSocket JavaScript API
2019-11-06 18:57:51 +00:00
[WebSocket JavaScript API ](https://developer.mozilla.org/en-US/docs/Web/API/WebSockets_API )
2019-09-07 14:22:01 +00:00
```javascript
var ws = new WebSocket("ws://" + host + "/api/v1/ws");
ws.onopen = function () {
console.log("Connection succeed!");
ws.send(JSON.stringify({
op: "ListCategories"
}));
};
```
2020-01-19 18:31:37 +00:00
### HTTP
Endpoints are at < code > http://***host***/api/v1/***endpoint***< / code > . They'll be listed below for each action.
#### Testing with Curl
##### Get Example
```
curl /community/list?sort=Hot
```
##### Post Example
```
curl -i -H \
"Content-Type: application/json" \
-X POST \
-d '{
2020-01-23 16:21:21 +00:00
"comment_id": X,
"post_id": X,
"score": X,
"auth": "..."
2020-01-19 18:31:37 +00:00
}' \
/comment/like
```
2019-09-07 14:22:01 +00:00
2019-05-15 16:04:05 +00:00
## Rate limits
2019-09-07 15:18:52 +00:00
2019-09-07 14:22:01 +00:00
- 1 per hour for signups and community creation.
- 1 per 10 minutes for post creation.
- 30 actions per minute for post voting and comment creation.
- Everything else is not rate-limited.
2019-05-15 16:04:05 +00:00
## Errors
```rust
{
op: String,
message: String,
}
```
2019-09-07 14:22:01 +00:00
## API documentation
2019-09-07 15:18:52 +00:00
2019-05-15 16:21:10 +00:00
### Sort Types
2019-09-07 15:18:52 +00:00
2019-09-07 14:22:01 +00:00
These go wherever there is a `sort` field. The available sort types are:
2020-08-05 16:03:46 +00:00
- `Active` - the hottest posts/communities, depending on votes, and newest comment publish date.
- `Hot` - the hottest posts/communities, depending on votes and publish date.
2019-09-07 14:22:01 +00:00
- `New` - the newest posts/communities
- `TopDay` - the most upvoted posts/communities of the current day.
- `TopWeek` - the most upvoted posts/communities of the current week.
- `TopMonth` - the most upvoted posts/communities of the current month.
- `TopYear` - the most upvoted posts/communities of the current year.
- `TopAll` - the most upvoted posts/communities on the current instance.
2019-05-15 16:21:10 +00:00
2020-07-21 14:15:17 +00:00
### Undoing actions
Whenever you see a `deleted: bool` , `removed: bool` , `read: bool` , `locked: bool` , etc, you can undo this action by sending `false` .
2020-01-19 18:31:37 +00:00
### Websocket vs HTTP
- Below are the websocket JSON requests / responses. For HTTP, ignore all fields except those inside `data` .
- For example, an http login will be a `POST` `{username_or_email: X, password: X}`
2019-09-07 14:22:01 +00:00
### User / Authentication / Admin actions
2019-09-07 15:18:52 +00:00
2019-05-15 16:04:05 +00:00
#### Login
2019-09-07 15:18:52 +00:00
2019-05-15 16:04:05 +00:00
The `jwt` string should be stored and used anywhere `auth` is called for.
##### Request
```rust
{
op: "Login",
data: {
username_or_email: String,
password: String
}
}
```
##### Response
```rust
{
2020-01-19 18:31:37 +00:00
op: "Login",
data: {
jwt: String,
}
2019-05-15 16:04:05 +00:00
}
```
2020-01-19 18:31:37 +00:00
##### HTTP
`POST /user/login`
2019-05-15 16:04:05 +00:00
#### Register
2020-01-19 18:31:37 +00:00
2019-05-15 16:04:05 +00:00
Only the first user will be able to be the admin.
##### Request
```rust
{
op: "Register",
data: {
username: String,
email: Option< String > ,
password: String,
password_verify: String,
2020-07-29 13:02:46 +00:00
admin: bool,
captcha_uuid: Option< String > , // Only checked if these are enabled in the server
captcha_answer: Option< String > ,
2019-05-15 16:04:05 +00:00
}
}
```
##### Response
```rust
{
2020-01-19 18:31:37 +00:00
op: "Register",
data: {
jwt: String,
}
2019-05-15 16:04:05 +00:00
}
```
2020-01-19 18:31:37 +00:00
##### HTTP
`POST /user/register`
2020-07-29 13:02:46 +00:00
#### Get Captcha
These expire after 10 minutes.
##### Request
```rust
{
op: "GetCaptcha",
}
```
##### Response
```rust
{
op: "GetCaptcha",
data: {
ok?: { // Will be undefined if captchas are disabled
png: String, // A Base64 encoded png
wav: Option< String > , // A Base64 encoded wav audio file
uuid: String,
}
}
}
```
##### HTTP
`GET /user/get_captcha`
2019-05-15 16:04:05 +00:00
#### Get User Details
##### Request
```rust
{
op: "GetUserDetails",
data: {
user_id: Option< i32 > ,
username: Option< String > ,
sort: String,
page: Option< i64 > ,
limit: Option< i64 > ,
community_id: Option< i32 > ,
saved_only: bool,
auth: Option< String > ,
}
}
```
##### Response
```rust
{
2020-01-19 18:31:37 +00:00
op: "GetUserDetails",
data: {
user: UserView,
follows: Vec< CommunityFollowerView > ,
moderates: Vec< CommunityModeratorView > ,
comments: Vec< CommentView > ,
posts: Vec< PostView > ,
}
2019-05-15 16:04:05 +00:00
}
```
2020-01-19 18:31:37 +00:00
##### HTTP
`GET /user`
2019-08-14 02:52:43 +00:00
#### Save User Settings
##### Request
```rust
{
2019-09-11 21:13:38 +00:00
op: "SaveUserSettings",
data: {
show_nsfw: bool,
2019-10-16 23:00:53 +00:00
theme: String, // Default 'darkly'
2019-10-21 19:48:43 +00:00
default_sort_type: i16, // The Sort types from above, zero indexed as a number
default_listing_type: i16, // Post listing types are `All, Subscribed, Community`
2020-08-05 16:03:46 +00:00
lang: String,
avatar: Option< String > ,
banner: Option< String > ,
preferred_username: Option< String > ,
email: Option< String > ,
bio: Option< String > ,
matrix_user_id: Option< String > ,
new_password: Option< String > ,
new_password_verify: Option< String > ,
old_password: Option< String > ,
show_avatars: bool,
send_notifications_to_email: bool,
auth: String,
2019-09-11 21:13:38 +00:00
}
2019-08-14 02:52:43 +00:00
}
```
##### Response
```rust
{
2020-01-19 18:31:37 +00:00
op: "SaveUserSettings",
data: {
jwt: String
}
2019-08-14 02:52:43 +00:00
}
```
2020-01-19 18:31:37 +00:00
##### HTTP
2020-09-13 15:20:24 +00:00
`PUT /user/save_user_settings`
2020-01-19 18:31:37 +00:00
2019-05-15 16:04:05 +00:00
#### Get Replies / Inbox
##### Request
```rust
{
op: "GetReplies",
data: {
sort: String,
page: Option< i64 > ,
limit: Option< i64 > ,
unread_only: bool,
auth: String
}
}
```
##### Response
```rust
{
2020-01-19 18:31:37 +00:00
op: "GetReplies",
data: {
replies: Vec< ReplyView > ,
}
2019-05-15 16:04:05 +00:00
}
```
2020-01-19 18:31:37 +00:00
##### HTTP
`GET /user/replies`
2019-05-15 16:04:05 +00:00
2019-11-23 00:39:53 +00:00
#### Get User Mentions
##### Request
```rust
{
op: "GetUserMentions",
data: {
sort: String,
page: Option< i64 > ,
limit: Option< i64 > ,
unread_only: bool,
auth: String,
}
}
```
##### Response
```rust
{
2020-01-19 18:31:37 +00:00
op: "GetUserMentions",
data: {
mentions: Vec< UserMentionView > ,
}
}
```
##### HTTP
2020-09-13 15:20:24 +00:00
`GET /user/mention`
2020-01-19 18:31:37 +00:00
2020-07-20 14:56:40 +00:00
#### Mark User Mention as read
2020-07-21 14:15:17 +00:00
Only the recipient can do this.
2020-01-19 18:31:37 +00:00
##### Request
```rust
{
2020-07-20 14:56:40 +00:00
op: "MarkUserMentionAsRead",
2020-01-19 18:31:37 +00:00
data: {
user_mention_id: i32,
2020-07-20 14:56:40 +00:00
read: bool,
2020-01-19 18:31:37 +00:00
auth: String,
}
}
```
##### Response
```rust
{
2020-07-20 14:56:40 +00:00
op: "MarkUserMentionAsRead",
2020-01-19 18:31:37 +00:00
data: {
mention: UserMentionView,
}
2019-11-23 00:39:53 +00:00
}
```
2020-01-19 18:31:37 +00:00
##### HTTP
2020-07-20 14:56:40 +00:00
`POST /user/mention/mark_as_read`
2019-11-23 00:39:53 +00:00
2020-07-20 04:29:44 +00:00
#### Get Private Messages
##### Request
```rust
{
op: "GetPrivateMessages",
data: {
unread_only: bool,
page: Option< i64 > ,
limit: Option< i64 > ,
auth: String,
}
}
```
##### Response
```rust
{
op: "GetPrivateMessages",
data: {
messages: Vec< PrivateMessageView > ,
}
}
```
##### HTTP
`GET /private_message/list`
#### Create Private Message
##### Request
```rust
{
op: "CreatePrivateMessage",
data: {
content: String,
recipient_id: i32,
auth: String,
}
}
```
##### Response
```rust
{
op: "CreatePrivateMessage",
data: {
message: PrivateMessageView,
}
}
```
##### HTTP
`POST /private_message`
#### Edit Private Message
##### Request
```rust
{
op: "EditPrivateMessage",
data: {
edit_id: i32,
content: String,
auth: String,
}
}
```
##### Response
```rust
{
op: "EditPrivateMessage",
data: {
message: PrivateMessageView,
}
}
```
##### HTTP
`PUT /private_message`
#### Delete Private Message
##### Request
```rust
{
op: "DeletePrivateMessage",
data: {
edit_id: i32,
deleted: bool,
auth: String,
}
}
```
##### Response
```rust
{
op: "DeletePrivateMessage",
data: {
message: PrivateMessageView,
}
}
```
##### HTTP
`POST /private_message/delete`
#### Mark Private Message as Read
2020-07-21 14:15:17 +00:00
Only the recipient can do this.
2020-07-20 04:29:44 +00:00
##### Request
```rust
{
op: "MarkPrivateMessageAsRead",
data: {
edit_id: i32,
read: bool,
auth: String,
}
}
```
##### Response
```rust
{
op: "MarkPrivateMessageAsRead",
data: {
message: PrivateMessageView,
}
}
```
##### HTTP
`POST /private_message/mark_as_read`
2019-11-23 00:39:53 +00:00
#### Mark All As Read
Marks all user replies and mentions as read.
2019-05-15 16:04:05 +00:00
##### Request
```rust
{
op: "MarkAllAsRead",
data: {
auth: String
}
}
```
##### Response
```rust
{
2020-01-19 18:31:37 +00:00
op: "MarkAllAsRead",
data: {
replies: Vec< ReplyView > ,
}
2019-05-15 16:04:05 +00:00
}
```
2020-01-19 18:31:37 +00:00
##### HTTP
`POST /user/mark_all_as_read`
2019-10-16 23:00:53 +00:00
#### Delete Account
2020-09-13 15:20:24 +00:00
*Permanently deletes your posts and comments*
2019-10-16 23:00:53 +00:00
##### Request
```rust
{
op: "DeleteAccount",
data: {
2019-10-19 04:42:35 +00:00
password: String,
2019-10-16 23:00:53 +00:00
auth: String
}
}
```
##### Response
```rust
{
2020-01-19 18:31:37 +00:00
op: "DeleteAccount",
data: {
jwt: String,
}
2019-10-16 23:00:53 +00:00
}
```
2020-01-19 18:31:37 +00:00
##### HTTP
`POST /user/delete_account`
2019-05-15 16:04:05 +00:00
#### Add admin
##### Request
```rust
{
op: "AddAdmin",
data: {
user_id: i32,
added: bool,
auth: String
}
}
```
##### Response
```rust
{
2020-01-19 18:31:37 +00:00
op: "AddAdmin",
data: {
admins: Vec< UserView > ,
}
2019-05-15 16:04:05 +00:00
}
```
2020-01-19 18:31:37 +00:00
##### HTTP
`POST /admin/add`
2019-05-15 16:04:05 +00:00
#### Ban user
##### Request
```rust
{
op: "BanUser",
data: {
user_id: i32,
ban: bool,
2020-08-17 18:12:36 +00:00
remove_data: Option< bool > , // Removes/Restores their comments, posts, and communities
2019-05-15 16:04:05 +00:00
reason: Option< String > ,
expires: Option< i64 > ,
auth: String
}
}
```
##### Response
```rust
{
2020-01-19 18:31:37 +00:00
op: "BanUser",
data: {
user: UserView,
banned: bool,
}
2019-05-15 16:04:05 +00:00
}
```
2020-01-19 18:31:37 +00:00
##### HTTP
`POST /user/ban`
2019-05-15 16:04:05 +00:00
2020-09-15 19:26:47 +00:00
#### User Join
##### Request
```rust
{
op: "UserJoin",
data: {
auth: String
}
}
```
##### Response
```rust
{
op: "UserJoin",
data: {
joined: bool,
}
}
```
##### HTTP
`POST /user/join`
2019-05-15 16:04:05 +00:00
### Site
#### List Categories
##### Request
```rust
{
op: "ListCategories"
}
```
##### Response
```rust
{
2020-01-19 18:31:37 +00:00
op: "ListCategories",
data: {
categories: Vec< Category >
}
2019-05-15 16:04:05 +00:00
}
```
2020-01-19 18:31:37 +00:00
##### HTTP
`GET /categories`
2019-05-15 16:04:05 +00:00
#### Search
2020-01-19 18:31:37 +00:00
2020-01-20 23:49:54 +00:00
Search types are `All, Comments, Posts, Communities, Users, Url`
2019-05-15 18:48:01 +00:00
2019-05-15 16:04:05 +00:00
##### Request
```rust
{
op: "Search",
data: {
q: String,
type_: String,
community_id: Option< i32 > ,
2020-10-05 00:57:35 +00:00
community_name: Option< String > ,
2019-05-15 16:04:05 +00:00
sort: String,
page: Option< i64 > ,
limit: Option< i64 > ,
2020-01-20 23:49:54 +00:00
auth?: Option< String > ,
2019-05-15 16:04:05 +00:00
}
}
```
##### Response
```rust
{
2020-01-19 18:31:37 +00:00
op: "Search",
data: {
2020-01-20 23:49:54 +00:00
type_: String,
2020-01-19 18:31:37 +00:00
comments: Vec< CommentView > ,
posts: Vec< PostView > ,
2020-01-20 23:49:54 +00:00
communities: Vec< CommunityView > ,
users: Vec< UserView > ,
2020-01-19 18:31:37 +00:00
}
2019-05-15 16:04:05 +00:00
}
```
2020-01-19 18:31:37 +00:00
##### HTTP
2020-09-13 15:20:24 +00:00
`GET /search`
2019-05-15 16:04:05 +00:00
#### Get Modlog
##### Request
```rust
{
op: "GetModlog",
data: {
mod_user_id: Option< i32 > ,
community_id: Option< i32 > ,
page: Option< i64 > ,
limit: Option< i64 > ,
}
}
```
##### Response
```rust
{
2020-01-19 18:31:37 +00:00
op: "GetModlog",
data: {
removed_posts: Vec< ModRemovePostView > ,
locked_posts: Vec< ModLockPostView > ,
removed_comments: Vec< ModRemoveCommentView > ,
removed_communities: Vec< ModRemoveCommunityView > ,
banned_from_community: Vec< ModBanFromCommunityView > ,
banned: Vec< ModBanView > ,
added_to_community: Vec< ModAddCommunityView > ,
added: Vec< ModAddView > ,
}
2019-05-15 16:04:05 +00:00
}
```
2020-01-19 18:31:37 +00:00
##### HTTP
`GET /modlog`
2019-05-15 16:04:05 +00:00
#### Create Site
##### Request
```rust
{
op: "CreateSite",
data: {
name: String,
description: Option< String > ,
2020-08-05 16:03:46 +00:00
icon: Option< String > ,
banner: Option< String > ,
2019-05-15 16:04:05 +00:00
auth: String
}
}
```
##### Response
```rust
{
2020-01-19 18:31:37 +00:00
op: "CreateSite",
data: {
site: SiteView,
}
2019-05-15 16:04:05 +00:00
}
```
2020-01-19 18:31:37 +00:00
##### HTTP
`POST /site`
2019-05-15 16:04:05 +00:00
#### Edit Site
##### Request
```rust
{
op: "EditSite",
data: {
name: String,
description: Option< String > ,
2020-08-05 16:03:46 +00:00
icon: Option< String > ,
banner: Option< String > ,
2019-05-15 16:04:05 +00:00
auth: String
}
}
```
##### Response
```rust
{
2020-01-19 18:31:37 +00:00
op: "EditSite",
data: {
site: SiteView,
}
2019-05-15 16:04:05 +00:00
}
```
2020-01-19 18:31:37 +00:00
##### HTTP
`PUT /site`
2019-05-15 16:04:05 +00:00
#### Get Site
##### Request
```rust
{
op: "GetSite"
2020-07-27 13:23:08 +00:00
data: {
auth: Option< String > ,
}
2019-05-15 16:04:05 +00:00
}
```
##### Response
```rust
{
2020-01-19 18:31:37 +00:00
op: "GetSite",
data: {
site: Option< SiteView > ,
admins: Vec< UserView > ,
banned: Vec< UserView > ,
2020-07-21 13:20:23 +00:00
online: usize, // This is currently broken
version: String,
2020-07-27 13:23:08 +00:00
my_user: Option< User_ > , // Gives back your user and settings if logged in
2020-01-19 18:31:37 +00:00
}
2019-05-15 16:04:05 +00:00
}
```
2020-01-19 18:31:37 +00:00
##### HTTP
`GET /site`
2019-05-15 16:04:05 +00:00
2019-08-25 18:16:46 +00:00
#### Transfer Site
##### Request
```rust
{
op: "TransferSite",
data: {
user_id: i32,
auth: String
}
}
```
##### Response
```rust
{
2020-01-19 18:31:37 +00:00
op: "TransferSite",
data: {
site: Option< SiteView > ,
admins: Vec< UserView > ,
banned: Vec< UserView > ,
}
2019-08-25 18:16:46 +00:00
}
```
2020-01-19 18:31:37 +00:00
##### HTTP
`POST /site/transfer`
2019-08-25 18:16:46 +00:00
2020-04-10 20:55:57 +00:00
#### Get Site Config
##### Request
```rust
{
op: "GetSiteConfig",
data: {
auth: String
}
}
```
##### Response
```rust
{
op: "GetSiteConfig",
data: {
config_hjson: String,
}
}
```
##### HTTP
`GET /site/config`
#### Save Site Config
##### Request
```rust
{
op: "SaveSiteConfig",
data: {
config_hjson: String,
auth: String
}
}
```
##### Response
```rust
{
op: "SaveSiteConfig",
data: {
config_hjson: String,
}
}
```
##### HTTP
`PUT /site/config`
2019-05-15 16:04:05 +00:00
### Community
#### Get Community
##### Request
```rust
{
op: "GetCommunity",
data: {
id: Option< i32 > ,
name: Option< String > ,
auth: Option< String >
}
}
```
##### Response
```rust
{
2020-01-19 18:31:37 +00:00
op: "GetCommunity",
data: {
community: CommunityView,
moderators: Vec< CommunityModeratorView > ,
}
2019-05-15 16:04:05 +00:00
}
```
2020-01-19 18:31:37 +00:00
##### HTTP
`GET /community`
2019-05-15 16:04:05 +00:00
#### Create Community
##### Request
```rust
{
op: "CreateCommunity",
data: {
name: String,
title: String,
description: Option< String > ,
2020-08-05 16:03:46 +00:00
icon: Option< String > ,
banner: Option< String > ,
2019-05-15 16:04:05 +00:00
category_id: i32 ,
auth: String
}
}
```
##### Response
```rust
{
2020-01-19 18:31:37 +00:00
op: "CreateCommunity",
data: {
community: CommunityView
}
2019-05-15 16:04:05 +00:00
}
```
2020-01-19 18:31:37 +00:00
##### HTTP
`POST /community`
2019-05-15 16:04:05 +00:00
#### List Communities
##### Request
```rust
{
op: "ListCommunities",
data: {
sort: String,
page: Option< i64 > ,
limit: Option< i64 > ,
auth: Option< String >
}
}
```
##### Response
```rust
{
2020-01-19 18:31:37 +00:00
op: "ListCommunities",
data: {
communities: Vec< CommunityView >
}
2019-05-15 16:04:05 +00:00
}
```
2020-01-19 18:31:37 +00:00
##### HTTP
`GET /community/list`
2019-05-15 16:04:05 +00:00
#### Ban from Community
##### Request
```rust
{
op: "BanFromCommunity",
data: {
community_id: i32,
user_id: i32,
ban: bool,
2020-08-17 18:12:36 +00:00
remove_data: Option< bool > , // Removes/Restores their comments and posts for that community
2019-05-15 16:04:05 +00:00
reason: Option< String > ,
expires: Option< i64 > ,
auth: String
}
}
```
##### Response
```rust
{
2020-01-19 18:31:37 +00:00
op: "BanFromCommunity",
data: {
user: UserView,
banned: bool,
}
2019-05-15 16:04:05 +00:00
}
```
2020-01-19 18:31:37 +00:00
##### HTTP
`POST /community/ban_user`
2019-05-15 16:04:05 +00:00
#### Add Mod to Community
##### Request
```rust
{
op: "AddModToCommunity",
data: {
community_id: i32,
user_id: i32,
added: bool,
auth: String
}
}
```
##### Response
```rust
{
2020-01-19 18:31:37 +00:00
op: "AddModToCommunity",
data: {
moderators: Vec< CommunityModeratorView > ,
}
2019-05-15 16:04:05 +00:00
}
```
2020-01-19 18:31:37 +00:00
##### HTTP
`POST /community/mod`
2019-05-15 16:04:05 +00:00
#### Edit Community
2020-07-20 17:37:39 +00:00
Only mods can edit a community.
2019-05-15 16:04:05 +00:00
##### Request
```rust
{
op: "EditCommunity",
data: {
edit_id: i32,
title: String,
description: Option< String > ,
2020-08-05 16:03:46 +00:00
icon: Option< String > ,
banner: Option< String > ,
2019-05-15 16:04:05 +00:00
category_id: i32,
auth: String
}
}
```
##### Response
```rust
{
2020-01-19 18:31:37 +00:00
op: "EditCommunity",
data: {
community: CommunityView
}
2019-05-15 16:04:05 +00:00
}
```
2020-01-19 18:31:37 +00:00
##### HTTP
`PUT /community`
2019-05-15 16:04:05 +00:00
2020-07-20 17:37:39 +00:00
#### Delete Community
Only a creator can delete a community
##### Request
```rust
{
op: "DeleteCommunity",
data: {
edit_id: i32,
deleted: bool,
auth: String,
}
}
```
##### Response
```rust
{
op: "DeleteCommunity",
data: {
community: CommunityView
}
}
```
##### HTTP
`POST /community/delete`
#### Remove Community
Only admins can remove a community.
##### Request
```rust
{
op: "RemoveCommunity",
data: {
edit_id: i32,
removed: bool,
reason: Option< String > ,
expires: Option< i64 > ,
auth: String,
}
}
```
##### Response
```rust
{
op: "RemoveCommunity",
data: {
community: CommunityView
}
}
```
##### HTTP
`POST /community/remove`
2019-05-15 16:04:05 +00:00
#### Follow Community
##### Request
```rust
{
op: "FollowCommunity",
data: {
community_id: i32,
follow: bool,
auth: String
}
}
```
##### Response
```rust
{
2020-01-19 18:31:37 +00:00
op: "FollowCommunity",
data: {
community: CommunityView
}
2019-05-15 16:04:05 +00:00
}
```
2020-01-19 18:31:37 +00:00
##### HTTP
`POST /community/follow`
2019-05-15 16:04:05 +00:00
#### Get Followed Communities
##### Request
```rust
{
op: "GetFollowedCommunities",
data: {
auth: String
}
}
```
##### Response
```rust
{
2020-01-19 18:31:37 +00:00
op: "GetFollowedCommunities",
data: {
communities: Vec< CommunityFollowerView >
}
2019-05-15 16:04:05 +00:00
}
```
2020-01-19 18:31:37 +00:00
##### HTTP
`GET /user/followed_communities`
2019-05-15 16:04:05 +00:00
2019-08-25 18:16:46 +00:00
#### Transfer Community
##### Request
```rust
{
op: "TransferCommunity",
data: {
community_id: i32,
user_id: i32,
auth: String
}
}
```
##### Response
```rust
{
2020-01-19 18:31:37 +00:00
op: "TransferCommunity",
data: {
community: CommunityView,
moderators: Vec< CommunityModeratorView > ,
admins: Vec< UserView > ,
}
2019-08-25 18:16:46 +00:00
}
```
2020-01-19 18:31:37 +00:00
##### HTTP
`POST /community/transfer`
2019-08-25 18:16:46 +00:00
2020-09-15 19:26:47 +00:00
#### Community Join
The main / frontpage community is `community_id: 0` .
##### Request
```rust
{
op: "CommunityJoin",
data: {
community_id: i32
}
}
```
##### Response
```rust
{
op: "CommunityJoin",
data: {
joined: bool,
}
}
```
##### HTTP
`POST /community/join`
2019-05-15 16:04:05 +00:00
### Post
#### Create Post
##### Request
```rust
{
op: "CreatePost",
data: {
name: String,
url: Option< String > ,
body: Option< String > ,
2020-07-21 03:46:36 +00:00
nsfw: bool,
2019-05-15 16:04:05 +00:00
community_id: i32,
2020-07-21 03:46:36 +00:00
auth: String,
2019-05-15 16:04:05 +00:00
}
}
```
##### Response
```rust
{
2020-01-19 18:31:37 +00:00
op: "CreatePost",
data: {
post: PostView
}
2019-05-15 16:04:05 +00:00
}
```
2020-01-19 18:31:37 +00:00
##### HTTP
`POST /post`
2019-05-15 16:04:05 +00:00
#### Get Post
##### Request
```rust
{
op: "GetPost",
data: {
id: i32,
auth: Option< String >
}
}
```
##### Response
```rust
{
2020-01-19 18:31:37 +00:00
op: "GetPost",
data: {
post: PostView,
comments: Vec< CommentView > ,
community: CommunityView,
moderators: Vec< CommunityModeratorView > ,
}
2019-05-15 16:04:05 +00:00
}
```
2020-01-19 18:31:37 +00:00
##### HTTP
`GET /post`
2019-05-15 16:04:05 +00:00
#### Get Posts
2020-01-19 18:31:37 +00:00
2019-05-15 20:50:18 +00:00
Post listing types are `All, Subscribed, Community`
2019-05-15 16:21:10 +00:00
2019-05-15 16:04:05 +00:00
##### Request
```rust
{
op: "GetPosts",
data: {
type_: String,
sort: String,
page: Option< i64 > ,
limit: Option< i64 > ,
community_id: Option< i32 > ,
2020-07-13 13:50:13 +00:00
community_name: Option< String > ,
2019-05-15 16:04:05 +00:00
auth: Option< String >
}
}
```
##### Response
```rust
{
2020-01-19 18:31:37 +00:00
op: "GetPosts",
data: {
posts: Vec< PostView > ,
}
2019-05-15 16:04:05 +00:00
}
```
2020-01-19 18:31:37 +00:00
##### HTTP
`GET /post/list`
2019-05-15 16:04:05 +00:00
#### Create Post Like
2020-01-19 18:31:37 +00:00
2019-05-15 20:50:18 +00:00
`score` can be 0, -1, or 1
2019-05-15 16:04:05 +00:00
##### Request
```rust
{
op: "CreatePostLike",
data: {
post_id: i32,
score: i16,
auth: String
}
}
```
##### Response
```rust
{
2020-01-19 18:31:37 +00:00
op: "CreatePostLike",
data: {
post: PostView
}
2019-05-15 16:04:05 +00:00
}
```
2020-01-19 18:31:37 +00:00
##### HTTP
`POST /post/like`
2019-05-15 16:04:05 +00:00
#### Edit Post
##### Request
```rust
{
op: "EditPost",
data: {
edit_id: i32,
name: String,
url: Option< String > ,
body: Option< String > ,
2020-07-21 03:46:36 +00:00
nsfw: bool,
auth: String,
2019-05-15 16:04:05 +00:00
}
}
```
##### Response
```rust
{
2020-01-19 18:31:37 +00:00
op: "EditPost",
data: {
post: PostView
}
2019-05-15 16:04:05 +00:00
}
```
2020-01-19 18:31:37 +00:00
##### HTTP
`PUT /post`
2020-07-21 03:46:36 +00:00
#### Delete Post
##### Request
```rust
{
op: "DeletePost",
data: {
edit_id: i32,
deleted: bool,
auth: String,
}
}
```
##### Response
```rust
{
op: "DeletePost",
data: {
post: PostView
}
}
```
##### HTTP
`POST /post/delete`
#### Remove Post
Only admins and mods can remove a post.
##### Request
```rust
{
op: "RemovePost",
data: {
edit_id: i32,
removed: bool,
reason: Option< String > ,
auth: String,
}
}
```
##### Response
```rust
{
op: "RemovePost",
data: {
post: PostView
}
}
```
##### HTTP
`POST /post/remove`
#### Lock Post
Only admins and mods can lock a post.
##### Request
```rust
{
op: "LockPost",
data: {
edit_id: i32,
locked: bool,
auth: String,
}
}
```
##### Response
```rust
{
op: "LockPost",
data: {
post: PostView
}
}
```
##### HTTP
`POST /post/lock`
#### Sticky Post
Only admins and mods can sticky a post.
##### Request
```rust
{
op: "StickyPost",
data: {
edit_id: i32,
stickied: bool,
auth: String,
}
}
```
##### Response
```rust
{
op: "StickyPost",
data: {
post: PostView
}
}
```
##### HTTP
`POST /post/sticky`
2019-05-15 16:04:05 +00:00
#### Save Post
##### Request
```rust
{
op: "SavePost",
data: {
post_id: i32,
save: bool,
auth: String
}
}
```
##### Response
```rust
{
2020-01-19 18:31:37 +00:00
op: "SavePost",
data: {
post: PostView
}
2019-05-15 16:04:05 +00:00
}
```
2020-01-19 18:31:37 +00:00
##### HTTP
`POST /post/save`
2019-05-15 16:04:05 +00:00
2020-09-15 19:26:47 +00:00
#### Post Join
##### Request
```rust
{
op: "PostJoin",
data: {
post_id: i32
}
}
```
##### Response
```rust
{
op: "PostJoin",
data: {
joined: bool,
}
}
```
##### HTTP
`POST /post/join`
2019-05-15 16:04:05 +00:00
### Comment
#### Create Comment
##### Request
```rust
{
op: "CreateComment",
data: {
content: String,
parent_id: Option< i32 > ,
post_id: i32,
2020-07-21 14:56:41 +00:00
form_id: Option< String > , // An optional form id, so you know which message came back
2019-05-15 16:04:05 +00:00
auth: String
}
}
```
##### Response
```rust
{
2020-01-19 18:31:37 +00:00
op: "CreateComment",
data: {
comment: CommentView
}
2019-05-15 16:04:05 +00:00
}
```
2020-01-19 18:31:37 +00:00
##### HTTP
`POST /comment`
2019-05-15 16:04:05 +00:00
#### Edit Comment
2020-01-19 18:31:37 +00:00
2020-07-21 01:37:44 +00:00
Only the creator can edit the comment.
2019-05-15 16:04:05 +00:00
##### Request
```rust
{
op: "EditComment",
data: {
content: String,
edit_id: i32,
2020-07-21 14:56:41 +00:00
form_id: Option< String > ,
2020-07-21 01:37:44 +00:00
auth: String,
2019-05-15 16:04:05 +00:00
}
}
```
##### Response
```rust
{
2020-01-19 18:31:37 +00:00
op: "EditComment",
data: {
comment: CommentView
}
2019-05-15 16:04:05 +00:00
}
```
2020-01-19 18:31:37 +00:00
##### HTTP
`PUT /comment`
2019-05-15 16:04:05 +00:00
2020-07-21 01:37:44 +00:00
#### Delete Comment
Only the creator can delete the comment.
##### Request
```rust
{
op: "DeleteComment",
data: {
edit_id: i32,
deleted: bool,
auth: String,
}
}
```
##### Response
```rust
{
op: "DeleteComment",
data: {
comment: CommentView
}
}
```
##### HTTP
`POST /comment/delete`
#### Remove Comment
Only a mod or admin can remove the comment.
##### Request
```rust
{
op: "RemoveComment",
data: {
edit_id: i32,
removed: bool,
reason: Option< String > ,
auth: String,
}
}
```
##### Response
```rust
{
op: "RemoveComment",
data: {
comment: CommentView
}
}
```
##### HTTP
`POST /comment/remove`
2020-09-15 19:26:47 +00:00
#### Get Comments
Comment listing types are `All, Subscribed, Community`
##### Request
```rust
{
op: "GetComments",
data: {
type_: String,
sort: String,
page: Option< i64 > ,
limit: Option< i64 > ,
community_id: Option< i32 > ,
community_name: Option< String > ,
auth: Option< String >
}
}
```
##### Response
```rust
{
op: "GetComments",
data: {
comments: Vec< CommentView > ,
}
}
```
##### HTTP
`GET /comment/list`
2020-07-21 01:37:44 +00:00
#### Mark Comment as Read
2020-07-21 14:15:17 +00:00
Only the recipient can do this.
2020-07-21 01:37:44 +00:00
##### Request
```rust
{
op: "MarkCommentAsRead",
data: {
edit_id: i32,
read: bool,
auth: String,
}
}
```
##### Response
```rust
{
op: "MarkCommentAsRead",
data: {
comment: CommentView
}
}
```
##### HTTP
`POST /comment/mark_as_read`
2019-05-15 16:04:05 +00:00
#### Save Comment
##### Request
```rust
{
op: "SaveComment",
data: {
comment_id: i32,
save: bool,
auth: String
}
}
```
##### Response
```rust
{
2020-01-19 18:31:37 +00:00
op: "SaveComment",
data: {
comment: CommentView
}
2019-05-15 16:04:05 +00:00
}
```
2020-01-19 18:31:37 +00:00
##### HTTP
2020-09-13 15:20:24 +00:00
`PUT /comment/save`
2019-05-15 16:04:05 +00:00
#### Create Comment Like
2020-01-19 18:31:37 +00:00
2019-05-15 20:50:18 +00:00
`score` can be 0, -1, or 1
2019-05-15 16:04:05 +00:00
##### Request
```rust
{
op: "CreateCommentLike",
data: {
comment_id: i32,
score: i16,
auth: String
}
}
```
##### Response
```rust
{
2020-01-19 18:31:37 +00:00
op: "CreateCommentLike",
data: {
comment: CommentView
}
2019-05-15 16:04:05 +00:00
}
```
2020-01-19 18:31:37 +00:00
##### HTTP
`POST /comment/like`
2019-12-07 05:09:59 +00:00
### RSS / Atom feeds
#### All
`/feeds/all.xml?sort=Hot`
#### Community
`/feeds/c/community-name.xml?sort=Hot`
#### User
`/feeds/u/user-name.xml?sort=Hot`
2020-10-26 11:07:23 +00:00
### Images
Lemmy forwards image requests to a locally running Pictrs.
#### Get
*Format and thumbnail are optional.*
`GET /pictrs/image/{filename}?format={webp, jpg, ...}&thumbnail={96}`
#### Create
##### Request
Uploaded content must be valid multipart/form-data with an image array located within the images[] key.
`POST /pictrs/image`
##### Response
```
{
"files": [
{
"delete_token": "{token}",
"file": "{file}.jpg"
}
],
"msg": "ok"
}
```
#### Delete
`GET /pictrs/image/delete/{delete_token}/{file}`