How to use Tweepy to retweet with a comment
Asked Answered
E

3

12

So i am stuck trying to figure out how to retweet a tweet with a comment, this was added to twitter recently.

this is when you click retweet and add a comment to the retweet and retweet it. basically this is what i am talking about :

enter image description here

i was looking at the api and count find a method dedicated to this. And even the retweet method does not have a parameter where i can pass text.

So i was wondering is there a way to do this?

Exsanguine answered 9/11, 2015 at 23:1 Comment(2)
Strange update_status is working for me. Did you try api.update_status(stat_forme, tweet_cid) because its throwing a syntax error using your codeIglesias
api.update_status(stat_forme, tweet_cid) works api.update_status(stat_forme) doesn't work... 403 bad request but if i add status like this it works api.update_status(status=stat_forme)Exsanguine
I
16

Tweepy doesn't have functionality to retweet with your own text, but what you can do is make a url like this https://twitter.com/<user_displayname>/status/<tweet_id> and include it with the text you want comment. It's not a retweet but you are embedding the tweet in your new tweet.

user_displayname - display name of person, whose tweet you are retweeting

tweet_id - tweet id of tweet you are retweeting

Iglesias answered 10/11, 2015 at 0:15 Comment(2)
Update for those that wander in like me, Tweepy now (2020) has retweet functionality. docs.tweepy.org/en/latest/api.html#API.retweetBritish
Just starting using tweepy but what it didn't exist (and still doesn't) is the functionality to retweet with a comment. From what they say in the question and answer, I think the plain retwwet already existedBureaucracy
B
4

September 2021 Update

Tweepy does have the functionality to quote retweet. Just provide the url of the tweet you want to quote into attachment_url of the API.update_status method.

Python example:

# Get the tweet you want to quote
tweet_to_quote_url="https://twitter.com/andypiper/status/903615884664725505"

# Quote it in a new status
api.update_status("text", attachment_url=tweet_to_quote_url)

# Done!
Brendis answered 5/9, 2021 at 22:36 Comment(0)
E
0

In the documentation, there is a quote_tweet_id parameter in create_tweet method.

You can create a new tweet with the tweet ID of the tweet you want to quote.

comment = "Yep!"
quote_tweet = 1592447141720780803

client = tweepy.Client(bearer_token=access_token)
client.create_tweet(text=comment, quote_tweet_id=quote_tweet, user_auth=False)
Elishaelision answered 16/11, 2022 at 11:47 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.