How to retweet using Python?

In continuation with a series of tutorial on Twitter Automation, we will be discussing about how to retweet a particular tweet using Python. In the previous article here,  we saw how to post tweet using Python. We saw how to use Tweepy package in Python to post tweets.

In this article, we will see, how to search Tweets based on certain keywords and retweet them.

Example : Let us say, you want to search Tweets based on the keyword “Hillary Clinton” and retweet them. We will see how to do it using Tweepy in Python.

Step 1 :  First step is to obtain the Consumer Keys and Access Token key. If you dont know how to obtain this, please refer here.

Step 2 :  Import Tweepy and

In this example, I assume that Tweepy is already installed. If not, you can install Tweepy using the command:


Step 3 :  First we need to login using the Consumer keys and Access token keys. You can login and obtain the API using the following code.

Step 4 :  Now, we need to search for all those tweets having the keyword “Hillary Clinton”. You can do using Tweepy as follows :

Based on the search key, you will get multiple tweets matching the keywords. Each of the tweet is identified by the Tweet ID.

Step 5 :  Once we know the id of each Tweet which has the keyword “Hillary Clinton”. You can retweet using the following code:

I hope, you find this article very useful. If you have any doubts or have any comments concerning this tutorial, Please leave a comment or contact me. I would be glad to help.



Kiran Chandrashekhar

Hey, Thanks for dropping by. My name is Kiran Chandrashekhar. I am a full-time software freelancer. I love Maths and Mathematical Shortcuts. Numbers fascinate me. I will be posting articles on Mathematical Shortcuts, Software Tips, Programming Tips in this website. I love teaching students preparing for various competitive examinations. Read my complete story.

Leave a Reply

Your email address will not be published. Required fields are marked *

Protected by WP Anti Spam