DEV Community

Discussion on: Get a video URL from Twitter API v2

Collapse
 
carlosduro profile image
CarlosDuro • Edited

Hi @andypiper, Im trying to get video url and already built this:
https://api.twitter.com/2/tweets/${tweetId}?expansions=author_id,attachments.media_keys&tweet.fields=attachments&user.fields=description&media.fields=url,variants,alt_text,preview_image_url,duration_ms,public_metrics;

But no retreiving video URL
function TWEET(url) {
const tweetId = helpers.tweetIdFromURL(url);
const tweet = helpers.tweet(tweetId);
return tweet.data.text;

function MEDIA_OF_TWEET(tweetURL) {
const tweetId = helpers.tweetIdFromURL(tweetURL);
const tweet = helpers.tweet(tweetId);
return helpers.lookupMedia(tweet);

Any suggestions?

Collapse
 
andypiper profile image
Andy Piper

Is it a native video or is it an ad?

You'll have to ask Twitter for help - you can try twittercommunity.com for example. You will need to provide a Tweet ID. I cannot help you any more.