Tweet entities object doesn't contain media object when original tweet contains native media

media
api

#1

EDIT : This was me being stupid and not trying things out. All I needed to do is add the parameter tweet_mode=extended and now I get the URI resource. I will leave this post in case anyone goes down my rabbit hole.

I am seeing behavior from the Twitter API that I do not understand. Hopefully I am missing something simple.

Endpoint: statuses/show.json

When I send a GET request to this endpoint with an ID parameter of a tweet containing a native media element such as an image or video, the entities object will contain a urls object instead of a media object. Because of this I am unable to get the URI of the media element of a tweet. If a tweet contains a video then I would like to get the URI of the video or image resource.

Below are examples of requests sent and their responses. Sorry for the wall of JSON but it is necessary.

Examples:
Contains No Media Object - https://api.twitter.com/1.1/statuses/show.json?id=1066316777364340736

    "created_at": "Wed Nov 21 19:54:13 +0000 2018",
    "id": 1065332575915380736,
    "id_str": "1065332575915380736",
    "text": "Video test https://t.co/kV47vI0IfG",
    "truncated": false,
    "entities": {
        "hashtags": [],
        "symbols": [],
        "user_mentions": [],
        "urls": [],
        "media": [
            {
                "id": 1065332460731289600,
                "id_str": "1065332460731289600",
                "indices": [
                    11,
                    34
                ],
                "media_url": "http://pbs.twimg.com/ext_tw_video_thumb/1065332460731289600/pu/img/Oe7pLTH3C0lOS7pN.jpg",
                "media_url_https": "https://pbs.twimg.com/ext_tw_video_thumb/1065332460731289600/pu/img/Oe7pLTH3C0lOS7pN.jpg",
                "url": "https://t.co/kV47vI0IfG",
                "display_url": "pic.twitter.com/kV47vI0IfG",
                "expanded_url": "https://twitter.com/JamesLeahy_Roto/status/1065332575915380736/video/1",
                "type": "photo",
                "sizes": {
                    "medium": {
                        "w": 640,
                        "h": 480,
                        "resize": "fit"
                    },
                    "thumb": {
                        "w": 150,
                        "h": 150,
                        "resize": "crop"
                    },
                    "small": {
                        "w": 640,
                        "h": 480,
                        "resize": "fit"
                    },
                    "large": {
                        "w": 640,
                        "h": 480,
                        "resize": "fit"
                    }
                }
            }
        ]
    },
    "extended_entities": {
        "media": [
            {
                "id": 1065332460731289600,
                "id_str": "1065332460731289600",
                "indices": [
                    11,
                    34
                ],
                "media_url": "http://pbs.twimg.com/ext_tw_video_thumb/1065332460731289600/pu/img/Oe7pLTH3C0lOS7pN.jpg",
                "media_url_https": "https://pbs.twimg.com/ext_tw_video_thumb/1065332460731289600/pu/img/Oe7pLTH3C0lOS7pN.jpg",
                "url": "https://t.co/kV47vI0IfG",
                "display_url": "pic.twitter.com/kV47vI0IfG",
                "expanded_url": "https://twitter.com/JamesLeahy_Roto/status/1065332575915380736/video/1",
                "type": "video",
                "sizes": {
                    "medium": {
                        "w": 640,
                        "h": 480,
                        "resize": "fit"
                    },
                    "thumb": {
                        "w": 150,
                        "h": 150,
                        "resize": "crop"
                    },
                    "small": {
                        "w": 640,
                        "h": 480,
                        "resize": "fit"
                    },
                    "large": {
                        "w": 640,
                        "h": 480,
                        "resize": "fit"
                    }
                },
                "video_info": {
                    "aspect_ratio": [
                        4,
                        3
                    ],
                    "duration_millis": 104672,
                    "variants": [
                        {
                            "bitrate": 2176000,
                            "content_type": "video/mp4",
                            "url": "https://video.twimg.com/ext_tw_video/1065332460731289600/pu/vid/640x480/lUycvZV4eNNEIwdN.mp4?tag=6"
                        },
                        {
                            "content_type": "application/x-mpegURL",
                            "url": "https://video.twimg.com/ext_tw_video/1065332460731289600/pu/pl/5T7Jtr9QqodwtWrg.m3u8?tag=6"
                        },
                        {
                            "bitrate": 256000,
                            "content_type": "video/mp4",
                            "url": "https://video.twimg.com/ext_tw_video/1065332460731289600/pu/vid/240x180/hwNKriO200CC_Ycj.mp4?tag=6"
                        },
                        {
                            "bitrate": 832000,
                            "content_type": "video/mp4",
                            "url": "https://video.twimg.com/ext_tw_video/1065332460731289600/pu/vid/480x360/y_7ZlFjstJl47jog.mp4?tag=6"
                        }
                    ]
                },
                "additional_media_info": {
                    "monetizable": false
                }
            }
        ]
    },
    "source": "<a href=\"http://twitter.com\" rel=\"nofollow\">Twitter Web Client</a>",
    "in_reply_to_status_id": null,
    "in_reply_to_status_id_str": null,
    "in_reply_to_user_id": null,
    "in_reply_to_user_id_str": null,
    "in_reply_to_screen_name": null,
    "user": {
        "id": 1060526420831731717,
        "id_str": "1060526420831731717",
        "name": "James Leahy",
        "screen_name": "JamesLeahy_Roto",
        "location": "",
        "description": "",
        "url": null,
        "entities": {
            "description": {
                "urls": []
            }
        },
        "protected": false,
        "followers_count": 0,
        "friends_count": 0,
        "listed_count": 0,
        "created_at": "Thu Nov 08 13:36:17 +0000 2018",
        "favourites_count": 1,
        "utc_offset": null,
        "time_zone": null,
        "geo_enabled": false,
        "verified": false,
        "statuses_count": 2,
        "lang": "en",
        "contributors_enabled": false,
        "is_translator": false,
        "is_translation_enabled": false,
        "profile_background_color": "F5F8FA",
        "profile_background_image_url": null,
        "profile_background_image_url_https": null,
        "profile_background_tile": false,
        "profile_image_url": "http://abs.twimg.com/sticky/default_profile_images/default_profile_normal.png",
        "profile_image_url_https": "https://abs.twimg.com/sticky/default_profile_images/default_profile_normal.png",
        "profile_link_color": "1DA1F2",
        "profile_sidebar_border_color": "C0DEED",
        "profile_sidebar_fill_color": "DDEEF6",
        "profile_text_color": "333333",
        "profile_use_background_image": true,
        "has_extended_profile": false,
        "default_profile": true,
        "default_profile_image": true,
        "following": false,
        "follow_request_sent": false,
        "notifications": false,
        "translator_type": "none"
    },
    "geo": null,
    "coordinates": null,
    "place": null,
    "contributors": null,
    "is_quote_status": false,
    "retweet_count": 0,
    "favorite_count": 1,
    "favorited": true,
    "retweeted": false,
    "possibly_sensitive": false,
    "possibly_sensitive_appealable": false,
    "lang": "en"
}

