Skip to main content
Version: 0.9

Class: RedditAPIClient

The Reddit API Client

Make sure you initialize this with new RedditAPIClient() at the top of your main.ts file before using it.

Example

const reddit = new RedditAPIClient();

const memes = await reddit.getSubredditByName('memes', metadata);
const posts = await memes.getHotPosts(metadata).all();
const hottestPost = posts[0];
const comments = await hottestPost.comments().all();

Table of contents

Methods

Methods

addEditorToWikiPage

addEditorToWikiPage(subredditName, page, username, metadata): Promise<void>

Add an editor to a wiki page.

Parameters

NameTypeDescription
subredditNamestringThe name of the subreddit the wiki is in.
pagestringThe name of the wiki page to add the editor to.
usernamestringThe username of the user to add as an editor.
metadataundefined | MetadataMetadata from the originating handler. Make sure to always include this.

Returns

Promise<void>


addModNote

addModNote(options, metadata): Promise<ModNote>

Add a mod note.

Parameters

NameTypeDescription
optionsOmit<Prettify<PostNotesRequest & { label: UserNoteLabel ; redditId: `t1_${string}` | `t3_${string}` }>, "redditId"> & { redditId: string }Options for the request
metadataundefined | MetadataMetadata from the originating handler. Make sure to always include this.

Returns

Promise<ModNote>

A Promise that resolves if the mod note was successfully added.


addWidget

addWidget(widgetData, metadata): Promise<ImageWidget | CalendarWidget | TextAreaWidget | ButtonWidget | CommunityListWidget | PostFlairWidget | CustomWidget>

Add a widget to a subreddit.

Parameters

NameTypeDescription
widgetDataAddWidgetDataThe data for the widget to add.
metadataundefined | MetadataMetadata from the originating handler. Make sure to always include this.

Returns

Promise<ImageWidget | CalendarWidget | TextAreaWidget | ButtonWidget | CommunityListWidget | PostFlairWidget | CustomWidget>

  • The added Widget object.

addWikiContributor

addWikiContributor(username, subredditName, metadata): Promise<void>

Add a user as a wiki contributor for a subreddit.

Parameters

NameTypeDescription
usernamestringThe username of the user to add as a wiki contributor. e.g. 'spez'
subredditNamestringThe name of the subreddit to add the user as a wiki contributor. e.g. 'memes'
metadataundefined | MetadataMetadata from the originating handler. Make sure to always include this.

Returns

Promise<void>


approve

approve(id, metadata): Promise<void>

Approve a post or comment.

Example

await reddit.approve('t3_123456', metadata);
await reddit.approve('t1_123456', metadata);

Parameters

NameTypeDescription
idstringThe id of the post (t3) or comment (t1) to approve.
metadataundefined | MetadataMetadata from the originating handler. Make sure to always include this.

Returns

Promise<void>


approveUser

approveUser(username, subredditName, metadata): Promise<void>

Approve a user to post in a subreddit.

Parameters

NameTypeDescription
usernamestringThe username of the user to approve. e.g. 'spez'
subredditNamestringThe name of the subreddit to approve the user in. e.g. 'memes'
metadataundefined | MetadataMetadata from the originating handler. Make sure to always include this.

Returns

Promise<void>


banUser

banUser(options, metadata): Promise<void>

Ban a user from a subreddit.

Parameters

NameTypeDescription
optionsBanUserOptionsOptions for the request
metadataundefined | MetadataMetadata from the originating handler. Make sure to always include this.

Returns

Promise<void>


banWikiContributor

banWikiContributor(options, metadata): Promise<void>

Ban a user from contributing to the wiki on a subreddit.

Parameters

NameTypeDescription
optionsBanWikiContributorOptionsOptions for the request
metadataundefined | MetadataMetadata from the originating handler. Make sure to always include this.

Returns

Promise<void>


createPostFlairTemplate

createPostFlairTemplate(options, metadata): Promise<FlairTemplate>

Create a post flair template for a subreddit.

Parameters

NameTypeDescription
optionsCreateFlairTemplateOptionsOptions for the request
metadataundefined | MetadataMetadata from the originating handler. Make sure to always include this.

Returns

Promise<FlairTemplate>

The created FlairTemplate object.


createUserFlairTemplate

createUserFlairTemplate(options, metadata): Promise<FlairTemplate>

Create a user flair template for a subreddit.

Parameters

NameTypeDescription
optionsCreateFlairTemplateOptionsOptions for the request
metadataundefined | MetadataMetadata from the originating handler. Make sure to always include this.

Returns

Promise<FlairTemplate>

The created FlairTemplate object.


createWikiPage

createWikiPage(options, metadata): Promise<WikiPage>

Create a new wiki page for a subreddit.

Parameters

NameTypeDescription
optionsCreateWikiPageOptionsOptions for the request
metadataundefined | MetadataMetadata from the originating handler. Make sure to always include this.

Returns

Promise<WikiPage>

  • The created WikiPage object.

crosspost

crosspost(options, metadata): Promise<Post>

Crossposts a post to a subreddit.

Parameters

NameTypeDescription
optionsCrosspostOptionsOptions for crossposting a post
metadataundefined | MetadataMetadata from the originating handler. Make sure to always include this.

Returns

Promise<Post>

  • A Promise that resolves to a Post object.

deleteFlairTemplate

deleteFlairTemplate(subredditName, flairTemplateId, metadata): Promise<void>

Delete a flair template from a subreddit.

Parameters

NameTypeDescription
subredditNamestringThe name of the subreddit to delete the flair template from.
flairTemplateIdstringThe ID of the flair template to delete.
metadataundefined | MetadataMetadata from the originating handler. Make sure to always include this.

Returns

Promise<void>


deleteModNote

deleteModNote(options, metadata): Promise<boolean>

Delete a mod note.

Parameters

NameTypeDescription
optionsDeleteNotesRequestOptions for the request
metadataundefined | MetadataMetadata from the originating handler. Make sure to always include this.

Returns

Promise<boolean>


deleteWidget

deleteWidget(subredditName, widgetId, metadata): Promise<void>

Delete a widget from a subreddit.

Parameters

NameTypeDescription
subredditNamestringThe name of the subreddit to delete the widget from.
widgetIdstringThe ID of the widget to delete.
metadataundefined | MetadataMetadata from the originating handler. Make sure to always include this.

Returns

Promise<void>


editFlairTemplate

editFlairTemplate(options, metadata): Promise<FlairTemplate>

Edit a flair template for a subreddit. This can be either a post or user flair template. Note: If you leave any of the options fields as undefined, they will reset to their default values.

Parameters

NameTypeDescription
optionsEditFlairTemplateOptionsOptions for the request
metadataundefined | MetadataMetadata from the originating handler. Make sure to always include this.

Returns

Promise<FlairTemplate>

The edited FlairTemplate object.


getAppUser

getAppUser(metadata): Promise<User>

Get the user that the app runs as on the provided metadata.

Example

const user = await reddit.getAppUser(metadata);

Parameters

NameTypeDescription
metadataundefined | MetadataMetadata from the originating handler. Make sure to always include this.

Returns

Promise<User>

A Promise that resolves to a User object.


getApprovedUsers

getApprovedUsers(options, metadata): Listing<User>

Get a list of users who have been approved to post in a subreddit.

Parameters

NameTypeDescription
optionsGetSubredditUsersOptionsOptions for the request
metadataundefined | MetadataMetadata from the originating handler. Make sure to always include this.

Returns

Listing<User>

A Listing of User objects.


getBannedUsers

getBannedUsers(options, metadata): Listing<User>

Get a list of users who are banned from a subreddit.

Parameters

NameTypeDescription
optionsGetSubredditUsersOptionsOptions for the request
metadataundefined | MetadataMetadata from the originating handler. Make sure to always include this.

Returns

Listing<User>

A Listing of User objects.


getBannedWikiContributors

getBannedWikiContributors(options, metadata): Listing<User>

Get a list of users who are banned from contributing to the wiki on a subreddit.

Parameters

NameTypeDescription
optionsGetSubredditUsersOptionsOptions for the request
metadataundefined | MetadataMetadata from the originating handler. Make sure to always include this.

Returns

Listing<User>

A Listing of User objects.


getCommentById

getCommentById(id, metadata): Promise<Comment>

Get a Comment object by ID

Example

const comment = await reddit.getCommentById('t1_1qjpg', metadata);

Parameters

NameTypeDescription
idstringThe ID (starting with t1_) of the comment to retrieve. e.g. t1_1qjpg
metadataundefined | MetadataMetadata from the originating handler. Make sure to always include this.

