Build a Twitter Bot with Python, Tweepy and the Twitter API
- This course is for Mac OS Linux
- Basic understanding of python functions and for loops
- Twitter account
This is the perfect weekend project for Python beginners looking to create their first Twitter bot!
What is this course?
This course is for python beginners and twitter lovers who are interested in learning how to build a Twitter bot.
While I have found it helpful to read textbooks and watch online tutorials to get a better understanding of the basics for any subject, nothing beats project-based learning. Actually getting your hands dirty and running into real problems that require specific solutions has been my ideal way to learn something new.
With that being said, the hardest question typically is, what project should I focus on? From my personal experience, I’ve found it beneficial to focus on something you are passionate about. To find that something, just think of what you frequently pay attention to in your spare time, when no one is paying you...to pay attention to it. For me that is Twitter.
We are going with a bot because it will be a fun project to group together various ideas we want to learn, such as APIs, python, and Twitter.
Power of python
I’ve been hooked on it ever since I took the class Automate the Boring Stuff with Python. It is undoubtedly a popular programming language so I think it will be beneficial for many years to come.
This class is not meant to be an introduction to programming or python, so my assumption is that you understand some basics. This class is geared more towards helping you apply Python programming to an actual project to help you better retain information while having fun within the process.
Power of Twitter
I must admit. I am addicted to Twitter. Now before you scorn me, understand that I think it is truly a magical place. One of my favorite Twitter follows, Nikhil Krishnan, has a great presentation about Why Twitter is Dope. In it he basically highlights these reasons which I think get at the root of why I love Twitter so much.
You get to discover people with mutual interests. This can include any age!
Making friends is geo agnostic. You can connect with people all over the world at anytime.
You can also access the smartest people in the world. I get to follow Elon Musk!
Twitter is the idea marketplace at it’s finest. If you are wrong, you will quickly learn why that is.
You get to follow people and not brands. People are brands essentially but atleast its more authentic.
It’s quality over quantity. A few good tweets is infinitely better than a million double taps.
It’s a conversation with an incredibly tight feedback loop.
Power of APIs
APIs are how software talks with other software. We can use APIs to build apps that add new services on top of the platforms or data from the platforms. This essentially provides a new experience for users via a layer of abstraction.
Kate Bae says APIs are “how to unleash data in new ways.” For our purposes, that means creating a bot that retweets an accounts likes. Most platforms, like Slack and Shopify, have public APIs with the hopes that devs build on them to build more value and create lock in.
Basically all of the major social media networks have APIs. They control them in different ways and prevent you from doing certain things while at the same time encouraging you to do other things to make a good user experience with the already public data. We will be using Twitters API for this project. You may not realize it but every time you use your phone, you’re using an API.
What You'll Learn
After you make it through the entirety of the course, you will walk away knowing how to do the following:
Setting up a virtual environment for your code
Signing up as a Twitter developer
How to Use Tweepy to call the Twitter API
Building a Bot that Retweets our Likes
Deploying a Bot using either AWS or Render
Please note this course requires MacOS. I do not have in-depth installation and setup instructions for Windows users.
- Beginner Python developers looking for a fun weekend side project
- Beginner programmers looking to build their first Twitter bot
- Twitter power users who want to automatically retweet a like
- Course Overview
- What You'll Learn
- Setting Up Your Environment
- Installing Python
- Creating A Virtual Environment
- Modules & Packages
- Visual Studio Code
- Creating a Bot Handle
- Creating a New Twitter Application
- Keys and Access Tokens
- Tweepy Overview
- Using Tweepy
- Checking for Likes
- Retweeting Likes
- Converting to Functions
- Finalizing Our Script
- Adding to Github
- Deploying with Render
- Deploying with AWS
I'm a passionate NBA basketball fan that knows way too much about Facebook Paid Advertising and just enough about Python Programming & the Pandas Library. I am constantly working on weekend side projects to help improve my coding abilities and enjoy sharing my work with the internet for constant feedback. I am currently living in San Francisco and work at a tech company. It's a great environment to apply everything I learn and teach online!