SDK installation and use

The Yandex Games SDK is a library that you can use to easily integrate games created by third-party developers into the Yandex Games platform.

Connecting the SDK is a mandatory condition for passing moderation.

With SDK, you can:

  • Integrate ad serving.
  • Manage the functionality without updating the build.
  • Set up automatic transition to the full-screen mode.
  • Set the screen orientation during the game and add a prompt for the user to turn their device.

Installation

You can connect the Yandex Games SDK either synchronously or asynchronously. Both options are equally valid, but the asynchronous connection enables you to control the installation process via callbacks. Choose the method you find most appropriate.

Pass the following line to the head of the HTML page:

<!-- Yandex Games SDK -->
<script src="https://yandex.ru/games/sdk/v2"></script>

Add the following code to the HTML page:

<!-- Yandex Games SDK -->
<script>
    (function(d) {
        var t = d.getElementsByTagName('script')[0];
        var s = d.createElement('script');
        s.src = 'https://yandex.ru/games/sdk/v2';
        s.async = true;
        t.parentNode.insertBefore(s, t);
        s.onload = initSDK;
    })(document);
</script>

Usage

To get started, initialize the SDK using the init method of the YaGames object.

YaGames
    .init()
    .then(ysdk => {
        console.log('Yandex SDK initialized');
        window.ysdk = ysdk;
    });

Possible problems

Uncaught ReferenceError: YaGames is not defined

Pay attention to the order of integrating the games/sdk/v2 script: it must be integrated before YaGames.init() is run.

Uncaught ReferenceError: ysdk is not defined

The error means you've tried to use SDK methods (ads, purchases, etc.) before initializing the SDK (the Yandex SDK initialized message should appear in the Games Console). If you don't know how to ensure the order of calls, rewrite the chunks of your code where you use the SDK. To do this, replace this line:

ysdk.adv.showFullscreenAdv()

with:

YaGames.init().then(ysdk => ysdk.adv.showFullscreenAdv())

SDK connection example

<!-- Yandex Games SDK -->
<script src="https://yandex.ru/games/sdk/v2"></script>
<script>
    YaGames.init().then(ysdk => {
        // ...
    });
</script>

Additional parameters

You can pass optional parameters to YaGames.init(): YaGames.init(options). For more information, see Other SDK objects and parameters.


Note

Our support team can help publish finished games or WebApps on Yandex Games. If you have any questions about development or testing, ask them in the Discord channel.

If you are facing an issue or have a question regarding the use of Yandex Games SDK, please contact support:

Send an email