Module Reddit_api_kernel.Endpoint

module Parameters : sig ... end
module Sequencer : sig ... end

A Sequencer.t represents an endpoint that cannot have multiple requests in flight simultaneously.

module Request : sig ... end
module Json_response_error : sig ... end
module Error : sig ... end

An Error.t represents a "normal" error when making an API request.

type 'a t = {
  1. request : Request.t;
  2. handle_response : (Cohttp.Response.t * Cohttp.Body.t) -> ('a, Error.t) Core.Result.t;
  3. sequencer : Sequencer.t option;
}

A t represents the combinaton of an HTTP request to Reddit and a function for turning the HTTP response into a typed representation.

val map : 'a t -> f:('a -> 'b) -> 'b t
type 'a with_listing_params := ?pagination:Listing.Pagination.t -> ?count:int -> ?limit:int -> ?show_all:unit -> 'a

A value of type _ with_listing_params is a function with optional arguments representing Reddit's "listing" pagination protocol.

Endpoints

Account

val me : Thing.User.t t
val karma : Karma_list.t t
val trophies : Thing.Award.t list t
val friends : (unit -> User_list.t t) with_listing_params
val blocked : (unit -> User_list.t t) with_listing_params
val messaging : (unit -> User_list.t t) with_listing_params
val trusted : (unit -> User_list.t t) with_listing_params

Flair