Returns

Promise<Comment>

A Promise that resolves to a Comment object.


getComments

getComments(options, metadata): Listing<Comment>

Get a list of comments from a specific post or comment.

Example

const comments = await reddit.getComments({
postId: 't3_1qjpg',
limit: 1000,
pageSize: 100
}, metadata).all();

Parameters

NameTypeDescription
optionsGetCommentsOptionsOptions for the request
metadataundefined | MetadataMetadata from the originating handler. Make sure to always include this.

Returns

Listing<Comment>

A Listing of Comment objects.


getCommentsByUser

getCommentsByUser(options, metadata): Listing<Comment>

Get a list of comments by a specific user.

Parameters

NameTypeDescription
optionsGetCommentsByUserOptionsOptions for the request
metadataundefined | MetadataMetadata from the originating handler. Make sure to always include this.

Returns

Listing<Comment>

A Listing of Comment objects.


getControversialPosts

getControversialPosts(options, metadata): Listing<Post>

Get a list of controversial posts from a specific subreddit.

Example

const posts = await reddit.getControversialPosts({
subredditName: 'memes',
timeframe: 'day',
limit: 1000,
pageSize: 100
}, metadata).all();

Parameters

NameTypeDescription
optionsGetPostsOptionsWithTimeframeOptions for the request
metadataundefined | MetadataMetadata from the originating handler. Make sure to always include this.

Returns

Listing<Post>

A Listing of Post objects.


getCurrentSubreddit

getCurrentSubreddit(metadata): Promise<Subreddit>

Retrieves the current subreddit based on the provided metadata.

Example

const currentSubreddit = await reddit.getCurrentSubreddit(metadata);

Parameters

NameTypeDescription
metadataundefined | MetadataMetadata from the originating handler. Make sure to always include this.

Returns

Promise<Subreddit>

A Promise that resolves a Subreddit object.


getCurrentUser

getCurrentUser(metadata): Promise<User>

Get the current calling user based on the provided metadata.

Example

const user = await reddit.getCurrentUser(metadata);

Parameters

NameTypeDescription
metadataundefined | MetadataMetadata from the originating handler. Make sure to always include this.

Returns

Promise<User>

A Promise that resolves to a User object.


getHotPosts

getHotPosts(options, metadata): Listing<Post>

Get a list of hot posts from a specific subreddit.

Example

const posts = await reddit.getHotPosts({
subredditName: 'memes',
limit: 1000,
pageSize: 100
}, metadata).all();

Parameters

NameTypeDescription
optionsGetHotPostsOptionsOptions for the request
metadataundefined | MetadataMetadata from the originating handler. Make sure to always include this.

Returns

Listing<Post>

A Listing of Post objects.


getModNotes

getModNotes(options, metadata): Listing<ModNote>

Get a list of mod notes related to a user in a subreddit.

Parameters

NameTypeDescription
optionsPrettify<Pick<GetNotesRequest, "subreddit" | "user"> & { filter?: ModNoteType } & Pick<ListingFetchOptions, "before" | "limit">>Options for the request
metadataundefined | MetadataMetadata from the originating handler. Make sure to always include this.

Returns

Listing<ModNote>

A listing of ModNote objects.


getModerationLog

getModerationLog(options, metadata): Listing<ModAction>

Get the moderation log for a subreddit.

Example

const modActions = await reddit.getModerationLog({
subredditName: 'memes',
limit: 1000,
pageSize: 100
}, metadata).all();

Parameters

NameTypeDescription
optionsGetModerationLogOptionsOptions for the request
metadataundefined | MetadataAdditional metadata to attach to the request

Returns

Listing<ModAction>

A Listing of ModAction objects.


getModerators

getModerators(options, metadata): Listing<User>

Get a list of users who are moderators for a subreddit.

Parameters

NameTypeDescription
optionsGetSubredditUsersOptionsOptions for the request
metadataundefined | MetadataMetadata from the originating handler. Make sure to always include this.

Returns

Listing<User>

A Listing of User objects.


getMutedUsers

getMutedUsers(options, metadata): Listing<User>

Get a list of users who are muted in a subreddit.

Parameters

NameTypeDescription
optionsGetSubredditUsersOptionsOptions for the request
metadataundefined | MetadataMetadata from the originating handler. Make sure to always include this.

Returns

Listing<User>

A listing of User objects.


