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