Skip to content

how to get full tweet text for rwClient.v2.search( ) #269

Answered by alkihis
MarufRien1 asked this question in Q&A
Discussion options

You must be logged in to vote

it's because they're retweets, and retweets are truncated following the 140 chars convention.

You need to ask for retweeted status aside with your request:

const search = await client.v2.search('My search text', { expansions: ['referenced_tweets.id'], 'tweet.fields': ['referenced_tweets'] })

for await (const tweet of search) {
  // Get the retweet object obtained from `includes.tweets` in response object
  const retweet = search.includes.retweet(tweet)
  // If retweet object found, use its text (bc its a retweet), otherwise use original tweet text
  const fullText = retweet ? retweet.text : tweet.text

  // Use {fullText}
}

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by MarufRien1
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants