Stay organized with collections
Save and categorize content based on your preferences.
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:
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.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-20 UTC."],[],[],null,["# YouTube Playables SDK - Getting started\n\nYouTube Playables SDK is a web SDK for connecting web games with the YouTube\nenvironment. The SDK features a robust API to support games in a variety of ways\nto create an excellent gaming experience on YouTube.\n\nAdd the Playables SDK to your game\n----------------------------------\n\nA game should have an `index.html` file in the root directory. Import the\nYouTube Playables SDK by adding this line before any of your game code: \n\n \u003cscript src=\"https://www.youtube.com/game_api/v1\"\u003e\u003c/script\u003e\n\n| **Important:** The SDK **MUST** be loaded before any of your game code. This creates a reproducible, sandboxed environment and to make certain functions available to the game immediately. This is validated during publishing and you can follow the [test suite guide](/youtube/gaming/playables/reference/test_suite_guide) to validate before submitting your game.\n\nThe SDK runs as a no-op when your game is served locally. To verify SDK\nintegration correctness, use the [test suite guide](/youtube/gaming/playables/reference/test_suite_guide).\n\nIntegrate with Playables SDK\n----------------------------\n\nThere are several required and optional integrations with the Playables SDK.\n\n### Required integrations\n\nReview the [publishing requirements](/youtube/gaming/playables/certification/requirements) overall, with a focus on [integration\nrequirements](/youtube/gaming/playables/certification/requirements_integration). Review the [Playables SDK reference](/youtube/gaming/playables/reference/sdk) for implementation details.\n\nExamples include:\n\n- `ytgame.game.firstFrameReady()`\n- `ytgame.game.gameReady()`\n- `ytgame.IN_PLAYABLES_ENV`\n- `ytgame.system.isAudioEnabled()`\n- `ytgame.system.onAudioEnabledChange((isAudioEnabled) =\u003e {})`\n- `ytgame.system.onPause(() =\u003e {})`\n- `ytgame.system.onResume(() =\u003e {})`\n- `ytgame.game.loadData()`\n- `ytgame.game.saveData(data)`\n\n### Recommended integrations\n\nIn addition to the required integrations, several other functions are available\nto create a highly engaging experience. Examples include:\n\n- `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.\n- `ytgame.engagement.sendScore({ value: newScore })` - Send a best score to YouTube to display.\n- `ytgame.engagement.openYTContent({ id: videoID })` - Open a YouTube video.\n- `ytgame.health.logError()` and `ytgame.health.logWarning()` - Log issues to YouTube.\n\nReview the [Playables SDK reference](/youtube/gaming/playables/reference/sdk) for implementation details and additional\nfunctions.\n\n### TypeScript type definitions\n\nFor games using TypeScript, [download type definitions](https://www.youtube.com/playablesportal/static/youtube_ytgame_web_deploy_mpm_files/index.d.ts).\n\n### Samples games\n\n[Samples are available](/youtube/gaming/playables/samples/oss_samples) that demonstrate how to integrate with YouTube\nPlayables SDK, including plain JavaScript, Flutter web, Godot, and Unity.\n\nTest your game with the test suite\n----------------------------------\n\nOnce you are ready, you can validate your integration using the test suite. To\nlearn how, follow the [test suite guide](/youtube/gaming/playables/reference/test_suite_guide)."]]