val select_flair : ?background_color:Parameters.Color.t -> ?css_class:string -> ?flair_template_id:Uuid.t -> ?text:string -> ?text_color:Parameters.Color.t -> unit -> subreddit:Subreddit_name.t -> target:Parameters.Flair_target.t -> unit t
val add_comment : ?return_rtjson:bool -> ?richtext_json:Jsonaf.t -> unit -> parent:[< `Link of Thing.Link.Id.t | `Comment of Thing.Comment.Id.t ] -> text:string -> Thing.Comment.t t
val reply_to_message : ?return_rtjson:bool -> ?richtext_json:Jsonaf.t -> unit -> parent:Thing.Message.Id.t -> text:string -> Thing.Message.t t
val delete : id:[< `Link of Thing.Link.Id.t | `Comment of Thing.Comment.Id.t ] -> unit t
val edit : ?return_rtjson:bool -> ?richtext_json:Jsonaf.t -> unit -> id:[< `Link of Thing.Link.Id.t | `Comment of Thing.Comment.Id.t ] -> text:string -> [> `Link of Thing.Link.t | `Comment of Thing.Comment.t ] t
val hide : links:Thing.Link.Id.t list -> unit t
val unhide : links:Thing.Link.Id.t list -> unit t
val lock : id:[< `Link of Thing.Link.Id.t | `Comment of Thing.Comment.Id.t ] -> unit t
val unlock : id:[< `Link of Thing.Link.Id.t | `Comment of Thing.Comment.Id.t ] -> unit t
val mark_nsfw : link:Thing.Link.Id.t -> unit t
val unmark_nsfw : link:Thing.Link.Id.t -> unit t
val more_children : ?limit_children:bool -> unit -> link:Thing.Link.Id.t -> more_comments:Thing.More_comments.Details.By_children.t -> sort:Parameters.Comment_sort.t -> [ `Comment of Thing.Comment.t | `More_comments of Thing.More_comments.t ] list t
val report : ?from_modmail:bool -> ?from_help_desk:bool -> ?additional_info:string -> ?custom_text:string -> ?other_reason:string -> ?rule_reason:string -> ?site_reason:string -> ?sr_name:string -> unit -> target: [< `Link of Thing.Link.Id.t | `Comment of Thing.Comment.Id.t | `Message of Thing.Message.Id.t | `Modmail_conversation of Thing.Modmail_conversation.Id.t ] -> reason:string -> unit t
val report_award : award_id:string -> (Cohttp.Response.t * Cohttp.Body.t) t
val save : ?category:string -> unit -> id:[< `Link of Thing.Link.Id.t | `Comment of Thing.Comment.Id.t ] -> unit t
val unsave : id:[< `Link of Thing.Link.Id.t | `Comment of Thing.Comment.Id.t ] -> unit t
val saved_categories : (Cohttp.Response.t * Cohttp.Body.t) t
val send_replies : id:[< `Link of Thing.Link.Id.t | `Comment of Thing.Comment.Id.t ] -> enabled:bool -> unit t
val set_contest_mode : link:Thing.Link.Id.t -> enabled:bool -> unit t
val set_subreddit_sticky : ?to_profile:bool -> unit -> link:Thing.Link.Id.t -> sticky_state:Parameters.Sticky_state.t -> unit t
val set_suggested_sort : link:Thing.Link.Id.t -> sort:Parameters.Comment_sort.t option -> unit t
val spoiler : link:Thing.Link.Id.t -> unit t
val unspoiler : link:Thing.Link.Id.t -> unit t
val store_visits : links:Thing.Link.Id.t list -> (Cohttp.Response.t * Cohttp.Body.t) t
val submit : ?ad:bool -> ?nsfw:bool -> ?resubmit:bool -> ?sendreplies:bool -> ?spoiler:bool -> ?flair_id:string -> ?flair_text:string -> ?collection_id:string -> ?event_start:Core.Time_ns.t -> ?event_end:Core.Time_ns.t -> ?event_tz:string -> unit -> subreddit:Subreddit_name.t -> title:string -> kind:Parameters.Link_kind.t -> (Thing.Link.Id.t * Uri.t) t
val vote : ?rank:int -> unit -> direction:Parameters.Vote_direction.t -> target:[< `Link of Thing.Link.Id.t | `Comment of Thing.Comment.Id.t ] -> unit t
val info : Parameters.Info_query.t -> [ `Comment of Thing.Comment.t | `Link of Thing.Link.t | `Subreddit of Thing.Subreddit.t ] list t

Listings

val best : (?include_categories:bool -> unit -> Thing.Link.t Listing.t t) with_listing_params
val comments : ?subreddit:Subreddit_name.t -> ?comment:Thing.Comment.Id.t -> ?context:int -> ?depth:int -> ?limit:int -> ?showedits:bool -> ?showmore:bool -> ?sort:Parameters.Comment_sort.t -> ?threaded:bool -> ?truncate:int -> unit -> link:Thing.Link.Id.t -> Comment_response.t t
val duplicates : (?crossposts_only:bool -> ?sort:Parameters.Duplicate_sort.t -> unit -> link:Thing.Link.Id.t -> Thing.Link.t Listing.t t) with_listing_params
val hot : (?location:string -> ?include_categories:bool -> ?subreddit:Subreddit_name.t -> unit -> Thing.Link.t Listing.t t) with_listing_params
val new_ : (?include_categories:bool -> ?subreddit:Subreddit_name.t -> unit -> Thing.Link.t Listing.t t) with_listing_params
val rising : (?include_categories:bool -> ?subreddit:Subreddit_name.t -> unit -> Thing.Link.t Listing.t t) with_listing_params
val top : (?since:Parameters.Historical_span.t -> ?include_categories:bool -> ?subreddit:Subreddit_name.t -> unit -> Thing.Link.t Listing.t t) with_listing_params
val controversial : (?since:Parameters.Historical_span.t -> ?include_categories:bool -> ?subreddit:Subreddit_name.t -> unit -> Thing.Link.t Listing.t t) with_listing_params
val random : ?subreddit:Subreddit_name.t -> unit -> Thing.Link.Id.t t

Private messages

val block_author : id:[< `Comment of Thing.Comment.Id.t | `Message of Thing.Message.Id.t ] -> unit t
val collapse_message : messages:Thing.Message.Id.t list -> unit t
val uncollapse_message : messages:Thing.Message.Id.t list -> unit t
val compose_message : ?g_recaptcha_response:string -> ?from_subreddit:Subreddit_name.t -> unit -> to_:Username.t -> subject:string -> text:string -> unit t
val delete_message : message:Thing.Message.Id.t -> (Cohttp.Response.t * Cohttp.Body.t) t
val read_message : messages:Thing.Message.Id.t list -> unit t
val unread_message : messages:Thing.Message.Id.t list -> unit t
val inbox : (?include_categories:bool -> ?mid:string -> unit -> mark_read:bool -> Inbox_item.t Listing.t t) with_listing_params
val unread : (?include_categories:bool -> ?mid:string -> unit -> mark_read:bool -> Inbox_item.t Listing.t t) with_listing_params
val sent : (?include_categories:bool -> ?mid:string -> unit -> Thing.Message.t Listing.t t) with_listing_params
val comment_replies : (?include_categories:bool -> ?mid:string -> unit -> mark_read:bool -> Inbox_item.Comment.t Listing.t t) with_listing_params
val subreddit_comments : (unit -> subreddit:Subreddit_name.t -> Thing.Comment.t Listing.t t) with_listing_params

Moderation

val log : (?mod_filter:Parameters.Mod_filter.t -> ?subreddit:Subreddit_name.t -> ?type_:string -> unit -> Mod_action.t Listing.t t) with_listing_params
val reports : (?location:string -> ?only:Parameters.Links_or_comments.t -> ?subreddit:Subreddit_name.t -> unit -> [ `Link of Thing.Link.t | `Comment of Thing.Comment.t ] Listing.t t) with_listing_params
val spam : (?location:string -> ?only:Parameters.Links_or_comments.t -> ?subreddit:Subreddit_name.t -> unit -> [ `Link of Thing.Link.t | `Comment of Thing.Comment.t ] Listing.t t) with_listing_params
val modqueue : (?location:string -> ?only:Parameters.Links_or_comments.t -> ?subreddit:Subreddit_name.t -> unit -> [ `Link of Thing.Link.t | `Comment of Thing.Comment.t ] Listing.t t) with_listing_params
val unmoderated : (?location:string -> ?only:Parameters.Links_or_comments.t -> ?subreddit:Subreddit_name.t -> unit -> [ `Link of Thing.Link.t | `Comment of Thing.Comment.t ] Listing.t t) with_listing_params
val edited : (?location:string -> ?only:Parameters.Links_or_comments.t -> ?subreddit:Subreddit_name.t -> unit -> [ `Link of Thing.Link.t | `Comment of Thing.Comment.t ] Listing.t t) with_listing_params
val accept_moderator_invite : subreddit:Subreddit_name.t -> (Cohttp.Response.t * Cohttp.Body.t) t
val approve : id:[< `Link of Thing.Link.Id.t | `Comment of Thing.Comment.Id.t ] -> unit t
val remove : id:[< `Link of Thing.Link.Id.t | `Comment of Thing.Comment.Id.t ] -> spam:bool -> unit t
val distinguish : ?sticky:bool -> unit -> id:[< `Link of Thing.Link.Id.t | `Comment of Thing.Comment.Id.t ] -> how:Parameters.How_to_distinguish.t -> [> `Link of Thing.Link.t | `Comment of Thing.Comment.t ] t
val ignore_reports : id:[< `Link of Thing.Link.Id.t | `Comment of Thing.Comment.Id.t ] -> unit t
val unignore_reports : id:[< `Link of Thing.Link.Id.t | `Comment of Thing.Comment.Id.t ] -> unit t
val leavecontributor : subreddit:Thing.Subreddit.Id.t -> unit t
val leavemoderator : subreddit:Thing.Subreddit.Id.t -> unit t
val mute_message_author : message:Thing.Message.Id.t -> unit t
val unmute_message_author : message:Thing.Message.Id.t -> unit t
val stylesheet : subreddit:Subreddit_name.t -> Stylesheet.t t

New modmail

val create_modmail_conversation : subject:string -> body:string -> subreddit:Subreddit_name.t -> to_:Parameters.Modmail_recipient.t -> hide_author:bool -> Modmail.Conversation.t t
val reply_modmail_conversation : body:string -> conversation_id:Modmail.Conversation.Id.t -> hide_author:bool -> internal:bool -> Modmail.Conversation.t t

Subreddits

val banned : (?include_categories:bool -> ?user:Username.t -> unit -> subreddit:Subreddit_name.t -> Relationship.Ban.t Listing.t t) with_listing_params
val muted : (?include_categories:bool -> ?user:Username.t -> unit -> subreddit:Subreddit_name.t -> Relationship.Mute.t Listing.t t) with_listing_params
val wiki_banned : (?include_categories:bool -> ?user:Username.t -> unit -> subreddit:Subreddit_name.t -> Relationship.Ban.t Listing.t t) with_listing_params
val contributors : (?include_categories:bool -> ?user:Username.t -> unit -> subreddit:Subreddit_name.t -> Relationship.Contributor.t Listing.t t) with_listing_params
val wiki_contributors : (?include_categories:bool -> ?user:Username.t -> unit -> subreddit:Subreddit_name.t -> Relationship.Contributor.t Listing.t t) with_listing_params
val moderators : (?include_categories:bool -> ?user:Username.t -> unit -> subreddit:Subreddit_name.t -> Relationship.Moderator.t Listing.t t) with_listing_params
val delete_subreddit_image : subreddit:Subreddit_name.t -> image:Parameters.Subreddit_image.t -> unit t
val search_subreddits_by_name : ?exact:bool -> ?include_over_18:bool -> ?include_unadvertisable:bool -> unit -> query:string -> Subreddit_name.t list t
val create_or_edit_subreddit : ?comment_score_hide_mins:int -> ?wiki_edit_age:int -> ?wiki_edit_karma:int -> unit -> all_original_content:bool -> allow_discovery:bool -> allow_images:bool -> allow_post_crossposts:bool -> allow_top:bool -> allow_videos:bool -> api_type:(string * string list) list -> collapse_deleted_comments:bool -> crowd_control_mode:bool -> description:string -> disable_contributor_requests:bool -> exclude_banned_modqueue:bool -> free_form_reports:bool -> g_recaptcha_response:string option -> header_title:string -> hide_ads:bool -> key_color:string -> lang:string -> link_type:Parameters.Link_type.t -> name:string -> original_content_tag_enabled:bool -> over_18:bool -> public_description:string -> restrict_commenting:bool -> restrict_posting:bool -> show_media:bool -> show_media_preview:bool -> spam_comments:Parameters.Spam_level.t -> spam_links:Parameters.Spam_level.t -> spam_selfposts:Parameters.Spam_level.t -> spoilers_enabled:bool -> subreddit:Subreddit_name.t -> submit_link_label:string -> submit_text:string -> submit_text_label:string -> suggested_comment_sort:Parameters.Comment_sort.t -> title:string -> type_:Parameters.Subreddit_type.t -> wiki_mode:Parameters.Wiki_mode.t -> (Cohttp.Response.t * Cohttp.Body.t) t
val submit_text : subreddit:Subreddit_name.t -> Submit_text.t t
val subreddit_autocomplete : ?limit:int -> ?include_categories:bool -> ?include_over_18:bool -> ?include_profiles:bool -> unit -> query:string -> Thing.Subreddit.t Listing.t t
val set_subreddit_stylesheet : ?reason:string -> unit -> subreddit:Subreddit_name.t -> stylesheet_contents:string -> unit t
val subscribe : ?skip_initial_defaults:bool -> unit -> action:Parameters.Subscription_action.t -> subreddits:Parameters.Subscription_list.t -> unit t
val search_users : (?sort:Parameters.Relevance_or_activity.t -> unit -> query:string -> Thing.User.t Listing.t t) with_listing_params
val about_subreddit : subreddit:Subreddit_name.t -> Thing.Subreddit.t t
val subreddit_settings : ?created:bool -> ?location:string -> unit -> subreddit:Subreddit_name.t -> Subreddit_settings.t t
val subreddit_rules : subreddit:Subreddit_name.t -> Subreddit_rules.t t
val subreddit_traffic : subreddit:Subreddit_name.t -> Subreddit_traffic.t t
val get_sticky : ?number:int -> unit -> subreddit:Subreddit_name.t -> Thing.Link.Id.t t
val get_subreddits : (?include_categories:bool -> unit -> relationship:Parameters.Subreddit_relationship.t -> Thing.Subreddit.t Listing.t t) with_listing_params
val search_subreddits_by_title_and_description : (?show_users:bool -> ?sort:Parameters.Relevance_or_activity.t -> unit -> query:string -> Thing.Subreddit.t Listing.t t) with_listing_params
val list_subreddits : (?include_categories:bool -> ?show_users:bool -> unit -> sort:Parameters.Subreddit_listing_sort.t -> Thing.Subreddit.t Listing.t t) with_listing_params

Users

val about_user : username:Username.t -> Thing.User.t t
val user_overview : (unit -> username:Username.t -> [ `Link of Thing.Link.t | `Comment of Thing.Comment.t ] Listing.t t) with_listing_params
val user_submitted : (unit -> username:Username.t -> Thing.Link.t Listing.t t) with_listing_params
val user_comments : (unit -> username:Username.t -> Thing.Comment.t Listing.t t) with_listing_params
val user_upvoted : (unit -> username:Username.t -> [ `Listing of Thing.Link.t Listing.t | `Private ] t) with_listing_params
val user_downvoted : (unit -> username:Username.t -> [ `Listing of Thing.Link.t Listing.t | `Private ] t) with_listing_params
val user_hidden : (unit -> logged_in_username:Username.t -> Thing.Link.t Listing.t t) with_listing_params
val user_saved : (unit -> logged_in_username:Username.t -> [ `Link of Thing.Link.t | `Comment of Thing.Comment.t ] Listing.t t) with_listing_params
val user_gilded : (unit -> username:Username.t -> [ `Link of Thing.Link.t | `Comment of Thing.Comment.t ] Listing.t t) with_listing_params
val user_trophies : username:Username.t -> Thing.Award.t list t
val list_user_subreddits : (?include_categories:bool -> unit -> sort:Parameters.User_subreddit_sort.t -> Thing.Subreddit.t Listing.t t) with_listing_params
val add_relationship : ?subreddit:Subreddit_name.t -> ?note:string -> ?ban_reason:string -> ?ban_message:string -> ?ban_context:string -> unit -> relationship:Parameters.Relationship_spec.t -> username:Username.t -> duration:Parameters.Relationship_spec.Duration.t -> unit t
val remove_relationship : ?subreddit:Subreddit_name.t -> unit -> relationship:Parameters.Relationship_spec.t -> username:Username.t -> unit t

Wiki

val add_wiki_editor : page:Wiki_page.Id.t -> user:Username.t -> unit t
val remove_wiki_editor : page:Wiki_page.Id.t -> user:Username.t -> unit t
val edit_wiki_page : ?previous:Wiki_page.Revision.Id.t -> ?reason:string -> unit -> content:string -> page:Wiki_page.Id.t -> (unit, Wiki_page.Edit_conflict.t) Core.Result.t t
val toggle_wiki_revision_visibility : page:Wiki_page.Id.t -> revision:Wiki_page.Revision.Id.t -> [ `Became_hidden | `Became_visible ] t
val revert_wiki_page : page:Wiki_page.Id.t -> revision:Wiki_page.Revision.Id.t -> unit t
val wiki_discussions : (unit -> page:Wiki_page.Id.t -> Thing.Link.t Listing.t t) with_listing_params
val wiki_pages : ?subreddit:Subreddit_name.t -> unit -> string list t
val subreddit_wiki_revisions : (?subreddit:Subreddit_name.t -> unit -> Wiki_page.Revision.t Listing.t t) with_listing_params
val wiki_page_revisions : (unit -> page:Wiki_page.Id.t -> Wiki_page.Revision.t Listing.t t) with_listing_params
val wiki_permissions : page:Wiki_page.Id.t -> Wiki_page.Permissions.t t
val set_wiki_permissions : page:Wiki_page.Id.t -> listed:bool -> level:Wiki_page.Permissions.Level.t -> Wiki_page.Permissions.t t
val wiki_page : ?compare_revisions:(string option * string option) -> unit -> page:Wiki_page.Id.t -> Wiki_page.t t