Hide navigation sidebar
Hide table of contents sidebar
Back to top
Toggle table of contents sidebar

# reddit.subreddits

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

  Subreddits is a Listing class that provides various subreddit lists.

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

    Initialize a `PRAWBase` instance.

    Parameters:

      reddit – An instance of `Reddit`.

  default(**generator_kwargs: Union[str, int, Dict[str, str]]) → Iterator[praw.models.Subreddit]

    Return a `ListingGenerator` for default subreddits.

    Additional keyword arguments are passed in the initialization of `ListingGenerator`.

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

    Alias for `premium()` to maintain backwards compatibility.

  new(**generator_kwargs: Union[str, int, Dict[str, str]]) → Iterator[praw.models.Subreddit]

    Return a `ListingGenerator` for new subreddits.

    Additional keyword arguments are passed in the initialization of `ListingGenerator`.

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

    Return an instance of `cls` from `data`.

    Parameters:

      - data – The structured data.

      - reddit – An instance of `Reddit`.

  popular(**generator_kwargs: Union[str, int, Dict[str, str]]) → Iterator[praw.models.Subreddit]

    Return a `ListingGenerator` for popular subreddits.

    Additional keyword arguments are passed in the initialization of `ListingGenerator`.

  premium(**generator_kwargs: Union[str, int, Dict[str, str]]) → Iterator[praw.models.Subreddit]

    Return a `ListingGenerator` for premium subreddits.

    Additional keyword arguments are passed in the initialization of `ListingGenerator`.

  recommended(subreddits: List[Union[str, praw.models.Subreddit]], omit_subreddits: Optional[List[Union[str, praw.models.Subreddit]]] = None) → List[praw.models.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: Union[str, int, Dict[str, str]]) → Iterator[praw.models.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.Subreddit]

    Return list of `Subreddit`s whose names begin with `query`.

    Parameters:

      - query – Search for subreddits beginning with this string.

      - exact – Return only exact matches to `query` (default: `False`).

      - include_nsfw – Include subreddits labeled NSFW (default: `True`).

  search_by_topic(query: str) → List[praw.models.Subreddit]

    Return list of Subreddits whose topics match `query`.

    Parameters:

      query – Search for subreddits relevant to the search topic.

    Note

    As of 09/01/2020, this endpoint always returns 404.

  stream(**stream_options: Union[str, int, Dict[str, str]]) → Iterator[praw.models.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()`.