0

anyone knows how to get a the relys for a specific tweet by it's ID maybe? i been trying but can't find any on the tweepy docs not discord's, can't seem to find anything about how to do it with twitter api v2, also is there a way to requests latest tweets from multiple users in bulk?

import tweepy
twitter_client = tweepy.Client(bearer_token=bearer)
all_tweets = twitter_client.get_users_tweets(id=(1334299956241461248,1346973288040263680,154449778,1516418305455763466))
print(all_tweets)

this is how i try it, but it's returning me an error

The `id` query parameter value [(1334299956241461248, 1346973288040263680, 154449778, 1516418305455763466)] is not valid

any help appreiciated, and thank you

AD DAB
  • 60
  • 1
  • 6

2 Answers2

1

and i found the answer at the end

def check_replys(tweet_ID):
    query = f"conversation_id:{tweet_ID} is:reply"
    replys= twitter_client.search_recent_tweets(query= query )
    return replys

you can find more info about making a query at https://developer.twitter.com/en/docs/twitter-api/tweets/search/integrate/build-a-query

AD DAB
  • 60
  • 1
  • 6
  • All I got is Response(data=None, includes={}, errors=[], meta={'result_count': 0}). Is there any alternative way? – Dammio Oct 24 '22 at 02:27
  • not sure what went wrong but pretty sure that method still works, probably the tweet you are trying to get got no replies? anyway, if you want to try something else then try this query string instead `in_reply_to_tweet_id: {tweet_id]}` – AD DAB Oct 24 '22 at 16:11
  • I built my own code to solve the problem. I believed Tweepy does not support full functions. – Dammio Oct 30 '22 at 02:17
0

You're asking two questions:

  1. How to get replies by Tweet ID
  2. How to lookup the latest Tweets for several users

For 1 - you can search for Tweets by conversation ID. The conversation ID is the ID of the original Tweet that led to the replies. The only wrinkle here is that by default (v2 Essential access) you can only search for Tweets within the past 7 days, so if the Tweet you want replies for is older than that, you'll need Academic access for full archive search.

For 2 - you cannot pass multiple values to the id parameter all at once. If you look at the Tweepy documentation and at the Twitter API docs, you'll see that id gets substituted into the URL path for the call, so you have to call the API multiple times, one for each user ID. That should be possible using a loop.

Andy Piper
  • 11,422
  • 2
  • 26
  • 49