getNewPosts

getNewPosts(options, metadata): Listing<Post>

Get a list of new posts from a specific subreddit.

Example

const posts = await reddit.getNewPosts({
subredditName: 'memes',
timeframe: 'day',
limit: 1000,
pageSize: 100
}, metadata).all();

Parameters

NameTypeDescription
optionsGetPostsOptionsOptions for the request
metadataundefined | MetadataMetadata from the originating handler. Make sure to always include this.

Returns

Listing<Post>

A Listing of Post objects.


getPostById

getPostById(id, metadata): Promise<Post>

Gets a Post object by ID

Parameters

NameType
idstring
metadataundefined | Metadata

Returns

Promise<Post>

A Promise that resolves to a Post object.


getPostFlairTemplates

getPostFlairTemplates(subredditName, metadata): Promise<FlairTemplate[]>

Get the list of post flair templates for a subreddit.

Parameters

NameTypeDescription
subredditNamestringThe name of the subreddit to get the post flair templates for.
metadataundefined | MetadataMetadata from the originating handler. Make sure to always include this.

Returns

Promise<FlairTemplate[]>

A Promise that resolves with an array of FlairTemplate objects.


getPostsByUser

getPostsByUser(options, metadata): Listing<Post>

Get a list of posts from a specific user.

Parameters

NameTypeDescription
optionsGetPostsByUserOptionsOptions for the request
metadataundefined | MetadataMetadata from the originating handler. Make sure to always include this.

Returns

Listing<Post>

A Listing of Post objects.


getRisingPosts

getRisingPosts(options, metadata): Listing<Post>

Get a list of hot posts from a specific subreddit.

Example

const posts = await reddit.getRisingPosts({
subredditName: 'memes',
timeframe: 'day',
limit: 1000,
pageSize: 100
}, metadata).all();

Parameters

NameTypeDescription
optionsGetPostsOptionsOptions for the request
metadataundefined | MetadataMetadata from the originating handler. Make sure to always include this.

Returns

Listing<Post>

A Listing of Post objects.


getSubredditById

getSubredditById(id, metadata): Promise<Subreddit>

Gets a Subreddit object by ID

Example

const memes = await reddit.getSubredditById('t5_2qjpg', metadata);

Parameters

NameTypeDescription
idstringThe ID (starting with t5_) of the subreddit to retrieve. e.g. t5_2qjpg
metadataundefined | MetadataMetadata from the originating handler. Make sure to always include this.

Returns

Promise<Subreddit>

A Promise that resolves a Subreddit object.


getSubredditByName

getSubredditByName(name, metadata): Promise<Subreddit>

Gets a Subreddit object by name

Example

const askReddit = await reddit.getSubredditByName('askReddit', metadata);

Parameters

NameTypeDescription
namestringThe name of a subreddit omitting the r/. This is case insensitive.
metadataundefined | MetadataMetadata from the originating handler. Make sure to always include this.

Returns

Promise<Subreddit>

A Promise that resolves a Subreddit object.


getTopPosts

getTopPosts(options, metadata): Listing<Post>

Get a list of controversial posts from a specific subreddit.

Example

const posts = await reddit.getControversialPosts({
subredditName: 'memes',
timeframe: 'day',
limit: 1000,
pageSize: 100
}, metadata).all();

Parameters

NameTypeDescription
optionsGetPostsOptionsWithTimeframeOptions for the request
metadataundefined | MetadataMetadata from the originating handler. Make sure to always include this.

Returns

Listing<Post>

A Listing of Post objects.


getUserById

getUserById(id, metadata): Promise<User>

Gets a User object by ID

Example

const user = await reddit.getUserById('t2_1qjpg', metadata);

Parameters

NameTypeDescription
idstringThe ID (starting with t2_) of the user to retrieve. e.g. t2_1qjpg
metadataundefined | MetadataMetadata from the originating handler. Make sure to always include this.

Returns

Promise<User>

A Promise that resolves to a User object.


getUserByUsername

getUserByUsername(username, metadata): Promise<User>

Gets a User object by username

Example

const user = await reddit.getUserByUsername('devvit', metadata);

Parameters

NameTypeDescription
usernamestringThe username of the user omitting the u/. e.g. 'devvit'
metadataundefined | MetadataMetadata from the originating handler. Make sure to always include this.

Returns

Promise<User>

A Promise that resolves to a User object.


