RedditPostsLoader#

class langchain_community.document_loaders.reddit.RedditPostsLoader(client_id: str, client_secret: str, user_agent: str, search_queries: Sequence[str], mode: str, categories: Sequence[str] = ['new'], number_posts: int | None = 10)[source]#

Load Reddit posts.

Read posts on a subreddit. First, you need to go to https://www.reddit.com/prefs/apps/ and create your application

Initialize with client_id, client_secret, user_agent, search_queries, mode,

categories, number_posts.

Example: https://www.reddit.com/r/learnpython/

Parameters:
  • client_id (str) – Reddit client id.

  • client_secret (str) – Reddit client secret.

  • user_agent (str) – Reddit user agent.

  • search_queries (Sequence[str]) – The search queries.

  • mode (str) – The mode.

  • categories (Sequence[str]) – The categories. Default: [β€œnew”]

  • number_posts (Optional[int]) – The number of posts. Default: 10

Methods

__init__(client_id,Β client_secret,Β ...[,Β ...])

Initialize with client_id, client_secret, user_agent, search_queries, mode,

alazy_load()

A lazy loader for Documents.

aload()

Load data into Document objects.

lazy_load()

A lazy loader for Documents.

load()

Load reddits.

load_and_split([text_splitter])

Load Documents and split into chunks.

__init__(client_id: str, client_secret: str, user_agent: str, search_queries: Sequence[str], mode: str, categories: Sequence[str] = ['new'], number_posts: int | None = 10)[source]#
Initialize with client_id, client_secret, user_agent, search_queries, mode,

categories, number_posts.

Example: https://www.reddit.com/r/learnpython/

Parameters:
  • client_id (str) – Reddit client id.

  • client_secret (str) – Reddit client secret.

  • user_agent (str) – Reddit user agent.

  • search_queries (Sequence[str]) – The search queries.

  • mode (str) – The mode.

  • categories (Sequence[str]) – The categories. Default: [β€œnew”]

  • number_posts (int | None) – The number of posts. Default: 10

async alazy_load() β†’ AsyncIterator[Document]#

A lazy loader for Documents.

Return type:

AsyncIterator[Document]

async aload() β†’ list[Document]#

Load data into Document objects.

Return type:

list[Document]

lazy_load() β†’ Iterator[Document]#

A lazy loader for Documents.

Return type:

Iterator[Document]

load() β†’ List[Document][source]#

Load reddits.

Return type:

List[Document]

load_and_split(text_splitter: TextSplitter | None = None) β†’ list[Document]#

Load Documents and split into chunks. Chunks are returned as Documents.

Do not override this method. It should be considered to be deprecated!

Parameters:

text_splitter (Optional[TextSplitter]) – TextSplitter instance to use for splitting documents. Defaults to RecursiveCharacterTextSplitter.

Returns:

List of Documents.

Return type:

list[Document]

Examples using RedditPostsLoader