Retrieve a caption

get /videos/{videoId}/captions/{language}

Retrieve a caption for a video in a specific language.

videoId

string

required

The unique identifier for the video you want captions for.

Example
"vi4k0jvEUuaTdRAEjQ4Prklg"

language

string

required

A valid language identifier using IETF language tags. You can use primary subtags like en (English), extended subtags like fr-CA (French, Canada), or region subtags like zh-Hans-CN (Simplified Chinese used in the PRC).

  • This parameter only accepts dashes for separators, for example fr-CA. If you use a different separator in your request, the API returns an error.
  • When the value in your request does not match any covered language, the API returns an error.
  • You can find the list of supported tags here.
Example
"en"

Request

// First install the go client with "go get github.com/apivideo/api.video-go-client"
// Documentation: https://github.com/apivideo/api.video-go-client/blob/main/docs/CaptionsApi.md#get

package main

import (
    "context"
    "fmt"
    "os"
    apivideosdk "github.com/apivideo/api.video-go-client"
)

func main() {
    client := apivideosdk.ClientBuilder("YOUR_API_KEY").Build()
    // if you rather like to use the sandbox environment:
    // client := apivideosdk.SandboxClientBuilder("YOUR_SANDBOX_API_KEY").Build()
        
    videoId := "vi4k0jvEUuaTdRAEjQ4Prklg" // string | The unique identifier for the video you want captions for.
    language := "en" // string | A valid language identifier using IETF language tags. You can use primary subtags like `en` (English), extended subtags like `fr-CA` (French, Canada), or region subtags like `zh-Hans-CN` (Simplified Chinese used in the PRC).

    
    res, err := client.Captions.Get(videoId, language)

    if err != nil {
        fmt.Fprintf(os.Stderr, "Error when calling `Captions.Get``: %v\
", err)
    }
    // response from `Get`: Caption
    fmt.Fprintf(os.Stdout, "Response from `Captions.Get`: %v\
", res)
}

Response

ExamplesSchema

Success

{
  "uri": "/videos/vi3N6cDinStg3oBbN79GklWS/captions/en",
  "src": "https://cdn.api.video/vod/vi3N6cDinStg3oBbN79GklWS/captions/en.vtt",
  "srclang": "en",
  "languageName": "English",
  "default": false
}

Upload a caption

post /videos/{videoId}/captions/{language}

Upload a VTT file to add captions to your video. More information can be found here

file

file

required

The video text track (VTT) you want to upload.

Request

// First install the go client with "go get github.com/apivideo/api.video-go-client"
// Documentation: https://github.com/apivideo/api.video-go-client/blob/main/docs/CaptionsApi.md#upload

package main

import (
    "context"
    "fmt"
    "os"
    apivideosdk "github.com/apivideo/api.video-go-client"
)

func main() {
    client := apivideosdk.ClientBuilder("YOUR_API_KEY").Build()
    // if you rather like to use the sandbox environment:
    // client := apivideosdk.SandboxClientBuilder("YOUR_SANDBOX_API_KEY").Build()
        
    videoId := "vi4k0jvEUuaTdRAEjQ4Prklg" // string | The unique identifier for the video you want to add a caption to.
    language := "en" // string | A valid language identifier using IETF language tags. You can use primary subtags like `en` (English), extended subtags like `fr-CA` (French, Canada), or region subtags like `zh-Hans-CN` (Simplified Chinese used in the PRC).
    file := os.NewFile(1234, "some_file") // *os.File | The video text track (VTT) you want to upload.

    
    res, err := client.Captions.UploadFile(videoId, language, file)

    // you can also use a Reader instead of a File:
    // client.Captions.Upload(videoId, language, fileName, fileReader)

    if err != nil {
        fmt.Fprintf(os.Stderr, "Error when calling `Captions.Upload``: %v\
", err)
    }
    // response from `Upload`: Caption
    fmt.Fprintf(os.Stdout, "Response from `Captions.Upload`: %v\
", res)
}

Response

ExamplesSchema

Success

{
  "uri": "/videos/vi3N6cDinStg3oBbN79GklWS/captions/en",
  "src": "https://cdn.api.video/vod/vi3N6cDinStg3oBbN79GklWS/captions/en.vtt",
  "srclang": "en",
  "languageName": "English",
  "default": false
}

Delete a caption

delete /videos/{videoId}/captions/{language}

Delete a caption in a specific language by by video id.

videoId

string

required

The unique identifier for the video you want to delete a caption from.

Example
"vi4k0jvEUuaTdRAEjQ4Prklgc"

language

string

required

A valid language identifier using IETF language tags. You can use primary subtags like en (English), extended subtags like fr-CA (French, Canada), or region subtags like zh-Hans-CN (Simplified Chinese used in the PRC).

  • This parameter only accepts dashes for separators, for example fr-CA. If you use a different separator in your request, the API returns an error.
  • When the value in your request does not match any covered language, the API returns an error.
  • You can find the list of supported tags here.