getUserFlairTemplates

getUserFlairTemplates(subredditName, metadata): Promise<FlairTemplate[]>

Get the list of user flair templates for a subreddit.

Parameters

NameTypeDescription
subredditNamestringThe name of the subreddit to get the user flair templates for.
metadataundefined | MetadataMetadata from the originating handler. Make sure to always include this.

Returns

Promise<FlairTemplate[]>

A Promise that resolves with an array of FlairTemplate objects.


getWidgets

getWidgets(subredditName, metadata): Promise<(ImageWidget | CalendarWidget | TextAreaWidget | ButtonWidget | CommunityListWidget | PostFlairWidget | CustomWidget)[]>

Get the widgets for a subreddit.

Parameters

NameTypeDescription
subredditNamestringThe name of the subreddit to get the widgets for.
metadataundefined | MetadataMetadata from the originating handler. Make sure to always include this.

Returns

Promise<(ImageWidget | CalendarWidget | TextAreaWidget | ButtonWidget | CommunityListWidget | PostFlairWidget | CustomWidget)[]>

  • An array of Widget objects.

getWikiContributors

getWikiContributors(options, metadata): Listing<User>

Get a list of users who are wiki contributors of a subreddit.

Parameters

NameTypeDescription
optionsGetSubredditUsersOptionsOptions for the request
metadataundefined | MetadataMetadata from the originating handler. Make sure to always include this.

Returns

Listing<User>

A Listing of User objects.


getWikiPage

getWikiPage(subredditName, page, metadata): Promise<WikiPage>

Get a wiki page from a subreddit.

Parameters

NameTypeDescription
subredditNamestringThe name of the subreddit to get the wiki page from.
pagestringThe name of the wiki page to get.
metadataundefined | MetadataMetadata from the originating handler. Make sure to always include this.

Returns

Promise<WikiPage>

The requested WikiPage object.


getWikiPageRevisions

getWikiPageRevisions(options, metadata): Listing<WikiPageRevision>

Get the revisions for a wiki page.

Parameters

NameTypeDescription
optionsGetPageRevisionsOptionsOptions for the request
metadataundefined | MetadataMetadata from the originating handler. Make sure to always include this.

Returns

Listing<WikiPageRevision>

A Listing of WikiPageRevision objects.


getWikiPageSettings

getWikiPageSettings(subredditName, page, metadata): Promise<WikiPageSettings>

Get the settings for a wiki page.

Parameters

NameTypeDescription
subredditNamestringThe name of the subreddit the wiki is in.
pagestringThe name of the wiki page to get the settings for.
metadataundefined | MetadataMetadata from the originating handler. Make sure to always include this.

Returns

Promise<WikiPageSettings>

A WikiPageSettings object.


getWikiPages

getWikiPages(subredditName, metadata): Promise<string[]>

Get the wiki pages for a subreddit.

Parameters

NameTypeDescription
subredditNamestringThe name of the subreddit to get the wiki pages from.
metadataundefined | MetadataMetadata from the originating handler. Make sure to always include this.

Returns

Promise<string[]>

A list of the wiki page names for the subreddit.


inviteModerator

inviteModerator(options, metadata): Promise<void>

Invite a user to become a moderator of a subreddit.

Parameters

NameTypeDescription
optionsInviteModeratorOptionsOptions for the request
metadataundefined | MetadataMetadata from the originating handler. Make sure to always include this.

Returns

Promise<void>


muteUser

muteUser(options, metadata): Promise<void>

Mute a user in a subreddit. Muting a user prevents them from sending modmail.

Parameters

NameTypeDescription
optionsMuteUserOptionsOptions for the request
metadataundefined | MetadataMetadata from the originating handler. Make sure to always include this.

Returns

Promise<void>


remove

remove(id, isSpam, metadata): Promise<void>

Remove a post or comment.

Example

await reddit.remove('t3_123456', false, metadata);
await reddit.remove('t1_123456', true, metadata);

Parameters

NameTypeDescription
idstringThe id of the post (t3) or comment (t1) to remove.
isSpambooleanWhether or not the post/comment is spam.
metadataundefined | MetadataMetadata from the originating handler. Make sure to always include this.

Returns

Promise<void>


removeEditorFromWikiPage

removeEditorFromWikiPage(subredditName, page, username, metadata): Promise<void>

Remove an editor from a wiki page.

