Sign up for free
get

Retrieve a caption

Retrieve a caption for a video in a specific language.

videoIdstring

required

The unique identifier for the video you want captions for.

Example
"vi4k0jvEUuaTdRAEjQ4Prklg"
languagestring

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"

Responses

Request examples

// 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 examples

Success

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

Upload a caption

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

filefile

required

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

Responses

Request examples

// 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 examples

Success

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

Delete a caption

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

videoIdstring

required

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

Example
"vi4k0jvEUuaTdRAEjQ4Prklgc"
languagestring

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"

Responses

Request examples

// 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 examples

No Content

Empty response

patch

Update a caption

Update caption settings.

defaultboolean

Set this parameter to true to define a caption as the default for a video.

Responses

Request examples

{
  "default": true
}

Response examples

Success

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

List video captions

Retrieve a list of available captions by video id.

currentPageint

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

Default
1
Example
2
pageSizeint

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

Default
25
Example
30

Responses

Request examples

// 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 examples

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?