Helps build lemmy HTTP requests.

Constructors

Properties

Methods

#buildFullUrl #wrapper addAdmin addModToCommunity approveRegistrationApplication banFromCommunity banPerson blockCommunity blockInstance blockPerson changePassword createComment createCommentReport createCommunity createCustomEmoji createPost createPostReport createPrivateMessage createPrivateMessageReport createSite deleteAccount deleteComment deleteCommunity deleteCustomEmoji deleteImage deletePost deletePrivateMessage distinguishComment donation_dialog_shown editComment editCommunity editCustomEmoji editPost editPrivateMessage editSite exportSettings featurePost followCommunity generateTotpSecret getBannedPersons getCaptcha getComment getComments getCommunity getFederatedInstances getModlog getPersonDetails getPersonMentions getPost getPosts getPrivateMessages getRegistrationApplication getReplies getReportCount getSite getSiteMetadata getUnreadCount getUnreadRegistrationApplicationCount hideCommunity hidePost importSettings leaveAdmin likeComment likePost listAllMedia listCommentLikes listCommentReports listCommunities listLogins listMedia listPostLikes listPostReports listPrivateMessageReports listRegistrationApplications lockPost login logout markAllAsRead markCommentReplyAsRead markPersonMentionAsRead markPostAsRead markPrivateMessageAsRead passwordChangeAfterReset passwordReset purgeComment purgeCommunity purgePerson purgePost register removeComment removeCommunity removePost resolveCommentReport resolveObject resolvePostReport resolvePrivateMessageReport saveComment savePost saveUserSettings search setHeaders transferCommunity updateTotp uploadImage validateAuth verifyEmail

Constructors

  • Generates a new instance of LemmyHttp.

    Parameters

    • baseUrl: string

      the base url, without the vX version: https://lemmy.ml -> goes to https://lemmy.ml/api/vX

    • Optional options: {
          fetchFunction?: {
              (input, init?): Promise<Response>;
              (input, init?): Promise<Response>;
          };
          headers?: {
              [key: string]: string;
          };
      }
      • Optional fetchFunction?: {
            (input, init?): Promise<Response>;
            (input, init?): Promise<Response>;
        }
          • (input, init?): Promise<Response>
          • Parameters

            • input: RequestInfo | URL
            • Optional init: RequestInit

            Returns Promise<Response>

          • (input, init?): Promise<Response>
          • Parameters

            • input: string | Request | URL
            • Optional init: RequestInit

            Returns Promise<Response>

      • Optional headers?: {
            [key: string]: string;
        }
        • [key: string]: string

    Returns LemmyHttp

Properties

#apiUrl: string
#fetchFunction: {
    (input, init?): Promise<Response>;
    (input, init?): Promise<Response>;
} = ...

Type declaration

    • (input, init?): Promise<Response>
    • Parameters

      • input: RequestInfo | URL
      • Optional init: RequestInit

      Returns Promise<Response>

    • (input, init?): Promise<Response>
    • Parameters

      • input: string | Request | URL
      • Optional init: RequestInit

      Returns Promise<Response>

#headers: {
    [key: string]: string;
} = {}

Type declaration

  • [key: string]: string
#pictrsUrl: string

