Helenis API
Start for free

Documents & mediaYouTube

YouTube Chapters API: Timestamps and Shorts Clips from a Transcript

YouTube chapters API tutorial: turn an SRT, a scraper's transcript or an audio file into valid chapters, titles, tags and Shorts clips with Python.

YouTube Chapters API cover: a clapperboard sticker, an arrow and a JSON response with 173.48 seconds, the chapter Understanding the Artemis Program at 00:00, youtube_chapters_valid true and a top clip scored 85.
A three-minute NASA video's captions in, three chapters YouTube accepts and ranked clips out.

Chapters make a long video navigable: viewers jump to the part they came for, the progress bar shows the structure, and Google can surface the sections as key moments in search. Writing them means scrubbing through the video and noting where each topic starts. Finding the 30-second moments worth cutting into Shorts, TikToks and Reels is the same job again, and an editor easily spends an hour per video on both.

A YouTube chapters API automates the work from the transcript. The hard part is not producing timestamps, any language model will do that, but producing timestamps that are real: each chapter on an actual topic change, clips that start and end on sentence boundaries, and a chapter list YouTube will accept. This tutorial generates chapters, titles, tags, quotes and short clips in Python from an SRT file, from a podcast transcript and from an audio file, with real responses.

YouTube's rules for chapters

YouTube only displays chapters typed in the description when they follow its published rules:

Rule Consequence
The first timestamp is 0:00 A list starting at 0:12 is ignored
At least three timestamps, in ascending order Two chapters are not enough
Each chapter lasts at least 10 seconds Short intro chapters must be merged

A list that breaks one rule is silently ignored, so the check belongs in code, not in a prompt. The Video Chapters & Shorts Clip Finder enforces the three rules after the AI has written the chapters, snaps every chapter to the start of a sentence in the transcript, and tells you in youtube_chapters_valid whether YouTube will show the result.

It never downloads from YouTube, TikTok or Instagram, whose terms forbid it. You send the transcript (SRT, WebVTT, timestamped lines, or JSON segments) or a media file you have the right to use.

Generate YouTube chapters from an SRT with Python

POST /v1/video-chapters/transcript takes the transcript in transcript (text), segments (JSON) or transcript_url (a link). NASA publishes SRT captions for its videos; this one is "#AskNASA - What is Artemis?", about three minutes. The API reference lists every option.

Python
import requests

HOST = "youtube-chapters-shorts-clip-finder-ai.p.rapidapi.com"
API = f"https://{HOST}/v1/video-chapters"
HEADERS = {"x-rapidapi-key": "YOUR_API_KEY", "x-rapidapi-host": HOST}

SRT = (
    "https://images-assets.nasa.gov/video/NHQ_2019_0923_AskNASA%20-%20What%20is"
    "%20Artemis/NHQ_2019_0923_AskNASA%20-%20What%20is%20Artemis.srt"
)
response = requests.post(
    f"{API}/transcript",
    headers=HEADERS,
    json={"transcript_url": SRT, "clips": 3},
    timeout=120,
)
response.raise_for_status()
video = response.json()
print(video["chapters_text"])

The real response, with the clips moved to the next section and the description, tags and hashtags shortened:

