add tweet pin/unpin functions master
authorIan Kelling <iank@fsf.org>
Tue, 21 Nov 2023 19:27:00 +0000 (14:27 -0500)
committerIan Kelling <iank@fsf.org>
Tue, 21 Nov 2023 19:27:00 +0000 (14:27 -0500)
tweepy/api.py

index 37caf07afcd8008b3e6ba46777e76414127cf4fb..2072ac66d06b85355b3ceeca571d3e2593c86329 100644 (file)
@@ -2543,6 +2543,36 @@ class API:
             'GET', 'account/settings', use_cache=False, **kwargs
         )
 
+    def pin_tweet(self, id, **kwargs):
+        """pin_tweet(*, id)
+
+        Pin a tweet on your account.
+
+        References
+        ----------
+
+        As of 2023-11-21, this endpoint is not listed in twitter's api documentation.
+        """
+
+        return self.request(
+            'POST', 'account/pin_tweet', endpoint_parameters=('tweet_mode', 'id'), tweet_mode='extended', id=id, **kwargs
+        )
+
+    def unpin_tweet(self, id, **kwargs):
+        """pin_tweet(*, id)
+
+        Unpin a tweet on your account
+
+        References
+        ----------
+
+        As of 2023-11-21, this endpoint is not listed in twitter's api documentation.
+        """
+
+        return self.request(
+            'POST', 'account/unpin_tweet', endpoint_parameters=('tweet_mode', 'id'), tweet_mode='extended', id=id, **kwargs
+        )
+
     @payload('user')
     def verify_credentials(self, **kwargs):
         """verify_credentials(*, include_entities, skip_status, include_email)