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.
Votre sortie apparaîtra ici
Complétez les entrées, puis cliquez sur Exécuter.
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.
Commencer à construire
Point de terminaison de l'API de la plateforme avec authentification unifiée et suivi de l'utilisation.
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"
}'Définissez votre clé API SandBase dans l'environnement de votre serveur. Les requêtes utilisent l'authentification Bearer.
export SANDBASE_API_KEY="YOUR_API_KEY"Conservez votre clé côté serveur. Ne l'exposez pas dans le code du navigateur.
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.
Exemple de réponse enregistré pour cette API ; aucune requête en direct n'est effectuée lors de l'affichage.
Aucune réponse enregistrée n'a été publiée. Exécutez l'API dans Playground pour inspecter sa réponse.
Explorer plus
| API | Prix | Réponse |
|---|---|---|
YouTube Video TranscriptCette API YouTube | À partir de $0.0009 par appel | JSON |
YouTube | À partir de $0.00045 par appel | JSON |
YouTube | À partir de $0.0012 par appel | JSON |
YouTube | À partir de $0.0012 par appel | JSON |
YouTube | À partir de $0.0012 par appel | JSON |
YouTube | $0.014286 par appel | JSON |
Questions
Envoyez une requête POST à https://api.sandbase.ai/v1/api/youtube/video-transcript avec votre clé API SandBase dans l’en-tête Authorization (Bearer) et les paramètres dans un corps JSON. Vous pouvez aussi l’essayer dans le Playground sur cette page sans écrire de code.
À partir de $0.0009 par appel, facturé depuis votre solde SandBase. Vous ne payez que les appels que vous effectuez ; aucun abonnement.
Aucun paramètre n’est requis. Facultatif : id (string) et url (string). Le tableau des paramètres et le Playground sur cette page listent tous les champs.
Une réponse JSON renvoyée dans la même requête HTTP (synchrone). Le README sur cette page inclut un exemple de réponse.
Non. YouTube Video Transcript fonctionne via SandBase, donc une seule clé API SandBase couvre ce point de terminaison ainsi que toutes les autres API et tous les modèles du catalogue. Vous n’avez pas besoin de demander un accès API YouTube séparément.