pip install tweepy
pip3 install tweepy
client = tweepy.Client(
consumer_key="API / Consumer Key here",
consumer_secret="API / Consumer Secret here",
access_token="Access Token here",
access_token_secret="Access Token Secret here"
)
tweet=client.get_tweet("tweet_id here")
{
"data": {
"id": "1460323737035677698",
"text": "Introducing a new era for the Twitter Developer Platform! nn📣The Twitter API v2 is now the primary API and full of new featuresn⏱Immediate access for most use cases, or apply to get more access for freen📖Removed certain restrictions in the Policynhttps://t.co/Hrm15bkBWJ https://t.co/YFfCDErHsg",
"edit_history_tweet_ids": [
"1460323737035677698"
]
}
}
text=tweet.data.get('text')
tweet=client.get_tweet("tweet_id here",tweet_fields="public_metrics,author_id")
count_fav=tweet.data.get("public_metrics").get("like_count")
user=client.get_user("user's id here")
user=client.get_user(username="username here")
{
"data": {
"id": "2244994945",
"name": "Twitter Dev",
"username": "TwitterDev"
}
}