Skip to main content

Bulk convert Twitter IDs to usernames without Twitter API

Apr 18, 2022 · Last updated: May 26, 2022 ·
Posted in weblog#tech
Categories: twitter

Recently, I found myself in a situation where I needed to convert a big list of permanent Twitter user IDs to usernames. Getting the username from an ID is as easy as following what this URL redirects to: https://twitter.com/intent/user?user_id=<ID>. But doing this is bulk requires using the Twitter API in some way. Registering for Twitter developer account requires verifying your phone number and I didn't want to deal with credentials for this temporary task.

Meanwhile, I found tweeterid.com. It allows you to convert Twitter IDs to screen names but you have to do it one by one.

Inspecting the network tab in the developer console, I found that it makes a POST request to https://tweeterid.com/ajax.php with the data input=<ID>. I made a file named twids with each line containing one ID, and ran the following command in my terminal. It takes each line of twids file, makes a POST request with the data, and writes out the response to stdout separated by newline characters.

xargs -I {} curl -s -d 'input={}' 'https://tweeterid.com/ajax.php' -w '\n' < twids

If you're wondering how I ended up with this problem, it all started when I decided to wipe out my Twitter profile and downloaded an archive of my data. I soon discovered that the file containing the list of accounts I followed only included the corresponding Twitter IDs, and I needed the usernames in order to obtain RSS feeds for Twitter accounts from nitter.net.