How to archive, then delete, old Tweets

I joined Twitter in January 2009 for what might not have been the best of reasons – I was being miserable about it on BBC Radio, and thought I should at least make an effort to try the thing I was being professionally miserable about – and, somehow, have kept using it ever since.

But, as the service has evolved from failwhales, #FFs and permissive API policies regarding third-party clients to its current, er, state, many things have become obvious, and one of them is that there’s precious little reason to leave old tweets live in the system.

With strict character limits, every moment’s tweets exist surrounded by a context that we assume is known to those reading them – the day’s news events, that stupid thing that such-and-such said on TV at 9am, that GIF of the dog with the Gameboy, or whatever – but which is bewilderingly detached when we look back at them even weeks hence.

For any human reading it’s a bit like pulling lines of type from a pile of shredded newspaper and trying to work out what the hell the original story was about – but for anyone with the time and skills it’s a huge archive of your data out there and available to be mined for advertising and god-knows-what-else-people-are-getting-up-to.

And so, many people have taken to auto-deleting their Tweets – 24 hours, seven days, or whatever – after they are posted. There’s a free service at that’s quite popular for this. But if like me you’re the kind of person with a cupboard full of old reporters’ notepads, stuffed full of interviews long-since written, published and lost in a website closure (gnnnnrrgh), you might want to keep an archive for your own reference before deleting.

And with that in mind, I made Tweety Deletey.

Tweety Deletey is a free, customisable tool that scans your Twitter account for tweets older than N days – you choose N, I’m using 30. It then stashes them – the Tweet ID, timestamp and text – in a Postgres database table, and once that’s done deletes the original. So you get a record that you can search, but the Tweet itself disappears from the internet.

It’s written in PHP with dependency management via Composer, so could be quite easily installed on, say, a Mac – but for a neater solution you can one-click install it to a free Heroku dyno, alongside a free Heroku Postgres database and a free Advanced Scheduler add-on. There’s a one click deploy button on the Github Readme. Twitter API credentials are required.