Example
"en"

Request

// First install the go client with "go get github.com/apivideo/api.video-go-client"
// Documentation: https://github.com/apivideo/api.video-go-client/blob/main/docs/CaptionsApi.md#delete

package main

import (
    "context"
    "fmt"
    "os"
    apivideosdk "github.com/apivideo/api.video-go-client"
)

func main() {
    client := apivideosdk.ClientBuilder("YOUR_API_KEY").Build()
    // if you rather like to use the sandbox environment:
    // client := apivideosdk.SandboxClientBuilder("YOUR_SANDBOX_API_KEY").Build()
        
    videoId := "vi4k0jvEUuaTdRAEjQ4Prklgc" // string | The unique identifier for the video you want to delete a caption from.
    language := "en" // string | A valid language identifier using IETF language tags. You can use primary subtags like `en` (English), extended subtags like `fr-CA` (French, Canada), or region subtags like `zh-Hans-CN` (Simplified Chinese used in the PRC).

    
    err := client.Captions.Delete(videoId, language)

    if err != nil {
        fmt.Fprintf(os.Stderr, "Error when calling `Captions.Delete``: %v\
", err)
    }
}

Response

ExamplesSchema

No Content

Empty response

Update a caption

patch /videos/{videoId}/captions/{language}

Update caption settings.

default

boolean

Request

{
  "default": true
}

Response

ExamplesSchema

Success

{
  "uri": "/videos/vi3N6cDinStg3oBbN79GklWS/captions/en",
  "src": "https://cdn.api.video/vod/vi3N6cDinStg3oBbN79GklWS/captions/en.vtt",
  "srclang": "en",
  "languageName": "English",
  "default": true
}

List video captions

get /videos/{videoId}/captions

Retrieve a list of available captions by video id.

currentPage

int

Choose the number of search results to return per page. Minimum value: 1

Default
1
Example
2

pageSize

int

Results per page. Allowed values 1-100, default is 25.

Default
25
Example
30

Request

// First install the go client with "go get github.com/apivideo/api.video-go-client"
// Documentation: https://github.com/apivideo/api.video-go-client/blob/main/docs/CaptionsApi.md#list

package main

import (
    "context"
    "fmt"
    "os"
    apivideosdk "github.com/apivideo/api.video-go-client"
)

func main() {
    client := apivideosdk.ClientBuilder("YOUR_API_KEY").Build()
    // if you rather like to use the sandbox environment:
    // client := apivideosdk.SandboxClientBuilder("YOUR_SANDBOX_API_KEY").Build()
        
    videoId := "vi4k0jvEUuaTdRAEjQ4Prklg" // string | The unique identifier for the video you want captions for.
    language := "en" // string | A valid language identifier using IETF language tags. You can use primary subtags like `en` (English), extended subtags like `fr-CA` (French, Canada), or region subtags like `zh-Hans-CN` (Simplified Chinese used in the PRC).

    
    res, err := client.Captions.Get(videoId, language)

    if err != nil {
        fmt.Fprintf(os.Stderr, "Error when calling `Captions.Get``: %v\
", err)
    }
    // response from `Get`: Caption
    fmt.Fprintf(os.Stdout, "Response from `Captions.Get`: %v\
", res)
}

Response

ExamplesSchema

Success

{
  "data": [
    {
      "uri": "/videos/vi3N6cDinStg3oBbN79GklWS/captions/en",
      "src": "https://cdn.api.video/vod/vi3N6cDinStg3oBbN79GklWS/captions/en.vtt",
      "srclang": "en",
      "languageName": "English",
      "default": false
    },
    {
      "uri": "/videos/vi3N6cDinStg3oBbN79GklWS/captions/fr",
      "src": "https://cdn.api.video/vod/vi3N6cDinStg3oBbN79GklWS/captions/fr.vtt",
      "srclang": "fr",
      "languageName": "Française",
      "default": false
    }
  ],
  "pagination": {
    "currentPage": 1,
    "currentPageItems": 2,
    "pageSize": 25,
    "pagesTotal": 1,
    "itemsTotal": 2,
    "links": [
      {
        "rel": "self",
        "uri": "/videos/vi3N6cDinStg3oBbN79GklWS/captions?currentPage=1&pageSize=25"
      },
      {
        "rel": "first",
        "uri": "/videos/vi3N6cDinStg3oBbN79GklWS/captions?currentPage=1&pageSize=25"
      },
      {
        "rel": "last",
        "uri": "/videos/vi3N6cDinStg3oBbN79GklWS/captions?currentPage=1&pageSize=25"
      }
    ]
  }
}

Was this page helpful?