So I am building a tool which displays tweets and allows the selection of them for various purposes. For some reason I can’t appear to retrieve any details about a YouTube embed from the tweet object.

For example, tweet URL: https://twitter.com/TeamEndpoint/status/1588229525900607488?s=20&t=xDfArfZk5_C9Ot3CrgjM5Q/TeamEndpoint/status/1588229525900607488

(curl: curl
-H “Authorization: Bearer $TOKEN”
https://api.twitter.com/2/tweets/1588229525900607488?tweet.fields=attachments%2Centities&expansions=attachments.media_keys&media.fields=type%2Cmedia_key%2Cpreview_image_url%2Curl” )

Is there anyway to get the correct information to display?

For ease, the playground link:

These are player cards: Player Card | Docs | Twitter Developer Platform you will need to retrieve these form the meta tags on YouTube.com html

Thanks @IgorBrigadir, but even so, is there no way to get the fact that one exists on the post via the API?

Oh, i also just noticed, the thing about this exact tweet, 1588229525900607488 is that it was posted via the Advertiser tools, which has special ad “cards” that can be anything the advertiser makes - in this case, it’s a youtube video, but this “card” and link is not available to the public API - only the ad owner can get the card info.

A normal tweet with a youtube link would be something like: 1588589376732164096

Where the json has the title and description and image sometimes, which might actually be enough:

"urls": [
          {
            "start": 17,
            "end": 40,
            "url": "https://t.co/FBEd3cWxCl",
            "expanded_url": "https://www.youtube.com/watch?v=W2j1TfyyDdo",
            "display_url": "youtube.com/watch?v=W2j1Tf…",
            "images": [
              {
                "url": "https://pbs.twimg.com/news_img/1588589380494467072/4WMWnIuw?format=jpg&name=orig",
                "width": 1280,
                "height": 720
              },
              {
                "url": "https://pbs.twimg.com/news_img/1588589380494467072/4WMWnIuw?format=jpg&name=150x150",
                "width": 150,
                "height": 150
              }
            ],
            "status": 200,
            "title": "Jesus Loves The Acid - Official - The Ecstasy Club (1988)",
            "description": "This is the official channel of the Ecstasy Club!!'Jesus Loves The Acid' by The Ecstasy Club. (1988) copy right control info@magikmusik.co.uk",
            "unwound_url": "https://www.youtube.com/watch?v=W2j1TfyyDdo"
          }
        ]

Otherwise the same is in the html:

<meta name="twitter:card" content="player">
<meta name="twitter:site" content="@youtube">
<meta name="twitter:url" content="https://www.youtube.com/watch?v=W2j1TfyyDdo">
<meta name="twitter:title" content="Jesus Loves The Acid  - Official - The Ecstasy Club (1988)">
<meta name="twitter:description" content="This is the official channel of the Ecstasy Club!!&#39;Jesus Loves The Acid&#39; by The Ecstasy Club. (1988) copy right control info@magikmusik.co.uk">
<meta name="twitter:image" content="https://i.ytimg.com/vi/W2j1TfyyDdo/maxresdefault.jpg">
<meta name="twitter:app:name:iphone" content="YouTube">
<meta name="twitter:app:id:iphone" content="544007664">
<meta name="twitter:app:name:ipad" content="YouTube">
<meta name="twitter:app:id:ipad" content="544007664">
<meta name="twitter:app:url:iphone" content="vnd.youtube://www.youtube.com/watch?v=W2j1TfyyDdo&amp;feature=applinks">
<meta name="twitter:app:url:ipad" content="vnd.youtube://www.youtube.com/watch?v=W2j1TfyyDdo&amp;feature=applinks">
<meta name="twitter:app:name:googleplay" content="YouTube">
<meta name="twitter:app:id:googleplay" content="com.google.android.youtube">
<meta name="twitter:app:url:googleplay" content="https://www.youtube.com/watch?v=W2j1TfyyDdo">
<meta name="twitter:player" content="https://www.youtube.com/embed/W2j1TfyyDdo">
<meta name="twitter:player:width" content="480">
<meta name="twitter:player:height" content="360">

Right OK, but I’m actually querying the tweets authenticated as the originating user. Does this elevated access not give me any additional insight to be able to get the embed?

Being honest, I would also find it strange that I would need elevated access given that it’s visible on the public Twitter feed.

Yes, i think to see the card created in twitter ads, you need to use the Ads API with the user’s token.