idstring
YouTube video ID. A Short uses the same ID as any other video.
https://api.sandbase.ai/v1/api/youtube/video-transcriptFetch the transcript/captions of a YouTube video or Short by URL or ID.
Su salida aparecerá aquí
Complete las entradas y luego haga clic en Ejecutar.
Returns the transcript of a YouTube video or Short as plain text and as timed segments. You pass either a video url or a video id.
curl -X POST "https://api.sandbase.ai/v1/api/youtube/video-transcript" \
-H "Authorization: Bearer $SANDBASE_API_KEY" \
-H "Content-Type: application/json" \
-d '{"url": "https://www.youtube.com/watch?v=dQw4w9WgXcQ"}'
The result is returned in outputs[0].data.
| Name | Type | Required | Description |
|---|---|---|---|
id | string | No | YouTube video ID. A Short uses the same ID as any other video. |
url | string | No | Full YouTube video URL. Shorts (youtube.com/shorts/...), youtu.be, live, and embed URLs all work. |
Real response for the request above, trimmed: lists keep their first item and long strings are cut.
{
"data": {
"language": "en",
"segments": [
{
"durationSeconds": 1.68,
"startSeconds": 1.36,
"text": "[♪♪♪]"
}
],
"transcript": "[♪♪♪]\n♪ We're no strangers to love ♪\n♪ You know the rules and so do I ♪\n♪ A full…"
},
"found": true
}
| Field | Meaning |
|---|---|
found | true when a transcript was found for the video. A lookup that finds nothing returns found: false. |
data.language | Language code of the transcript, for example en. |
data.transcript | The full transcript as one string. Each caption line is separated by a newline. |
data.segments[].text | The text of one caption line. Music cues such as [♪♪♪] can appear as text. |
data.segments[].startSeconds | Start time of the segment, in seconds from the beginning of the video. |
data.segments[].durationSeconds | How long the segment lasts, in seconds. |
url or id. A Short uses the same ID as any other video, and youtube.com/shorts/..., youtu.be, live, and embed URLs all work for url.id is the value after v= in a standard watch URL, for example dQw4w9WgXcQ.data.transcript for the whole text and data.segments when you need timing.Billed at the actual cost of each call, about $0.0009 for the request above. Failed calls are not charged.
Empiece a construir
Endpoint de la API de la plataforma con autenticación unificada y seguimiento de uso.
curl -X POST "https://api.sandbase.ai/v1/api/youtube/video-transcript" \
-H "Authorization: Bearer $SANDBASE_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"url": "https://www.youtube.com/watch?v=dQw4w9WgXcQ"
}'Configure su clave de API de SandBase en el entorno de su servidor. Las solicitudes usan autenticación Bearer.
export SANDBASE_API_KEY="YOUR_API_KEY"Conserve su clave en el servidor. No la exponga en código del navegador.
idstringYouTube video ID. A Short uses the same ID as any other video.
urlstringFull YouTube video URL. Shorts (youtube.com/shorts/...), youtu.be, live, and embed URLs all work.
Respuesta de ejemplo guardada para esta API; no se realiza ninguna solicitud en vivo al verla.
No se ha publicado ninguna respuesta guardada. Ejecute la API en Playground para inspeccionar su respuesta.
Explorar más
| API | Precio | Respuesta |
|---|---|---|
YouTube Video TranscriptEsta API YouTube | Desde $0.0009 por llamada | JSON |
YouTube | Desde $0.00045 por llamada | JSON |
YouTube | Desde $0.0012 por llamada | JSON |
YouTube | Desde $0.0012 por llamada | JSON |
YouTube | Desde $0.0012 por llamada | JSON |
YouTube | $0.014286 por llamada | JSON |
Preguntas
Envía una solicitud POST a https://api.sandbase.ai/v1/api/youtube/video-transcript con tu clave API de SandBase en el encabezado Authorization (Bearer) y los parámetros como un cuerpo JSON. También puedes probarlo en el Playground de esta página sin escribir código.
Desde $0.0009 por llamada, facturado desde tu saldo de SandBase. Solo se te cobra por las llamadas que haces; no hay suscripción.
No se requieren parámetros. Opcionales: id (string) y url (string). La tabla de Parámetros y el Playground de esta página enumeran todos los campos.
Una respuesta JSON devuelta en la misma solicitud HTTP (sincrónica). El README de esta página incluye una respuesta de ejemplo.
No. YouTube Video Transcript funciona a través de SandBase, así que una sola clave API de SandBase cubre este endpoint y todas las demás APIs y modelos del catálogo. No necesitas solicitar acceso a la API de YouTube por separado.