Search code examples
pythonapitwittertweepytwitterapi-python

Can I tweet mp4 files with tweepy?


I was just wondering if it was possible to tweet an mp4 file with tweepy (maybe using api.update_with_media). I've seen a post from a few years ago saying that it's not possible with the official tweepy, but I find it really hard to believe that there's no way to do it with the official tweepy. Can anyone please help?


Solution

  • update_with_media was deprecated as a Twitter API method about 5 years ago. This pre-dated the ability to upload GIFs and video MP4s. If you want to post media on Twitter via the API, you must find a library that supports the media upload endpoints (and chunked uploads). The process is

    • upload the media file (chunked if necessary depending on size and format)
    • retrieve a media ID string
    • post a Tweet, and add the media ID to the Tweet.

    Note that you can only post multiple images on a single Tweet; you can only post a single GIF or video file on a single Tweet, not multiple.

    I do not believe the default Tweepy release supports this but I could be wrong, you’ll need to check the Tweepy documentation.

    Do NOT use update_with_media - it’s very old and unsupported as an API path.

    Also worth being aware that tweepy itself is a third party library - that we at Twitter LOVE - but this is not officially supported.