UNET API - v0.0.0
    Preparing search index...

    Class UnetApi

    UNET REST API (/open/v1), acting as the signed-in user: read (feed, posts, profiles, search, comments, notifications), write (posts, comments, likes, follows, library, safety, profile). Each method names the permission (scope) it needs; the app must be granted it in the Developers Console. Every method returns plain JSON-typed data; 404 is thrown as ApiError(404).

    Index
    withSignal feed post profile userReplies userReposts musicPlaylist userMusic searchMusic addMusic reorderMusic removeMusic search suggestedUsers notifications markNotificationsRead createPost searchPlaces media mediaLink longForm postLikes postReposts commentLikes commentReposts translatePost placePosts followers following follow unfollow removeFollower followRequests acceptFollowRequest rejectFollowRequest save unsave saved likes blocks block unblock muted mute unmute report updateProfile uploadAvatar uploadBanner removeBanner settings updateSettings addMutedKeyword removeMutedKeyword fediverse setFediverse fediverseFeed searchFediverse fediverseHashtag fediverseActor lookupFediverseActor fediverseActorPosts fediverseActorConnections followOnFediverse unfollowOnFediverse blockOnFediverse unblockOnFediverse fediverseBlocked fediversePost fediverseThread likeOnFediverse unlikeOnFediverse boostOnFediverse unboostOnFediverse replyOnFediverse updateFediverseReply deleteFediverseReply voteInFediversePoll hashtagPosts topicPosts subscribeToAuthor unsubscribeFromAuthor mutualConnections postSubscription subscribeToPost unsubscribeFromPost pinPost unpinPost notInterested notInterestedItems removeNotInterested like unlike repost unrepost comments replies comment uploadCommentImage likeComment unlikeComment deleteComment getComment repostComment unrepostComment updateComment pinComment unpinComment stickerPacks stickerPack installStickerPack uninstallStickerPack scheduledPosts updatePost deletePost reschedulePost realtime
    • Parameters

      • base: string
      • request: Requester
      • options: ApiOptions = {}

      Returns UnetApi

    • The same API, but every request is cancelled when signal aborts (the call then rejects with the browser's AbortError, never with NetworkError).

      const ctl = new AbortController();
      const page = await unet.api.withSignal(ctl.signal).feed();

      Parameters

      • signal: AbortSignal

      Returns UnetApi

    • A feed as this user sees it: type is "global" (default, everyone), "following" or "foryou" (personalised; ApiError 403 not_allowed when the account has privacy mode on). Pass nextCursor back as cursor. Older servers ignore type and always answer with the global feed.

      Parameters

      • options: { limit?: number; cursor?: string | null; type?: FeedType } = {}

      Returns Promise<FeedPage>

    post

    • post(id: string | number): Promise<Post>

      One post, by numeric id or by hashId (the id in post links). Public posts can also be read without signing in (no viewer state, at most the public fields).

      Parameters

      • id: string | number

      Returns Promise<Post>

    • Parameters

      • username: string
      • options: { limit?: number; offset?: number } = {}

      Returns Promise<ProfilePage>

    • Comments a user wrote (the profile "Replies" tab), newest first, each with the post it answers. Empty if hidden from you.

      Parameters

      • username: string
      • options: { limit?: number; offset?: number } = {}

      Returns Promise<UserRepliesPage>

    • Posts a user reposted (the profile "Reposts" tab), newest repost first. Empty if hidden from you.

      Parameters

      • username: string
      • options: { limit?: number; offset?: number } = {}

      Returns Promise<UserRepostsPage>

    • Songs on a user's profile (the "Music" tab), in the owner's order, and how many a profile may hold.

      Parameters

      • username: string

      Returns Promise<MusicPlaylist>

    • Just the songs of musicPlaylist().

      Parameters

      • username: string

      Returns Promise<MusicTrack[]>

    • Find songs to put on your profile (30-second previews). Needs profile:write.

      Parameters

      • term: string
      • options: { limit?: number } = {}

      Returns Promise<MusicSearchResult[]>

    • Add a song (itunesId from searchMusic) to the end of your profile playlist. ApiError 409 already_exists / playlist_full. Needs profile:write.

      Parameters

      • itunesId: string

      Returns Promise<MusicPlaylist>

    • The new order of your songs: every track id, once. Returns the playlist in that order.

      Parameters

      • orderedTrackIds: number[]

      Returns Promise<MusicTrack[]>

    • Remove one of your songs; returns what is left.

      Parameters

      • trackId: number

      Returns Promise<MusicTrack[]>

    • People, posts, hashtags and topics. from / after / before narrow the posts; offset pages them (nextPostsOffset).

      Parameters

      Returns Promise<SearchResult>

    • Accounts to follow (the apps' “Follow suggestions”; people you already follow are left out). Needs content:read.

      Parameters

      • options: { limit?: number; cursor?: string | null } = {}

      Returns Promise<SuggestedUsersPage>

    • Your notifications (likes, replies, mentions, follows). Needs notifications:read.

      Parameters

      • options: { limit?: number; offset?: number; unreadOnly?: boolean } = {}

      Returns Promise<NotificationsPage>

    • Mark one notification (or all, when id is omitted) as read. Returns the new unread count.

      Parameters

      • Optionalid: number

      Returns Promise<number>

    • Publish a post as the user (text, images, voice/video, audio, GIF, schedule...). Needs posts:write.

      Parameters

      Returns Promise<Post>

    • Places to attach to a post: pass one as createPost({ place }) (id, name, lat, lon). Needs posts:write.

      Parameters

      • query: string

      Returns Promise<Place[]>

    • The file behind post.video.url, post.audioUrl or a sticker url as a Blob (content:read). Those URLs need a UNET session token, which a <video src> / <audio src> cannot send, so the SDK downloads the file with your access token (same visibility rules as the post). Play it with a blob URL:

      const blob = await unet.api.media(post.video!.url);
      video.src = URL.createObjectURL(blob); // URL.revokeObjectURL(video.src) when done

      Not for images: those URLs are public, use them in <img src> directly. No download timeout; pass a signal (api.withSignal) to cancel.

      Parameters

      • url: string

      Returns Promise<Blob>

    • A link a <video src> can stream from directly (content:read): playback starts at once and seeking works, with no full download. Pass post.video.url. The link is signed for you and valid for about 30 minutes (expiresAt); ask again when it runs out. Same visibility rules as the post. Prefer this to media() for video.

      const { url } = await unet.api.mediaLink(post.video!.url);
      video.src = url;

      Parameters

      • url: string

      Returns Promise<{ url: string; expiresAt: string }>

    • Full text of a long post (content:read). Short content is only the lead.

      Parameters

      • postId: number

      Returns Promise<LongForm>

    • People who liked your post, newest first (since = when). As in the apps only the author sees this: ApiError 403 not_allowed for anyone else's post. Fediverse accounts are not listed. Needs content:read.

      Parameters

      • postId: number
      • options: { limit?: number; offset?: number } = {}

      Returns Promise<PeoplePage>

    • People who reposted your post, same rules and shape as postLikes.

      Parameters

      • postId: number
      • options: { limit?: number; offset?: number } = {}

      Returns Promise<PeoplePage>

    • People who liked your comment, newest first (since = when): the "View activity" of a comment. Only the comment's author sees this: ApiError 404 not_found, 403 not_allowed for anyone else. Needs content:read.

      Parameters

      • commentId: number
      • options: { limit?: number; offset?: number } = {}

      Returns Promise<PeoplePage>

    • People who reposted your comment, same rules and shape as commentLikes.

      Parameters

      • commentId: number
      • options: { limit?: number; offset?: number } = {}

      Returns Promise<PeoplePage>

    • A post (text and long-form body) translated into targetLang (default: the user's translation language). Results are cached per language. ApiError codes: 403 translation_not_allowed (the author did not allow it, or a private account) / translation_unavailable; 400 same_language / invalid_language / nothing_to_translate; 429 RateLimited (the daily quota or the hourly cap; retryAfter says when). Needs content:read.

      Parameters

      • postId: number
      • OptionaltargetLang: string

      Returns Promise<Translation>

    • Posts tagged with a place, newest first (post.place.id; pass its lat / lon too so posts of the same spot saved under another id are found). The user's own rules apply (blocks, private accounts, NSFW). Needs content:read.

      Parameters

      • placeId: string
      • options: { lat?: number; lon?: number; limit?: number; offset?: number } = {}

      Returns Promise<PlacePostsPage>

    • Parameters

      • username: string
      • options: { limit?: number; offset?: number } = {}

      Returns Promise<PeoplePage>

    • Parameters

      • username: string
      • options: { limit?: number; offset?: number } = {}

      Returns Promise<PeoplePage>

    • Follow. Private accounts return { following: false, pending: true } until they approve. Idempotent.

      Parameters

      • username: string

      Returns Promise<FollowState>

    • Unfollow, or cancel a pending request. Idempotent.

      Parameters

      • username: string

      Returns Promise<FollowState>

    • Remove someone from your followers.

      Parameters

      • username: string

      Returns Promise<void>

    • Parameters

      • options: { limit?: number; offset?: number } = {}

      Returns Promise<FollowRequestsPage>

    • Parameters

      • requestId: number

      Returns Promise<void>

    • Parameters

      • requestId: number

      Returns Promise<void>

    • Save a post to your collection. Idempotent.

      Parameters

      • postId: number

      Returns Promise<{ saved: boolean }>

    • Parameters

      • postId: number

      Returns Promise<{ saved: boolean }>

    • Your saved posts, newest first.

      Parameters

      • options: { limit?: number; cursor?: string | null } = {}

      Returns Promise<LibraryPage>

    • Posts you liked, newest like first.

      Parameters

      • options: { limit?: number; cursor?: string | null } = {}

      Returns Promise<LibraryPage>

    • Parameters

      • options: { limit?: number; offset?: number } = {}

      Returns Promise<PeoplePage>

    • Block someone (also removes follows between you). Idempotent.

      Parameters

      • username: string

      Returns Promise<{ blocked: boolean }>

    • Parameters

      • username: string

      Returns Promise<{ blocked: boolean }>

    • People whose posts you hide from your feeds.

      Parameters

      • options: { limit?: number; offset?: number } = {}

      Returns Promise<PeoplePage>

    • Parameters

      • username: string

      Returns Promise<{ muted: boolean }>

    • Parameters

      • username: string

      Returns Promise<{ muted: boolean }>

    • Report a user, post or comment to UNET moderators.

      Parameters

      Returns Promise<void>

    • Change the profile picture (JPEG, PNG, WebP, GIF or HEIC, up to 10 MB). The server scans and resizes it like the apps do. ApiError 400 invalid_file, 413 payload_too_large, 451 content_policy, 503 scan_unavailable. Needs profile:write.

      Parameters

      • file: Blob

      Returns Promise<
          {
              avatarUrl: string;
              width: number
              | null;
              height: number | null;
              animated: boolean;
          },
      >

    • Change the profile banner (same rules as uploadAvatar). Needs profile:write.

      Parameters

      • file: Blob

      Returns Promise<{ bannerUrl: string }>

    • Remove the profile banner. Needs profile:write.

      Returns Promise<void>

    • Privacy, notification, content (translation, link previews, view counts) and “For you” feed settings, as in the apps' Settings. Never includes password, two-factor, sessions or other security settings. Needs settings:read.

      Returns Promise<Settings>

    • Change settings; send only what changes. Everything is validated before anything is saved (ApiError 400 invalid_request, the message names the field). privacy.isNsfwProfile changes once a day (RateLimited), privacy.dmRequestsRequirePlus needs Plus (ApiError 403 not_allowed). Returns all settings. Needs settings:write.

      Parameters

      Returns Promise<Settings>

    • Hide posts containing keyword from “For you” (lower-cased, up to 100 characters). Returns the list. Needs settings:write.

      Parameters

      • keyword: string

      Returns Promise<string[]>

    • Stop hiding keyword. Returns the list. Needs settings:write.

      Parameters

      • keyword: string

      Returns Promise<string[]>

    • Whether you can use the Fediverse and whether it is on, plus your handle there. Needs settings:read.

      Returns Promise<FediverseStatus>

    • Switch the Fediverse on or off. Turning it on sends your profile and public posts in plaintext to other servers, which may keep copies, so acceptedPlaintextDisclosure: true is required (ApiError 400 disclosure_required; 403 not_available). Needs settings:write.

      Parameters

      • enabled: boolean
      • options: { acceptedPlaintextDisclosure?: boolean } = {}

      Returns Promise<FediverseStatus>

    • Posts of the Fediverse accounts you follow, newest first; enabled: false and no items while it is off. Needs content:read.

      Parameters

      • options: { limit?: number; cursor?: string | null } = {}

      Returns Promise<FediversePage>

    • Look up Fediverse accounts, posts and hashtags (q: a handle like [email protected], an address, or words). Needs search:read; the Fediverse must be on.

      Parameters

      • q: string
      • options: { limit?: number } = {}

      Returns Promise<FediverseSearchResult>

    • Posts of the Fediverse that use a hashtag (tag without the #). Needs content:read.

      Parameters

      • tag: string
      • options: { limit?: number; cursor?: string | null } = {}

      Returns Promise<Omit<FediversePage, "enabled">>

    • An account on another server, with what you are to each other. Needs content:read.

      Parameters

      • id: string

      Returns Promise<FediverseActor>

    • An account by its handle ([email protected], with or without the leading @): found on its own server when this one has not seen it yet, so a profile can be opened from a plain mention. ApiError 404 not_found when there is no such account. Needs content:read.

      Parameters

      • handle: string

      Returns Promise<FediverseActor>

    • Their posts, newest first. reposts: true: what they boosted. replies: false: only posts of their own, replies: true: only their replies (see FediverseItem.inReplyTo); left out: both together. Needs content:read.

      Parameters

      • id: string
      • options: { limit?: number; cursor?: string | null; reposts?: boolean; replies?: boolean } = {}

      Returns Promise<Omit<FediversePage, "enabled">>

    • The people an account follows or is followed by, as the account's own server publishes them (available: false: it keeps the list private). Page with nextCursor. Needs content:read.

      Parameters

      • id: string
      • kind: "following" | "followers"
      • options: { limit?: number; cursor?: string | null } = {}

      Returns Promise<
          {
              actors: FediverseActor[];
              nextCursor: string
              | null;
              available: boolean;
          },
      >

    • Follow an account by handle (name@host) or address; a locked account gets a request (viewer.follow: "pending"). Needs follows:write.

      Parameters

      • handle: string

      Returns Promise<FediverseActor>

    • Stop following an account on another server. Needs follows:write.

      Parameters

      • actorId: string

      Returns Promise<void>

    • Block / unblock an account on another server. Needs safety:manage.

      Parameters

      • actorId: string

      Returns Promise<void>

    • Parameters

      • actorId: string

      Returns Promise<void>

    • Fediverse accounts you blocked. Needs safety:manage.

      Parameters

      • options: { limit?: number; offset?: number } = {}

      Returns Promise<{ actors: FediverseActor[]; nextOffset: number | null }>

    • One Fediverse post by its address (uri), with what you did to it. Needs content:read.

      Parameters

      • uri: string

      Returns Promise<FediverseItem>

    • The replies under a Fediverse post, oldest first. What this server has seen: other servers may hold more. Needs content:read.

      Parameters

      • uri: string
      • options: { limit?: number; cursor?: string | null } = {}

      Returns Promise<{ items: FediverseComment[]; nextCursor: string | null }>

    • Like / unlike a Fediverse post. Idempotent. Needs posts:interact.

      Parameters

      • uri: string

      Returns Promise<FediverseInteraction>

    • Boost (repost) / take back a boost of a Fediverse post. Idempotent. Needs posts:interact.

      Parameters

      • uri: string

      Returns Promise<FediverseInteraction>

    • Reply to a Fediverse post, or to one of its replies (uri is the address of what you answer; text, up to 5000 characters). Delivered to other servers in the background (deliveryState). Needs posts:interact.

      Parameters

      • uri: string
      • content: string

      Returns Promise<
          {
              uri: string;
              text: string;
              deliveryState: string;
              createdAt: string;
              parentUri?: string
              | null;
              rootUri?: string;
          },
      >

    • Change your reply. Needs posts:manage.

      Parameters

      • uri: string
      • content: string

      Returns Promise<void>

    • Delete your reply. Needs posts:manage.

      Parameters

      • uri: string

      Returns Promise<void>

    • Vote in a Fediverse poll (choices: option numbers from 0). Needs posts:interact.

      Parameters

      • uri: string
      • choices: number[]

      Returns Promise<FediversePoll>

    • Posts with a hashtag (tag without the #), newest first. ApiError 404 not_found for a tag nobody used. Needs content:read.

      Parameters

      • tag: string
      • options: { limit?: number; offset?: number } = {}

      Returns Promise<HashtagPostsPage>

    • Posts of a topic (id is post.topic.id). ApiError 404 not_found for an unknown topic. Needs content:read.

      Parameters

      • id: number
      • options: { limit?: number; offset?: number } = {}

      Returns Promise<TopicPostsPage>

    • The bell on a profile: be notified about this author's new posts. Only for people you follow (ApiError 403 not_following). Needs follows:write.

      Parameters

      • username: string

      Returns Promise<void>

    • Stop those notifications. Needs follows:write.

      Parameters

      • username: string

      Returns Promise<void>

    • People you follow who follow username (Profile.mutual has a preview). Needs content:read.

      Parameters

      • username: string
      • options: { limit?: number; offset?: number } = {}

      Returns Promise<MutualPage>

    • Whether you watch this post (be notified about new comment activity under it). Needs content:read.

      Parameters

      • postId: number

      Returns Promise<{ subscribed: boolean }>

    • Watch a post: batched notifications about new comments under it (the bell on the post page). ApiError 400 invalid_request for your own post, 403 comments_disabled where comments are off, 404 for a post you cannot see. Idempotent. Needs posts:interact.

      Parameters

      • postId: number

      Returns Promise<void>

    • Stop watching it. Idempotent. Needs posts:interact.

      Parameters

      • postId: number

      Returns Promise<void>

    • Pin one of your posts to your profile (pinned posts come first; Post.isPinned). ApiError 403 not_allowed for someone else's, 409 pin_limit_reached at the limit (3; pinning a pinned post moves it to the top). Needs posts:manage.

      Parameters

      • postId: number

      Returns Promise<void>

    • Unpin it. Needs posts:manage.

      Parameters

      • postId: number

      Returns Promise<void>

    • Tell the feed to show less like this post (its author, topic, hashtags and language). Needs posts:interact.

      Parameters

      • postId: number

      Returns Promise<void>

    • What you told the feed to show less of. Needs settings:read.

      Parameters

      • options: {
            type?: "post" | "author" | "topic" | "hashtag" | "language";
            limit?: number;
            offset?: number;
        } = {}

      Returns Promise<NotInterestedPage>

    • Take one of them back. Needs settings:write.

      Parameters

      • itemId: number

      Returns Promise<void>

    • Like a post. Idempotent: liking twice leaves it liked.

      Parameters

      • postId: number

      Returns Promise<{ liked: boolean; likeCount: number }>

    • Parameters

      • postId: number

      Returns Promise<{ liked: boolean; likeCount: number }>

    • Repost a post (not your own). Idempotent.

      Parameters

      • postId: number

      Returns Promise<{ reposted: boolean; repostCount: number }>

    • Parameters

      • postId: number

      Returns Promise<{ reposted: boolean; repostCount: number }>

    • Comments of a post (content:read).

      Parameters

      • postId: number
      • options: { limit?: number; offset?: number; sort?: CommentSort } = {}

      Returns Promise<CommentsPage>

    • Replies to a comment (content:read).

      Parameters

      • commentId: number
      • options: { limit?: number; offset?: number } = {}

      Returns Promise<CommentsPage>

    • Comment on a post, or reply to a comment with parentId. Text and/or a GIF (gifUrl from api.gifs), or a sticker (stickerId from api.stickerPacks(); not together with a GIF), or up to 3 pictures (images: files, uploaded for you; or imageKeys from uploadCommentImage(); not together with a GIF or a sticker). The post's "who can comment" setting, blocks and privacy are enforced (ApiError 403 not_allowed). Sends an Idempotency-Key, so a retry cannot double-comment.

      Parameters

      • postId: number
      • input: {
            content?: string;
            gifUrl?: string;
            stickerId?: number;
            imageKeys?: string[];
            images?: Blob[];
            parentId?: number;
            idempotencyKey?: string;
        }

      Returns Promise<Comment>

    • Upload one picture for a comment (JPEG, PNG, WebP, GIF or HEIC, up to 10 MB; scanned and resized like in the apps). Pass the returned imageKey (up to 3) as imageKeys of comment(). ApiError 400 invalid_file, 413 payload_too_large, 451 content_policy, 503 scan_unavailable. Needs posts:interact.

      Parameters

      • file: Blob

      Returns Promise<
          {
              imageKey: string;
              url: string;
              sizes: { thumbnail: string; medium: string; full: string };
          },
      >

    • Parameters

      • commentId: number

      Returns Promise<{ liked: boolean; likeCount: number }>

    • Parameters

      • commentId: number

      Returns Promise<{ liked: boolean; likeCount: number }>

    • Delete one of your own comments (posts:manage).

      Parameters

      • commentId: number

      Returns Promise<void>

    • One comment (e.g. the comment a post quotes: post.quoteCommentId). Needs content:read.

      Parameters

      • commentId: number

      Returns Promise<Comment>

    • Repost a comment (not your own). Idempotent. Quote it with createPost({ quoteCommentId }).

      Parameters

      • commentId: number

      Returns Promise<{ reposted: boolean; repostCount: number }>

    • Parameters

      • commentId: number

      Returns Promise<{ reposted: boolean; repostCount: number }>

    • Edit the text of your own comment. Only within 30 minutes of posting (ApiError 403 edit_window_closed after that). Needs posts:manage.

      Parameters

      • commentId: number
      • content: string

      Returns Promise<Comment>

    • The post's author pins one comment under the post (replaces the pinned one); unpinComment removes it. Needs posts:manage.

      Parameters

      • commentId: number

      Returns Promise<{ pinned: boolean }>

    • Parameters

      • commentId: number

      Returns Promise<{ pinned: boolean }>

    • Sticker packs for a picker: the ones you installed (default) or the public catalogue (q searches).

      Parameters

      • options: { source?: "installed" | "public"; q?: string; limit?: number; offset?: number } = {}

      Returns Promise<StickerPacksPage>

    • One pack with all its stickers.

      Parameters

      • packId: number

      Returns Promise<StickerPack>

    • Parameters

      • packId: number

      Returns Promise<{ installed: boolean }>

    • Parameters

      • packId: number

      Returns Promise<{ installed: boolean }>

    • Your scheduled, not-yet-published posts. Needs posts:write.

      Returns Promise<Post[]>

    • Edit one of your posts (also posts made in other apps). Needs posts:manage.

      Parameters

      Returns Promise<Post>

    • Delete a post of yours, or cancel it if it is still scheduled. Needs posts:manage.

      Parameters

      • id: number

      Returns Promise<void>

    • Move a scheduled post to a new future time. Needs posts:manage.

      Parameters

      • id: number
      • when: string | Date

      Returns Promise<void>

    • Live hints from the server (new notifications, changes on posts you show, new posts in a feed): see Realtime. The stream opens at once and reconnects by itself; call close() when you stop needing it. Needs notifications:read for notifications and content:read for posts / feeds.

      Parameters

      Returns Realtime

    gifs: {
        search: (
            query: string,
            options?: { limit?: number; offset?: number },
        ) => Promise<GifPage>;
        trending: (
            options?: { limit?: number; offset?: number },
        ) => Promise<GifPage>;
    } = ...

    GIF picker backend (needs posts:write). Pick one, then createPost({ gifUrl: gif.gifUrl }).

    const { gifs } = await unet.api.gifs.search("cat");
    await unet.api.createPost({ content: "meow", gifUrl: gifs[0].gifUrl });