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][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.

self is explicitly positional-only to allow self as a field name.

param reddit_client: Any [Required]#
param reddit_client_id: str | None [Required]#
param reddit_client_secret: str | None [Required]#
param reddit_user_agent: str | None [Required]#
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