]> Untitled Git - lemmy.git/blob - docs/src/contributing_websocket_http_api.md
Merge remote-tracking branch 'nutomic/http-api' into dessalines-http-api
[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 `All, Comments, Posts, Communities, Users, Url`
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     auth?: Option<String>,
628   }
629 }
630 ```
631 ##### Response
632 ```rust
633 {
634   op: "Search",
635   data: {
636     type_: String,
637     comments: Vec<CommentView>,
638     posts: Vec<PostView>,
639     communities: Vec<CommunityView>,
640     users: Vec<UserView>,
641   }
642 }
643 ```
644 ##### HTTP
645
646 `POST /search`
647
648 #### Get Modlog
649 ##### Request
650 ```rust
651 {
652   op: "GetModlog",
653   data: {
654     mod_user_id: Option<i32>,
655     community_id: Option<i32>,
656     page: Option<i64>,
657     limit: Option<i64>,
658   }
659 }
660 ```
661 ##### Response
662 ```rust
663 {
664   op: "GetModlog",
665   data: {
666     removed_posts: Vec<ModRemovePostView>,
667     locked_posts: Vec<ModLockPostView>,
668     removed_comments: Vec<ModRemoveCommentView>,
669     removed_communities: Vec<ModRemoveCommunityView>,
670     banned_from_community: Vec<ModBanFromCommunityView>,
671     banned: Vec<ModBanView>,
672     added_to_community: Vec<ModAddCommunityView>,
673     added: Vec<ModAddView>,
674   }
675 }
676 ```
677
678 ##### HTTP
679
680 `GET /modlog`
681
682 #### Create Site
683 ##### Request
684 ```rust
685 {
686   op: "CreateSite",
687   data: {
688     name: String,
689     description: Option<String>,
690     auth: String
691   }
692 }
693 ```
694 ##### Response
695 ```rust
696 {
697   op: "CreateSite",
698     data: {
699     site: SiteView,
700   }
701 }
702 ```
703
704 ##### HTTP
705
706 `POST /site`
707
708 #### Edit Site
709 ##### Request
710 ```rust
711 {
712   op: "EditSite",
713   data: {
714     name: String,
715     description: Option<String>,
716     auth: String
717   }
718 }
719 ```
720 ##### Response
721 ```rust
722 {
723   op: "EditSite",
724   data: {
725     site: SiteView,
726   }
727 }
728 ```
729 ##### HTTP
730
731 `PUT /site`
732
733 #### Get Site
734 ##### Request
735 ```rust
736 {
737   op: "GetSite"
738 }
739 ```
740 ##### Response
741 ```rust
742 {
743   op: "GetSite",
744   data: {
745     site: Option<SiteView>,
746     admins: Vec<UserView>,
747     banned: Vec<UserView>,
748   }
749 }
750 ```
751 ##### HTTP
752
753 `GET /site`
754
755 #### Transfer Site
756 ##### Request
757 ```rust
758 {
759   op: "TransferSite",
760   data: {
761     user_id: i32,
762     auth: String
763   }
764 }
765 ```
766 ##### Response
767 ```rust
768 {
769   op: "TransferSite",
770   data: {
771     site: Option<SiteView>,
772     admins: Vec<UserView>,
773     banned: Vec<UserView>,
774   }
775 }
776 ```
777 ##### HTTP
778
779 `POST /site/transfer`
780
781 ### Community
782 #### Get Community
783 ##### Request
784 ```rust
785 {
786   op: "GetCommunity",
787   data: {
788     id: Option<i32>,
789     name: Option<String>,
790     auth: Option<String>
791   }
792 }
793 ```
794 ##### Response
795 ```rust
796 {
797   op: "GetCommunity",
798   data: {
799     community: CommunityView,
800     moderators: Vec<CommunityModeratorView>,
801     admins: Vec<UserView>,
802   }
803 }
804 ```
805 ##### HTTP
806
807 `GET /community`
808
809 #### Create Community
810 ##### Request
811 ```rust
812 {
813   op: "CreateCommunity",
814   data: {
815     name: String,
816     title: String,
817     description: Option<String>,
818     category_id: i32 ,
819     auth: String
820   }
821 }
822 ```
823 ##### Response
824 ```rust
825 {
826   op: "CreateCommunity",
827   data: {
828     community: CommunityView
829   }
830 }
831 ```
832 ##### HTTP
833
834 `POST /community`
835
836 #### List Communities
837 ##### Request
838 ```rust
839 {
840   op: "ListCommunities",
841   data: {
842     sort: String,
843     page: Option<i64>,
844     limit: Option<i64>,
845     auth: Option<String>
846   }
847 }
848 ```
849 ##### Response
850 ```rust
851 {
852   op: "ListCommunities",
853   data: {
854     communities: Vec<CommunityView>
855   }
856 }
857 ```
858 ##### HTTP
859
860 `GET /community/list`
861
862 #### Ban from Community
863 ##### Request
864 ```rust
865 {
866   op: "BanFromCommunity",
867   data: {
868     community_id: i32,
869     user_id: i32,
870     ban: bool,
871     reason: Option<String>,
872     expires: Option<i64>,
873     auth: String
874   }
875 }
876 ```
877 ##### Response
878 ```rust
879 {
880   op: "BanFromCommunity",
881   data: {
882     user: UserView,
883     banned: bool,
884   }
885 }
886 ```
887 ##### HTTP
888
889 `POST /community/ban_user`
890
891 #### Add Mod to Community
892 ##### Request
893 ```rust
894 {
895   op: "AddModToCommunity",
896   data: {
897     community_id: i32,
898     user_id: i32,
899     added: bool,
900     auth: String
901   }
902 }
903 ```
904 ##### Response
905 ```rust
906 {
907   op: "AddModToCommunity",
908   data: {
909     moderators: Vec<CommunityModeratorView>,
910   }
911 }
912 ```
913 ##### HTTP
914
915 `POST /community/mod`
916
917 #### Edit Community
918 Mods and admins can remove and lock a community, creators can delete it.
919
920 ##### Request
921 ```rust
922 {
923   op: "EditCommunity",
924   data: {
925     edit_id: i32,
926     name: String,
927     title: String,
928     description: Option<String>,
929     category_id: i32,
930     removed: Option<bool>,
931     deleted: Option<bool>,
932     reason: Option<String>,
933     expires: Option<i64>,
934     auth: String
935   }
936 }
937 ```
938 ##### Response
939 ```rust
940 {
941   op: "EditCommunity",
942   data: {
943     community: CommunityView
944   }
945 }
946 ```
947 ##### HTTP
948
949 `PUT /community`
950
951 #### Follow Community
952 ##### Request
953 ```rust
954 {
955   op: "FollowCommunity",
956   data: {
957     community_id: i32,
958     follow: bool,
959     auth: String
960   }
961 }
962 ```
963 ##### Response
964 ```rust
965 {
966   op: "FollowCommunity",
967   data: {
968     community: CommunityView
969   }
970 }
971 ```
972 ##### HTTP
973
974 `POST /community/follow`
975
976 #### Get Followed Communities
977 ##### Request
978 ```rust
979 {
980   op: "GetFollowedCommunities",
981   data: {
982     auth: String
983   }
984 }
985 ```
986 ##### Response
987 ```rust
988 {
989   op: "GetFollowedCommunities",
990   data: {
991     communities: Vec<CommunityFollowerView>
992   }
993 }
994 ```
995 ##### HTTP
996
997 `GET /user/followed_communities`
998
999 #### Transfer Community
1000 ##### Request
1001 ```rust
1002 {
1003   op: "TransferCommunity",
1004   data: {
1005     community_id: i32,
1006     user_id: i32,
1007     auth: String
1008   }
1009 }
1010 ```
1011 ##### Response
1012 ```rust
1013 {
1014   op: "TransferCommunity",
1015   data: {
1016     community: CommunityView,
1017     moderators: Vec<CommunityModeratorView>,
1018     admins: Vec<UserView>,
1019   }
1020 }
1021 ```
1022 ##### HTTP
1023
1024 `POST /community/transfer`
1025
1026 ### Post
1027 #### Create Post
1028 ##### Request
1029 ```rust
1030 {
1031   op: "CreatePost",
1032   data: {
1033     name: String,
1034     url: Option<String>,
1035     body: Option<String>,
1036     community_id: i32,
1037     auth: String
1038   }
1039 }
1040 ```
1041 ##### Response
1042 ```rust
1043 {
1044   op: "CreatePost",
1045   data: {
1046     post: PostView
1047   }
1048 }
1049 ```
1050 ##### HTTP
1051
1052 `POST /post`
1053
1054 #### Get Post
1055 ##### Request
1056 ```rust
1057 {
1058   op: "GetPost",
1059   data: {
1060     id: i32,
1061     auth: Option<String>
1062   }
1063 }
1064 ```
1065 ##### Response
1066 ```rust
1067 {
1068   op: "GetPost",
1069   data: {
1070     post: PostView,
1071     comments: Vec<CommentView>,
1072     community: CommunityView,
1073     moderators: Vec<CommunityModeratorView>,
1074     admins: Vec<UserView>,
1075   }
1076 }
1077 ```
1078 ##### HTTP
1079
1080 `GET /post`
1081
1082 #### Get Posts
1083
1084 Post listing types are `All, Subscribed, Community`
1085
1086 ##### Request
1087 ```rust
1088 {
1089   op: "GetPosts",
1090   data: {
1091     type_: String,
1092     sort: String,
1093     page: Option<i64>,
1094     limit: Option<i64>,
1095     community_id: Option<i32>,
1096     auth: Option<String>
1097   }
1098 }
1099 ```
1100 ##### Response
1101 ```rust
1102 {
1103   op: "GetPosts",
1104   data: {
1105     posts: Vec<PostView>,
1106   }
1107 }
1108 ```
1109 ##### HTTP
1110
1111 `GET /post/list`
1112
1113 #### Create Post Like
1114
1115 `score` can be 0, -1, or 1
1116
1117 ##### Request
1118 ```rust
1119 {
1120   op: "CreatePostLike",
1121   data: {
1122     post_id: i32,
1123     score: i16,
1124     auth: String
1125   }
1126 }
1127 ```
1128 ##### Response
1129 ```rust
1130 {
1131   op: "CreatePostLike",
1132   data: {
1133     post: PostView
1134   }
1135 }
1136 ```
1137 ##### HTTP
1138
1139 `POST /post/like`
1140
1141 #### Edit Post
1142
1143 Mods and admins can remove and lock a post, creators can delete it.
1144
1145 ##### Request
1146 ```rust
1147 {
1148   op: "EditPost",
1149   data: {
1150     edit_id: i32,
1151     creator_id: i32,
1152     community_id: i32,
1153     name: String,
1154     url: Option<String>,
1155     body: Option<String>,
1156     removed: Option<bool>,
1157     deleted: Option<bool>,
1158     locked: Option<bool>,
1159     reason: Option<String>,
1160     auth: String
1161   }
1162 }
1163 ```
1164 ##### Response
1165 ```rust
1166 {
1167   op: "EditPost",
1168   data: {
1169     post: PostView
1170   }
1171 }
1172 ```
1173
1174 ##### HTTP
1175
1176 `PUT /post`
1177
1178 #### Save Post
1179 ##### Request
1180 ```rust
1181 {
1182   op: "SavePost",
1183   data: {
1184     post_id: i32,
1185     save: bool,
1186     auth: String
1187   }
1188 }
1189 ```
1190 ##### Response
1191 ```rust
1192 {
1193   op: "SavePost",
1194   data: {
1195     post: PostView
1196   }
1197 }
1198 ```
1199 ##### HTTP
1200
1201 `POST /post/save`
1202
1203 ### Comment
1204 #### Create Comment
1205 ##### Request
1206 ```rust
1207 {
1208   op: "CreateComment",
1209   data: {
1210     content: String,
1211     parent_id: Option<i32>,
1212     edit_id: Option<i32>,
1213     post_id: i32,
1214     auth: String
1215   }
1216 }
1217 ```
1218 ##### Response
1219 ```rust
1220 {
1221   op: "CreateComment",
1222   data: {
1223     comment: CommentView
1224   }
1225 }
1226 ```
1227
1228 ##### HTTP
1229
1230 `POST /comment`
1231
1232 #### Edit Comment
1233
1234 Mods and admins can remove a comment, creators can delete it.
1235
1236 ##### Request
1237 ```rust
1238 {
1239   op: "EditComment",
1240   data: {
1241     content: String,
1242     parent_id: Option<i32>,
1243     edit_id: i32,
1244     creator_id: i32,
1245     post_id: i32,
1246     removed: Option<bool>,
1247     deleted: Option<bool>,
1248     reason: Option<String>,
1249     read: Option<bool>,
1250     auth: String
1251   }
1252 }
1253 ```
1254 ##### Response
1255 ```rust
1256 {
1257   op: "EditComment",
1258   data: {
1259     comment: CommentView
1260   }
1261 }
1262 ```
1263 ##### HTTP
1264
1265 `PUT /comment`
1266
1267 #### Save Comment
1268 ##### Request
1269 ```rust
1270 {
1271   op: "SaveComment",
1272   data: {
1273     comment_id: i32,
1274     save: bool,
1275     auth: String
1276   }
1277 }
1278 ```
1279 ##### Response
1280 ```rust
1281 {
1282   op: "SaveComment",
1283   data: {
1284     comment: CommentView
1285   }
1286 }
1287 ```
1288 ##### HTTP
1289
1290 `POST /comment/save`
1291
1292 #### Create Comment Like
1293
1294 `score` can be 0, -1, or 1
1295
1296 ##### Request
1297 ```rust
1298 {
1299   op: "CreateCommentLike",
1300   data: {
1301     comment_id: i32,
1302     post_id: i32,
1303     score: i16,
1304     auth: String
1305   }
1306 }
1307 ```
1308 ##### Response
1309 ```rust
1310 {
1311   op: "CreateCommentLike",
1312   data: {
1313     comment: CommentView
1314   }
1315 }
1316 ```
1317 ##### HTTP
1318
1319 `POST /comment/like`
1320
1321 ### RSS / Atom feeds
1322
1323 #### All
1324
1325 `/feeds/all.xml?sort=Hot`
1326
1327 #### Community
1328
1329 `/feeds/c/community-name.xml?sort=Hot`
1330
1331 #### User
1332
1333 `/feeds/u/user-name.xml?sort=Hot`
1334