Parameters

NameTypeDescription
subredditNamestringThe name of the subreddit the wiki is in.
pagestringThe name of the wiki page to remove the editor from.
usernamestringThe username of the user to remove as an editor.
metadataundefined | MetadataMetadata from the originating handler. Make sure to always include this.

Returns

Promise<void>


removeModerator

removeModerator(username, subredditName, metadata): Promise<void>

Remove a user as a moderator of a subreddit.

Parameters

NameTypeDescription
usernamestringThe username of the user to remove as a moderator. e.g. 'spez'
subredditNamestringThe name of the subreddit to remove the user as a moderator from. e.g. 'memes'
metadataundefined | MetadataMetadata from the originating handler. Make sure to always include this.

Returns

Promise<void>


removePostFlair

removePostFlair(subredditName, postId, metadata): Promise<void>

Remove the flair for a post in a subreddit.

Parameters

NameTypeDescription
subredditNamestringThe name of the subreddit to remove the flair from.
postIdstringThe ID of the post to remove the flair from.
metadataundefined | MetadataMetadata from the originating handler. Make sure to always include this.

Returns

Promise<void>


removeUser

removeUser(username, subredditName, metadata): Promise<void>

Remove a user's approval to post in a subreddit.

Parameters

NameTypeDescription
usernamestringThe username of the user to remove approval from. e.g. 'spez'
subredditNamestringThe name of the subreddit to remove the user's approval from. e.g. 'memes'
metadataundefined | MetadataMetadata from the originating handler. Make sure to always include this.

Returns

Promise<void>


removeUserFlair

removeUserFlair(subredditName, username, metadata): Promise<void>

Remove the flair for a user in a subreddit.

Parameters

NameTypeDescription
subredditNamestringThe name of the subreddit to remove the flair from.
usernamestringThe username of the user to remove the flair from.
metadataundefined | MetadataMetadata from the originating handler. Make sure to always include this.

Returns

Promise<void>


removeWikiContributor

removeWikiContributor(username, subredditName, metadata): Promise<void>

Remove a user's wiki contributor status for a subreddit.

Parameters

NameTypeDescription
usernamestringThe username of the user to remove wiki contributor status from. e.g. 'spez'
subredditNamestringThe name of the subreddit to remove the user's wiki contributor status from. e.g. 'memes'
metadataundefined | MetadataMetadata from the originating handler. Make sure to always include this.

Returns

Promise<void>


reorderWidgets

reorderWidgets(subredditName, orderByIds, metadata): Promise<void>

Reorder the widgets for a subreddit.

Parameters

NameTypeDescription
subredditNamestringThe name of the subreddit to reorder the widgets for.
orderByIdsstring[]An array of widget IDs in the order that they should be displayed.
metadataundefined | MetadataMetadata from the originating handler. Make sure to always include this.

Returns

Promise<void>


revertWikiPage

revertWikiPage(subredditName, page, revisionId, metadata): Promise<void>

Revert a wiki page to a previous revision.

Parameters

NameTypeDescription
subredditNamestringThe name of the subreddit the wiki is in.
pagestringThe name of the wiki page to revert.
revisionIdstringThe ID of the revision to revert to.
metadataundefined | MetadataMetadata from the originating handler. Make sure to always include this.

Returns

Promise<void>


revokeModeratorInvite

revokeModeratorInvite(username, subredditName, metadata): Promise<void>

Revoke a moderator invite for a user to a subreddit.

Parameters

NameTypeDescription
usernamestringThe username of the user to revoke the invite for. e.g. 'spez'
subredditNamestringThe name of the subreddit to revoke the invite for. e.g. 'memes'
metadataundefined | MetadataMetadata from the originating handler. Make sure to always include this.

Returns

Promise<void>


sendPrivateMessage

sendPrivateMessage(options, metadata): Promise<void>

Sends a private message to a user.

Parameters

NameTypeDescription
optionsSendPrivateMessageOptionsThe options for sending the message.
metadataundefined | MetadataMetadata from the orignating handler.

Returns

Promise<void>

A Promise that resolves if the private message was successfully sent.


sendPrivateMessageAsSubreddit

sendPrivateMessageAsSubreddit(options, metadata): Promise<void>

Sends a private message to a user on behalf of a subreddit.

Parameters