Methods

  • Parameters

    • endpoint: string

    Returns string

  • Type Parameters

    • BodyType extends object
    • ResponseType

    Parameters

    • type_: HttpType
    • endpoint: string
    • form: BodyType
    • options: undefined | RequestOptions

    Returns Promise<ResponseType>

  • Add an admin to your site.

    HTTP.POST /admin/add

    Parameters

    • form: AddAdmin
    • Optional options: RequestOptions

    Returns Promise<AddAdminResponse>

  • Ban a person from your site.

    HTTP.POST /user/ban

    Parameters

    • form: BanPerson
    • Optional options: RequestOptions

    Returns Promise<BanPersonResponse>

  • Change your user password.

    HTTP.PUT /user/change_password

    Parameters

    Returns Promise<LoginResponse>

  • Create a post.

    HTTP.POST /post

    Parameters

    Returns Promise<PostResponse>

  • Create your site.

    HTTP.POST /site

    Parameters

    Returns Promise<SiteResponse>

  • Delete your account.

    HTTP.POST /user/delete_account

    Parameters

    Returns Promise<SuccessResponse>

  • Delete a comment.

    HTTP.POST /comment/delete

    Parameters

    Returns Promise<CommentResponse>

  • Delete a custom emoji

    HTTP.Post /custom_emoji/delete

    Parameters

    Returns Promise<SuccessResponse>

  • Delete a pictrs image

    Parameters

    • __namedParameters: DeleteImage
    • Optional options: RequestOptions

    Returns Promise<boolean>

  • Delete a post.

    HTTP.POST /post/delete

    Parameters

    Returns Promise<PostResponse>

  • Distinguishes a comment (speak as moderator)

    HTTP.POST /comment/distinguish

    Parameters

    Returns Promise<CommentResponse>

  • Mark donation dialog as shown, so it isn't displayed anymore.

    HTTP.POST /user/donation_dialog_shown

    Parameters

    • Optional options: RequestOptions

    Returns Promise<SuccessResponse>

  • Edit a post.

    HTTP.PUT /post

    Parameters

    • form: EditPost
    • Optional options: RequestOptions

    Returns Promise<PostResponse>

  • Edit your site.

    HTTP.PUT /site

    Parameters

    • form: EditSite
    • Optional options: RequestOptions

    Returns Promise<SiteResponse>

  • Export a backup of your user settings, including your saved content, followed communities, and blocks.

    HTTP.GET /user/export_settings

    Parameters

    • Optional options: RequestOptions

    Returns Promise<string>

  • A moderator can feature a community post ( IE stick it to the top of a community ).

    HTTP.POST /post/feature

    Parameters

    Returns Promise<PostResponse>

  • Follow / subscribe to a community.

    HTTP.POST /community/follow

    Parameters

    Returns Promise<CommunityResponse>

  • Generate a TOTP / two-factor secret.

    Afterwards you need to call /user/totp/update with a valid token to enable it.

    HTTP.POST /user/totp/generate

    Parameters

    • Optional options: RequestOptions

    Returns Promise<GenerateTotpSecretResponse>

  • Get a list of banned users

    HTTP.GET /user/banned

    Parameters

    • Optional options: RequestOptions

    Returns Promise<BannedPersonsResponse>

  • Fetch a Captcha.

    HTTP.GET /user/get_captcha

    Parameters

    • Optional options: RequestOptions

    Returns Promise<GetCaptchaResponse>

  • Get / fetch comment.

    HTTP.GET /comment

    Parameters

    Returns Promise<CommentResponse>

  • Get / fetch a post.

    HTTP.GET /post

    Parameters

    • form: GetPost = {}
    • Optional options: RequestOptions

    Returns Promise<GetPostResponse>

  • Get / fetch posts, with various filters.

    HTTP.GET /post/list

    Parameters

    • form: GetPosts = {}
    • Optional options: RequestOptions

    Returns Promise<GetPostsResponse>

  • Gets the site, and your user data.

    HTTP.GET /site

    Parameters

    • Optional options: RequestOptions

    Returns Promise<GetSiteResponse>

  • Hide a community from public / "All" view. Admins only.

    HTTP.PUT /community/hide

    Parameters

    Returns Promise<SuccessResponse>

  • Hide a post from list views.

    HTTP.POST /post/hide

    Parameters

    • form: HidePost
    • Optional options: RequestOptions

    Returns Promise<SuccessResponse>

  • Import a backup of your user settings.

    HTTP.POST /user/import_settings

    Parameters

    • form: any
    • Optional options: RequestOptions

    Returns Promise<SuccessResponse>

  • Leave the Site admins.

    HTTP.POST /user/leave_admin

    Parameters

    • Optional options: RequestOptions

    Returns Promise<GetSiteResponse>

  • Like / vote on a post.

    HTTP.POST /post/like

    Parameters

    Returns Promise<PostResponse>

  • List all the media known to your instance.

    HTTP.GET /admin/list_all_media

    Parameters

    • form: ListMedia = {}
    • Optional options: RequestOptions

    Returns Promise<ListMediaResponse>

  • List login tokens for your user

    HTTP.GET /user/list_logins

    Parameters

    • Optional options: RequestOptions

    Returns Promise<LoginToken[]>

  • List all the media for your user

    HTTP.GET /account/list_media

    Parameters

    • form: ListMedia = {}
    • Optional options: RequestOptions

    Returns Promise<ListMediaResponse>

  • A moderator can lock a post ( IE disable new comments ).

    HTTP.POST /post/lock

    Parameters

    • form: LockPost
    • Optional options: RequestOptions

    Returns Promise<PostResponse>

  • Log into lemmy.

    HTTP.POST /user/login

    Parameters

    • form: Login
    • Optional options: RequestOptions

    Returns Promise<LoginResponse>

  • Invalidate the currently used auth token.

    HTTP.POST /user/logout

    Parameters

    • Optional options: RequestOptions

    Returns Promise<SuccessResponse>

  • Mark all replies as read.

    HTTP.POST /user/mark_all_as_read

    Parameters

    • Optional options: RequestOptions

    Returns Promise<GetRepliesResponse>

  • Mark a post as read.

    HTTP.POST /post/mark_as_read

    Parameters

    Returns Promise<SuccessResponse>

  • Change your password from an email / token based reset.

    HTTP.POST /user/password_change

    Parameters

    Returns Promise<SuccessResponse>

  • Reset your password.

    HTTP.POST /user/password_reset

    Parameters

    Returns Promise<SuccessResponse>

  • Purge / Delete a comment from the database.

    HTTP.POST /admin/purge/comment

    Parameters

    Returns Promise<SuccessResponse>

  • Purge / Delete a community from the database.

    HTTP.POST /admin/purge/community

    Parameters

    Returns Promise<SuccessResponse>

  • Purge / Delete a person from the database.

    HTTP.POST /admin/purge/person

    Parameters

    Returns Promise<SuccessResponse>

  • Purge / Delete a post from the database.

    HTTP.POST /admin/purge/post

    Parameters

    • form: PurgePost
    • Optional options: RequestOptions

    Returns Promise<SuccessResponse>

  • Register a new user.

    HTTP.POST /user/register

    Parameters

    • form: Register
    • Optional options: RequestOptions

    Returns Promise<LoginResponse>

  • A moderator remove for a comment.

    HTTP.POST /comment/remove

    Parameters

    Returns Promise<CommentResponse>

  • A moderator remove for a community.

    HTTP.POST /community/remove

    Parameters

    Returns Promise<CommunityResponse>

  • A moderator remove for a post.

    HTTP.POST /post/remove

    Parameters

    Returns Promise<PostResponse>

  • Resolve a post report. Only a mod can do this.

    HTTP.PUT /post/report/resolve

    Parameters

    Returns Promise<PostReportResponse>

  • Save a comment.

    HTTP.PUT /comment/save

    Parameters

    Returns Promise<CommentResponse>

  • Save a post.

    HTTP.PUT /post/save

    Parameters

    • form: SavePost
    • Optional options: RequestOptions

    Returns Promise<PostResponse>

  • Save your user settings.

    HTTP.PUT /user/save_user_settings

    Parameters

    Returns Promise<SuccessResponse>

  • Search lemmy.

    HTTP.GET /search

    Parameters

    • form: Search
    • Optional options: RequestOptions

    Returns Promise<SearchResponse>

  • Set the headers (can be used to set the auth header)

    Parameters

    • headers: {
          [key: string]: string;
      }
      • [key: string]: string

    Returns void

  • Enable / Disable TOTP / two-factor authentication.

    To enable, you need to first call /user/totp/generate and then pass a valid token to this.

    Disabling is only possible if 2FA was previously enabled. Again it is necessary to pass a valid token.

    HTTP.POST /user/totp/update

    Parameters

    Returns Promise<UpdateTotpResponse>

  • Returns an error message if your auth token is invalid

    HTTP.GET /user/validate_auth

    Parameters

    • Optional options: RequestOptions

    Returns Promise<SuccessResponse>

  • Verify your email

    HTTP.POST /user/verify_email

    Parameters

    Returns Promise<SuccessResponse>