Extracting transcriptions

At a high level, extracting a transcription from a video involves the following steps:

  • Upload and index a video. When you upload a video by calling the /tasks endpoint, the API service creates a video indexing task and returns its unique identifier.
  • Retrieve the unique identifier of your video . Once the API service finishes indexing your video you can retrieve the unique identifier of your video by calling the /tasks/{task-id} endpoint and passing it the unique identifier of your video indexing task.
  • Retrieve a transcription. Call the /indexes/{index-id}/videos/{video-id}/transcription endpoint passing it the unique identifiers of your index and video. For a description of each field in the request and response, see the API Reference > Retrieve transcriptions page.

Note that, although the example code in this guide is written in Python and Node.js, the API is compatible with most programming languages, and you can also use Postman or other REST clients to send requests and view responses.


  • A valid Twelve Labs account. For details about creating an account and retrieving your API key, see the Authentication page.
  • You’re familiar with the concepts that are described on the Quickstart page.
  • You’ve created at least one index, and the unique identifier of your index is stored in a variable named INDEX_ID. For details, see the Creating indexes page.
  • You've uploaded a video, and the API service has finished indexing it. The unique identifier of your video is stored in a variable named VIDEO_ID. For details see the Uploading videos page.


  1. Construct the URL for extracting the transcription based on the INDEX_ID and VIDEO_ID variables:

    TRANSCRIPTIONS_URL = f"{API_URL}/indexes/{INDEX_ID}/videos/{VIDEO_ID}/transcription"
    const TRANSCRIPTIONS_URL = `${API_URL}/indexes/${INDEX_ID}/videos/${VIDEO_ID}/transcription`
  2. Retrieve the transcription and print it out to the console:

    response = requests.get(TRANSCRIPTIONS_URL, headers=headers)
    print (f"Status code: {response.status_code}")
    pprint (response.json())
    config = {
      method: 'get',
      headers: headers,
    resp = await axios(config)
    response = await resp.data
    console.log(`Status code: ${resp.status}`)

    The following example output was truncated for brevity:

    Status code: 200
    {'_id': '62aff6da154f59c87660ce9a',
     'data': [{'end': 287.05,
               'start': 280.94,
               'value': " Oh I'm so glad I was recording it."},
              {'end': 295.66,
               'start': 287.44,
               'value': ' Ah ha ha ha got like a big stick or something.'},
              {'end': 299.85, 'start': 299.04, 'value': ' Big stick,'},
              {'end': 302.81,
               'start': 301.54,
               'value': " it's heavy whatever it is."},
              {'end': 309.11, 'start': 306.55, 'value': ' Ah that is not a stick.'},
              {'end': 313.86,
               'start': 309.12,
               'value': " Oh my God that's not a stick at all."}],
     'index_id': '629deb409ea24f052b971993',

    Note that you can use the start and end query parameters to specify the time range for which you want to retrieve the transcription. The following example URL retrieves the transcription for the first 10 seconds of the video:

    TRANSCRIPTIONS_URL = f"{API_URL}/indexes/{INDEX_ID}/videos/{VIDEO_ID}/transcription?start=0&end=10"
    const TRANSCRIPTIONS_URL = `${API_URL}/indexes/${INDEX_ID}/videos/${VIDEO_ID}/transcription?start=0&end=10`

Related Topics