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" you can do manually in a conversation or on your phone.
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:
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.