Universal Sublinks/Lemmy client that works with both APIs

Constructors

Properties

Methods

addAdmin addModToCommunity approveRegistrationApplication banFromCommunity banPerson blockCommunity blockInstance blockPerson call 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 getReplies getReportCount getSite getSiteMetadata getUnreadCount getUnreadRegistrationApplicationCount hideCommunity importSettings leaveAdmin likeComment likePost listCommentLikes listCommentReports listCommunities listLogins listPostLikes listPostReports listPrivateMessageReports listRegistrationApplications lockPost login logout markAllAsRead markCommentReplyAsRead markPersonMentionAsRead markPostAsRead markPrivateMessageAsRead now passwordChangeAfterReset passwordReset purgeComment purgeCommunity purgePerson purgePost register removeComment removeCommunity removePost resolveCommentReport resolveObject resolvePostReport resolvePrivateMessageReport saveComment savePost saveUserSettings search setAuth setHeader setHeaders transferCommunity updateTotp uploadImage validateAuth verifyEmail

Constructors

  • Client library for Sublinks and, during compatibility phase, Lemmy.

    Parameters

    • instance: string

      should be the domain of the instance without the scheme (e.g. sublinks.example.com). HTTPS is assumed and enforced by the library.

    • Optional options: HttpClientConstructorOptions

      is an object of type HttpClientConstructorOptions

    Returns SublinksClient

Properties

baseURL: string
cache: FetchCache
compatible18: boolean
fetchFunction: {
    (input, init?): Promise<Response>;
    (input, init?): Promise<Response>;
} = fetch

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: HeadersObject
instance: string

Methods

  • Standard fetch wrapper for native API calls.

    ResponseType is the type definition to expect from the response.

    FormDataType is the type definition for the form parameter data

    Note: These are reversed from how Lemmy's wrapper function is implemented to allow shorter invocations for GET requests by not requiring a dummy 'object' type be passed for the non-existent form data when not needed.

    Type Parameters

    • ResponseType

    • FormDataType extends object = object

    Parameters

    • method: HTTP

      HTTP method to use for the call

    • endpoint: string

      The relative API endpoint (e.g. /siteinfo -> https://{instance.com}/sublinks-api/v2/siteinfo)

    • form: FormDataType = ...

      The optional body payload for non-GET requests or key/values for GET query string params

    Returns Promise<ResponseType>

  • Parameters

    Returns Promise<boolean>

  • Returns the current date/time as a Unix timestamp rounded down to nearest second.

    Returns number

  • Convenience method to set the Authorization: Bearer {token} header

    Parameters

    • jwt: string

    Returns void

  • Sets an individual header key to the provided value or removes the key from the headers if a value is not provided.

    Parameters

    • key: string
    • Optional value: string

    Returns void

  • Parameters

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

    Returns void

Generated using TypeDoc