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 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: any = ...
#headers: {
    [key: string]: string;
} = {}

Type declaration

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

Methods

  • Parameters

    • endpoint: string

    Returns string

  • Delete a pictrs image

    Parameters

    Returns Promise<boolean>

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

    HTTP.GET /user/export_settings

    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>

  • 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

    Returns Promise<GenerateTotpSecretResponse>

  • Import a backup of your user settings.

    HTTP.POST /user/import_settings

    Parameters

    • form: any

    Returns Promise<SuccessResponse>

  • List login tokens for your user

    HTTP.GET /user/list_logins

    Returns Promise<LoginToken[]>

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

    HTTP.POST /post/lock

    Parameters

    Returns Promise<PostResponse>

  • Invalidate the currently used auth token.

    HTTP.POST /user/logout

    Returns Promise<SuccessResponse>

  • A moderator remove for a post.

    HTTP.POST /post/remove

    Parameters

    Returns Promise<PostResponse>

  • 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

    Returns Promise<SuccessResponse>