.. literalinclude:: ../examples/API_v2/create_tweet.py
- .. tab:: Get User's Timeline
+ .. tab:: Get User's Tweets
- .. literalinclude:: ../examples/API_v2/get_users_timeline.py
+ .. literalinclude:: ../examples/API_v2/get_users_tweets.py
.. tab:: Get User's Mentions
.. literalinclude:: ../examples/API_v2/get_users_mentions.py
-
- .. tab:: Get Tweets liked by a User
+
+ .. tab:: Get User's Liked Tweets
.. literalinclude:: ../examples/API_v2/get_liked_tweets.py
-
- .. tab:: Get Retweeters of a Tweet
+
+ .. tab:: Get Retweeters
.. literalinclude:: ../examples/API_v2/get_retweeters.py
-
- .. tab:: Get Users liking a Tweet
+
+ .. tab:: Get Liking Users
.. literalinclude:: ../examples/API_v2/get_liking_users.py
-
- .. tab:: Get a User's Followers
+
+ .. tab:: Get User's Followers
.. literalinclude:: ../examples/API_v2/get_users_followers.py
-
- .. tab:: Lookup Tweets using Tweet IDs
- .. literalinclude:: ../examples/API_v2/lookup_tweets_using_tweet_ids.py
-
- .. tab:: Lookup Users using User IDs
+ .. tab:: Get Tweets
+
+ .. literalinclude:: ../examples/API_v2/get_tweets.py
+
+ .. tab:: Get Users
+
+ .. literalinclude:: ../examples/API_v2/get_users.py
- .. literalinclude:: ../examples/API_v2/lookup_users_using_user_ids.py
-
- .. tab:: Recent Tweet Counts
+ .. tab:: Get Recent Tweets Count
- .. literalinclude:: ../examples/API_v2/recent_tweets_count.py
+ .. literalinclude:: ../examples/API_v2/get_recent_tweets_count.py
import tweepy
-# Replace bearer token value with your own
bearer_token = ""
-# Initializing the Tweepy client
client = tweepy.Client(bearer_token)
-# Replace User ID
-id = 2244994945
+# Get User's Liked Tweets
-# 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, tweet_fields=["created_at"])
+# This endpoint/method allows you to get information about a user’s liked
+# Tweets
-# Print the Tweet id and the time the Tweet was created
-for tweet in tweets.data:
- print(tweet.id)
- print(tweet.created_at)
-
\ No newline at end of file
+user_id = 2244994945
+
+# By default, only the ID and text fields of each Tweet will be returned
+# Additional fields can be retrieved using the tweet_fields parameter
+response = client.get_liked_tweets(user_id, tweet_fields=["created_at"])
+
+for tweet in response.data:
+ print(tweet.id, tweet.created_at)
import tweepy
-# Replace bearer token value with your own
bearer_token = ""
-# Initializing the Tweepy client
client = tweepy.Client(bearer_token)
-# Replace Tweet ID
-id = 1441054496931541004
+# Get Liking Users
-# 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, user_fields=["profile_image_url"])
+# This endpoint/method allows you to get information about a Tweet’s liking
+# users
-# 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
+tweet_id = 1460323737035677698
+
+# By default, only the ID, name, and username fields of each user will be
+# returned
+# Additional fields can be retrieved using the user_fields parameter
+response = client.get_liking_users(tweet_id, user_fields=["profile_image_url"])
+
+for user in response.data:
+ print(user.username, user.profile_image_url)
--- /dev/null
+import tweepy
+
+
+bearer_token = ""
+
+client = tweepy.Client(bearer_token)
+
+# Get Recent Tweets Count
+
+# This endpoint/method returns count of Tweets from the last seven days that
+# match a search query
+
+query = "Tweepy -is:retweet"
+
+# Granularity is what you want the timeseries count data to be grouped by
+# You can request minute, hour, or day granularity
+# The default granularity, if not specified is hour
+response = client.get_recent_tweets_count(query, granularity="day")
+
+for count in response.data:
+ print(count)
import tweepy
-# Replace bearer token value with your own
bearer_token = ""
-# Initializing the Tweepy client
client = tweepy.Client(bearer_token)
-# Replace Tweet ID
-id = 1441054496931541004
+# Get Retweeters
-# 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, user_fields=["profile_image_url"])
+# This endpoint/method allows you to get information about who has Retweeted a
+# Tweet
-# 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
+tweet_id = 1460323737035677698
+
+# By default, only the ID, name, and username fields of each user will be
+# returned
+# Additional fields can be retrieved using the user_fields parameter
+response = client.get_retweeters(tweet_id, user_fields=["profile_image_url"])
+
+for user in response.data:
+ print(user.username, user.profile_image_url)
--- /dev/null
+import tweepy
+
+
+bearer_token = ""
+
+client = tweepy.Client(bearer_token)
+
+# Get Tweets
+
+# This endpoint/method returns a variety of information about the Tweet(s)
+# specified by the requested ID or list of IDs
+
+tweet_ids = [1460323737035677698, 1293593516040269825, 1293595870563381249]
+
+# By default, only the ID and text fields of each Tweet will be returned
+# Additional fields can be retrieved using the tweet_fields parameter
+response = client.get_tweets(tweet_ids, tweet_fields=["created_at"])
+
+for tweet in response.data:
+ print(tweet.id, tweet.created_at)
--- /dev/null
+import tweepy
+
+
+bearer_token = ""
+
+client = tweepy.Client(bearer_token)
+
+# Get Users
+
+# This endpoint/method returns a variety of information about one or more users
+# specified by the requested IDs or usernames
+
+user_ids = [2244994945, 6253282]
+
+# By default, only the ID, name, and username fields of each user will be
+# returned
+# Additional fields can be retrieved using the user_fields parameter
+response = client.get_users(ids=user_ids, user_fields=["profile_image_url"])
+
+for user in response.data:
+ print(user.username, user.profile_image_url)
import tweepy
-# Replace bearer token value with your own
bearer_token = ""
-# Initializing the Tweepy client
client = tweepy.Client(bearer_token)
-# Replace user ID
-id = 2244994945
+# Get User's Followers
-# 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, user_fields=["profile_image_url"])
+# This endpoint/method returns a list of users who are followers of the
+# specified user ID
-# 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
+user_id = 2244994945
+
+# By default, only the ID, name, and username fields of each user will be
+# returned
+# Additional fields can be retrieved using the user_fields parameter
+response = client.get_users_followers(
+ user_id, user_fields=["profile_image_url"]
+)
+
+for user in response.data:
+ print(user.username, user.profile_image_url)
+
+# By default, this endpoint/method returns 100 results
+# You can retrieve up to 1000 users by specifying max_results
+response = client.get_users_followers(user_id, max_results=1000)
import tweepy
-# Replace bearer token value with your own
bearer_token = ""
-# Initializing the Tweepy client
client = tweepy.Client(bearer_token)
-# Replace user ID
-id = 2244994945
+# Get User's Mentions
-# By default the Tweet ID and Tweet text will be returned.
-tweets = client.get_users_mentions(id)
+# This endpoint/method returns Tweets mentioning a single user specified by the
+# requested user ID
-# Print the Tweet id
-for tweet in tweets.data:
+user_id = 2244994945
+
+response = client.get_users_mentions(user_id)
+
+# By default, only the ID and text fields of each Tweet will be returned
+for tweet in response.data:
print(tweet.id)
-
\ No newline at end of file
+ print(tweet.text)
+
+# By default, the 10 most recent Tweets will be returned
+# You can retrieve up to 100 Tweets by specifying max_results
+response = client.get_users_mentions(user_id, max_results=100)
+++ /dev/null
-import tweepy
-
-
-# Replace bearer token value with your own
-bearer_token = ""
-
-# Initializing the Tweepy client
-client = tweepy.Client(bearer_token)
-
-# Replace user ID
-id = 2244994945
-
-# By default the Tweet ID and Tweet text will be returned.
-tweets = client.get_users_tweets(id)
-
-# Print the Tweet id
-for tweet in tweets.data:
- print(tweet.id)
-
\ No newline at end of file
--- /dev/null
+import tweepy
+
+
+bearer_token = ""
+
+client = tweepy.Client(bearer_token)
+
+# Get User's Tweets
+
+# This endpoint/method returns Tweets composed by a single user, specified by
+# the requested user ID
+
+user_id = 2244994945
+
+response = client.get_users_tweets(user_id)
+
+# By default, only the ID and text fields of each Tweet will be returned
+for tweet in response.data:
+ print(tweet.id)
+ print(tweet.text)
+
+# By default, the 10 most recent Tweets will be returned
+# You can retrieve up to 100 Tweets by specifying max_results
+response = client.get_users_tweets(user_id, max_results=100)
+++ /dev/null
-import tweepy
-
-
-# Replace bearer token value with your own
-bearer_token = ""
-
-# Initializing the Tweepy client
-client = tweepy.Client(bearer_token)
-
-# Replace Tweet IDs
-ids = [1409935014725177344, 1409931481552543749, 1441054496931541004]
-
-# By default the Tweet ID and Tweet text are returned. If you want additional
-# Tweet fields, specify those in tweet_fields
-tweets = client.get_tweets(ids=ids, tweet_fields=["created_at"])
-
-# Print the Tweet id and the time the Tweet was created
-for tweet in tweets.data:
- print(tweet.id)
- print(tweet.created_at)
-
\ No newline at end of file
+++ /dev/null
-import tweepy
-
-
-# Replace bearer token value with your own
-bearer_token = ""
-
-# Initializing the Tweepy client
-client = tweepy.Client(bearer_token)
-
-# Replace User IDs
-ids = [2244994945, 6253282]
-
-# 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"])
-
-# 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
+++ /dev/null
-import tweepy
-
-
-# Replace bearer token value with your own
-bearer_token = ""
-
-# Initializing the Tweepy client
-client = tweepy.Client(bearer_token)
-
-# Replace with your own search query
-query = "tweepy -is:retweet"
-
-# Granularity can be day, hour or minute
-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
# objects
tweets = response.data
-# Each Tweet object has default id and text fields
+# Each Tweet object has default ID and text fields
for tweet in tweets:
print(tweet.id)
+ print(tweet.text)
# By default, this endpoint/method returns 10 results
# You can retrieve up to 100 Tweets by specifying max_results