Skip to content
Twitter Purge
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.


Purges old Tweets



You probably don't want to host this yourself

This was me just futzing around with what Google Cloud had to offer. It theoretically will work for you, but other tools are likely easier and more feature complete.

If you want to clean up old tweets, check out or

If you want to host your tweets somewhere else, use



If you do want to run this on your account

Setup a Twitter Developer account and create an app:

Running Locally

Set the following environment variables:

  • BLUMHOUSE_TWITTER_NAME - the user name you want to begin purging
  • TWITTER_API_KEY - from Twitter API
  • TWITTER_API_SECRET - from Twitter API
  • BLUMHOUSE_WHITELISTED_TWEET_ID - a single Tweet you'd like to preserve. Useful for pinned tweets

Get a Google Cloud account and create a project.

Create a Service Account and download the JSON credentials file. Add an GOOGLE_APPLICATION_CREDENTIALS environment variable pointing to that file.

Run the purge:

cd fns
go run ./cmd/local/

Generate the static site:

cd static
npm i
npm start

Running on The Cloud

Edit fns/cloudbuild.yaml and setup Google Cloud Build to deploy new Cloud Functions on commits:

After the first deploy, add the appropriate environment variables (see above) to the Cloud Functions. I did this manually through the console.

Setup a new Cloud Scheduler trigger to execute the function periodically through a Pub/Sub event:

In the Cloud Scheduler payload, pass in two values separated by a comma, such as 2,1. The first value is the number of Tweets to attempt to purge. The second is the number of days of recent Twitter history to preserve.

Next, edit static/cloudbuild.yaml and setup another Cloud Build job to deploy to a new static content bucket on commits:

Deleting Older Tweets

You can only get the last 3200 tweets this way. To purge everything, see fns/cmd/purge2.

You can’t perform that action at this time.