I've been trying to get a specific users last tweets and the public metrics of it. In playgrounds i can easily get it but when i use tweepy i can't get public metrics.
import tweepy
auth = tweepy.OAuth2BearerHandler("token")
api = tweepy.API(auth)
client = tweepy.Client("token")
allTweets = client.get_users_tweets(900437084321832960,tweet_fields=['public_metrics',])
print(allTweets)
this returns only text and id but not public metrics
{
"id": "id",
"text": "text"
},
Created a small python script to get last 1000 tweets of the user. It first creates jsonObject that will store all the tweet data later. Then creates a for loop, in first if block it checks if there is a pagination token or not. After getting the tweets it changes the data into a json object.