Separate Client.get_tweet from Client.get_tweets
authorHarmon <Harmon758@gmail.com>
Wed, 24 Feb 2021 03:22:02 +0000 (21:22 -0600)
committerHarmon <Harmon758@gmail.com>
Wed, 24 Feb 2021 03:22:02 +0000 (21:22 -0600)
tweepy/client.py

index abcb4c862be8e09eeb2d7e2204df0f4cbd0a79d5..3970e2fd9fbe0ebbbfb076cb17b6f2e6fca24536 100644 (file)
@@ -138,21 +138,26 @@ class Client:
             user_auth=True
         )
 
-    def get_tweets(self, ids, **params):
+    def get_tweet(self, id, **params):
         """
         Tweet lookup
         https://developer.twitter.com/en/docs/twitter-api/tweets/lookup/api-reference/get-tweets
-        https://developer.twitter.com/en/docs/twitter-api/tweets/lookup/api-reference/get-tweets-id
         """
-        route = "/2/tweets"
-
-        if isinstance(ids, (int, str)):
-            route += f"/{ids}"
-        else:
-            params["ids"] = ids
+        return self._make_request(
+            "GET", f"/2/tweets/{id}", params=params,
+            allowed_params=("expansions", "media.fields", "place.fields",
+                            "poll.fields", "tweet.fields", "user.fields"),
+            data_type=Tweet
+        )
 
+    def get_tweets(self, ids, **params):
+        """
+        Tweets lookup
+        https://developer.twitter.com/en/docs/twitter-api/tweets/lookup/api-reference/get-tweets-id
+        """
+        params["ids"] = ids
         return self._make_request(
-            "GET", route, params=params,
+            "GET", "/2/tweets", params=params,
             allowed_params=("ids", "expansions", "media.fields",
                             "place.fields", "poll.fields", "tweet.fields",
                             "user.fields"),