Skip to main content

Class: Reddit

Constructors#

constructor#

+ new Reddit(data: RedditConstructor): Reddit

Parameters#

NameType
dataRedditConstructor

Returns: Reddit

Defined in: reddit.ts:31

Properties#

auth#

• Optional auth: Auth

Defined in: reddit.ts:29


linkUrl#

• linkUrl: string= "https://www.reddit.com"

Defined in: reddit.ts:31

Accessors#

all#

• get all(): Subreddit

The r/all pseudo subreddit

Returns: Subreddit

Defined in: reddit.ts:219


self#

• get self(): null | Self

Returns: null | Self

Defined in: reddit.ts:227

Methods#

collection#

â–¸ collection(id: string): Promise<Collection>

Parameters#

NameType
idstring

Returns: Promise<Collection>

Defined in: reddit.ts:232


login#

â–¸ login(data: AuthData): Promise<void>

Parameters#

NameType
dataAuthData

Returns: Promise<void>

Defined in: reddit.ts:54


oauth#

â–¸ oauth(clientId: string, redirectUri: string, scopes: Scope[], temporary?: boolean): string

Parameters#

NameType
clientIdstring
redirectUristring
scopesScope[]
temporary?boolean

Returns: string

Defined in: reddit.ts:154


searchSubmission#

â–¸ searchSubmission(query: string, options?: SubmissionSearchOptions): Promise<Page<FullSubmission, any>>

Parameters#

NameType
querystring
options?SubmissionSearchOptions

Returns: Promise<Page<FullSubmission, any>>

Defined in: reddit.ts:248


searchSubreddit#

â–¸ searchSubreddit(query: string, options?: SearchOptions): Promise<Page<FullSubreddit, any>>

Search subreddits by title and description

Parameters#

NameType
querystring
options?SearchOptions

Returns: Promise<Page<FullSubreddit, any>>

Defined in: reddit.ts:264


searchUser#

â–¸ searchUser(query: string, options?: SearchOptions): Promise<Page<FullUser, any>>

Parameters#

NameType
querystring
options?SearchOptions

Returns: Promise<Page<FullUser, any>>

Defined in: reddit.ts:279


submission#

â–¸ submission(id: string): Submission

Get a submission

example Get the title of a submission

const s = await r.submission("87").fetch();
console.log(s.title); // The Downing Street Memo

Parameters#

NameTypeDescription
idstringThe id with or without a prefix

Returns: Submission

Defined in: reddit.ts:209


subreddit#

â–¸ subreddit(...names: string[]): Subreddit

Parameters#

NameType
...namesstring[]

Returns: Subreddit

Defined in: reddit.ts:214


trendingSubreddits#

â–¸ trendingSubreddits(): Promise<Subreddit[]>

Returns: Promise<Subreddit[]>

Defined in: reddit.ts:240


user#

â–¸ user(name: string): User

Parameters#

NameType
namestring

Returns: User

Defined in: reddit.ts:223