TwitterTweetLoader#
- class langchain_community.document_loaders.twitter.TwitterTweetLoader(auth_handler: OAuthHandler | OAuth2BearerHandler, twitter_users: Sequence[str], number_tweets: int | None = 100)[source]#
Load Twitter tweets.
Read tweets of the userβs Twitter handle.
First you need to go to https://developer.twitter.com/en/docs/twitter-api /getting-started/getting-access-to-the-twitter-api to get your token. And create a v2 version of the app.
Methods
__init__
(auth_handler,Β twitter_users[,Β ...])A lazy loader for Documents.
aload
()Load data into Document objects.
from_bearer_token
(oauth2_bearer_token,Β ...)Create a TwitterTweetLoader from OAuth2 bearer token.
from_secrets
(access_token,Β ...[,Β number_tweets])Create a TwitterTweetLoader from access tokens and secrets.
A lazy loader for Documents.
load
()Load tweets.
load_and_split
([text_splitter])Load Documents and split into chunks.
- Parameters:
auth_handler (Union[OAuthHandler, OAuth2BearerHandler]) β
twitter_users (Sequence[str]) β
number_tweets (Optional[int]) β
- __init__(auth_handler: OAuthHandler | OAuth2BearerHandler, twitter_users: Sequence[str], number_tweets: int | None = 100)[source]#
- Parameters:
auth_handler (Union[OAuthHandler, OAuth2BearerHandler]) β
twitter_users (Sequence[str]) β
number_tweets (Optional[int]) β
- async alazy_load() AsyncIterator[Document] #
A lazy loader for Documents.
- Return type:
AsyncIterator[Document]
- classmethod from_bearer_token(oauth2_bearer_token: str, twitter_users: Sequence[str], number_tweets: int | None = 100) TwitterTweetLoader [source]#
Create a TwitterTweetLoader from OAuth2 bearer token.
- Parameters:
oauth2_bearer_token (str) β
twitter_users (Sequence[str]) β
number_tweets (int | None) β
- Return type:
- classmethod from_secrets(access_token: str, access_token_secret: str, consumer_key: str, consumer_secret: str, twitter_users: Sequence[str], number_tweets: int | None = 100) TwitterTweetLoader [source]#
Create a TwitterTweetLoader from access tokens and secrets.
- Parameters:
access_token (str) β
access_token_secret (str) β
consumer_key (str) β
consumer_secret (str) β
twitter_users (Sequence[str]) β
number_tweets (int | None) β
- Return type:
- 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 TwitterTweetLoader