langchain_community.utilities.reddit_search.RedditSearchAPIWrapper¶

class langchain_community.utilities.reddit_search.RedditSearchAPIWrapper[source]¶

Bases: BaseModel

Wrapper for Reddit API

To use, set the environment variables REDDIT_CLIENT_ID, REDDIT_CLIENT_SECRET, REDDIT_USER_AGENT to set the client ID, client secret, and user agent, respectively, as given by Reddit’s API. Alternatively, all three can be supplied as named parameters in the constructor: reddit_client_id, reddit_client_secret, and reddit_user_agent, respectively.

Example

from langchain_community.utilities import RedditSearchAPIWrapper
reddit_search = RedditSearchAPIWrapper()

Create a new model by parsing and validating input data from keyword arguments.

Raises ValidationError if the input data cannot be parsed to form a valid model.

param reddit_client: Any = None¶
param reddit_client_id: Optional[str] = None¶
param reddit_client_secret: Optional[str] = None¶
param reddit_user_agent: Optional[str] = None¶
results(query: str, sort: str, time_filter: str, subreddit: str, limit: int) List[Dict][source]¶

Use praw to search Reddit and return a list of dictionaries, one for each post.

Parameters
  • query (str) –

  • sort (str) –

  • time_filter (str) –

  • subreddit (str) –

  • limit (int) –

Return type

List[Dict]

run(query: str, sort: str, time_filter: str, subreddit: str, limit: int) str[source]¶

Search Reddit and return posts as a single string.

Parameters
  • query (str) –

  • sort (str) –

  • time_filter (str) –

  • subreddit (str) –

  • limit (int) –

Return type

str

Examples using RedditSearchAPIWrapper¶