---
metadata:
  - name: generator
    content: Diplodoc Platform v5.52.0
alternate:
  - https://yandex.com/dev/games/doc/en/sdk/sdk-about.md
  - https://yandex.com/dev/games/doc/hi/sdk/sdk-about.md
  - https://yandex.com/dev/games/doc/ko/sdk/sdk-about.md
  - https://yandex.com/dev/games/doc/ru/sdk/sdk-about.md
  - https://yandex.com/dev/games/doc/tr/sdk/sdk-about.md
  - https://yandex.com/dev/games/doc/vi/sdk/sdk-about.md
  - https://yandex.com/dev/games/doc/zh/sdk/sdk-about.md
  - href: en/sdk/sdk-about.md
    type: text/markdown
    title: Markdown version
  - href: ../llms.txt
    type: text/markdown
    title: llms.txt
---
> **Documentation Index:** Fetch the complete configuration index at https://yandex.com/dev/games/doc/en/llms.txt

# Connection and usage

<!-- source: en/_includes/script-common.md -->
<!-- source: en/_includes/script/index-js.md -->

<!-- endsource: en/_includes/script/index-js.md -->

<!-- source: en/_includes/script/requirements-js.md -->

<!-- endsource: en/_includes/script/requirements-js.md -->

<!-- source: en/_includes/script/image-modal-js.md -->

<!-- endsource: en/_includes/script/image-modal-js.md -->
<!-- endsource: en/_includes/script-common.md -->

## Connection {#connect}

{% note alert %}

To ensure your game passes moderation successfully, specify the up-to-date path for connecting Yandex&nbsp;Games SDK:

- If you upload the game archive to the Yandex server via the [Developer Console](https://games.yandex.com/console){.external}, specify a [relative path](#yandex-server). This is the recommended option.
- If you are using integration via your own domain, specify an [absolute path](#iframe).

{% endnote %}

You can connect the Yandex Games SDK in two equally valid ways:

- Via the `
    ```

    Use the following attributes:

    - `async` — for non-blocking loading.
    - `onload` — to execute code after the script loads.

    Example code for running `initSDK` after the script loads. `initSDK` refers to [SDK initialization](#use):

    ```html showLineNumbers
    <!-- Yandex Games SDK -->
    
    ```

- Dynamic loading

    Add the following code snippet to your `
```

## Usage {#use}

After the script loads, initialize the SDK using the `init()` method of the `YaGames` object.

{% note tip %}

The `YaGames.init()` and [ysdk.getPayments()](https://yandex.com/dev/games/doc/en/sdk/sdk-purchases.md#install) methods accept an optional `signed: boolean` parameter for [fraud protection](https://yandex.com/dev/games/doc/en/sdk/sdk-purchases.md#signature). The value depends on where payment processing occurs:

- Client-side processing — call methods without the `signed: boolean` parameter or pass `signed: false`. Purchase methods will return data in plaintext.
- Server-side processing — pass `signed: true`. In this case, responses from [payments.getPurchases()](https://yandex.com/dev/games/doc/en/sdk/sdk-purchases.md#getpurchases) and [payments.purchase()](https://yandex.com/dev/games/doc/en/sdk/sdk-purchases.md#payments-purchase) will return all data exclusively in encrypted form via the `signature` parameter.

{% endnote %}

{% list tabs %}

- Client-side processing

    Initialization with the default parameter (`signed: false`):

    ```javascript
    const ysdk = await YaGames.init();
    ```

- Server-side processing

    Initialization with `signed: true`:

    ```javascript
    const ysdk = await YaGames.init({ signed: true });
    ```

{% endlist %}

&nbsp; {.empty}

## Verification {#check}

{% note warning %}

The `/sdk.js` script must be connected before executing [YaGames.init()](#use).

{% endnote %}

Check if the SDK is connected correctly using the loader:

1. Open the game with the [debug panel](https://yandex.com/dev/games/doc/en/console/debug-panel.md):

   <!-- source: en/_includes/requirements/start-debug-panel.md -->
   {% list tabs %}

   - Using the developer console
       1. Open the [Yandex Games console](https://games.yandex.com/console){.external}.
       2. Select the game you need.
       3. In the top left corner, click on **Open with debug panel**.

   - Using the address bar
       1. Open the required game.
       2. Add `&debug-mode=16` to the end of the browser's address bar.

          Example link: `https://yandex.com/games/app/XXXX?debug-mode=16`, where `XXXX` is the unique game ID.

   {% endlist %}
   <!-- endsource: en/_includes/requirements/start-debug-panel.md -->

2. In the bottom left corner, check the value of the [loader indicator](https://yandex.com/dev/games/doc/en/console/debug-panel.md#loader):

    - `W` — waiting for initialization.
    - `IT` — the SDK loader is initialized correctly.
    - `IF` — an old loader is being used. Download the SDK according to the [documentation](#connect).

## Troubleshooting {#faq}

### Uncaught ReferenceError: YaGames is not defined {#yagames-not-defined}

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

### Uncaught ReferenceError: ysdk is not defined {#ysdk-not-defined}

You've tried to use SDK methods (ads, purchases, etc.) before initializing the SDK. You can track the initialization moment in debug mode by the `Initialized` message in the console. To control the order of calls, add SDK initialization before calling the method:

```javascript showLineNumbers
const ysdk = await YaGames.init();

ysdk.adv.showFullscreenAdv();
```

### SDK connection example {#connection-example}

```html showLineNumbers
<!-- Yandex Games SDK -->


```

---

<!-- source: en/_includes/sdk-support.md -->
{% note info %}

Our support team can help publish finished games on Yandex Games. If you have any questions about development or testing, ask them in the [Discord channel](https://discord.com/invite/wU4p3whr4T){.external}.

{% endnote %}

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

<!-- source: en/_includes/button-chat.md -->
<a href="https://yandex.com/chat/#/user/a4fa5c06-75db-9b38-6eea-b1673785f7d5">
  <span class="button">Write to chat</span>
</a>
<!-- endsource: en/_includes/button-chat.md -->
<!-- endsource: en/_includes/sdk-support.md -->
