Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Twitter API V2 video url

Tags:

rest

twitter

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.

like image 790
Jimmar Avatar asked Oct 19 '25 04:10

Jimmar


1 Answers

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

like image 163
Anthony Avatar answered Oct 21 '25 19:10

Anthony



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!