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