JSON
{
  "source": "transcript",
  "duration_seconds": 173.48,
  "minutes_billed": 3,
  "language": "en",
  "output_language": "en",
  "summary": "NASA astronaut Serena Aunon-Chancellor answers a variety of questions from the public regarding the Artemis program, the future of lunar exploration, and her personal experiences living and working in space.",
  "chapters": [
    {
      "start": 0.0,
      "end": 57.18,
      "timestamp": "00:00",
      "title": "Understanding the Artemis Program",
      "summary": "An overview of the Artemis mission goals, including landing the first woman on the Moon and preparing for Mars."
    },
    {
      "start": 57.18,
      "end": 112.22,
      "timestamp": "00:57",
      "title": "Spacecraft and Personal Life",
      "summary": "A discussion about the Orion vehicle, personal items taken to space, and favorite foods for lunar missions."
    },
    {
      "start": 112.22,
      "end": 173.48,
      "timestamp": "01:52",
      "title": "Life and Emotions in Space",
      "summary": "Reflections on missing Earth, the reality of living on the space station, and personal anecdotes from an astronaut."
    }
  ],
  "chapters_text": "00:00 Understanding the Artemis Program\n00:57 Spacecraft and Personal Life\n01:52 Life and Emotions in Space",
  "youtube_chapters_valid": true,
  "titles": [
    "NASA Astronaut Answers Your Questions",
    "What is the Artemis Program?",
    "Life in Space: An Astronaut's Perspective",
    "Returning to the Moon with Artemis",
    "Behind the Scenes with NASA Astronaut Serena Aunon-Chancellor"
  ],
  "description": "Join NASA astronaut Serena Aunon-Chancellor as she answers questions about the future of lunar exploration and the Artemis program. ...",
  "tags": ["nasa", "artemis", "astronaut", "space exploration", "orion spacecraft", "moon landing", "..."],
  "hashtags": ["#NASA", "#Artemis", "#SpaceExploration", "#Astronaut"],
  "quotes": [
    {
      "start": 117.42,
      "timestamp": "01:57",
      "text": "I missed feeling the Earth, so I missed the wind. I missed the rain, I missed the smell of the Earth, the smell of the grass."
    }
  ],
  "notes": [
    "2 clip suggestion(s) were dropped (overlap, outside the video, or no sentence boundaries in the duration range)."
  ]
}

The call took 6.5 seconds and used 10 credits. chapters_text is the block to paste at the end of the YouTube description. Tags stay under 480 characters, inside YouTube's 500-character limit. quotes are verbatim: each one must be found word for word in the transcript, or it is removed, which makes them safe to put on a thumbnail or in a social post.

Find short clips for Shorts, TikTok and Reels

The same call returns up to 10 clip suggestions (clips, 5 by default), each within your duration range (clip_min_seconds and clip_max_seconds, 15 to 60 seconds by default, up to 180). Two of the three real clips from the NASA video:

JSON
[
  {
    "rank": 1,
    "start": 117.42,
    "end": 136.78,
    "duration": 19.36,
    "start_timestamp": "01:57",
    "end_timestamp": "02:16",
    "title": "What Astronauts Miss About Earth",
    "hook": "I missed feeling the Earth, so I missed the wind.",
    "caption": "Ever wonder what you'd miss most if you left the planet? Even astronauts crave the simple things like the smell of rain and grass. #NASA #Space #Earth",
    "hashtags": ["#NASA", "#Space", "#Earth"],
    "score": 85,
    "reason": "This clip provides a relatable, emotional connection to the human experience of space travel.",
    "text": "I missed feeling the Earth, so I missed the wind. I missed the rain, I missed the smell of the Earth, the smell of the grass. These are the things you just can't imitate on station. ..."
  },
  {
    "rank": 2,
    "start": 18.72,
    "end": 50.46,
    "duration": 31.74,
    "start_timestamp": "00:18",
    "end_timestamp": "00:50",
    "title": "Why We Are Going Back",
    "hook": "so the Artemis program is our lunar exploration program.",
    "caption": "The Artemis program is more than just a moon landing; it's our practice ground for reaching Mars. #Artemis #NASA #SpaceExploration",
    "hashtags": ["#Artemis", "#NASA", "#SpaceExploration"],
    "score": 70,
    "reason": "It clearly explains the strategic purpose of the Artemis mission in a concise way.",
    "text": "so the Artemis program is our lunar exploration program. We will get to the South Pole of the Moon by 2024, landing the first American woman and the next man. ..."
  }
]

The model proposes each clip with its first and last words; the code then finds those words in the transcript and moves the start to the beginning of the sentence that contains them and the end to the end of a sentence, inside the duration range. Clips never overlap and never run past the end of the video. When a suggestion cannot satisfy all of that, it is dropped and notes says so, as in the response above.

The score (0 to 100) is an opinion on the text: surprise, emotion, a useful tip, a moment understood without context. It is a way to sort a cut list, not a prediction of views. The third clip of this run, about the Orion capsule and scored 60, ends on the interviewer's next question ("Serena, did you always want to be an astronaut?"): read the text before cutting.

