/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.
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).
fr-CA
. If you use a different separator in your request, the API returns an error.// 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)
}
Success
{
"uri": "/videos/vi3N6cDinStg3oBbN79GklWS/captions/en",
"src": "https://cdn.api.video/vod/vi3N6cDinStg3oBbN79GklWS/captions/en.vtt",
"srclang": "en",
"languageName": "English",
"default": false
}
/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.
// 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)
}
Success
{
"uri": "/videos/vi3N6cDinStg3oBbN79GklWS/captions/en",
"src": "https://cdn.api.video/vod/vi3N6cDinStg3oBbN79GklWS/captions/en.vtt",
"srclang": "en",
"languageName": "English",
"default": false
}
/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.
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).
fr-CA
. If you use a different separator in your request, the API returns an error.// 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)
}
}
No Content
Empty response
/videos/{videoId}/captions/{language}
Update caption settings.
default
boolean
Set this parameter to true
to define a caption as the default for a video.
{
"default": true
}
Success
{
"uri": "/videos/vi3N6cDinStg3oBbN79GklWS/captions/en",
"src": "https://cdn.api.video/vod/vi3N6cDinStg3oBbN79GklWS/captions/en.vtt",
"srclang": "en",
"languageName": "English",
"default": true
}
/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
pageSize
int
Results per page. Allowed values 1-100, default is 25.
// 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)
}
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?