Download Media from Twitter private message



I have a developer who asked me to implement the ability to download a media from a private message.

After being refused due to the authentication information being required I noticed that the data sent from the twitter ton api was different if I was authenticated on compared to use the OAuth authentication credentials from a Twitter app.

It sems that the version contains some kind of header. Would you please give me more information concerning this.

Here is the difference between the 2 files. On the left the version, on the right the same file from the same url but using OAuth.

Thank you


Please note that I did try to add the content-type image/jpeg but the data returned is still the same.


Unfortunately we don’t currently have any API support for image access in DMs, but it’s a known request.


I have seen this request and I understand that it is not supported but I do not understand what Twitter is actually returning.
Could you potentially provide more information on this?


Sorry, I meant that we know that developers would like API support in this area, but at the moment we haven’t documented a formal way to work with images in DMs, so there’s not much I can do to help on this one.


Alright thank you, I will be waiting eagerly for more news!


hi andy, is this there a way to obtain media from DM ? or is still unsupported?


I’m adding an Authorization header with oauth_consumer_key, oauth_signature_method, oauth_nonce, oauth_signature, oauth_timestamp, oauth_version and trying to get and image with a GET request but i receive e 401.


In addition to @MartinRazzo it would be interested to know how the Twitter client fixes the problem of the missing header.
If the team is creating new headers directly within the client it would be interested if you could share the logic.

By providing this information, the developers can integrate this logic in their clients and the TwitterDev team will have a new endpoint available for the public without any effort!


Downloading images from DMs is supported by the API, posting them is not. I believe the original docs were added in 2014 sometime. You just need to oauth the image download


As mentioned in the first post of this thread, the problem is that the API is not returning the same binary as what is being uploaded.

The problem is that the binary returned by Twitter is invalid and cannot be used by any image viewer.