client = tweepy.Client(bearer_token)
# Replace User ID
-id = '2244994945'
+id = 2244994945
# By default the Tweet ID and text are returned. If you want additional fields,
# request them using the tweet_fields parameter
-tweets = client.get_liked_tweets(id=id, tweet_fields=['context_annotations','created_at'])
+tweets = client.get_liked_tweets(id, tweet_fields=["created_at"])
+# Print the Tweet text and the time the Tweet was created
for tweet in tweets.data:
- print(tweet)
+ print(tweet.text)
+ print(tweet.created_at)
\ No newline at end of file
client = tweepy.Client(bearer_token)
# Replace Tweet ID
-id = '1441054496931541004'
+id = 1441054496931541004
# By default the user ID, name and username are returned. user_fields can be used
# to specify the additional user data that you want returned for each user e.g. profile_image_url
-users = client.get_liking_users(id=id, user_fields=['profile_image_url'])
+users = client.get_liking_users(id, user_fields=["profile_image_url"])
+# Print the username and the user's profile image url
for user in users.data:
- print(user)
+ print(user.username)
+ print(user.profile_image_url)
\ No newline at end of file
client = tweepy.Client(bearer_token)
# Replace Tweet ID
-id = '1441054496931541004'
+id = 1441054496931541004
# By default the user ID, name and username are returned. user_fields can be used
# to specify the additional user data that you want returned for each user e.g. profile_image_url
-users = client.get_retweeters(id=id, user_fields=['profile_image_url'])
+users = client.get_retweeters(id, user_fields=["profile_image_url"])
+# Print the username and the user's profile image url
for user in users.data:
- print(user)
+ print(user.username)
+ print(user.profile_image_url)
\ No newline at end of file
client = tweepy.Client(bearer_token)
# Replace user ID
-id = '2244994945'
+id = 2244994945
# By default the user ID, name and username are returned. user_fields can be used
# to specify the additional user data that you want returned for each user e.g. profile_image_url
-users = client.get_users_followers(id=id, user_fields=['profile_image_url'])
+users = client.get_users_followers(id, user_fields=["profile_image_url"])
+# Print the username and the user's profile image url
for user in users.data:
- print(user.id)
+ print(user.username)
+ print(user.profile_image_url)
\ No newline at end of file
client = tweepy.Client(bearer_token)
# Replace user ID
-id = '2244994945'
+id = 2244994945
-# By default the Tweet ID and Tweet text will be returned. If you want additional data,
-# specify it used fields and expansions
-tweets = client.get_users_mentions(id=id)
+# By default the Tweet ID and Tweet text will be returned.
+tweets = client.get_users_mentions(id)
+# Print the Tweet text
for tweet in tweets.data:
- print(tweet)
+ print(tweet.text)
\ No newline at end of file
client = tweepy.Client(bearer_token)
# Replace user ID
-id = '2244994945'
+id = 2244994945
-# By default the Tweet ID and Tweet text will be returned. If you want additional data,
-# specify it used fields and expansions
-tweets = client.get_users_tweets(id=id)
+# By default the Tweet ID and Tweet text will be returned.
+tweets = client.get_users_tweets(id)
+# Print the Tweet text
for tweet in tweets.data:
- print(tweet)
+ print(tweet.text)
\ No newline at end of file
client = tweepy.Client(bearer_token)
# Replace Tweet IDs
-ids = ['1409935014725177344', '1409931481552543749', '1441054496931541004']
+ids = ["1409935014725177344", "1409931481552543749", "1441054496931541004"]
# By default the Tweet ID and Tweet text are returned. If you want additional fields, use the appropriate
# fields and expansions
-tweets = client.get_tweets(ids=ids, tweet_fields=['context_annotations','created_at','geo'])
+tweets = client.get_tweets(ids, tweet_fields=["created_at"])
+# Print the Tweet text and the time the Tweet was created
for tweet in tweets.data:
print(tweet)
+ print(tweet.created_at)
\ No newline at end of file
# By default the user ID, name and username are returned. user_fields can be used
# to specify the additional user data that you want returned for each user e.g. profile_image_url
-users = client.get_users(ids=ids, user_fields=['profile_image_url'])
+users = client.get_users(ids, user_fields=["profile_image_url"])
+# Print the username and the user's profile image url
for user in users.data:
+ print(user.username)
print(user.profile_image_url)
\ No newline at end of file
client = tweepy.Client(bearer_token)
# Replace with your own search query
-query = 'covid -is:retweet'
+query = "tweepy -is:retweet"
# Granularity can be day, hour or minute
-counts = client.get_recent_tweets_count(query=query, granularity='day')
+counts = client.get_recent_tweets_count(query, granularity="day")
+# Print the daily count of Tweets for your query
for count in counts.data:
print(count)
\ No newline at end of file