reddit.subreddits

class praw.models.Subreddits(reddit: Reddit, _data: Optional[Dict[str, Any]])

Subreddits is a Listing class that provides various subreddit lists.

__init__(reddit: Reddit, _data: Optional[Dict[str, Any]])

Initialize a PRAWModel instance.

Parameters:reddit – An instance of Reddit.
default(**generator_kwargs) → Iterator[praw.models.reddit.subreddit.Subreddit]

Return a ListingGenerator for default subreddits.

Additional keyword arguments are passed in the initialization of ListingGenerator.

gold(**generator_kwargs) → Iterator[praw.models.reddit.subreddit.Subreddit]

Alias for premium() to maintain backwards compatibility.

new(**generator_kwargs) → Iterator[praw.models.reddit.subreddit.Subreddit]

Return a ListingGenerator for new subreddits.

Additional keyword arguments are passed in the initialization of ListingGenerator.

classmethod parse(data: Dict[str, Any], reddit: Reddit) → Any

Return an instance of cls from data.

Parameters:
  • data – The structured data.
  • reddit – An instance of Reddit.
popular(**generator_kwargs) → Iterator[praw.models.reddit.subreddit.Subreddit]

Return a ListingGenerator for popular subreddits.

Additional keyword arguments are passed in the initialization of ListingGenerator.

premium(**generator_kwargs) → Iterator[praw.models.reddit.subreddit.Subreddit]

Return a ListingGenerator for premium subreddits.

Additional keyword arguments are passed in the initialization of ListingGenerator.

recommended(subreddits: List[Union[str, praw.models.reddit.subreddit.Subreddit]], omit_subreddits: Optional[List[Union[str, praw.models.reddit.subreddit.Subreddit]]] = None) → List[praw.models.reddit.subreddit.Subreddit]

Return subreddits recommended for the given list of subreddits.

Parameters:
  • subreddits – A list of Subreddit instances and/or subreddit names.
  • omit_subreddits – A list of Subreddit instances and/or subreddit names to exclude from the results (Reddit’s end may not work as expected).
search(query: str, **generator_kwargs) → Iterator[praw.models.reddit.subreddit.Subreddit]

Return a ListingGenerator of subreddits matching query.

Subreddits are searched by both their title and description.

Parameters:query – The query string to filter subreddits by.

Additional keyword arguments are passed in the initialization of ListingGenerator.

See also

search_by_name() to search by subreddit names

search_by_name(query: str, include_nsfw: bool = True, exact: bool = False) → List[praw.models.reddit.subreddit.Subreddit]

Return list of Subreddits whose names begin with query.

Parameters:
  • query – Search for subreddits beginning with this string.
  • include_nsfw – Include subreddits labeled NSFW (default: True).
  • exact – Return only exact matches to query (default: False).
search_by_topic(query: str) → List[praw.models.reddit.subreddit.Subreddit]

Return list of Subreddits whose topics match query.

Parameters:query – Search for subreddits relevant to the search topic.
stream(**stream_options) → Iterator[praw.models.reddit.subreddit.Subreddit]

Yield new subreddits as they are created.

Subreddits are yielded oldest first. Up to 100 historical subreddits will initially be returned.

Keyword arguments are passed to stream_generator().