I wrote up my experiences as an explainer for nontechnical people: https://jamiehall.cc/2020/03/10/delete-all-your-tweets-with-...
TL;DR, here is the oneliner I've been using:
$ twurl "/1.1/statuses/user_timeline.json?screen_name=YOUR_TWITTER_HANDLE&count=200
&max_id=$(
twurl '/1.1/statuses/user_timeline.json?screen_name=YOUR_TWITTER_HANDLE&count=200&include_rts=1'
| jq -c -r '.[] | .id_str' | head -10 | tail -1)
&include_rts=1"
| jq -c -r '.[] | .id_str'
| parallel -j 10 -a - twurl -X POST /1.1/statuses/destroy/{1}.json
> /dev/null
[Edit: I've put line breaks in there to make it more legible.]I'm curious if it's possible to do better. In particular: could this be more elegant? Is it possible to do it using common built-ins, instead of twurl and jq?
Any suggestions or improvements would be very welcome!
This would also allow others to fork your code to improve upon or keep a copy for themselves.
jq -c -r '.[] | .id_str'
# Can be rewritten to
jq -r '.[].id_str'
jq -c -r '.[] | .id_str' | head -10 | tail -1
# Can be rewritten to
jq -r '.[9].id_str'
Other than that, thanks for writing this! I've been thinking about a tool like this and this might come in handy. The code looks fine to me although I would probably spin this out into a script and add some logging, as others have already pointed out.
[0] https://developer.twitter.com/en/docs/basics/rate-limits
Those might include tweets that you'd most want to delete. As well as ones that you'd most want to retain, for that matter.