skip to Main Content

I’m trying to fetch a tweet’s video url using API V2.

Using API V1.1 I can use

https://api.twitter.com/1.1/statuses/show.json?id=<ID>&include_entities=true

and get the direct mp4 urls in the response at

extended_entities.media[0].video_info.variants

But using API V2 I can’t seem to find any ways to get those, I was only able to get the video thumbnail but not the actual video.

I’ve tried it with both the lookup and the recent search endpoints but couldn’t find a way to do that.

In lookup docs twitter says:

This endpoint was recently graduated from Twitter Developer Labs, and is the replacement of v1.1 statuses/show, v1.1 statuses/lookup, and Labs Tweet lookup. If you are currently using any of these endpoints, you can use our migration materials to start working with this new endpoint.

but that doesn’t seem to be the case, is that feature not included ? Also if there is any other way to be able to embed a twitter video in a web page (without the tweet text) that’d be helpful.

3

Answers


  1. The videos are not currently available in the Twitter API v2 at this time. This is a known request.

    Login or Signup to reply.
  2. Progress on twitter-api-v2 media handling, Maybe this will allow the video URLs too in the response.

    https://twittercommunity.com/t/v1-1-media-endpoints-available-for-essential-access-in-the-twitter-api-v2/171664

    Login or Signup to reply.
  3. For those who still looking for an answer, you can do it on the V2 by adding the following parameters :

    • expansions=attachments.media_keys
    • media.fields=variants

    Your final link should give https://api.twitter.com/2/users/{{uid}}/tweets?expansions=attachments.media_keys&media.fields=variants

    Source : https://developer.twitter.com/en/docs/twitter-api/data-dictionary/object-model/media

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search