Localizing YouTube videos with the Data API v3: what the official docs say about titles, descriptions, captions and quota
YouTube can show a viewer the title and description of a video in the viewer's own language, and it can offer subtitles in many languages. Both are part of the public YouTube Data API v3. This post walks through what the
YouTube can show a viewer the title and description of a video in the viewer's own language, and it can offer
subtitles in many languages. Both are part of the public YouTube Data API v3. This post walks through what the official
documentation says about each piece, with links, and the details that are easy to miss when you read it for the first
time.
Two separate things: localized metadata and caption tracks
The API keeps translated text in two different places:
-
Localized metadata: the
localizationsproperty of a video. The Videos resource describes it as a map from a language code to a localizedtitleanddescription. YouTube shows the version that matches the viewer's language. -
Caption tracks: separate Captions resources, one per
language, each with its own timing. They have their own methods (
captions.list,captions.download,captions.insert,captions.update).
They are different endpoints with different permissions and very different quota costs, so it helps to plan them as two
jobs.
Titles and descriptions: videos.update with localizations
From the videos.update reference and the Videos
resource:
-
Localizations need a default language. The docs tie
localizationstosnippet.defaultLanguage, the language of the original title and description. Set it before adding translations. -
An update replaces what you send. The
videos.updatepage warns that properties you leave out of an updated part lose their existing values. Forlocalizationsthat means the map you send becomes the full set, so read the current values first and send them back together with the new language. -
snippetis all or nothing. If the request includes thesnippetpart, the docs listtitleandcategoryIdas required. Send back the snippet you read.
Playlists have the same localizations property, with
the same rules.
Caption tracks: list, download, insert or update
From the Captions reference:
-
captions.listreturns the tracks of a video. Each has alanguageand atrackKind:standardfor a regular track,ASRfor one made by YouTube's automatic speech recognition, andforcedfor forced-only captions. -
captions.downloadreturns the track text. Thetfmtparameter picks the format (srt,vtt,sbv,scc,ttml), andtlangasks YouTube for a machine translation of the track. The docs say the method requires permission to edit the video. -
captions.insertuploads a new track for a language;captions.updateupdates an existing one. Checkcaptions.listfirst, or the video ends up with two tracks in the same language.
A practical note on subtitle files: an SRT file is numbered cues, each with a timestamp line and text. When the text is
translated, keep the timestamps and the number of cues as they were; only the text lines should change.
The quota bill
The quota cost table says a project gets 10,000 units
a day by default for most endpoints. At the time of writing it lists 1 unit for videos.list, 50 for captions.list
and videos.update, 400 for captions.insert and 450 for captions.update; the captions.download page gives 200
units. Check the current numbers before you plan around them.
What follows from the table:
- Titles and descriptions for one video in 20 languages fit into one
videos.update, because all languages go into the samelocalizationsmap: 50 units. - Subtitles for the same video in 20 languages are 20
captions.insertcalls: 8,000 units, most of a default day. - So put every language of a video into one metadata update, skip languages that already exist, and request a quota extension early through the quota and compliance audit.
Language codes
YouTube uses BCP-47 style language codes, and the region or script matters: pt-BR and pt-PT, zh-Hans and
zh-Hant, es-419 and es. Use the same code for the localization and for the caption track, so a
viewer gets both.
Why it matters for a channel
For a creator this is not an engineering detail. A title and description in the viewer's language is what that viewer
sees in search, in recommendations and on the watch page; subtitles in their language are what lets them follow the
video. A channel that only has its original language competes for one audience. The same video with localized metadata
and subtitle tracks can be found and understood in many more countries, and some of those markets pay more per 1,000
views than the creator's home market.
Doing this by hand in YouTube Studio means one language and one video at a time, which is why most channels never
localize past one or two languages. Following the documentation above, we implemented this flow in
Creator Tools, a YouTube metadata translator for titles, descriptions and subtitles:
it translates the metadata and existing subtitle tracks of many videos at once and writes them to the channel in 140+
languages.
Sources
- Videos resource and
localizations: https://developers.google.com/youtube/v3/docs/videos -
videos.update: https://developers.google.com/youtube/v3/docs/videos/update - Captions resource and methods: https://developers.google.com/youtube/v3/docs/captions
-
captions.download: https://developers.google.com/youtube/v3/docs/captions/download - Quota costs: https://developers.google.com/youtube/v3/determine_quota_cost
- Quota and compliance audits: https://developers.google.com/youtube/v3/guides/quota_and_compliance_audits
Originally published by Dev.to WebDev. Aggregated on AIWithGhost for educational purposes — full credit and traffic to the original publisher.