Chain a transcript scraper or another API

Most YouTube transcript scrapers return arrays of segments with start, duration, offset or startMs keys. Pass the item as it comes in segments; seconds, milliseconds and 01:23 strings are all recognized. The same works with the output of another API. Here the 10-minute podcast episode transcribed in the podcast API tutorial is sent in the common scraper shape, with Spanish output:

Python
segments = [
    {
        "text": s["text"],
        "start": s["start"],
        "duration": round(s["end"] - s["start"], 2),
    }
    for s in transcript["segments"]  # 93 segments from /episode/transcribe
]
item = {"title": "How a record El Nino is hitting your wallet", "transcript": segments}
body = {
    "segments": [item],
    "clips": 2,
    "language": "Spanish",
}
episode = requests.post(
    f"{API}/transcript", headers=HEADERS, json=body, timeout=120
).json()

The real response, shortened to the chapters, one quote and one clip:

JSON
{
  "source": "transcript",
  "duration_seconds": 609.85,
  "minutes_billed": 11,
  "language": "en",
  "output_language": "Spanish",
  "chapters_text": "00:00 Origen de El Niño\n02:28 La riqueza pesquera peruana\n04:03 Impacto en la industria\n06:00 Consecuencias económicas globales",
  "youtube_chapters_valid": true,
  "quotes": [
    {
      "start": 492.02,
      "timestamp": "08:12",
      "text": "By the end of the century, their study suggested that El Niño events could cost the global economy $84 trillion."
    }
  ],
  "clips": [
    {
      "rank": 2,
      "start": 492.02,
      "end": 517.02,
      "duration": 25.0,
      "title": "84 billones en pérdidas",
      "hook": "By the end of the century, their study suggested that El Niño events could cost the global economy $84 trillion.",
      "caption": "El costo de El Niño para la economía global es astronómico. ¿Estamos preparados para lo que viene? #Finanzas #CambioClimatico",
      "score": 80
    }
  ]
}

language is the spoken language, read from the transcript (English); output_language is the one requested. Chapters, titles, descriptions and captions are written in Spanish; quotes and hooks stay verbatim in English. One translation detail is worth checking by a person: the clip title says "84 billones", which is correct in Spanish, where a "billón" is a million million, the English trillion. The call took 6.6 seconds and used 11 credits (10 for the first 10 minutes, 1 for the eleventh). A JSON body is capped at 64 KB, about 20 minutes of segments; for longer videos send the SRT or the JSON as a file to /v1/video-chapters/transcript/upload (up to 5 MB and 4 hours).

Analyse an audio or video file directly

Without a transcript, POST /v1/video-chapters/media takes a direct link to a file (MP4, MOV, WEBM, MP3, M4A, WAV...; up to 150 MB and 90 minutes), transcribes it, then analyses it. A real call on a three-minute public-domain LibriVox reading of Kate Chopin's "Emancipation: A Life Fable", with two clips of 15 to 45 seconds (response shortened):

JSON
{
  "source": "url",
  "duration_seconds": 180.35,
  "minutes_billed": 3,
  "language": "en",
  "chapters_text": "00:00 Life in the Cage\n01:11 The Open Door\n02:06 The Price of Freedom",
  "youtube_chapters_valid": true,
  "clips": [
    {
      "rank": 1,
      "start": 71.0,
      "end": 96.0,
      "duration": 25.0,
      "title": "The Moment of Choice",
      "hook": "Awaking one day from his slothful rest, lo, the door of his cage stood open.",
      "score": 85,
      "text": "Awaking one day from his slothful rest, lo, the door of his cage stood open. Accident had opened it. ..."
    },
    {
      "rank": 2,
      "start": 157.0,
      "end": 172.0,
      "duration": 15.0,
      "title": "The Reality of Freedom",
      "hook": "So does he live, seeking, finding, joying and suffering.",
      "score": 78,
      "text": "So does he live, seeking, finding, joying and suffering. The door which accident had opened is open still, but the cage remains forever empty. End of recording."
    }
  ],
  "transcript": {
    "language": "en",
    "segments": [
      { "start": 0.0, "end": 6.0, "text": "Emancipation, a life fable by Kate Chopin." },
      { "start": 6.0, "end": 9.0, "text": "Read by Maria Grazia Tundo." }
    ]
  }
}

