]> Untitled Git - lemmy.git/blob - docs/src/contributing_websocket_http_api.md
Updating API docs.
[lemmy.git] / docs / src / contributing_websocket_http_api.md
1 # Lemmy API
2 *Note: this may lag behind the actual API endpoints [here](../server/src/api).*
3
4 <!-- toc -->
5
6 - [Data types](#data-types)
7 - [Basic usage](#basic-usage)
8   * [WebSocket](#websocket)
9     + [Testing with Websocat](#testing-with-websocat)
10     + [Testing with the WebSocket JavaScript API](#testing-with-the-websocket-javascript-api)
11   * [HTTP](#http)
12     + [Testing with Curl](#testing-with-curl)
13       - [Get Example](#get-example)
14       - [Post Example](#post-example)
15 - [Rate limits](#rate-limits)
16 - [Errors](#errors)
17 - [API documentation](#api-documentation)
18   * [Sort Types](#sort-types)
19   * [Websocket vs HTTP](#websocket-vs-http)
20   * [User / Authentication / Admin actions](#user--authentication--admin-actions)
21     + [Login](#login)
22       - [Request](#request)
23       - [Response](#response)
24       - [HTTP](#http-1)
25     + [Register](#register)
26       - [Request](#request-1)
27       - [Response](#response-1)
28       - [HTTP](#http-2)
29     + [Get User Details](#get-user-details)
30       - [Request](#request-2)
31       - [Response](#response-2)
32       - [HTTP](#http-3)
33     + [Save User Settings](#save-user-settings)
34       - [Request](#request-3)
35       - [Response](#response-3)
36       - [HTTP](#http-4)
37     + [Get Replies / Inbox](#get-replies--inbox)
38       - [Request](#request-4)
39       - [Response](#response-4)
40       - [HTTP](#http-5)
41     + [Get User Mentions](#get-user-mentions)
42       - [Request](#request-5)
43       - [Response](#response-5)
44       - [HTTP](#http-6)
45     + [Edit User Mention](#edit-user-mention)
46       - [Request](#request-6)
47       - [Response](#response-6)
48       - [HTTP](#http-7)
49     + [Mark All As Read](#mark-all-as-read)
50       - [Request](#request-7)
51       - [Response](#response-7)
52       - [HTTP](#http-8)
53     + [Delete Account](#delete-account)
54       - [Request](#request-8)
55       - [Response](#response-8)
56       - [HTTP](#http-9)
57     + [Add admin](#add-admin)
58       - [Request](#request-9)
59       - [Response](#response-9)
60       - [HTTP](#http-10)
61     + [Ban user](#ban-user)
62       - [Request](#request-10)
63       - [Response](#response-10)
64       - [HTTP](#http-11)
65   * [Site](#site)
66     + [List Categories](#list-categories)
67       - [Request](#request-11)
68       - [Response](#response-11)
69       - [HTTP](#http-12)
70     + [Search](#search)
71       - [Request](#request-12)
72       - [Response](#response-12)
73       - [HTTP](#http-13)
74     + [Get Modlog](#get-modlog)
75       - [Request](#request-13)
76       - [Response](#response-13)
77       - [HTTP](#http-14)
78     + [Create Site](#create-site)
79       - [Request](#request-14)
80       - [Response](#response-14)
81       - [HTTP](#http-15)
82     + [Edit Site](#edit-site)
83       - [Request](#request-15)
84       - [Response](#response-15)
85       - [HTTP](#http-16)
86     + [Get Site](#get-site)
87       - [Request](#request-16)
88       - [Response](#response-16)
89       - [HTTP](#http-17)
90     + [Transfer Site](#transfer-site)
91       - [Request](#request-17)
92       - [Response](#response-17)
93       - [HTTP](#http-18)
94   * [Community](#community)
95     + [Get Community](#get-community)
96       - [Request](#request-18)
97       - [Response](#response-18)
98       - [HTTP](#http-19)
99     + [Create Community](#create-community)
100       - [Request](#request-19)
101       - [Response](#response-19)
102       - [HTTP](#http-20)
103     + [List Communities](#list-communities)
104       - [Request](#request-20)
105       - [Response](#response-20)
106       - [HTTP](#http-21)
107     + [Ban from Community](#ban-from-community)
108       - [Request](#request-21)
109       - [Response](#response-21)
110       - [HTTP](#http-22)
111     + [Add Mod to Community](#add-mod-to-community)
112       - [Request](#request-22)
113       - [Response](#response-22)
114       - [HTTP](#http-23)
115     + [Edit Community](#edit-community)
116       - [Request](#request-23)
117       - [Response](#response-23)
118       - [HTTP](#http-24)
119     + [Follow Community](#follow-community)
120       - [Request](#request-24)
121       - [Response](#response-24)
122       - [HTTP](#http-25)
123     + [Get Followed Communities](#get-followed-communities)
124       - [Request](#request-25)
125       - [Response](#response-25)
126       - [HTTP](#http-26)
127     + [Transfer Community](#transfer-community)
128       - [Request](#request-26)
129       - [Response](#response-26)
130       - [HTTP](#http-27)
131   * [Post](#post)
132     + [Create Post](#create-post)
133       - [Request](#request-27)
134       - [Response](#response-27)
135       - [HTTP](#http-28)
136     + [Get Post](#get-post)
137       - [Request](#request-28)
138       - [Response](#response-28)
139       - [HTTP](#http-29)
140     + [Get Posts](#get-posts)
141       - [Request](#request-29)
142       - [Response](#response-29)
143       - [HTTP](#http-30)
144     + [Create Post Like](#create-post-like)
145       - [Request](#request-30)
146       - [Response](#response-30)
147       - [HTTP](#http-31)
148     + [Edit Post](#edit-post)
149       - [Request](#request-31)
150       - [Response](#response-31)
151       - [HTTP](#http-32)
152     + [Save Post](#save-post)
153       - [Request](#request-32)
154       - [Response](#response-32)
155       - [HTTP](#http-33)
156   * [Comment](#comment)
157     + [Create Comment](#create-comment)
158       - [Request](#request-33)
159       - [Response](#response-33)
160       - [HTTP](#http-34)
161     + [Edit Comment](#edit-comment)
162       - [Request](#request-34)
163       - [Response](#response-34)
164       - [HTTP](#http-35)
165     + [Save Comment](#save-comment)
166       - [Request](#request-35)
167       - [Response](#response-35)
168       - [HTTP](#http-36)
169     + [Create Comment Like](#create-comment-like)
170       - [Request](#request-36)
171       - [Response](#response-36)
172       - [HTTP](#http-37)
173   * [RSS / Atom feeds](#rss--atom-feeds)
174     + [All](#all)
175     + [Community](#community-1)
176     + [User](#user)
177
178 <!-- tocstop -->
179
180 ## Data types
181
182 - `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.
183 - <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***.
184 - <code>Vec<***SomeType***></code> is a list which contains objects of type ***SomeType***.
185 - `chrono::NaiveDateTime` is a timestamp string in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format. Timestamps will be UTC.
186 - Other data types are listed [here](../server/src/db).
187
188 ## Basic usage
189
190 Request and response strings are in [JSON format](https://www.json.org).
191
192 ### WebSocket
193
194 Connect to <code>ws://***host***/api/v1/ws</code> to get started.
195
196 If the ***`host`*** supports secure connections, you can use <code>wss://***host***/api/v1/ws</code>.
197
198 #### Testing with Websocat
199
200 [Websocat link](https://github.com/vi/websocat)
201
202 `websocat ws://127.0.0.1:8536/api/v1/ws -nt`
203
204 A simple test command:
205 `{"op": "ListCategories"}`
206
207 #### Testing with the WebSocket JavaScript API
208
209 [WebSocket JavaScript API](https://developer.mozilla.org/en-US/docs/Web/API/WebSockets_API)
210 ```javascript
211 var ws = new WebSocket("ws://" + host + "/api/v1/ws");
212 ws.onopen = function () {
213   console.log("Connection succeed!");
214   ws.send(JSON.stringify({
215     op: "ListCategories"
216   }));
217 };
218 ```
219 ### HTTP
220
221 Endpoints are at <code>http://***host***/api/v1/***endpoint***</code>. They'll be listed below for each action.
222
223 #### Testing with Curl
224
225 ##### Get Example
226
227 ```
228 curl /community/list?sort=Hot
229 ```
230
231 ##### Post Example
232
233 ```
234 curl -i -H \
235 "Content-Type: application/json" \
236 -X POST \
237 -d '{
238   comment_id: X,
239   pub post_id: X,
240   score: X,
241   auth: X,
242 }' \
243 /comment/like
244 ```
245
246 ## Rate limits
247
248 - 1 per hour for signups and community creation.
249 - 1 per 10 minutes for post creation.
250 - 30 actions per minute for post voting and comment creation.
251 - Everything else is not rate-limited.
252
253 ## Errors
254 ```rust
255 {
256   op: String,
257   message: String,
258 }
259 ```
260
261 ## API documentation
262
263 ### Sort Types
264
265 These go wherever there is a `sort` field. The available sort types are:
266
267 - `Hot` - the hottest posts/communities, depending on votes, views, comments and publish date
268 - `New` - the newest posts/communities
269 - `TopDay` - the most upvoted posts/communities of the current day.
270 - `TopWeek` - the most upvoted posts/communities of the current week.
271 - `TopMonth` - the most upvoted posts/communities of the current month.
272 - `TopYear` - the most upvoted posts/communities of the current year.
273 - `TopAll` - the most upvoted posts/communities on the current instance.
274
275 ### Websocket vs HTTP
276
277 - Below are the websocket JSON requests / responses. For HTTP, ignore all fields except those inside `data`.
278 - For example, an http login will be a `POST` `{username_or_email: X, password: X}`
279
280 ### User / Authentication / Admin actions
281
282 #### Login
283
284 The `jwt` string should be stored and used anywhere `auth` is called for.
285
286 ##### Request
287 ```rust
288 {
289   op: "Login",
290   data: {
291     username_or_email: String,
292     password: String
293   }
294 }
295 ```
296 ##### Response
297 ```rust
298 {
299   op: "Login",
300   data: {
301     jwt: String,
302   }
303 }
304 ```
305
306 ##### HTTP
307
308 `POST /user/login`
309
310 #### Register
311
312 Only the first user will be able to be the admin.
313
314 ##### Request
315 ```rust
316 {
317   op: "Register",
318   data: {
319     username: String,
320     email: Option<String>,
321     password: String,
322     password_verify: String,
323     admin: bool
324   }
325 }
326 ```
327 ##### Response
328 ```rust
329 {
330   op: "Register",
331   data: {
332     jwt: String,
333   }
334 }
335 ```
336
337 ##### HTTP
338
339 `POST /user/register`
340
341 #### Get User Details
342 ##### Request
343 ```rust
344 {
345   op: "GetUserDetails",
346   data: {
347     user_id: Option<i32>,
348     username: Option<String>,
349     sort: String,
350     page: Option<i64>,
351     limit: Option<i64>,
352     community_id: Option<i32>,
353     saved_only: bool,
354     auth: Option<String>,
355   }
356 }
357 ```
358 ##### Response
359 ```rust
360 {
361   op: "GetUserDetails",
362   data: {
363     user: UserView,
364     follows: Vec<CommunityFollowerView>,
365     moderates: Vec<CommunityModeratorView>,
366     comments: Vec<CommentView>,
367     posts: Vec<PostView>,
368   }
369 }
370 ```
371 ##### HTTP
372
373 `GET /user`
374
375 #### Save User Settings
376 ##### Request
377 ```rust
378 {
379   op: "SaveUserSettings",
380   data: {
381     show_nsfw: bool,
382     theme: String, // Default 'darkly'
383     default_sort_type: i16, // The Sort types from above, zero indexed as a number
384     default_listing_type: i16, // Post listing types are `All, Subscribed, Community`
385     auth: String
386   }
387 }
388 ```
389 ##### Response
390 ```rust
391 {
392   op: "SaveUserSettings",
393   data: {
394     jwt: String
395   }
396 }
397 ```
398 ##### HTTP
399
400 `PUT /save_user_settings`
401
402 #### Get Replies / Inbox
403 ##### Request
404 ```rust
405 {
406   op: "GetReplies",
407   data: {
408     sort: String,
409     page: Option<i64>,
410     limit: Option<i64>,
411     unread_only: bool,
412     auth: String
413   }
414 }
415 ```
416 ##### Response
417 ```rust
418 {
419   op: "GetReplies",
420   data: {
421     replies: Vec<ReplyView>,
422   }
423 }
424 ```
425 ##### HTTP
426
427 `GET /user/replies`
428
429
430 #### Get User Mentions
431 ##### Request
432 ```rust
433 {
434   op: "GetUserMentions",
435   data: {
436     sort: String,
437     page: Option<i64>,
438     limit: Option<i64>,
439     unread_only: bool,
440     auth: String,
441   }
442 }
443 ```
444 ##### Response
445 ```rust
446 {
447   op: "GetUserMentions",
448   data: {
449     mentions: Vec<UserMentionView>,
450   }
451 }
452 ```
453
454 ##### HTTP
455
456 `GET /user/mentions`
457
458 #### Edit User Mention
459 ##### Request
460 ```rust
461 {
462   op: "EditUserMention",
463   data: {
464     user_mention_id: i32,
465     read: Option<bool>,
466     auth: String,
467   }
468 }
469 ```
470 ##### Response
471 ```rust
472 {
473   op: "EditUserMention",
474   data: {
475     mention: UserMentionView,
476   }
477 }
478 ```
479 ##### HTTP
480
481 `PUT /user/mention`
482
483 #### Mark All As Read
484
485 Marks all user replies and mentions as read.
486
487 ##### Request
488 ```rust
489 {
490   op: "MarkAllAsRead",
491   data: {
492     auth: String
493   }
494 }
495 ```
496 ##### Response
497 ```rust
498 {
499   op: "MarkAllAsRead",
500   data: {
501     replies: Vec<ReplyView>,
502   }
503 }
504 ```
505
506 ##### HTTP
507
508 `POST /user/mark_all_as_read`
509
510 #### Delete Account
511
512 *Permananently deletes your posts and comments*
513
514 ##### Request
515 ```rust
516 {
517   op: "DeleteAccount",
518   data: {
519     password: String,
520     auth: String
521   }
522 }
523 ```
524 ##### Response
525 ```rust
526 {
527   op: "DeleteAccount",
528   data: {
529     jwt: String,
530   }
531 }
532 ```
533
534 ##### HTTP
535
536 `POST /user/delete_account`
537
538 #### Add admin
539 ##### Request
540 ```rust
541 {
542   op: "AddAdmin",
543   data: {
544     user_id: i32,
545     added: bool,
546     auth: String
547   }
548 }
549 ```
550 ##### Response
551 ```rust
552 {
553   op: "AddAdmin",
554   data: {
555     admins: Vec<UserView>,
556   }
557 }
558 ```
559 ##### HTTP
560
561 `POST /admin/add`
562
563 #### Ban user
564 ##### Request
565 ```rust
566 {
567   op: "BanUser",
568   data: {
569     user_id: i32,
570     ban: bool,
571     reason: Option<String>,
572     expires: Option<i64>,
573     auth: String
574   }
575 }
576 ```
577 ##### Response
578 ```rust
579 {
580   op: "BanUser",
581   data: {
582     user: UserView,
583     banned: bool,
584   }
585 }
586 ```
587 ##### HTTP
588
589 `POST /user/ban`
590
591 ### Site
592 #### List Categories
593 ##### Request
594 ```rust
595 {
596   op: "ListCategories"
597 }
598 ```
599 ##### Response
600 ```rust
601 {
602   op: "ListCategories",
603   data: {
604     categories: Vec<Category>
605   }
606 }
607 ```
608 ##### HTTP
609
610 `GET /categories`
611
612 #### Search
613
614 Search types are `Both, Comments, Posts`.
615
616 ##### Request
617 ```rust
618 {
619   op: "Search",
620   data: {
621     q: String,
622     type_: String,
623     community_id: Option<i32>,
624     sort: String,
625     page: Option<i64>,
626     limit: Option<i64>,
627   }
628 }
629 ```
630 ##### Response
631 ```rust
632 {
633   op: "Search",
634   data: {
635     comments: Vec<CommentView>,
636     posts: Vec<PostView>,
637   }
638 }
639 ```
640 ##### HTTP
641
642 `POST /search`
643
644 #### Get Modlog
645 ##### Request
646 ```rust
647 {
648   op: "GetModlog",
649   data: {
650     mod_user_id: Option<i32>,
651     community_id: Option<i32>,
652     page: Option<i64>,
653     limit: Option<i64>,
654   }
655 }
656 ```
657 ##### Response
658 ```rust
659 {
660   op: "GetModlog",
661   data: {
662     removed_posts: Vec<ModRemovePostView>,
663     locked_posts: Vec<ModLockPostView>,
664     removed_comments: Vec<ModRemoveCommentView>,
665     removed_communities: Vec<ModRemoveCommunityView>,
666     banned_from_community: Vec<ModBanFromCommunityView>,
667     banned: Vec<ModBanView>,
668     added_to_community: Vec<ModAddCommunityView>,
669     added: Vec<ModAddView>,
670   }
671 }
672 ```
673
674 ##### HTTP
675
676 `GET /modlog`
677
678 #### Create Site
679 ##### Request
680 ```rust
681 {
682   op: "CreateSite",
683   data: {
684     name: String,
685     description: Option<String>,
686     auth: String
687   }
688 }
689 ```
690 ##### Response
691 ```rust
692 {
693   op: "CreateSite",
694     data: {
695     site: SiteView,
696   }
697 }
698 ```
699
700 ##### HTTP
701
702 `POST /site`
703
704 #### Edit Site
705 ##### Request
706 ```rust
707 {
708   op: "EditSite",
709   data: {
710     name: String,
711     description: Option<String>,
712     auth: String
713   }
714 }
715 ```
716 ##### Response
717 ```rust
718 {
719   op: "EditSite",
720   data: {
721     site: SiteView,
722   }
723 }
724 ```
725 ##### HTTP
726
727 `PUT /site`
728
729 #### Get Site
730 ##### Request
731 ```rust
732 {
733   op: "GetSite"
734 }
735 ```
736 ##### Response
737 ```rust
738 {
739   op: "GetSite",
740   data: {
741     site: Option<SiteView>,
742     admins: Vec<UserView>,
743     banned: Vec<UserView>,
744   }
745 }
746 ```
747 ##### HTTP
748
749 `GET /site`
750
751 #### Transfer Site
752 ##### Request
753 ```rust
754 {
755   op: "TransferSite",
756   data: {
757     user_id: i32,
758     auth: String
759   }
760 }
761 ```
762 ##### Response
763 ```rust
764 {
765   op: "TransferSite",
766   data: {
767     site: Option<SiteView>,
768     admins: Vec<UserView>,
769     banned: Vec<UserView>,
770   }
771 }
772 ```
773 ##### HTTP
774
775 `POST /site/transfer`
776
777 ### Community
778 #### Get Community
779 ##### Request
780 ```rust
781 {
782   op: "GetCommunity",
783   data: {
784     id: Option<i32>,
785     name: Option<String>,
786     auth: Option<String>
787   }
788 }
789 ```
790 ##### Response
791 ```rust
792 {
793   op: "GetCommunity",
794   data: {
795     community: CommunityView,
796     moderators: Vec<CommunityModeratorView>,
797     admins: Vec<UserView>,
798   }
799 }
800 ```
801 ##### HTTP
802
803 `GET /community`
804
805 #### Create Community
806 ##### Request
807 ```rust
808 {
809   op: "CreateCommunity",
810   data: {
811     name: String,
812     title: String,
813     description: Option<String>,
814     category_id: i32 ,
815     auth: String
816   }
817 }
818 ```
819 ##### Response
820 ```rust
821 {
822   op: "CreateCommunity",
823   data: {
824     community: CommunityView
825   }
826 }
827 ```
828 ##### HTTP
829
830 `POST /community`
831
832 #### List Communities
833 ##### Request
834 ```rust
835 {
836   op: "ListCommunities",
837   data: {
838     sort: String,
839     page: Option<i64>,
840     limit: Option<i64>,
841     auth: Option<String>
842   }
843 }
844 ```
845 ##### Response
846 ```rust
847 {
848   op: "ListCommunities",
849   data: {
850     communities: Vec<CommunityView>
851   }
852 }
853 ```
854 ##### HTTP
855
856 `GET /community/list`
857
858 #### Ban from Community
859 ##### Request
860 ```rust
861 {
862   op: "BanFromCommunity",
863   data: {
864     community_id: i32,
865     user_id: i32,
866     ban: bool,
867     reason: Option<String>,
868     expires: Option<i64>,
869     auth: String
870   }
871 }
872 ```
873 ##### Response
874 ```rust
875 {
876   op: "BanFromCommunity",
877   data: {
878     user: UserView,
879     banned: bool,
880   }
881 }
882 ```
883 ##### HTTP
884
885 `POST /community/ban_user`
886
887 #### Add Mod to Community
888 ##### Request
889 ```rust
890 {
891   op: "AddModToCommunity",
892   data: {
893     community_id: i32,
894     user_id: i32,
895     added: bool,
896     auth: String
897   }
898 }
899 ```
900 ##### Response
901 ```rust
902 {
903   op: "AddModToCommunity",
904   data: {
905     moderators: Vec<CommunityModeratorView>,
906   }
907 }
908 ```
909 ##### HTTP
910
911 `POST /community/mod`
912
913 #### Edit Community
914 Mods and admins can remove and lock a community, creators can delete it.
915
916 ##### Request
917 ```rust
918 {
919   op: "EditCommunity",
920   data: {
921     edit_id: i32,
922     name: String,
923     title: String,
924     description: Option<String>,
925     category_id: i32,
926     removed: Option<bool>,
927     deleted: Option<bool>,
928     reason: Option<String>,
929     expires: Option<i64>,
930     auth: String
931   }
932 }
933 ```
934 ##### Response
935 ```rust
936 {
937   op: "EditCommunity",
938   data: {
939     community: CommunityView
940   }
941 }
942 ```
943 ##### HTTP
944
945 `PUT /community`
946
947 #### Follow Community
948 ##### Request
949 ```rust
950 {
951   op: "FollowCommunity",
952   data: {
953     community_id: i32,
954     follow: bool,
955     auth: String
956   }
957 }
958 ```
959 ##### Response
960 ```rust
961 {
962   op: "FollowCommunity",
963   data: {
964     community: CommunityView
965   }
966 }
967 ```
968 ##### HTTP
969
970 `POST /community/follow`
971
972 #### Get Followed Communities
973 ##### Request
974 ```rust
975 {
976   op: "GetFollowedCommunities",
977   data: {
978     auth: String
979   }
980 }
981 ```
982 ##### Response
983 ```rust
984 {
985   op: "GetFollowedCommunities",
986   data: {
987     communities: Vec<CommunityFollowerView>
988   }
989 }
990 ```
991 ##### HTTP
992
993 `GET /user/followed_communities`
994
995 #### Transfer Community
996 ##### Request
997 ```rust
998 {
999   op: "TransferCommunity",
1000   data: {
1001     community_id: i32,
1002     user_id: i32,
1003     auth: String
1004   }
1005 }
1006 ```
1007 ##### Response
1008 ```rust
1009 {
1010   op: "TransferCommunity",
1011   data: {
1012     community: CommunityView,
1013     moderators: Vec<CommunityModeratorView>,
1014     admins: Vec<UserView>,
1015   }
1016 }
1017 ```
1018 ##### HTTP
1019
1020 `POST /community/transfer`
1021
1022 ### Post
1023 #### Create Post
1024 ##### Request
1025 ```rust
1026 {
1027   op: "CreatePost",
1028   data: {
1029     name: String,
1030     url: Option<String>,
1031     body: Option<String>,
1032     community_id: i32,
1033     auth: String
1034   }
1035 }
1036 ```
1037 ##### Response
1038 ```rust
1039 {
1040   op: "CreatePost",
1041   data: {
1042     post: PostView
1043   }
1044 }
1045 ```
1046 ##### HTTP
1047
1048 `POST /post`
1049
1050 #### Get Post
1051 ##### Request
1052 ```rust
1053 {
1054   op: "GetPost",
1055   data: {
1056     id: i32,
1057     auth: Option<String>
1058   }
1059 }
1060 ```
1061 ##### Response
1062 ```rust
1063 {
1064   op: "GetPost",
1065   data: {
1066     post: PostView,
1067     comments: Vec<CommentView>,
1068     community: CommunityView,
1069     moderators: Vec<CommunityModeratorView>,
1070     admins: Vec<UserView>,
1071   }
1072 }
1073 ```
1074 ##### HTTP
1075
1076 `GET /post`
1077
1078 #### Get Posts
1079
1080 Post listing types are `All, Subscribed, Community`
1081
1082 ##### Request
1083 ```rust
1084 {
1085   op: "GetPosts",
1086   data: {
1087     type_: String,
1088     sort: String,
1089     page: Option<i64>,
1090     limit: Option<i64>,
1091     community_id: Option<i32>,
1092     auth: Option<String>
1093   }
1094 }
1095 ```
1096 ##### Response
1097 ```rust
1098 {
1099   op: "GetPosts",
1100   data: {
1101     posts: Vec<PostView>,
1102   }
1103 }
1104 ```
1105 ##### HTTP
1106
1107 `GET /post/list`
1108
1109 #### Create Post Like
1110
1111 `score` can be 0, -1, or 1
1112
1113 ##### Request
1114 ```rust
1115 {
1116   op: "CreatePostLike",
1117   data: {
1118     post_id: i32,
1119     score: i16,
1120     auth: String
1121   }
1122 }
1123 ```
1124 ##### Response
1125 ```rust
1126 {
1127   op: "CreatePostLike",
1128   data: {
1129     post: PostView
1130   }
1131 }
1132 ```
1133 ##### HTTP
1134
1135 `POST /post/like`
1136
1137 #### Edit Post
1138
1139 Mods and admins can remove and lock a post, creators can delete it.
1140
1141 ##### Request
1142 ```rust
1143 {
1144   op: "EditPost",
1145   data: {
1146     edit_id: i32,
1147     creator_id: i32,
1148     community_id: i32,
1149     name: String,
1150     url: Option<String>,
1151     body: Option<String>,
1152     removed: Option<bool>,
1153     deleted: Option<bool>,
1154     locked: Option<bool>,
1155     reason: Option<String>,
1156     auth: String
1157   }
1158 }
1159 ```
1160 ##### Response
1161 ```rust
1162 {
1163   op: "EditPost",
1164   data: {
1165     post: PostView
1166   }
1167 }
1168 ```
1169
1170 ##### HTTP
1171
1172 `PUT /post`
1173
1174 #### Save Post
1175 ##### Request
1176 ```rust
1177 {
1178   op: "SavePost",
1179   data: {
1180     post_id: i32,
1181     save: bool,
1182     auth: String
1183   }
1184 }
1185 ```
1186 ##### Response
1187 ```rust
1188 {
1189   op: "SavePost",
1190   data: {
1191     post: PostView
1192   }
1193 }
1194 ```
1195 ##### HTTP
1196
1197 `POST /post/save`
1198
1199 ### Comment
1200 #### Create Comment
1201 ##### Request
1202 ```rust
1203 {
1204   op: "CreateComment",
1205   data: {
1206     content: String,
1207     parent_id: Option<i32>,
1208     edit_id: Option<i32>,
1209     post_id: i32,
1210     auth: String
1211   }
1212 }
1213 ```
1214 ##### Response
1215 ```rust
1216 {
1217   op: "CreateComment",
1218   data: {
1219     comment: CommentView
1220   }
1221 }
1222 ```
1223
1224 ##### HTTP
1225
1226 `POST /comment`
1227
1228 #### Edit Comment
1229
1230 Mods and admins can remove a comment, creators can delete it.
1231
1232 ##### Request
1233 ```rust
1234 {
1235   op: "EditComment",
1236   data: {
1237     content: String,
1238     parent_id: Option<i32>,
1239     edit_id: i32,
1240     creator_id: i32,
1241     post_id: i32,
1242     removed: Option<bool>,
1243     deleted: Option<bool>,
1244     reason: Option<String>,
1245     read: Option<bool>,
1246     auth: String
1247   }
1248 }
1249 ```
1250 ##### Response
1251 ```rust
1252 {
1253   op: "EditComment",
1254   data: {
1255     comment: CommentView
1256   }
1257 }
1258 ```
1259 ##### HTTP
1260
1261 `PUT /comment`
1262
1263 #### Save Comment
1264 ##### Request
1265 ```rust
1266 {
1267   op: "SaveComment",
1268   data: {
1269     comment_id: i32,
1270     save: bool,
1271     auth: String
1272   }
1273 }
1274 ```
1275 ##### Response
1276 ```rust
1277 {
1278   op: "SaveComment",
1279   data: {
1280     comment: CommentView
1281   }
1282 }
1283 ```
1284 ##### HTTP
1285
1286 `POST /comment/save`
1287
1288 #### Create Comment Like
1289
1290 `score` can be 0, -1, or 1
1291
1292 ##### Request
1293 ```rust
1294 {
1295   op: "CreateCommentLike",
1296   data: {
1297     comment_id: i32,
1298     post_id: i32,
1299     score: i16,
1300     auth: String
1301   }
1302 }
1303 ```
1304 ##### Response
1305 ```rust
1306 {
1307   op: "CreateCommentLike",
1308   data: {
1309     comment: CommentView
1310   }
1311 }
1312 ```
1313 ##### HTTP
1314
1315 `POST /comment/like`
1316
1317 ### RSS / Atom feeds
1318
1319 #### All
1320
1321 `/feeds/all.xml?sort=Hot`
1322
1323 #### Community
1324
1325 `/feeds/c/community-name.xml?sort=Hot`
1326
1327 #### User
1328
1329 `/feeds/u/user-name.xml?sort=Hot`
1330