A direct evolution from tweetstorms, Twitter threads are a powerful way to inject storytelling into your feed. Twitter keeps on making improvements to its user interface to make it easier to post threads.

A whole suite of apps, often powered by bots, have appeared to help people make these threads more readable (Thread reader is a good example).

One could argue that threads break away from the original “micro-blogging” purpose of the platform, but they are an important part of a balanced Twitter presence.

The mechanics of a Twitter thread

An important aspect of a thread is pacing. Even though the Twitter web client makes it easy to string together a series of tweets, without the ability to both schedule the first tweet AND control the amount of time between tweets, it’s not that helpful.

I love Chirr app, a smart web app that lets us write and post Twitter threads. It is free to use, although you’ll need to upgrade to a plus or pro plan to unlock features like scheduling, the ability to save drafts, etc.

I’ve made it a habit now to search GitHub for scripts to automate tasks, though. I even contributed a small script to save money on your MailChimp plan.

And sure enough, I found something.

Python can help!

Python is a great language for small, command line-based applications that get stuff done.

A quick GitHub search returned Thread Scheduler, a Python script based on Tweepy, the fantastic Python wrapper for the Twitter API. It does a simple thing very well: It ingests a JSON file that has all the necessary data about your thread and schedules it. Note that if you’re using the script locally, you will have to keep your terminal open until the whole thread is published.

Before I continue, I will assume that:

  • You have a recent version of Python 3 installed on your machine (if you don’t, download it).
  • You are comfortable using the Linux command line, either on a Mac terminal, or the Windows Linux subsystem.
  • You already have a Twitter app registered with Twitter’s dev site.


After creating a virtual environment, activating it, and cloning the repo, you’ll have to install the dependencies through pip and requirements.txt. It’s all in the README.md file.

The next step is to create a settings.py file (in the directory) that will contain your Twitter API credentials: API key, API secret, Access token key, and Access token secret. You’ll find all of these keys in your custom app settings on Twitter’s dev site. You’re now ready to start writing your thread.

Writing the Twitter thread

A JSON thread looks like this:

  • Start is the start date, on your local machine or on your server
  • Tweets is your tweets’ copy
  • Offset is the time, in seconds, between tweets
  • Media is the path where your media (image or video) lives

I’ve used ObjGen, a free web application, to create my JSON thread, and you can use the model I’ve built if that’s helpful. It’s neat.

Once you’ve saved your thread as a JSON file, you can run a quick check by typing:

python thread_scheduler.py tweets.json --check

where tweets.json is your thread file. It is the equivalent of a dry run.

When you’re happy with it, you can run the same command without the –check flag, and the script will go to sleep until the time to start posting comes.

After the thread posts, the script will modify your JSON file to insert the id of the tweets and the timestamp for each. I thought that was a really nice touch.

Have fun!

About Thomas Deneuville

Thomas lives in Freeville, NY with his wife and two sons, where he reads, codes, and plays the bagpipe.

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.