It took 9.1 seconds and 16 credits: 10 for the analysis and 2 per minute transcribed. The transcript comes back too, ready to be saved as captions. Notice the second clip ends with "End of recording.", the reader's closing line: an editor would trim the last second, which is why the text of each clip is returned.

A YouTube page link is refused before anything is downloaded. The real answer:

JSON
{
  "error": {
    "status": 400,
    "code": "unsupported_source",
    "message": "Video pages (YouTube, TikTok, Instagram...) are not downloaded: send the video's transcript to /transcript (any YouTube transcript scraper's output works), or a direct link to a file you own."
  }
}

Publish the chapters safely

Before writing anything to a video description, check the flag and keep a human in the loop for titles:

Python
def description_with_chapters(video: dict, intro: str) -> str | None:
    if not video["youtube_chapters_valid"]:
        return None  # under 30 s or too few topic changes: no chapters
    hashtags = " ".join(video["hashtags"][:3])
    return f"{intro}\n\n{video['chapters_text']}\n\n{hashtags}"

For subtitles or a full transcript of the same file, the speech to text tutorial covers SRT and WebVTT output, and a written article can be condensed the same way with the text summarization guide.

What it costs

10 credits per video up to 10 minutes, +1 per started minute beyond; a media file adds 2 credits per minute transcribed. Failed calls (4xx, 5xx) use none.

Plan Price per month Credits In practice
BASIC Free 15 per day 1 transcript of up to 15 minutes, or 1 file of up to 2 minutes
PRO $4.99 4,000 $0.0125 per video up to 10 min; a 1-hour talk about $0.075
ULTRA $14.99 12,000 same unit prices, 3x the volume
MEGA $49.99 40,000 same unit prices, 10x the volume

Beyond the quota, paid plans continue at $0.015 per credit. A 10-minute file costs about $0.0375 on PRO with its transcript. For comparison, a video breakdown actor on the Apify Store charges $0.10 for 10 minutes, and an audio transcriber with AI chapters $0.07.

What the YouTube chapters API does not do

  • No YouTube, TikTok or Instagram downloads. Send the transcript or your own file.
  • No visual analysis. It reads what is said, not what is shown; silent scenes and on-screen text are invisible to it, and music-only files get no_speech.
  • No view predictions. The virality score is an opinion on the transcript.
  • No video editing. It returns start and end times; cutting and reframing to 9:16 is your editor's job.
  • Limited precision without punctuation. Automatic captions without punctuation are cut at caption edges, or inside a caption by interpolation.
  • Files up to 90 minutes. Longer videos go through their transcript (up to 4 hours).

Frequently asked questions

How do I generate YouTube timestamps automatically?

Send the video's transcript (SRT, VTT or a transcript scraper's JSON) to /v1/video-chapters/transcript and paste chapters_text at the end of the description. Check youtube_chapters_valid first: it is true only when the chapters follow YouTube's rules.

Why are my YouTube chapters not showing?

Usually because the list breaks a rule: the first timestamp is not 0:00, there are fewer than three, or a chapter is shorter than 10 seconds. YouTube also needs the timestamps in ascending order.

Can I send a YouTube link?

No. Downloading from YouTube is against its terms. Send the transcript (any transcript scraper's output works as is) or a file you own.

How are short clips chosen?

The AI picks moments that work on their own (a strong line, an emotion, a useful tip) and scores them 0 to 100; the code then snaps each clip to sentence boundaries within your duration range and removes overlaps.

Which languages are supported?

Transcripts in any language. Chapters, titles, descriptions and captions are written in the transcript's language or the one you set in language; quotes and hooks stay verbatim.

Get started

YouTube Chapters & Shorts Clip Finder API

Video file, YouTube Studio captions or SRT to YouTube chapters, Shorts clips, titles and tags.

  • YouTube
  • Video
  • Content Creation
  • Python
  • LLM