---
metadata:
  - name: generator
    content: Diplodoc Platform v5.52.0
alternate:
  - https://yandex.com/dev/games/doc/en/sdk/sdk-other-games.md
  - https://yandex.com/dev/games/doc/hi/sdk/sdk-other-games.md
  - https://yandex.com/dev/games/doc/ko/sdk/sdk-other-games.md
  - https://yandex.com/dev/games/doc/ru/sdk/sdk-other-games.md
  - https://yandex.com/dev/games/doc/tr/sdk/sdk-other-games.md
  - https://yandex.com/dev/games/doc/vi/sdk/sdk-other-games.md
  - https://yandex.com/dev/games/doc/zh/sdk/sdk-other-games.md
  - href: zh/sdk/sdk-other-games.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/zh/llms.txt

# 其他游戏链接

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

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

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

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

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

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

Yandex Games SDK允许您自动获得指向您其他游戏的正确链接（包括特定游戏和游戏列表），以便在游戏中引用它们。

为确保游戏确实可在当前平台和域上访问（参见[第8.4.1项](https://yandex.com/dev/games/doc/zh/concepts/requirements.md#8-4-1)），请使用`GamesAPI.getAllGames()`和`GamesAPI.getGameByID()`方法。

## ysdk.features.GamesAPI.getAllGames() {#get-all-games}

当您需要获取有关当前平台和域上可用的所有游戏的信息时，请使用此方法。

### 示例 {#get-all-games-ex}

```javascript showLineNumbers
ysdk.features.GamesAPI.getAllGames().then(({games, developerURL}) => {
    games.forEach((game) => {
        // 游戏处理逻辑。
    })
}).catch(err => {
    // 获取游戏数据时出错。
})
```

### 回应格式 {#get-all-games-response}

```javascript showLineNumbers
{
    [games](*key_games): IGame[];
    [developerURL](*key_developerURL): string;
}
```

#|
|| **参数** | **类型** | **描述** ||
|| `games` | [IGame[]](#igame) | 包含游戏信息的对象数组。 ||
|| `developerURL` | `string` | 开发者页面的链接。 ||
|#

## ysdk.features.GamesAPI.getGameByID() {#get-game-by-id}

当您需要获取有关特定游戏及其在当前平台和域上的可用性的数据时，请使用此方法。

接受参数：

<div class="table-25 table-2c25">

#|
|| **参数** | **类型** | **描述** ||
|| `appID` | `number` | 开发人员控制台中的游戏 ID。 ||
|#

</div>

### 示例 {#get-by-id-ex}

```javascript showLineNumbers
ysdk.features.GamesAPI.getGameByID(100000).then(({isAvailable, game}) => {
    if (isAvailable) {
        // 如果游戏可用，请处理 game。
    } else {
        // 游戏不可用时的逻辑，game 对象未定义（undefined）。
    }
}).catch(err => {
    // 获取游戏数据时出错。
})
```

### 回应格式 {#get-by-id-response}

```javascript showLineNumbers
{
    [game](*key_game)?: IGame;
    [isAvailable](*key_isAvailable): boolean;
}
```

#|
|| **参数** | **类型** | **描述** ||
|| `game` | [IGame](#igame) | 关于游戏的信息对象。 ||
|| `isAvailable` | `boolean` | 表示游戏是否可用：
* `true` —— 游戏可用；
* `false` —— 游戏不可用，`game` 对象未定义（`undefined`）。 ||
|#

## IGame 接口 {#igame}

```typescript showLineNumbers
interface IGame {
    [appID](*key_appId): string;
    [title](*key_title): string;
    [url](*key_url): string;
    [coverURL](*key_coverURL): string;
    [iconURL](*key_iconURL): string;
}
```

#|
|| **参数** | **类型** | **描述** ||
|| `appID` | `string` | 在开发人员控制台中设置的游戏标识符。 ||
|| `title` | `string` | 游戏的名称。 ||
|| `url` | `string` | 游戏的链接。 ||
|| `coverURL` | `string` | 游戏封面的链接。 ||
|| `iconURL` | `string` | 游戏图标的链接。 ||
|#

---

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

技术支持团队将协助您将已完成的游戏发布到 Yandex 游戏平台。关于开发和测试方面的具体问题，其他开发人员将在[Discord 频道](https://discord.com/invite/wU4p3whr4T){.external}中进行回答。

{% endnote %}

如果您遇到 Yandex Games SDK 方面的问题或有其他问题想要咨询，请联系支持部门：

<!-- source: zh/_includes/button-chat.md -->
<a href="https://yandex.com/chat/#/user/a4fa5c06-75db-9b38-6eea-b1673785f7d5">
  <span class="button">写入聊天信息</span>
</a>
<!-- endsource: zh/_includes/button-chat.md -->
<!-- endsource: zh/_includes/sdk-support.md -->

[*key_games]: 包含游戏信息的对象数组。

[*key_developerURL]: 开发者页面的链接。

[*key_game]: 关于游戏的信息对象。

[*key_isAvailable]: 表示游戏是否可用：
* `true` —— 游戏可用；
* `false` —— 游戏不可用，`game` 对象未定义（`undefined`）。

[*key_appId]: 在开发人员控制台中设置的游戏标识符。

[*key_title]: 游戏的名称。

[*key_url]: 游戏的链接。

[*key_coverURL]: 游戏封面的链接。

[*key_iconURL]: 游戏图标的链接。