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 PRAWModel instance.
- Parameters
reddit – An instance of
Reddit.
- default(**generator_kwargs: Union[str, int, Dict[str, str]]) Iterator[praw.models.Subreddit]¶
Return a
ListingGeneratorfor 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
ListingGeneratorfor 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
clsfromdata.- 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
ListingGeneratorfor popular subreddits.Additional keyword arguments are passed in the initialization of
ListingGenerator.
Return a
ListingGeneratorfor premium subreddits.Additional keyword arguments are passed in the initialization of
ListingGenerator.
- recommended(subreddits: List[Union[praw.models.Subreddit, str]], omit_subreddits: Optional[List[Union[praw.models.Subreddit, str]]] = 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
ListingGeneratorof subreddits matchingquery.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 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.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().