NameTypeDescription
optionsSendPrivateMessageAsSubredditOptionsThe options for sending the message as a subreddit.
metadataundefined | MetadataMetadata from the orignating handler.

Returns

Promise<void>

A Promise that resolves if the private message was successfully sent.


setModeratorPermissions

setModeratorPermissions(username, subredditName, permissions, metadata): Promise<void>

Update the permissions of a moderator of a subreddit.

Parameters

NameTypeDescription
usernamestringThe username of the user to update the permissions for. e.g. 'spez'
subredditNamestringThe name of the subreddit. e.g. 'memes'
permissionsModeratorPermission[]The permissions to give the user. e.g ['posts', 'wiki']
metadataundefined | MetadataMetadata from the originating handler. Make sure to always include this.

Returns

Promise<void>


setPostFlair

setPostFlair(options, metadata): Promise<void>

Set the flair for a post in a subreddit.

Parameters

NameTypeDescription
optionsSetPostFlairOptionsOptions for the request
metadataundefined | MetadataMetadata from the originating handler. Make sure to always include this.

Returns

Promise<void>


setUserFlair

setUserFlair(options, metadata): Promise<void>

Set the flair for a user in a subreddit.

Parameters

NameTypeDescription
optionsSetUserFlairOptionsOptions for the request
metadataundefined | MetadataMetadata from the originating handler. Make sure to always include this.

Returns

Promise<void>


submitComment

submitComment(options, metadata): Promise<Comment>

Submit a new comment to a post or comment.

Parameters

NameTypeDescription
optionsObjectYou must provide either options.text or options.richtext but not both.
metadataundefined | MetadataMetadata from the originating handler. Make sure to always include this.

Returns

Promise<Comment>

A Promise that resolves to a Comment object.


submitPost

submitPost(options, metadata): Promise<Post>

Submits a new post to a subreddit.

Example

const post = await reddit.submitPost({
subredditName: 'devvit',
title: 'Hello World',
richtext: new RichTextBuilder()
.heading({ level: 1 }, (h) => {
h.rawText('Hello world');
})
.codeBlock({}, (cb) => cb.rawText('This post was created via the Devvit API'))
.build()
}, metadata);

Parameters

NameTypeDescription
optionsSubmitPostOptionsEither a self post or a link post.
metadataundefined | MetadataMetadata from the originating handler. Make sure to always include this.

Returns

Promise<Post>

A Promise that resolves to a Post object.


unbanUser

unbanUser(username, subredditName, metadata): Promise<void>

Unban a user from a subreddit.

Parameters

NameTypeDescription
usernamestringThe username of the user to unban. e.g. 'spez'
subredditNamestringThe name of the subreddit to unban the user from. e.g. 'memes'
metadataundefined | MetadataMetadata from the originating handler. Make sure to always include this.

Returns

Promise<void>


unbanWikiContributor

unbanWikiContributor(username, subredditName, metadata): Promise<void>

Parameters

NameTypeDescription
usernamestringThe username of the user to unban. e.g. 'spez'
subredditNamestringThe name of the subreddit to unban the user from contributing to the wiki on. e.g. 'memes'
metadataundefined | MetadataMetadata from the originating handler. Make sure to always include this.

Returns

Promise<void>


unmuteUser

unmuteUser(username, subredditName, metadata): Promise<void>

Unmute a user in a subreddit. Unmuting a user allows them to send modmail.

Parameters

NameTypeDescription
usernamestringThe username of the user to unmute. e.g. 'spez'
subredditNamestringThe name of the subreddit to unmute the user in. e.g. 'memes'
metadataundefined | MetadataMetadata from the originating handler. Make sure to always include this.

Returns

Promise<void>


updateWikiPage

updateWikiPage(options, metadata): Promise<WikiPage>

Update a wiki page.

Parameters

NameTypeDescription
optionsUpdateWikiPageOptionsOptions for the request
metadataundefined | MetadataMetadata from the originating handler. Make sure to always include this.

Returns

Promise<WikiPage>

The updated WikiPage object.


updateWikiPageSettings

updateWikiPageSettings(options, metadata): Promise<WikiPageSettings>

Update the settings for a wiki page.

Parameters

NameTypeDescription
optionsUpdatePageSettingsOptionsOptions for the request
metadataundefined | MetadataMetadata from the originating handler. Make sure to always include this.

Returns

Promise<WikiPageSettings>

A WikiPageSettings object.