youtubeyoutube-apiyoutube-data-api

How do I get info about a Youtube video's chapters from the API?


Recently, YouTube added the ability to break up their videos in the progress bar into sections called "chapters".

https://support.google.com/youtube/answer/9884579?hl=en

Currently I am able to get info about a video from the YouTube API. However, it doesn't seem like there's any info about a video's chapters, and I haven't found anything in the API documentation about chapters. Am I missing something, or is there simply no way to get chapter data yet?


Solution

  • As far as I know, such data is in plain text in the description of the video.

    So, you can use the following example:

    Video used in this demonstration: Top 10 Monsters with 2500 Attack in YuGiOh

    URL Request:

    https://www.googleapis.com/youtube/v3/videos?part=snippet&id=NNgYId7b4j0&key=[YOUR_API_KEY]
    

    Response:

    {
        "kind": "youtube#videoListResponse",
        "etag": "YpVLmrSx1iP8hAJOnumaTBoKqqQ",
        "items": [
            {
                "kind": "youtube#video",
                "etag": "oIoJq5F3RHvBbtVohafaJ_1SThU",
                "id": "NNgYId7b4j0",
                "snippet": {
                    "publishedAt": "2020-09-14T18:37:46Z",
                    "channelId": "UC0roOaAn95Rtgoe078RkVXQ",
                    "title": "Top 10 Monsters with 2500 Attack in YuGiOh",
                    "description": "In this video we'll go over the best monsters that have 2500 attack, and attack threshold for a lot of boss monsters actually.\n\nCheck out my DnD channel @TheD&DLogs \n\n--The List--\nIntro: (0:00)\n10- Blue-Eyes Spirit Dragon: (0:00)\n9- Invoked Mechaba: (2:14)\n8- Number S39: Utopia the Lightning: (3:23)\n7- Earthbound Immortal Aslla Piscu: (4:35)\n6- Eldlich the golden Lord: (6:04)\n5- True King Lithosagym the Disaster: (7:34)\n4- Block Dragon: (8:54)\n3- Astrograph sorcerer: (10:25)\n2- Beatrice lady of the eternal: (12:36)\n1- Firewall Dragon: (14:37)\n- \n-----------------------------------------\n#yugioh #top10 \n\nDuels are all done on EDOpro, its completely free and updated all the time. If you want it, just look for the EDOpro discord and you'll find all you need to download it from there\n\nSome of the Video backgrounds in this video were made by \"Amitai Angor AA VFX\" https://www.youtube.com/dvdangor2011\n\n\nhttps://twitter.com/hirumared\nhttps://twitter.com/TheDuelLogs",
                    "thumbnails": {
                        "default": {
                            "url": "https://i.ytimg.com/vi/NNgYId7b4j0/default.jpg",
                            "width": 120,
                            "height": 90
                        },
                        "medium": {
                            "url": "https://i.ytimg.com/vi/NNgYId7b4j0/mqdefault.jpg",
                            "width": 320,
                            "height": 180
                        },
                        "high": {
                            "url": "https://i.ytimg.com/vi/NNgYId7b4j0/hqdefault.jpg",
                            "width": 480,
                            "height": 360
                        },
                        "standard": {
                            "url": "https://i.ytimg.com/vi/NNgYId7b4j0/sddefault.jpg",
                            "width": 640,
                            "height": 480
                        },
                        "maxres": {
                            "url": "https://i.ytimg.com/vi/NNgYId7b4j0/maxresdefault.jpg",
                            "width": 1280,
                            "height": 720
                        }
                    },
                    "channelTitle": "TheDuelLogs",
                    "tags": [
                        "yugioh",
                        "ygo",
                        "dev",
                        "pro",
                        "link",
                        "duels",
                        "auto-matic duels",
                        "online",
                        "current",
                        "ban",
                        "list",
                        "dueling",
                        "network",
                        "theduellogs",
                        "the",
                        "duel",
                        "logs",
                        "loggs",
                        "Yu",
                        "Gi",
                        "Oh!",
                        "YGOpro",
                        "gimmick",
                        "links",
                        "top ten",
                        "2020",
                        "edopro"
                    ],
                    "categoryId": "20",
                    "liveBroadcastContent": "none",
                    "localized": {
                        "title": "Top 10 Monsters with 2500 Attack in YuGiOh",
                        "description": "In this video we'll go over the best monsters that have 2500 attack, and attack threshold for a lot of boss monsters actually.\n\nCheck out my DnD channel @TheD&DLogs \n\n--The List--\nIntro: (0:00)\n10- Blue-Eyes Spirit Dragon: (0:00)\n9- Invoked Mechaba: (2:14)\n8- Number S39: Utopia the Lightning: (3:23)\n7- Earthbound Immortal Aslla Piscu: (4:35)\n6- Eldlich the golden Lord: (6:04)\n5- True King Lithosagym the Disaster: (7:34)\n4- Block Dragon: (8:54)\n3- Astrograph sorcerer: (10:25)\n2- Beatrice lady of the eternal: (12:36)\n1- Firewall Dragon: (14:37)\n- \n-----------------------------------------\n#yugioh #top10 \n\nDuels are all done on EDOpro, its completely free and updated all the time. If you want it, just look for the EDOpro discord and you'll find all you need to download it from there\n\nSome of the Video backgrounds in this video were made by \"Amitai Angor AA VFX\" https://www.youtube.com/dvdangor2011\n\n\nhttps://twitter.com/hirumared\nhttps://twitter.com/TheDuelLogs"
                    },
                    "defaultAudioLanguage": "en"
                }
            }
        ],
        "pageInfo": {
            "totalResults": 1,
            "resultsPerPage": 1
        }
    }
    

    Get the response:

    response.items[0].snippet.description
    

    Results:

    "In this video we'll go over the best monsters that have 2500 attack, and attack threshold for a lot of boss monsters actually.
    
    Check out my DnD channel @TheD&DLogs 
    
    --The List--
    Intro: (0:00)
    10- Blue-Eyes Spirit Dragon: (0:00)
    9- Invoked Mechaba: (2:14)
    8- Number S39: Utopia the Lightning: (3:23)
    7- Earthbound Immortal Aslla Piscu: (4:35)
    6- Eldlich the golden Lord: (6:04)
    5- True King Lithosagym the Disaster: (7:34)
    4- Block Dragon: (8:54)
    3- Astrograph sorcerer: (10:25)
    2- Beatrice lady of the eternal: (12:36)
    1- Firewall Dragon: (14:37)
    - 
    -----------------------------------------
    #yugioh #top10 
    
    Duels are all done on EDOpro, its completely free and updated all the time. If you want it, just look for the EDOpro discord and you'll find all you need to download it from there
    
    Some of the Video backgrounds in this video were made by "Amitai Angor AA VFX" https://www.youtube.com/dvdangor2011
    
    
    https://twitter.com/hirumared
    https://twitter.com/TheDuelLogs"