Documentation has been updated: see help center and changelog in one place.

YouTube Subtitles

Learn how to scrape subtitles (closed captions) from YouTube videos using Web Scraper API. Find out more about its parameters and practical examples.

You can get YouTube subtitles and closed captions (CC) by providing the YouTube video ID and a language_code to the youtube_subtitles source.

Request samples

The following example demonstrates how to retrieve English closed captions from a YouTube video where captions were provided by the uploader.

curl 'https://realtime.oxylabs.io/v1/queries' \
--user 'USERNAME:PASSWORD' \
-H 'Content-Type: application/json' \
-d '{
        "source": "youtube_subtitles",
        "query": "c4P_YuNnZ7U",
        "context": [
            {
                "key": "language_code",
                "value": "en"
            },
            {
                "key": "subtitle_origin",
                "value": "uploader_provided"
            }
        ]
    }'

Our examples use Realtime integration method. If you would like to use Proxy Endpoint, or asynchronous Push-Pull integration, refer to the Integration Methods section.

Request parameter values

Generic

Parameter
Description
Default Value

source

Sets the scraper.

youtube_subtitles

query

YouTube video ID.

context: language_code

Specifies the language of the subtitles. Find available values here. NOTE: If the provided language_code has no matching subtitles / closed captions in the YouTube video, the result returns a 404 status.

context: subtitle_origin

Specifies whether to retrieve subtitles that are auto_generated or uploader_provided.

callback_url

URL to your callback endpoint. More info.

– mandatory parameter

Last updated

Was this helpful?