When Twitter released the Direct Messages feature, it was not possible to get back old messages due to technical choices and limitations. However, they have never been deleted and it is now possible to read any of the messages posted in a conversation using Direct Messages.
Sadly, the DMs are not part of your archive (because I guess it would require to contain tweets from other people of your conversations to make sense). Consequently, the answer from silpol is currently not correct because you will not be able to retrieve your DMs this way for the moment.
If you just would like to read or download them to keep them offline, there are three ways to do this:
- Use the Twitter API and deal with its limitations: only the latest 200 Direct Messages can be retrieved.
- Scroll up manually in the conversation in a browser or on your phone. This method will be sufficient for small conversations but unreliable for large ones.
- Use a tool to simulate the browsing of a conversation and parse the result.
Maybe I can help you with the third idea. I have created a tool (https://github.com/Mincka/DMArchiver) to download my direct messages, with the ability to also download the uploaded images and GIFs (as MP4).
Because it does not rely on the API, it is possible to download more than 200 messages. The script just simulate the "scrolling method" and parse the result. No third-party service is involved so you keep your credentials and messages private.
If you would like to use the same logic to make your own program to retrieve the DMs, the main idea is to make requests in loop by calling the following URL with a valid auth_token
cookie value for the authentication and parse the json response:
https://twitter.com/messages/with/conversation?id=1337&max_entry_id=1337
The max_entry_id
value is not required for the first request. You need to use the value of the min_entry_id
variable in the response as the new max_entry_id
in each subsequent iteration to get the next 20 (older) tweets. When max_entry_id
is not in the json response, you are at the begin of the thread.