Check which captions actually exist

For lecture notes, query with video_id or video_url and initially omit language_code to inspect available caption languages. Do not assume your preferred language exists. This operation should not be described as automatic transcription for a video without captions. If no usable captions are available, retain that limitation instead of generating a plausible-looking lecture transcript.

Choose the format for the task

After choosing a language, provide language_code. Use srt when you need sequence numbers, timestamps, and text to revisit passages. txt is useful for reading but contains no timeline. xml and json3 correspond to the original XML and YouTube JSON formats. Parse the chosen representation appropriately rather than treating them as interchangeable or inventing sentence timings from plain text.

Wait for the actual result before calling it complete

Larger videos may return status set to processing. Use job_id with the caption-result operation to retrieve the final content. Your study record can retain the video source, language, selected format, and completion state. For a hypothetical definition you want to quote, listen to the relevant passage to confirm terminology after obtaining the text. Captions provide existing wording, not fact verification; both automatic and human captions may contain errors, and quotations still need clear attribution.

Request URL and parameters

GET https://api.trmesh.com/openapi/api/v1/youtube/web_v2/get_video_captions

Parameter Type Required Meaning
video_id string No Video ID
video_url string No Video URL
language_code string No Language code, returns available caption list if empty
format string No Caption format

Run the Python example

Install requests and set TRMESH_API_TOKEN in your environment. Replace the sample identifiers with the public object you intend to inspect. Example IDs may no longer be available.

import os
import requests

# Read your own developer key from the server environment.
url = "https://api.trmesh.com/openapi/api/v1/youtube/web_v2/get_video_captions"
params = {
    "video_id": "dQw4w9WgXcQ",
    "video_url": "https://www.youtube.com/watch?v=dQw4w9WgXcQ",
    "language_code": "en",
    "format": "srt"
}
response = requests.get(
    url, params=params, timeout=30,
    headers={"Authorization": f"Bearer {os.environ['TRMESH_API_TOKEN']}"},
)
response.raise_for_status()
payload = response.json()
print(payload)  # Inspect the actual response before mapping fields

Endpoint documentation · Free profile tool

API calls use your TRMesh account allowance. Check the endpoint price before running a script.