YouTube Playables SDK is a web SDK for connecting web games with the YouTube environment. The SDK features a robust API to support games in a variety of ways to create an excellent gaming experience on YouTube.
Add the Playables SDK to your game
A game should have an index.html file in the root directory. Import the
YouTube Playables SDK by adding this line before any of your game code:
<script src="https://www.youtube.com/game_api/v1"></script>
Integrate with Playables SDK
There are several required and optional integrations with the Playables SDK.
Required integrations
Review the publishing requirements overall, with a focus on integration requirements. Review the Playables SDK reference for implementation details.
Examples include:
Pause and resume
Cloud save
Recommended integrations
In addition to the required integrations, several other functions are available to create a highly engaging experience. Examples include:
ytgame.system.getLanguage()
Use this to retrieve the user's current locale
setting. Don't use other functions or store the language in the cloud
save, as this may change at any time.
ytgame.engagement.sendScore({ value: newScore })
Send a best score to YouTube to display.
ytgame.engagement.openYTContent({ id: videoID })
Open a YouTube video.
ytgame.health.logError() and ytgame.health.logWarning()
Log issues to YouTube.
ytgame.ads.requestInterstitialAd() and requestRewardedAd(rewardId: string)
Integrate ads features into your game.
Review the Playables SDK reference for implementation details and additional functions.
TypeScript type definitions
For games using TypeScript, download type definitions.
Sample games
Samples are available that demonstrate how to integrate with YouTube Playables SDK, including plain JavaScript, Flutter web, Godot, and Unity.
Test your game with the test suite
Once you are ready, you can validate your integration using the test suite. To learn how, follow the test suite guide.
Test suite guide