YouTube 動画字幕
YouTube 動画字幕 API でEC データ API の連携を行えます。リクエストパラメーター、レスポンスのフィールド、実行可能なコード例を確認してください。
API データの例
このエンドポイントのリクエスト本文とレスポンス全体の構造を確認できます。
{
"videoId": "htVYnq8rz_8",
"language": "en"
}{
"request_id": "e0b92083-cd4f-43c1-baf1-576a17b1ba47",
"data": {
"video_id": "htVYnq8rz_8",
"language": "en",
"language_name": "English",
"format": "txt",
"content": "There's a pretty big difference between the earbuds sitting here. Depending on what you're looking for, you might not need the most expensive pair…",
"available_languages": null
}
}このページでは Ecommerce Data API の公開契約を説明します。フィールド名、パス、技術例はそのまま保持しているため、そのまま統合できます。
Availability: Available
This endpoint is active in the v1 gateway, OpenAPI, and subscription catalog. Each call consumes 3 billing units, including calls that find nothing (
RESULT_NOT_FOUND).
POST /v1/social/youtube/videos/transcript
The request and response fields below match the current public contract.
API マッピング
| Item | Value |
|---|---|
| MCP Code | social_youtube_videos_transcript |
クイック呼び出し
First create an API key, then store it in a server-side environment variable:
export ECOMMERCE_DATA_API_KEY="your_api_key"curl --request POST \
--url https://ecommercedataapi.com/v1/social/youtube/videos/transcript \
--header "Content-Type: application/json" \
--header "X-API-Key: ${ECOMMERCE_DATA_API_KEY}" \
--data '{
"videoId": "htVYnq8rz_8",
"language": "en"
}'Integrate with an AI CLI
Copy for your AI CLI
Paste this task into Codex, Claude Code, Gemini CLI, or another coding agent.
Integrate the "YouTube Video Transcript" endpoint from Ecommerce Data API into the current repository. Make the changes directly instead of only returning sample code.
API documentation: https://ecommercedataapi.com/ja/docs/social/youtube/video-transcript
Endpoint: POST https://ecommercedataapi.com/v1/social/youtube/videos/transcript
API key environment variable: ECOMMERCE_DATA_API_KEY
Example request:
{
"videoId": "htVYnq8rz_8",
"language": "en"
}
Requirements:
1. Read the API documentation first, then inspect the repository's language, framework, HTTP client, directory structure, and environment-variable conventions.
2. Reuse the existing API client and error-handling patterns. If none exist, add the smallest reusable Ecommerce Data API client and an endpoint-specific wrapper.
3. Read the key from the server-side ECOMMERCE_DATA_API_KEY environment variable and send Content-Type: application/json plus the X-API-Key header. Never write a real key into source code, browser code, logs, test snapshots, or Git.
4. If the environment variable is missing, tell me to configure ECOMMERCE_DATA_API_KEY myself. Do not request, print, or invent the real key, and continue implementing code and tests that do not require a live request.
5. Implement request and response types from the documentation. Handle non-2xx responses, request_id, error.code, error.message, and 429 rate limits.
6. Add a minimal usage example or test that follows the repository's conventions. Run one minimal live request only when the key is already configured and external requests are allowed; otherwise use mocks or static validation.
7. Run the relevant formatter, type checker, and tests. Report changed files, usage, verification results, and any environment variable I still need to configure.Open this request in Postman
Download the preconfigured collection for this endpoint, then import it into Postman.
Node.js example
const response = await fetch(
'https://ecommercedataapi.com/v1/social/youtube/videos/transcript',
{
method: 'POST',
headers: {
'Content-Type': 'application/json',
'X-API-Key': process.env.ECOMMERCE_DATA_API_KEY,
},
body: JSON.stringify({
videoId: 'htVYnq8rz_8',
language: 'en',
}),
}
);
const result = await response.json();
if (!response.ok) {
throw new Error(`${result.error?.code}: ${result.error?.message}`);
}
console.log(result.data);Python example
import os
import requests
response = requests.post(
"https://ecommercedataapi.com/v1/social/youtube/videos/transcript",
headers={
"Content-Type": "application/json",
"X-API-Key": os.environ["ECOMMERCE_DATA_API_KEY"],
},
json={
"videoId": "htVYnq8rz_8",
"language": "en",
},
timeout=30,
)
response.raise_for_status()
print(response.json()["data"])Request body
Send the fields below directly in the JSON body without an extra wrapper. Undefined fields are rejected.
| Field | Type | Required | Description | Example |
|---|---|---|---|---|
videoId | String | Yes | YouTube video ID, the 11 characters after v= in a watch URL (or after /shorts/ or youtu.be/). | htVYnq8rz_8 |
language | String | No | Caption language code from Video Details caption_languages, such as en. Omit to list the languages available. | en |
format | String | No | txt (default, plain text) or srt (with timestamps). | txt |
Response structure
| Field | Type | Description |
|---|---|---|
request_id | String | Unique identifier for this request. |
data | Object | Endpoint business data. |
The fields below are inside data. For array endpoints they describe one array item; for paginated endpoints they describe one record in items[].
Response fields
| Field | Type | Description | Example |
|---|---|---|---|
video_id | String | Video ID. | - |
language | String | Language returned, or the one asked for when the video lacks it. | en |
language_name | String | Language name. | English |
format | String | txt or srt. | txt |
content | String | Transcript; null when listing languages or when the language is missing. | - |
available_languages | Array | Languages the video has, each with language and name; returned instead of content when no language was given or the one asked for is missing. A video with no captions at all is RESULT_NOT_FOUND. | - |
Response example
{
"request_id": "e0b92083-cd4f-43c1-baf1-576a17b1ba47",
"data": {
"video_id": "htVYnq8rz_8",
"language": "en",
"language_name": "English",
"format": "txt",
"content": "There's a pretty big difference between the earbuds sitting here. Depending on what you're looking for, you might not need the most expensive pair…",
"available_languages": null
}
}See Errors and rate limits for error payloads, request tracing, and rate-limit headers.