Twitter allows users to download parts of their data, see How to download your Twitter archive.
But what's not included in that data dump is the usernames/handles of the people that you follow or are following you. All you get is account IDs which is just an internal number and so a bit useless when it comes to archival.
Here's a way to get that data (you need to know how to run stuff in the terminal):
- Go to your Twitter profile in a desktop browser (Firefox or Chrome)
- Right click on page → Inspect → Network tab
- Click on the Following link (e.g. https://twitter.com/{yourusername}/following)
- Scroll through the entire list of following users (e.g. keep pressing page down, space or scroll)
- In the filter/search bar of the Network tab: type
Following?
to only get the requests we're interested in - Right click on requests → Save All As HAR or Save all as HAR with content; Name it
following.har
Then, in a terminal, with jq installed, run:
jq -r '.log.entries[] | .response.content.text | fromjson? | .data.user.result.timeline.timeline.instructions[-1].entries[] | .content.itemContent.user_results.result | values | [.rest_id, .legacy.screen_name, .legacy.name, .legacy.description] | @csv' following.har > following.csv
That will give you the ID, username, display name and description in a CSV file.
If you want to archive all the data that Twitter returns, run this to get a JSON stream:
jq -r '.log.entries[] | .response.content.text | fromjson? | .data.user.result.timeline.timeline.instructions[-1].entries[] | .content.itemContent.user_results.result | values' following.har > following.json
If you want to export your followers too, clear the Network requests and then repeat the steps but use the Followers link, filter requests by Followers?
and use different filenames. The rest is the same.
(Tweet about it here: https://twitter.com/niborst/status/1589883662048579584)
Hey, any help with this?