Contains Media Object - https://api.twitter.com/1.1/statuses/show.json?id=1065332575915380736

    "created_at": "Sat Nov 24 13:05:05 +0000 2018",
    "id": 1066316777364340736,
    "id_str": "1066316777364340736",
    "text": "Today, #OSU and Michigan face off. During this game 68 years ago, the two competed in the infamous “Snow Bowl.” \nPl… https://t.co/uH2B45IUOc",
    "truncated": true,
    "entities": {
        "hashtags": [
            {
                "text": "OSU",
                "indices": [
                    7,
                    11
                ]
            }
        ],
        "symbols": [],
        "user_mentions": [],
        "urls": [
            {
                "url": "https://t.co/uH2B45IUOc",
                "expanded_url": "https://twitter.com/i/web/status/1066316777364340736",
                "display_url": "twitter.com/i/web/status/1…",
                "indices": [
                    117,
                    140
                ]
            }
        ]
    },
    "source": "<a href=\"https://www.hootsuite.com\" rel=\"nofollow\">Hootsuite Inc.</a>",
    "in_reply_to_status_id": null,
    "in_reply_to_status_id_str": null,
    "in_reply_to_user_id": null,
    "in_reply_to_user_id_str": null,
    "in_reply_to_screen_name": null,
    "user": {
        "id": 14084032,
        "id_str": "14084032",
        "name": "Ohio History Connection",
        "screen_name": "OhioHistory",
        "location": "Ohio",
        "description": "Our mission is to spark discovery of Ohio's stories. Embrace the present, share the past & transform the future. Explore our 50+ historic sites.",
        "url": "http://t.co/DMzkNkNasg",
        "entities": {
            "url": {
                "urls": [
                    {
                        "url": "http://t.co/DMzkNkNasg",
                        "expanded_url": "http://www.ohiohistory.org",
                        "display_url": "ohiohistory.org",
                        "indices": [
                            0,
                            22
                        ]
                    }
                ]
            },
            "description": {
                "urls": []
            }
        },
        "protected": false,
        "followers_count": 17038,
        "friends_count": 931,
        "listed_count": 532,
        "created_at": "Wed Mar 05 17:17:54 +0000 2008",
        "favourites_count": 3592,
        "utc_offset": null,
        "time_zone": null,
        "geo_enabled": true,
        "verified": false,
        "statuses_count": 7949,
        "lang": "en",
        "contributors_enabled": false,
        "is_translator": false,
        "is_translation_enabled": false,
        "profile_background_color": "444F6B",
        "profile_background_image_url": "http://abs.twimg.com/images/themes/theme7/bg.gif",
        "profile_background_image_url_https": "https://abs.twimg.com/images/themes/theme7/bg.gif",
        "profile_background_tile": false,
        "profile_image_url": "http://pbs.twimg.com/profile_images/467430044885721088/FM9Y9_yf_normal.png",
        "profile_image_url_https": "https://pbs.twimg.com/profile_images/467430044885721088/FM9Y9_yf_normal.png",
        "profile_banner_url": "https://pbs.twimg.com/profile_banners/14084032/1507741116",
        "profile_link_color": "990000",
        "profile_sidebar_border_color": "DFDFDF",
        "profile_sidebar_fill_color": "F3F3F3",
        "profile_text_color": "333333",
        "profile_use_background_image": true,
        "has_extended_profile": false,
        "default_profile": false,
        "default_profile_image": false,
        "following": false,
        "follow_request_sent": false,
        "notifications": false,
        "translator_type": "none"
    },
    "geo": null,
    "coordinates": null,
    "place": null,
    "contributors": null,
    "is_quote_status": false,
    "retweet_count": 19,
    "favorite_count": 40,
    "favorited": false,
    "retweeted": false,
    "possibly_sensitive": false,
    "possibly_sensitive_appealable": false,
    "lang": "en"
}

I assume this is the expected behavior but I cannot find any documentation about it online.

Am I missing something simple?


#2

Glad you found the answer!


#3