跳转到内容

Overview

  • Version: 2.0.0
  • Servers: https://store.xsolla.com/api
  • Contact Us by Email
  • Contact URL: https://xsolla.com/
  • Required TLS version: 1.2

The Catalog API allows you to configure a catalog of in-game items on the Xsolla side and display the catalog to users in your store.

The API allows you to manage the following catalog entities:

  • Virtual items — in-game items such as weapons, skins, boosters.
  • Virtual currency — virtual money used to purchase virtual goods.
  • Virtual currency packages — predefined bundles of virtual currency.
  • Bundles — combined packages of virtual items, currency, or game keys sold as a single SKU.
  • Game keys — keys for games and DLCs distributed via platforms like Steam or other DRM providers.
  • Groups — logical groupings for organizing and sorting items within the catalog.

API calls

The API is divided into the following groups:

  • Admin — calls for creating, updating, deleting, and configuring catalog items and groups. Authenticated via basic access authentication with your merchant or project credentials. Not intended for storefront use.
  • Catalog — calls for retrieving items and building custom storefronts for end users. Designed to handle high-load scenarios. Support optional user JWT authorization to return personalized data such as user-specific limits and active promotions.

Authentication

API calls require authentication either on behalf of a user or on behalf of a project. The authentication scheme used is specified in the Security section in the description of each call.

Authentication using user's JWT

User's JWT authentication is used when a request is sent from a browser, mobile application, or game. By default, the XsollaLoginUserJWT scheme is applied. For details on how to create a token, see the Xsolla Login API documentation.

The token is passed in the Authorization header in the following format: Authorization: Bearer <user_JWT>, where <user_JWT> is the user token. The token identifies the user and provides access to personalized data.

或者,您也可以使用用于打开支付UI的令牌

Basic HTTP authentication

Basic HTTP authentication is used for server-to-server interactions, when an API call is sent directly from your server rather than from a user's browser or mobile application. HTTP Basic authentication with an API key is typically used.

Note

The API key is confidential and must not be stored or used in client applications.

With basic server-side authentication, all API requests must include the following header:

  • for basicAuthAuthorization: Basic <your_authorization_basic_key>, where your_authorization_basic_key is the project_id:api_key pair encoded in Base64
  • for basicMerchantAuthAuthorization: Basic <your_authorization_basic_key>, where your_authorization_basic_key is the merchant_id:api_key pair encoded in Base64

You can find the parameter values in Publisher Account:

  • merchant_id is displayed:
    • In Company settings > Company.
    • In the URL in the browser address bar on any Publisher Account page. The URL has the following format: https://publisher.xsolla.com/<merchant_id>.
  • project_id is displayed:
    • Next to the project name in Publisher Account.
    • In the URL in the browser address bar when working on a project in Publisher Account. The URL has the following format: https://publisher.xsolla.com/<merchant_id>/projects/<project_id>.
  • api_key is shown in Publisher Account only at the time of creation and must be stored securely on your side. You can create an API key in the following sections:
Notice

If a required API call doesn't include the project_id path parameter, use an API key that is valid across all company projects for authorization.

For more information about working with API keys, see the API references.

Authentication with guest access support

AuthForCart身份认证方案用于购物车购买,支持两种模式:

  1. Authentication with a user's JWT. The token is passed in the Authorization header in the following format: Authorization: Bearer <user_JWT>, where <user_JWT> is the user token. The token identifies the user and provides access to personalized data. Alternatively, you can use a token for opening the payment UI.

  2. Simplified mode without Authorization header. This mode is used only for unauthorized users and can be applied only for game key sales. Instead of a token, the request must include the following headers:

    • x-unauthorized-id with a request ID
    • x-user with the user's email address encoded in Base64

Core entity structure

Items of all types (virtual items, bundles, virtual currency, and keys) use a similar data structure. Understanding the basic structure simplifies working with the API and helps you navigate the documentation more easily.

Note

Some calls may include additional fields but they don't change the basic structure.

Identification

  • merchant_id — company ID in Publisher Account
  • project_id — project ID in Publisher Account
  • sku — item SKU, unique within the project

Store display

  • name — item name
  • description — item description
  • image_url — image URL
  • is_enabled — item availability
  • is_show_in_store — whether the item is displayed in the catalog

For more information about managing item availability in the catalog, see the documentation.

Organization

  • type — item type, for example, a virtual item (virtual_item) or bundle (bundle)
  • groups — groups the item belongs to
  • order — display order in the catalog

Sale conditions

  • prices — prices in real or virtual currency
  • limits — purchase limits
  • periods — availability periods
  • regions — regional restrictions

Example of core entity structure:

{
  "attributes": [],
  "bundle_type": "virtual_currency_package",
  "content": [
    {
      "description": {
        "en": "Main in-game currency"
      },
      "image_url": "https://.../image.png",
      "name": {
        "en": "Crystals",
        "de": "Kristalle"
      },
      "quantity": 500,
      "sku": "com.xsolla.crystal_2",
      "type": "virtual_currency"
    }
  ],
  "description": {
    "en": "Crystals x500"
  },
  "groups": [],
  "image_url": "https://.../image.png",
  "is_enabled": true,
  "is_free": false,
  "is_show_in_store": true,
  "limits": {
    "per_item": null,
    "per_user": null,
    "recurrent_schedule": null
  },
  "long_description": null,
  "media_list": [],
  "name": {
    "en": "Medium crystal pack"
  },
  "order": 1,
  "periods": [
    {
      "date_from": null,
      "date_until": "2020-08-11T20:00:00+03:00"
    }
  ],
  "prices": [
    {
      "amount": 20,
      "country_iso": "US",
      "currency": "USD",
      "is_default": true,
      "is_enabled": true
    }
  ],
  "regions": [],
  "sku": "com.xsolla.crystal_pack_2",
  "type": "bundle",
  "vc_prices": []
}

Basic purchase flow

The Xsolla API allows you to implement in-game store logic, including retrieving the item catalog, managing the cart, creating orders, and tracking their status. Depending on the integration scenario, API calls are divided into Admin and Catalog subsections, which use different authentication schemes.

The following example shows a basic flow for setting up and operating a store, from item creation to purchase.

Create items and groups (Admin)

Create an item catalog for your store, such as virtual items, bundles, or virtual currency.

Example API calls:

Set up promotions, chains, and limits (Admin)

Configure user acquisition and monetization tools, such as discounts, bonuses, daily rewards, or offer chains.

Example API calls:

Get item information (Client)

Configure item display in your application.

Notice

Do not use API calls from the Admin subsection to build a user catalog. These API calls have rate limits and aren't intended for user traffic.

Example API calls:

Note

By default, catalog API calls return items that are currently available in the store at the time of the request. To retrieve items that are not yet available or are no longer available, include the parameter "show_inactive_time_limited_items": 1 in the catalog request.

Sell items

You can sell items using the following methods:

  • Fast purchase — sell one SKU multiple times.
  • Cart purchase — the user adds items to the cart, removes items, and updates quantities within a single order.

If an item is purchased using virtual currency instead of real money, use the Create order with specified item purchased by virtual currency API call. The payment UI is not required, as the charge is processed when the API call is executed.

For free item purchase, use the Create order with specified free item API call or the Create order with free cart API call. The payment UI is not required — the order is immediately set to the done status.

Fast purchase

Use the client-side API call to create an order with a specified item. The call returns a token used to open the payment UI.

Note

Discount information is available to the user only in the payment UI. Promo codes are not supported.

Cart purchase

Cart setup and purchase can be performed on the client or on the server side.

Set up and purchase a cart on the client

Implement the logic of adding and removing items by yourself. Before calling the API for setting up a cart, you will not have information about which promotions will be applied to the purchase. This means that the total cost and details of the added bonus items will not be known.

Implement the following cart logic:

  1. After the player has filled a cart, use the Fill cart with items API call. The call returns the current information about the selected items (prices before and after discounts, bonus items).
  2. Update the cart contents based on user actions:
Note

To get the current status of the cart, use the Get current user's cart API call.
  1. Use the Create order with all items from current cart API call. The call returns the order ID and payment token. The newly created order is set to new status by default.

Set up and purchase a cart on the server

This setup option may take longer for setting the cart up, since each change to the cart must be accompanied by API calls.

Implement the following cart logic:

  1. After the player has filled a cart, use the Fill cart with items API call. The call returns current information about the selected items (prices before and after discounts, bonus items).
  2. Use the Create order with all items from current cart API call. The call returns the order ID and payment token. The newly created order is set to new status by default.

Open payment UI

Use the returned token to open the payment UI in a new window. Other ways to open the payment UI are described in the documentation.

ActionEndpoint
Open in production environment.https://secure.xsolla.com/paystation4/?token={token}
Open in sandbox mode.https://sandbox-secure.xsolla.com/paystation4/?token={token}
Note

Use sandbox mode during development and testing. Test purchases don't charge real accounts. You can use test bank cards.

After the first real payment is made, a strict sandbox payment policy takes effect. A payment in sandbox mode is available only to users specified in Publisher Account > Company settings > Users.

Buying virtual currency and items for real currency is possible only after signing a license agreement with Xsolla. To do this, in Publisher Account, go to Agreements & Taxes > Agreements, complete the agreement form, and wait for confirmation. It may take up to 3 business days to review the agreement.

To enable or disable sandbox mode, change the value of the sandbox parameter in the request for fast purchase and cart purchase. Sandbox mode is off by default.

Possible order statuses:

  • new — order created
  • paid — payment received
  • done — item delivered
  • canceled — order canceled
  • expired — order expired

Track order status using one of the following methods:

Pagination

API calls that return large sets of records (for example, when building a catalog) return data in pages. Pagination is a mechanism that limits the number of items returned in a single API response and allows you to retrieve subsequent pages sequentially.

Use the following parameters to control the number of returned items:

  • limit — number of items per page
  • offset — index of the first item on the page (numbering starts from 0)
  • has_more — indicates whether another page is available
  • total_items_count — total number of items

Example request:

GET /items?limit=20&offset=40

Response example:

{
  "items": [...],
  "has_more": true,
  "total_items_count": 135
}

It is recommended to send subsequent requests until the response returns has_more = false.

Date and time format

Dates and time values are passed in the ISO 8601 format.

The following are supported:

  • UTC offset
  • null value when there is no time restriction for displaying an item
  • Unix timestamp (in seconds) used in some fields

Format: YYYY-MM-DDTHH:MM:SS±HH:MM

Example: 2026-03-16T10:00:00+03:00

Localization

Xsolla supports localization of user-facing fields such as item name and description. Localized values are passed as an object where the language code is used as the key. The full list of supported languages is available in the documentation.

Supported fields

Localization can be specified for the following parameters:

  • name
  • description
  • long_description

Locale format

The locale key can be specified in one of the following formats:

  • Two-letter language code: en, ru
  • Five-letter language code: en-US, ru-RU, de-DE

Examples

Example with a two-letter language code:

{
  "name": {
    "en": "Starter Pack",
    "ru": "Стартовый набор"
  }
}

Example with a five-letter language code:

{
  "description": {
    "en-US": "Premium bundle",
    "de-DE": "Premium-Paket"
  }
}

Country and currency determination

The user's country determines catalog prices, the payment currency, and available payment methods in the payment UI. Depending on the API call, the country is determined as follows:

  • In client-side API calls, the country is determined by the IP address of the request.
  • In server-side API calls, the country is determined by the value of the user.country.value parameter or by the user's IP address from the X-User-Ip header. If both are passed, the user.country.value parameter takes precedence.
Note

Only IPv4 addresses are supported for country determination. Passing an IPv6 address may result in incorrect country and currency detection. If you use the server-side API call and cannot provide the user's IPv4 address, pass the country in the user.country.value parameter.

Error response format

If an error occurs, the API returns an HTTP status and a JSON response body. The full list of store-related errors is available in the documentation.

Response example:

{
  "errorCode": 1102,
  "errorMessage": "Validation error",
  "statusCode": 422,
  "transactionId": "c9e1a..."
}
  • errorCode — error code.
  • errorMessage — short error description.
  • statusCode — HTTP response status.
  • transactionId — request ID. Returned only in some cases.
  • errorMessageExtended — additional error details, such as request parameters. Returned only in some cases.

Extended response example:

{
  "errorCode": 7001,
  "errorMessage": "Chain not found",
  "errorMessageExtended": {
    "chain_id": "test_chain_id",
    "project_id": "test_project_id",
    "step_number": 2
  },
  "statusCode": 404
}

Common HTTP status codes

  • 400 — invalid request
  • 401 — authentication error
  • 403 — insufficient permissions
  • 404 — resource not found
  • 422 — validation error
  • 429 — rate limit exceeded

Recommendations

  • Handle the HTTP status and the response body together.
  • Use errorCode to process errors related to application logic.
  • Use transactionId to identify requests more quickly when analyzing errors.
下载 OpenAPI 描述
语言
服务器
https://store.xsolla.com/api/
Mock server
https://xsolla.redocly.app/_mock/zh/api/catalog/

概述

您可以使用虚拟物品和虚拟货币构建游戏内购商店,并配置其向用户展示的方式。可使用以下商品类型:

  • 虚拟物品 — 武器、皮肤、加成道具等游戏内商品。可使用真实货币或虚拟货币销售。
  • 虚拟货币 — 用于购买虚拟物品的游戏内货币。可使用真实货币或虚拟货币销售。
  • 虚拟货币套餐 — 固定数量的虚拟货币。可使用真实货币或虚拟货币销售。

组(Group)用于组织商品目录中的商品。通过组,您可以按逻辑对商品进行分组,并管理商品的显示方式。

使用管理子部分中的API调用来创建、更新和删除商品。

使用商品目录子部分中的API调用获取商品列表,并向用户展示商品。

提示

请勿使用管理子部分中的API调用来构建商店商品目录。

注:

获取虚拟物品列表API调用会返回详细的商品数据,包括价格和属性,并支持分页。请使用该调用在商店前端显示商品目录页面。

获取所有虚拟物品列表API调用会返回商品SKU、名称、描述,以及组ID和组名称,且不分页。请将其用于客户端侧搜索或索引。

如需使用虚拟货币的购买,请使用使用以虚拟货币购买的指定商品创建订单 API调用。无需支付UI⸺扣款会在执行API调用时完成。

使用虚拟货币购买流程示例:

使用虚拟货币购买流程示例

操作
操作
操作

概述

游戏Key是一次性使用的唯一字母数字代码,可授予用户在游戏平台上访问游戏或DLC的权限。您可以通过直接链接商店UI小组件销售游戏Key。您还可以配置区域限制,以便在特定国家/地区销售游戏Key。有关详细信息,请参阅游戏Key套餐部分。

销售游戏Key不要求用户身份认证——游戏Key会发送到用户在结算时指定的邮箱。您可以配置身份认证,以支持更多场景:个性化购买限制权益系统。有关详细信息,请参阅销售游戏Key时如何设置身份认证部分。

游戏Key销售流程:

  1. 使用创建游戏API调用创建游戏。
  2. 配置区域限制。
  3. 使用上传游戏Key API调用将游戏Key上传到游戏Key套餐,使其可供购买。
  4. 使用获取游戏列表API调用展示游戏目录,并显示适用于用户所在区域的价格。
  5. 创建订单。如需实现快速购买,可以使用使用当前购物车中的所有商品创建订单API调用,并传入游戏Key SKU。响应会返回用于打开支付UI的令牌。
  6. 实现支付UI的打开逻辑,以便用户支付订单。

如需及时接收支付成功通知并向用户交付商品,请设置订单状态跟踪,例如使用Webhook。游戏Key会发送到用户在结算时指定的邮箱,订单状态将变为done

游戏Key

操作

请求

获取用于构建商品目录的游戏列表。

注意

所有项目对响应中可获取的商品数量均有限制。默认值和最大值均为每个响应50个商品。如需按页获取更多数据,请使用limitoffset字段。

注:

未经授权使用此API调用时,会返回通用商品目录数据。如需获取 个性化 用户数据,例如与商品相关的数量限制和促销活动,请使用授权。为此,请在Authorization请求头中传递用户JWT。 有关用户JWT的更多信息,请参阅此调用的Security部分。
安全
XsollaLoginUserJWT
路径
project_idinteger必需

项目ID。您可以在发布商帐户的项目名称旁找到此参数;使用项目时,也可以在浏览器地址栏中找到此参数。URL格式如下:https://publisher.xsolla.com/<merchant_id>/projects/<project_id>

示例: 44056
查询
limitinteger>= 1

页面上元素数量的限制。

示例: limit=50
offsetinteger>= 0

生成列表时作为起始位置的元素编号(从0开始计数)。

示例: offset=0
localestring

响应语言。符合ISO 639-1标准的两位小写语言代码(例如en)。namedescription等本地化字段支持五字符区域代码(例如en-US),但在响应中会标准化为两位代码。支持的语言完整列表请参阅文档

默认值 "en"
additional_fields[]Array of strings

响应中需额外返回的字段。默认不返回这些字段。如需返回,请传入对应的字段值。

Enum"media_list""order""long_description""custom_attributes""item_order_in_group"
countrystring

符合ISO 3166-1 alpha-2标准的两位大写国家/地区代码。关于艾克索拉支持的国家/地区国家/地区判定流程的详细信息,请参阅文档。

示例: country=US
promo_codestring[ 1 .. 128 ] characters

区分大小写的唯一兑换码。包含字母和数字。

示例: promo_code=WINTER2021
show_inactive_time_limited_itemsinteger

显示对用户不可用的时效性商品。这类商品的有效期尚未开始或已经结束。

默认值 0
示例: show_inactive_time_limited_items=1
curl -i -X GET \
  'https://store.xsolla.com/api/v2/project/44056/items/game?limit=50&offset=0&locale=en&additional_fields%5B%5D=media_list&country=US&promo_code=WINTER2021&show_inactive_time_limited_items=1' \
  -H 'Authorization: Bearer <YOUR_JWT_HERE>'

响应

已成功接收游戏列表。

正文application/json
has_moreboolean

用作指示还有更多页面。

itemsArray of objects
示例: [{"sku":"com.xsolla.game_1","name":"Game name","groups":[{"external_id":"all","name":"All games"},{"external_id":"Xsolla","name":"Xsolla games"}],"type":"unit","unit_type":"game","description":"Game description","image_url":"https://cdn.xsolla.net/img/misc/images/b79342cdf24f0f8557b63c87e8326e62.png","attributes":[{"external_id":"genre","name":"Genre","values":[{"external_id":"23fda05111c125608af8f1fa0e99db45a10ea1cc","value":"Horror"}]}],"promotions":[],"unit_items":[{"sku":"com.xsolla.game_key_01","type":"game_key","is_free":false,"price":{"amount":"30.5","amount_without_discount":"30.5","currency":"USD"},"virtual_prices":[],"can_be_bought":true,"drm_name":"Steam","drm_sku":"steam_key_1","has_keys":true,"is_pre_order":true,"release_date":"2020-08-11T10:00:00+03:00","promotions":[],"periods":[{"date_from":"2020-08-11T10:00:00+03:00","date_until":"2020-08-11T20:00:00+03:00"}]},{"sku":"com.xsolla.game_key_02","type":"game_key","is_free":false,"price":{"amount":"30.5","amount_without_discount":"30.5","currency":"USD"},"virtual_prices":[],"can_be_bought":true,"drm_name":"Origin","drm_sku":"origin_key_1","has_keys":false,"is_pre_order":false,"release_date":null,"promotions":[],"periods":[]}]},{"sku":"com.xsolla.game_2","name":"Game name","groups":[{"external_id":"all","name":"All games"}],"type":"unit","unit_type":"game","description":"Game description","image_url":"https://cdn.xsolla.net/img/misc/images/b79342cdf24f0f8557b63c87e8326e62.png","attributes":[{"external_id":"OS","name":"OS","values":[{"external_id":"9d5c5efb7c0f00a00fe4e3583f1215b0050bc723","value":"Windows"}]}],"promotions":[],"unit_items":[{"sku":"com.xsolla.game_key_01","type":"game_key","is_free":false,"price":{"amount":"30.5","amount_without_discount":"30.5","currency":"USD"},"virtual_prices":[],"can_be_bought":true,"drm_name":"Steam","drm_sku":"steam_key_2","has_keys":false,"is_pre_order":false,"release_date":null,"promotions":[],"periods":[{"date_from":null,"date_until":"2020-08-11T20:00:00+03:00"}]}]}]
items[].​skustring

唯一商品ID。SKU只能包含大小写英文字母、数字、句点、短横线和下划线。

示例: "game_01"
items[].​namestring

商品名称。

示例: "Game name"
items[].​groupsArray of objects

商品所属分组。

items[].​groups[].​external_idstring

创建商品组时指定的外部商品组ID

示例: "exclusive"
items[].​groups[].​namestring

组名称。

示例: "Exclusive"
items[].​groups[].​item_order_in_groupinteger

商品在组内的位置,用于决定其显示顺序。 仅在通过additional_fields[]查询参数请求时返回。

示例: 1
items[].​attributesArray of objects

与商品对应的属性及其值的列表。可用于商品目录筛选。

items[].​attributes[].​external_idstring[ 1 .. 255 ] characters^[a-zA-Z0-9-_]+$

唯一属性ID。 external_id只能包含大小写英文字母、数字、短横线和下划线。

items[].​attributes[].​namestring

属性名称。

示例: "Genre"
items[].​attributes[].​valuesArray of objects
items[].​attributes[].​values[].​external_idstring[ 1 .. 255 ] characters^[-_.\d\w]+$

属性的唯一值ID。 external_id只能包含小写英文字母、数字、短横线和下划线。

items[].​attributes[].​values[].​valuestring

属性值。

示例: "Strategy"
items[].​typestring

商品类型:virtual_good/virtual_currency/bundle/physical_good/unit

示例: "unit"
items[].​unit_typestring

单元类型:game

示例: "game"
items[].​descriptionstring

商品描述。

示例: "Game description"
items[].​image_urlstring

图片URL。

示例: "https://cdn.xsolla.net/img/misc/images/b79342cdf24f0f8557b63c87e8326e62.png"
items[].​promotionsArray of objects

应用于购物车中指定商品的促销活动。仅在以下情况下返回该数组:

  • 为某商品配置了折扣促销活动。

  • 应用了具有对所选商品提供折扣设置的兑换码。

如果未应用任何商品级促销活动,则返回空数组。

items[].​promotions[].​namestring
items[].​promotions[].​date_startstring or null(date-time)
items[].​promotions[].​date_endstring or null(date-time)
items[].​promotions[].​discountobject or null
items[].​promotions[].​discount.​percentstring or null
items[].​promotions[].​discount.​valuestring or null
items[].​promotions[].​bonusArray of objects
items[].​promotions[].​bonus[].​skustring
items[].​promotions[].​bonus[].​quantityinteger
items[].​promotions[].​bonus[].​typestring

赠品类型。

Enum"virtual_good""virtual_currency""bundle""physical_good""game_key""nft"
items[].​promotions[].​bonus[].​namestring

赠品名称。不适用于physical_good赠品类型。

items[].​promotions[].​bonus[].​image_urlstring

赠品图片URL。不适用于physical_good赠品类型。

items[].​promotions[].​bonus[].​bundle_typestring

赠品捆绑包商品类型。仅适用于bundle赠品类型。

Enum"standard""virtual_currency_package"
items[].​promotions[].​limitsobject
items[].​promotions[].​limits.​per_userobject
items[].​promotions[].​limits.​per_user.​availableinteger
items[].​promotions[].​limits.​per_user.​totalinteger
items[].​unit_itemsArray of objects
items[].​unit_items[].​skustring

唯一商品ID。SKU只能包含大小写英文字母、数字、句点、短横线和下划线。

示例: "game_01"
items[].​unit_items[].​typestring

商品类型:game_key

示例: "game_key"
items[].​unit_items[].​is_freeboolean

该商品是否免费。

items[].​unit_items[].​priceobject

商品价格。

items[].​unit_items[].​price.​amountstring

商品折后价格。

示例: "2.9900"
items[].​unit_items[].​price.​amount_without_discountstring

商品价格。

示例: "2.9900"
items[].​unit_items[].​price.​currencystring

商品价格币种。符合ISO 4217标准的三字母代码。

示例: "USD"
items[].​unit_items[].​virtual_pricesArray of objects

虚拟价格。

items[].​unit_items[].​virtual_prices[].​amountinteger

以虚拟货币表示的商品价格。

示例: 100
items[].​unit_items[].​virtual_prices[].​amount_without_discountinteger

商品折扣前的虚拟货币价格。由于折扣不适用于虚拟货币价格,因此该值始终等于amount

示例: 200
items[].​unit_items[].​virtual_prices[].​skustring

虚拟货币SKU。

示例: "vc_gold"
items[].​unit_items[].​virtual_prices[].​is_defaultboolean

是否为默认虚拟货币价格。

示例: true
items[].​unit_items[].​virtual_prices[].​image_urlstring or null

虚拟货币图片URL。

示例: "http://image.png"
items[].​unit_items[].​virtual_prices[].​namestring

虚拟货币名称。

示例: "Gold"
items[].​unit_items[].​virtual_prices[].​typestring

商品类型。对于虚拟货币,该值为virtual_currency

示例: "virtual_currency"
items[].​unit_items[].​virtual_prices[].​descriptionstring or null

虚拟货币说明。

示例: "In-game currency used to purchase weapons and upgrades"
items[].​unit_items[].​can_be_boughtboolean

如为true,则用户可以购买商品。

items[].​unit_items[].​drm_namestring

DRM名称。

示例: "Steam"
items[].​unit_items[].​drm_skustring

唯一DRM ID。 SKU只能包含大小写英文字母、数字、句点、短横线和下划线。

示例: "steam"
items[].​unit_items[].​has_keysboolean

如果为true,则该游戏Key有供销售的Key。

示例: false
items[].​unit_items[].​is_pre_orderboolean

如果为true,则该游戏Key为预售,且尚未到发布日期。

示例: true
items[].​unit_items[].​release_datestring or null

游戏Key发布日期,采用ISO 8601格式。

示例: "2020-08-11T10:00:00+03:00"
items[].​unit_items[].​promotionsArray of objects

应用于购物车中指定商品的促销活动。仅在以下情况下返回该数组:

  • 为某商品配置了折扣促销活动。

  • 应用了具有对所选商品提供折扣设置的兑换码。

如果未应用任何商品级促销活动,则返回空数组。

items[].​unit_items[].​promotions[].​namestring
items[].​unit_items[].​promotions[].​date_startstring or null(date-time)
items[].​unit_items[].​promotions[].​date_endstring or null(date-time)
items[].​unit_items[].​promotions[].​discountobject or null
items[].​unit_items[].​promotions[].​discount.​percentstring or null
items[].​unit_items[].​promotions[].​discount.​valuestring or null
items[].​unit_items[].​promotions[].​bonusArray of objects
items[].​unit_items[].​promotions[].​bonus[].​skustring
items[].​unit_items[].​promotions[].​bonus[].​quantityinteger
items[].​unit_items[].​promotions[].​bonus[].​typestring

赠品类型。

Enum"virtual_good""virtual_currency""bundle""physical_good""game_key""nft"
items[].​unit_items[].​promotions[].​bonus[].​namestring

赠品名称。不适用于physical_good赠品类型。

items[].​unit_items[].​promotions[].​bonus[].​image_urlstring

赠品图片URL。不适用于physical_good赠品类型。

items[].​unit_items[].​promotions[].​bonus[].​bundle_typestring

赠品捆绑包商品类型。仅适用于bundle赠品类型。

Enum"standard""virtual_currency_package"
items[].​unit_items[].​promotions[].​limitsobject
items[].​unit_items[].​promotions[].​limits.​per_userobject
items[].​unit_items[].​promotions[].​limits.​per_user.​availableinteger
items[].​unit_items[].​promotions[].​limits.​per_user.​totalinteger
items[].​unit_items[].​periodsArray of objects or null

商品销售期。

items[].​unit_items[].​periods[].​date_fromstring(date-time)

指定商品开始可购的日期。

示例: "2020-08-11T10:00:00+03:00"
items[].​unit_items[].​periods[].​date_untilstring or null(date-time)

指定商品停止可购的日期。可为null

示例: "2020-08-11T20:00:00+03:00"
items[].​unit_items[].​vp_rewardsArray of objects

该商品的累充积分奖励列表。

items[].​unit_items[].​vp_rewards[].​item_idinteger

内部唯一商品ID。

items[].​unit_items[].​vp_rewards[].​skustring

唯一累充积分ID。

items[].​unit_items[].​vp_rewards[].​amountinteger

累充积分数量。

items[].​unit_items[].​vp_rewards[].​namestring

累充积分名称。

items[].​unit_items[].​vp_rewards[].​image_urlstring

图片URL。

items[].​unit_items[].​vp_rewards[].​is_clanboolean

累充积分是否用于公会累充奖励链。

响应
application/json
{ "has_more": false, "items": [ {}, {} ] }

按指定组获取游戏列表Client-side

请求

从指定组获取用于构建商品目录的游戏列表。

注意

所有项目对响应中可获取的商品数量均有限制。默认值和最大值均为每个响应50个商品。如需按页获取更多数据,请使用limitoffset字段。

注:

未经授权使用此API调用时,会返回通用商品目录数据。如需获取 个性化 用户数据,例如与商品相关的数量限制和促销活动,请使用授权。为此,请在Authorization请求头中传递用户JWT。 有关用户JWT的更多信息,请参阅此调用的Security部分。
安全
XsollaLoginUserJWT
路径
project_idinteger必需

项目ID。您可以在发布商帐户的项目名称旁找到此参数;使用项目时,也可以在浏览器地址栏中找到此参数。URL格式如下:https://publisher.xsolla.com/<merchant_id>/projects/<project_id>

示例: 44056
external_idstring必需

创建商品组时指定的外部商品组ID

示例: weapons
查询
limitinteger>= 1

页面上元素数量的限制。

示例: limit=50
offsetinteger>= 0

生成列表时作为起始位置的元素编号(从0开始计数)。

示例: offset=0
localestring

响应语言。符合ISO 639-1标准的两位小写语言代码(例如en)。namedescription等本地化字段支持五字符区域代码(例如en-US),但在响应中会标准化为两位代码。支持的语言完整列表请参阅文档

默认值 "en"
additional_fields[]Array of strings

响应中需额外返回的字段。默认不返回这些字段。如需返回,请传入对应的字段值。

Enum"media_list""order""long_description""custom_attributes""item_order_in_group"
countrystring

符合ISO 3166-1 alpha-2标准的两位大写国家/地区代码。关于艾克索拉支持的国家/地区国家/地区判定流程的详细信息,请参阅文档。

示例: country=US
promo_codestring[ 1 .. 128 ] characters

区分大小写的唯一兑换码。包含字母和数字。

示例: promo_code=WINTER2021
show_inactive_time_limited_itemsinteger

显示对用户不可用的时效性商品。这类商品的有效期尚未开始或已经结束。

默认值 0
示例: show_inactive_time_limited_items=1
curl -i -X GET \
  'https://store.xsolla.com/api/v2/project/44056/items/game/group/weapons?limit=50&offset=0&locale=en&additional_fields%5B%5D=media_list&country=US&promo_code=WINTER2021&show_inactive_time_limited_items=1' \
  -H 'Authorization: Bearer <YOUR_JWT_HERE>'

响应

已成功接收游戏列表。

正文application/json
has_moreboolean

用作指示还有更多页面。

itemsArray of objects
示例: [{"sku":"com.xsolla.game_1","name":"Game name","groups":[{"external_id":"all","name":"All games"},{"external_id":"Xsolla","name":"Xsolla games"}],"type":"unit","unit_type":"game","description":"Game description","image_url":"https://cdn.xsolla.net/img/misc/images/b79342cdf24f0f8557b63c87e8326e62.png","attributes":[{"external_id":"genre","name":"Genre","values":[{"external_id":"23fda05111c125608af8f1fa0e99db45a10ea1cc","value":"Horror"}]}],"promotions":[],"unit_items":[{"sku":"com.xsolla.game_key_01","type":"game_key","is_free":false,"price":{"amount":"30.5","amount_without_discount":"30.5","currency":"USD"},"virtual_prices":[],"can_be_bought":true,"drm_name":"Steam","drm_sku":"steam_key_1","has_keys":true,"is_pre_order":true,"release_date":"2020-08-11T10:00:00+03:00","promotions":[],"periods":[{"date_from":"2020-08-11T10:00:00+03:00","date_until":"2020-08-11T20:00:00+03:00"}]},{"sku":"com.xsolla.game_key_02","type":"game_key","is_free":false,"price":{"amount":"30.5","amount_without_discount":"30.5","currency":"USD"},"virtual_prices":[],"can_be_bought":true,"drm_name":"Origin","drm_sku":"origin_key_1","has_keys":false,"is_pre_order":false,"release_date":null,"promotions":[],"periods":[]}]},{"sku":"com.xsolla.game_2","name":"Game name","groups":[{"external_id":"all","name":"All games"}],"type":"unit","unit_type":"game","description":"Game description","image_url":"https://cdn.xsolla.net/img/misc/images/b79342cdf24f0f8557b63c87e8326e62.png","attributes":[{"external_id":"OS","name":"OS","values":[{"external_id":"9d5c5efb7c0f00a00fe4e3583f1215b0050bc723","value":"Windows"}]}],"promotions":[],"unit_items":[{"sku":"com.xsolla.game_key_01","type":"game_key","is_free":false,"price":{"amount":"30.5","amount_without_discount":"30.5","currency":"USD"},"virtual_prices":[],"can_be_bought":true,"drm_name":"Steam","drm_sku":"steam_key_2","has_keys":false,"is_pre_order":false,"release_date":null,"promotions":[],"periods":[{"date_from":null,"date_until":"2020-08-11T20:00:00+03:00"}]}]}]
items[].​skustring

唯一商品ID。SKU只能包含大小写英文字母、数字、句点、短横线和下划线。

示例: "game_01"
items[].​namestring

商品名称。

示例: "Game name"
items[].​groupsArray of objects

商品所属分组。

items[].​groups[].​external_idstring

创建商品组时指定的外部商品组ID

示例: "exclusive"
items[].​groups[].​namestring

组名称。

示例: "Exclusive"
items[].​groups[].​item_order_in_groupinteger

商品在组内的位置,用于决定其显示顺序。 仅在通过additional_fields[]查询参数请求时返回。

示例: 1
items[].​attributesArray of objects

与商品对应的属性及其值的列表。可用于商品目录筛选。

items[].​attributes[].​external_idstring[ 1 .. 255 ] characters^[a-zA-Z0-9-_]+$

唯一属性ID。 external_id只能包含大小写英文字母、数字、短横线和下划线。

items[].​attributes[].​namestring

属性名称。

示例: "Genre"
items[].​attributes[].​valuesArray of objects
items[].​attributes[].​values[].​external_idstring[ 1 .. 255 ] characters^[-_.\d\w]+$

属性的唯一值ID。 external_id只能包含小写英文字母、数字、短横线和下划线。

items[].​attributes[].​values[].​valuestring

属性值。

示例: "Strategy"
items[].​typestring

商品类型:virtual_good/virtual_currency/bundle/physical_good/unit

示例: "unit"
items[].​unit_typestring

单元类型:game

示例: "game"
items[].​descriptionstring

商品描述。

示例: "Game description"
items[].​image_urlstring

图片URL。

示例: "https://cdn.xsolla.net/img/misc/images/b79342cdf24f0f8557b63c87e8326e62.png"
items[].​promotionsArray of objects

应用于购物车中指定商品的促销活动。仅在以下情况下返回该数组:

  • 为某商品配置了折扣促销活动。

  • 应用了具有对所选商品提供折扣设置的兑换码。

如果未应用任何商品级促销活动,则返回空数组。

items[].​promotions[].​namestring
items[].​promotions[].​date_startstring or null(date-time)
items[].​promotions[].​date_endstring or null(date-time)
items[].​promotions[].​discountobject or null
items[].​promotions[].​discount.​percentstring or null
items[].​promotions[].​discount.​valuestring or null
items[].​promotions[].​bonusArray of objects
items[].​promotions[].​bonus[].​skustring
items[].​promotions[].​bonus[].​quantityinteger
items[].​promotions[].​bonus[].​typestring

赠品类型。

Enum"virtual_good""virtual_currency""bundle""physical_good""game_key""nft"
items[].​promotions[].​bonus[].​namestring

赠品名称。不适用于physical_good赠品类型。

items[].​promotions[].​bonus[].​image_urlstring

赠品图片URL。不适用于physical_good赠品类型。

items[].​promotions[].​bonus[].​bundle_typestring

赠品捆绑包商品类型。仅适用于bundle赠品类型。

Enum"standard""virtual_currency_package"
items[].​promotions[].​limitsobject
items[].​promotions[].​limits.​per_userobject
items[].​promotions[].​limits.​per_user.​availableinteger
items[].​promotions[].​limits.​per_user.​totalinteger
items[].​unit_itemsArray of objects
items[].​unit_items[].​skustring

唯一商品ID。SKU只能包含大小写英文字母、数字、句点、短横线和下划线。

示例: "game_01"
items[].​unit_items[].​typestring

商品类型:game_key

示例: "game_key"
items[].​unit_items[].​is_freeboolean

该商品是否免费。

items[].​unit_items[].​priceobject

商品价格。

items[].​unit_items[].​price.​amountstring

商品折后价格。

示例: "2.9900"
items[].​unit_items[].​price.​amount_without_discountstring

商品价格。

示例: "2.9900"
items[].​unit_items[].​price.​currencystring

商品价格币种。符合ISO 4217标准的三字母代码。

示例: "USD"
items[].​unit_items[].​virtual_pricesArray of objects

虚拟价格。

items[].​unit_items[].​virtual_prices[].​amountinteger

以虚拟货币表示的商品价格。

示例: 100
items[].​unit_items[].​virtual_prices[].​amount_without_discountinteger

商品折扣前的虚拟货币价格。由于折扣不适用于虚拟货币价格,因此该值始终等于amount

示例: 200
items[].​unit_items[].​virtual_prices[].​skustring

虚拟货币SKU。

示例: "vc_gold"
items[].​unit_items[].​virtual_prices[].​is_defaultboolean

是否为默认虚拟货币价格。

示例: true
items[].​unit_items[].​virtual_prices[].​image_urlstring or null

虚拟货币图片URL。

示例: "http://image.png"
items[].​unit_items[].​virtual_prices[].​namestring

虚拟货币名称。

示例: "Gold"
items[].​unit_items[].​virtual_prices[].​typestring

商品类型。对于虚拟货币,该值为virtual_currency

示例: "virtual_currency"
items[].​unit_items[].​virtual_prices[].​descriptionstring or null

虚拟货币说明。

示例: "In-game currency used to purchase weapons and upgrades"
items[].​unit_items[].​can_be_boughtboolean

如为true,则用户可以购买商品。

items[].​unit_items[].​drm_namestring

DRM名称。

示例: "Steam"
items[].​unit_items[].​drm_skustring

唯一DRM ID。 SKU只能包含大小写英文字母、数字、句点、短横线和下划线。

示例: "steam"
items[].​unit_items[].​has_keysboolean

如果为true,则该游戏Key有供销售的Key。

示例: false
items[].​unit_items[].​is_pre_orderboolean

如果为true,则该游戏Key为预售,且尚未到发布日期。

示例: true
items[].​unit_items[].​release_datestring or null

游戏Key发布日期,采用ISO 8601格式。

示例: "2020-08-11T10:00:00+03:00"
items[].​unit_items[].​promotionsArray of objects

应用于购物车中指定商品的促销活动。仅在以下情况下返回该数组:

  • 为某商品配置了折扣促销活动。

  • 应用了具有对所选商品提供折扣设置的兑换码。

如果未应用任何商品级促销活动,则返回空数组。

items[].​unit_items[].​promotions[].​namestring
items[].​unit_items[].​promotions[].​date_startstring or null(date-time)
items[].​unit_items[].​promotions[].​date_endstring or null(date-time)
items[].​unit_items[].​promotions[].​discountobject or null
items[].​unit_items[].​promotions[].​discount.​percentstring or null
items[].​unit_items[].​promotions[].​discount.​valuestring or null
items[].​unit_items[].​promotions[].​bonusArray of objects
items[].​unit_items[].​promotions[].​bonus[].​skustring
items[].​unit_items[].​promotions[].​bonus[].​quantityinteger
items[].​unit_items[].​promotions[].​bonus[].​typestring

赠品类型。

Enum"virtual_good""virtual_currency""bundle""physical_good""game_key""nft"
items[].​unit_items[].​promotions[].​bonus[].​namestring

赠品名称。不适用于physical_good赠品类型。

items[].​unit_items[].​promotions[].​bonus[].​image_urlstring

赠品图片URL。不适用于physical_good赠品类型。

items[].​unit_items[].​promotions[].​bonus[].​bundle_typestring

赠品捆绑包商品类型。仅适用于bundle赠品类型。

Enum"standard""virtual_currency_package"
items[].​unit_items[].​promotions[].​limitsobject
items[].​unit_items[].​promotions[].​limits.​per_userobject
items[].​unit_items[].​promotions[].​limits.​per_user.​availableinteger
items[].​unit_items[].​promotions[].​limits.​per_user.​totalinteger
items[].​unit_items[].​periodsArray of objects or null

商品销售期。

items[].​unit_items[].​periods[].​date_fromstring(date-time)

指定商品开始可购的日期。

示例: "2020-08-11T10:00:00+03:00"
items[].​unit_items[].​periods[].​date_untilstring or null(date-time)

指定商品停止可购的日期。可为null

示例: "2020-08-11T20:00:00+03:00"
items[].​unit_items[].​vp_rewardsArray of objects

该商品的累充积分奖励列表。

items[].​unit_items[].​vp_rewards[].​item_idinteger

内部唯一商品ID。

items[].​unit_items[].​vp_rewards[].​skustring

唯一累充积分ID。

items[].​unit_items[].​vp_rewards[].​amountinteger

累充积分数量。

items[].​unit_items[].​vp_rewards[].​namestring

累充积分名称。

items[].​unit_items[].​vp_rewards[].​image_urlstring

图片URL。

items[].​unit_items[].​vp_rewards[].​is_clanboolean

累充积分是否用于公会累充奖励链。

响应
application/json
{ "has_more": false, "items": [ {}, {} ] }

获取商品目录中的游戏Client-side

请求

获取用于商品目录的游戏。

注:

未经授权使用此API调用时,会返回通用商品目录数据。如需获取 个性化 用户数据,例如与商品相关的数量限制和促销活动,请使用授权。为此,请在Authorization请求头中传递用户JWT。 有关用户JWT的更多信息,请参阅此调用的Security部分。
安全
XsollaLoginUserJWT
路径
project_idinteger必需

项目ID。您可以在发布商帐户的项目名称旁找到此参数;使用项目时,也可以在浏览器地址栏中找到此参数。URL格式如下:https://publisher.xsolla.com/<merchant_id>/projects/<project_id>

示例: 44056
item_skustring必需

商品SKU。

默认值 "full_game_1"
查询
localestring

响应语言。符合ISO 639-1标准的两位小写语言代码(例如en)。namedescription等本地化字段支持五字符区域代码(例如en-US),但在响应中会标准化为两位代码。支持的语言完整列表请参阅文档

默认值 "en"
additional_fields[]Array of strings

响应中需额外返回的字段。默认不返回这些字段。如需返回,请传入对应的字段值。

Enum"media_list""order""long_description""custom_attributes""item_order_in_group"
countrystring

符合ISO 3166-1 alpha-2标准的两位大写国家/地区代码。关于艾克索拉支持的国家/地区国家/地区判定流程的详细信息,请参阅文档。

示例: country=US
promo_codestring[ 1 .. 128 ] characters

区分大小写的唯一兑换码。包含字母和数字。

示例: promo_code=WINTER2021
show_inactive_time_limited_itemsinteger

显示对用户不可用的时效性商品。这类商品的有效期尚未开始或已经结束。

默认值 0
示例: show_inactive_time_limited_items=1
curl -i -X GET \
  'https://store.xsolla.com/api/v2/project/44056/items/game/sku/{item_sku}?locale=en&additional_fields%5B%5D=media_list&country=US&promo_code=WINTER2021&show_inactive_time_limited_items=1' \
  -H 'Authorization: Bearer <YOUR_JWT_HERE>'

响应

已成功获取游戏。

正文application/json
skustring

唯一商品ID。SKU只能包含大小写英文字母、数字、句点、短横线和下划线。

示例: "game_01"
namestring

商品名称。

示例: "Game name"
groupsArray of objects

商品所属分组。

groups[].​external_idstring

创建商品组时指定的外部商品组ID

示例: "exclusive"
groups[].​namestring

组名称。

示例: "Exclusive"
groups[].​item_order_in_groupinteger

商品在组内的位置,用于决定其显示顺序。 仅在通过additional_fields[]查询参数请求时返回。

示例: 1
attributesArray of objects

与商品对应的属性及其值的列表。可用于商品目录筛选。

attributes[].​external_idstring[ 1 .. 255 ] characters^[a-zA-Z0-9-_]+$

唯一属性ID。 external_id只能包含大小写英文字母、数字、短横线和下划线。

attributes[].​namestring

属性名称。

示例: "Genre"
attributes[].​valuesArray of objects
attributes[].​values[].​external_idstring[ 1 .. 255 ] characters^[-_.\d\w]+$

属性的唯一值ID。 external_id只能包含小写英文字母、数字、短横线和下划线。

attributes[].​values[].​valuestring

属性值。

示例: "Strategy"
typestring

商品类型:virtual_good/virtual_currency/bundle/physical_good/unit

示例: "unit"
unit_typestring

单元类型:game

示例: "game"
descriptionstring

商品描述。

示例: "Game description"
image_urlstring

图片URL。

示例: "https://cdn.xsolla.net/img/misc/images/b79342cdf24f0f8557b63c87e8326e62.png"
promotionsArray of objects

应用于购物车中指定商品的促销活动。仅在以下情况下返回该数组:

  • 为某商品配置了折扣促销活动。

  • 应用了具有对所选商品提供折扣设置的兑换码。

如果未应用任何商品级促销活动,则返回空数组。

promotions[].​namestring
promotions[].​date_startstring or null(date-time)
promotions[].​date_endstring or null(date-time)
promotions[].​discountobject or null
promotions[].​discount.​percentstring or null
promotions[].​discount.​valuestring or null
promotions[].​bonusArray of objects
promotions[].​bonus[].​skustring
promotions[].​bonus[].​quantityinteger
promotions[].​bonus[].​typestring

赠品类型。

Enum"virtual_good""virtual_currency""bundle""physical_good""game_key""nft"
promotions[].​bonus[].​namestring

赠品名称。不适用于physical_good赠品类型。

promotions[].​bonus[].​image_urlstring

赠品图片URL。不适用于physical_good赠品类型。

promotions[].​bonus[].​bundle_typestring

赠品捆绑包商品类型。仅适用于bundle赠品类型。

Enum"standard""virtual_currency_package"
promotions[].​limitsobject
promotions[].​limits.​per_userobject
promotions[].​limits.​per_user.​availableinteger
promotions[].​limits.​per_user.​totalinteger
unit_itemsArray of objects
unit_items[].​skustring

唯一商品ID。SKU只能包含大小写英文字母、数字、句点、短横线和下划线。

示例: "game_01"
unit_items[].​typestring

商品类型:game_key

示例: "game_key"
unit_items[].​is_freeboolean

该商品是否免费。

unit_items[].​priceobject

商品价格。

unit_items[].​price.​amountstring

商品折后价格。

示例: "2.9900"
unit_items[].​price.​amount_without_discountstring

商品价格。

示例: "2.9900"
unit_items[].​price.​currencystring

商品价格币种。符合ISO 4217标准的三字母代码。

示例: "USD"
unit_items[].​virtual_pricesArray of objects

虚拟价格。

unit_items[].​virtual_prices[].​amountinteger

以虚拟货币表示的商品价格。

示例: 100
unit_items[].​virtual_prices[].​amount_without_discountinteger

商品折扣前的虚拟货币价格。由于折扣不适用于虚拟货币价格,因此该值始终等于amount

示例: 200
unit_items[].​virtual_prices[].​skustring

虚拟货币SKU。

示例: "vc_gold"
unit_items[].​virtual_prices[].​is_defaultboolean

是否为默认虚拟货币价格。

示例: true
unit_items[].​virtual_prices[].​image_urlstring or null

虚拟货币图片URL。

示例: "http://image.png"
unit_items[].​virtual_prices[].​namestring

虚拟货币名称。

示例: "Gold"
unit_items[].​virtual_prices[].​typestring

商品类型。对于虚拟货币,该值为virtual_currency

示例: "virtual_currency"
unit_items[].​virtual_prices[].​descriptionstring or null

虚拟货币说明。

示例: "In-game currency used to purchase weapons and upgrades"
unit_items[].​can_be_boughtboolean

如为true,则用户可以购买商品。

unit_items[].​drm_namestring

DRM名称。

示例: "Steam"
unit_items[].​drm_skustring

唯一DRM ID。 SKU只能包含大小写英文字母、数字、句点、短横线和下划线。

示例: "steam"
unit_items[].​has_keysboolean

如果为true,则该游戏Key有供销售的Key。

示例: false
unit_items[].​is_pre_orderboolean

如果为true,则该游戏Key为预售,且尚未到发布日期。

示例: true
unit_items[].​release_datestring or null

游戏Key发布日期,采用ISO 8601格式。

示例: "2020-08-11T10:00:00+03:00"
unit_items[].​promotionsArray of objects

应用于购物车中指定商品的促销活动。仅在以下情况下返回该数组:

  • 为某商品配置了折扣促销活动。

  • 应用了具有对所选商品提供折扣设置的兑换码。

如果未应用任何商品级促销活动,则返回空数组。

unit_items[].​promotions[].​namestring
unit_items[].​promotions[].​date_startstring or null(date-time)
unit_items[].​promotions[].​date_endstring or null(date-time)
unit_items[].​promotions[].​discountobject or null
unit_items[].​promotions[].​discount.​percentstring or null
unit_items[].​promotions[].​discount.​valuestring or null
unit_items[].​promotions[].​bonusArray of objects
unit_items[].​promotions[].​bonus[].​skustring
unit_items[].​promotions[].​bonus[].​quantityinteger
unit_items[].​promotions[].​bonus[].​typestring

赠品类型。

Enum"virtual_good""virtual_currency""bundle""physical_good""game_key""nft"
unit_items[].​promotions[].​bonus[].​namestring

赠品名称。不适用于physical_good赠品类型。

unit_items[].​promotions[].​bonus[].​image_urlstring

赠品图片URL。不适用于physical_good赠品类型。

unit_items[].​promotions[].​bonus[].​bundle_typestring

赠品捆绑包商品类型。仅适用于bundle赠品类型。

Enum"standard""virtual_currency_package"
unit_items[].​promotions[].​limitsobject
unit_items[].​promotions[].​limits.​per_userobject
unit_items[].​promotions[].​limits.​per_user.​availableinteger
unit_items[].​promotions[].​limits.​per_user.​totalinteger
unit_items[].​limitsobject or null

商品限制数。

unit_items[].​limits.​per_userobject or null

单个用户的商品购买数量限制。

unit_items[].​limits.​per_user.​totalinteger

单个用户可购买的最大商品数量。

示例: 5
unit_items[].​limits.​per_user.​availableinteger

当前用户可购买的剩余商品数量。

示例: 3
unit_items[].​limits.​per_user.​recurrent_schedule(object or null)
One of:

用户的商品限制循环刷新周期。

object or null
unit_items[].​limits.​per_user.​limit_exceeded_visibilitystring

设定商品在达到购买限制后、下次限制重置前在商品目录中的可见性。

适用于在recurrent_schedule数组中配置了周期性重置数量限制的商品。

如果未配置重置限制,则达到购买限制后,无论limit_exceeded_visibility的值如何,该商品都不会显示在商品目录中。

可能值:

  • show — 达到购买限制后,商品目录检索API调用仍会返回该商品。在客户端侧 商品目录检索API调用中,达到限制后返回的商品会带有can_be_bought: false 标志。下一次重置日期 将在reset_next_date中返回。
  • hide — 达到购买限制后,在限制 重置之前,商品目录检索API调用不会返回该商品。
Enum"show""hide"
unit_items[].​limits.​per_itemobject or null

单个商品的购买数量限制。

unit_items[].​limits.​per_item.​totalinteger

所有用户可购买的最大商品数量。

示例: 5
unit_items[].​limits.​per_item.​availableinteger

所有用户还可购买的剩余商品数量。

示例: 3
unit_items[].​periodsArray of objects or null

商品销售期。

unit_items[].​periods[].​date_fromstring(date-time)

指定商品开始可购的日期。

示例: "2020-08-11T10:00:00+03:00"
unit_items[].​periods[].​date_untilstring or null(date-time)

指定商品停止可购的日期。可为null

示例: "2020-08-11T20:00:00+03:00"
unit_items[].​vp_rewardsArray of objects

该商品的累充积分奖励列表。

unit_items[].​vp_rewards[].​item_idinteger

内部唯一商品ID。

unit_items[].​vp_rewards[].​skustring

唯一累充积分ID。

unit_items[].​vp_rewards[].​amountinteger

累充积分数量。

unit_items[].​vp_rewards[].​namestring

累充积分名称。

unit_items[].​vp_rewards[].​image_urlstring

图片URL。

unit_items[].​vp_rewards[].​is_clanboolean

累充积分是否用于公会累充奖励链。

响应
application/json
{ "sku": "com.xsolla.game_1", "name": "Game name", "groups": [ {}, {} ], "type": "unit", "unit_type": "game", "description": "Game description", "image_url": "https://cdn.xsolla.net/img/misc/images/b79342cdf24f0f8557b63c87e8326e62.png", "attributes": [ {}, {} ], "promotions": [], "unit_items": [ {}, {} ] }
操作
操作

概述

捆绑包是作为一个单位销售的一组商品。捆绑包可以包含虚拟物品、虚拟货币、虚拟货币套餐、游戏Key以及其他捆绑包。您可以使用捆绑包创建新手礼包、季节性优惠和特惠活动。

如需实现捆绑包相关功能,请使用以下API调用组:

  • 使用管理子部分中的API调用创建、更新、删除捆绑包,并管理其可见性。
  • 使用商品目录子部分中的API调用获取捆绑包。

创建或更新捆绑包时,可通过limits对象配置购买限制。有关更多信息,请参阅限制概述。您还可以配置区域限制,以便在特定国家/地区销售商品。

注:

有关配置捆绑包的详细信息,请参阅捆绑包部分。

捆绑包管理场景:

  1. 使用创建捆绑包API调用创建捆绑包。如需验证已创建的捆绑包,请使用获取捆绑包API调用。如需获取项目中的所有捆绑包,请使用获取捆绑包列表API调用。
  2. 如有需要,可使用更新捆绑包API调用修改捆绑包内容或设置。
  3. 使用获取捆绑包列表获取指定的捆绑包获取指定组的捆绑包列表API调用,在您的商店前端中实现捆绑包展示逻辑。
  4. 使用购物车与支付部分中的API创建订单。例如,如需实现快速购买,可以使用使用指定商品创建订单API调用,并传入捆绑包SKU。响应中包含用于打开支付UI的令牌。
  5. 实现支付UI的打开逻辑,以便用户支付订单。
  6. 设置订单状态跟踪,例如使用Webhook,以便及时接收支付成功商品的数据并向用户发放商品。

捆绑包管理场景

操作
操作

概述

购物车是一种购买机制,可将多个商品合并到同一个订单中。用户可以使用真实货币购买任意类型、任意数量的商品,也可以使用兑换码

购物车存储在艾克索拉侧。购物车能否跨会话保存取决于用户是否已授权:

  • 对于已授权用户,购物车会关联到具体用户。只要请求始终代表同一用户发送,购物车就会跨会话保存。

  • 对于未授权用户,购物车能否保存取决于是否传入x-unauthorized-id请求头。如需跨会话保存未授权用户的购物车,请在每个请求中传入相同的x-unauthorized-id。此选项仅适用于游戏Key销售。

您可以通过两种方式识别购物车:通过用户JWT自动识别或通过购物车ID (cart_id)识别。

可在客户端侧和服务器侧管理购物车。

在服务器侧,您可以向购物车添加商品,例如在恢复用户会话时。客户端侧支持以下操作:

  • 获取当前用户的购物车或按ID获取购物车
  • 向购物车添加商品
  • 更新购物车中的商品
  • 从购物车中删除商品

如需购买购物车中的商品,请使用客户端和服务器的订单创建调用。

购物车的存活时间(TTL)默认为72小时。如果购物车内容发生变化,例如添加了新商品,则TTL会延长。

支付成功后,购物车不会自动清空。如需清空购物车,请使用以下客户端侧API调用:

购物车使用场景:

  1. 实现商店UI,供用户选择商品。

  2. 用户在商店中选择商品后,将商品添加到购物车,例如使用在购物车里添加商品调用。在items数组中,需要传入商品SKU和所需数量。

  3. 实现购物车查看UI。用户进入购物车时,使用获取当前用户的购物车调用展示购物车内容。响应将返回商品最终价格信息,包括折扣和已应用的促销活动。

  4. 实现支付UI的打开逻辑,以便用户支付订单。例如,可以使用使用特定购物车中的所有商品创建订单调用。响应会返回用于打开支付UI的令牌。

  5. 配置订单状态跟踪,例如使用Webhook,以便及时接收支付成功商品的数据并向用户发放商品。

注:

如需实现游戏内和线上商品销售,请参阅集成指南

购物车和支付流程

订单生命周期

了解订单生命周期有助于您跟踪订单,并正确实现购买后逻辑,例如商品交付。

订单会经历以下状态:

状态描述备注
new订单已创建。系统正在等待付款确认。交易状态说明请参阅支付收银台API文档
paid订单已支付(交易已流转至done状态),可以向用户发放商品。 在付款确认前,订单会保持new状态。
done商品已发放给用户。
canceled付款已退款。 交易状态变更为refunded时,订单会流转至此状态。
expired 对于限购商品、兑换码或促销活动,创建新订单时,任何包含该商品且此前未支付的订单都会流转至expired状态。只有最新订单可以付款。 如果用户尝试支付已过期的订单,支付UI将显示2002错误,付款将失败。

订单生命周期

注:

如果用户正在完成付款时订单流转至expired状态,但付款成功,则订单会从expired流转至paid状态。仅当付款后不会超出订单中商品的购买限制时,此规则才适用。

购物车(客户端侧)

使用本部分中的调用在客户端侧管理购物车。

操作

购物车(服务器侧)

使用本部分中的调用在服务器侧管理购物车。

操作

支付(客户端侧)

使用本部分中的调用在客户端侧创建支付令牌。

操作

支付(服务器侧)

使用本部分中的调用在服务器侧创建支付令牌。

操作

订单

使用本部分中的调用获取订单信息。

操作

免费商品

使用本部分中的调用向用户发放免费商品

操作

概述

购买限制可用于限制单个用户或所有用户可购买的商品数量。您还可以配置定期重置限制。

限制存储在艾克索拉侧,可在发布商帐户中按单个商品进行配置,也可在以下API调用中通过limits对象进行配置:

在以下用于获取商品目录的API调用中,限制信息会在items.limits对象中返回:

限制组的管理部分中的API调用可用于获取限制的当前状态,并针对特定用户更新限制,例如在任务完成后重置计数器,或手动调整剩余数量。

注:

有关在商品目录中配置限制的详细信息,请参阅商品购买限制部分。
操作
操作
操作
操作

商品目录

此API可用于获取任意类型的可售商品或特定商品。

操作

通用区域

区域销售限制用于控制商品可在哪些国家/地区或国家/地区组销售。例如,受授权许可限制时,您可以将某款游戏设置为仅在特定国家/地区销售。

销售限制通过区域进行配置。每个区域使用一个region_id标识符关联一个或多个国家/地区。您可以将一个商品关联到一个或多个区域。

商品是否可售按以下规则判断:

  • 如果未为商品指定区域,则该商品可在所有国家/地区购买。
  • 如果为商品指定了区域,且用户所在国家/地区包含在其中任一区域内,则该商品对该用户可售。
  • 如果为商品指定了区域,但用户所在国家/地区不包含在任何指定区域内,则该商品对该用户不可售。

通过商品目录子部分中的API调用请求商品目录时,可通过country参数传入用户所在国家/地区。如果未传入该参数,系统会根据用户的IP地址判断其所在国家/地区。

系统会在两个环节校验用户所在国家/地区是否符合商品的区域设置:请求商品目录时和创建订单时。不可售商品不会返回在商品目录响应中;包含不可售商品的订单也无法创建。

如需创建、更新或删除区域,请使用通用区域组中的API调用。

区域销售限制设置流程:

  1. 使用创建区域API调用创建区域,并指定国家/地区列表。响应会返回下一步需要使用的region_id
  2. 创建更新虚拟物品时,在regions数组中传入该区域的region_id,将虚拟物品关联到该区域。
  3. 使用商品目录子部分中的API调用向用户展示商品目录,例如获取虚拟物品列表API调用。系统会根据country参数确定用户所在国家/地区;如果未提供该参数,则根据用户的IP地址判断。用户所在国家/地区不可售的商品不会包含在商品目录响应中。
  4. 当用户继续支付商品或购物车时,创建订单:

响应中包含用于打开支付UI的令牌。

注:

艾克索拉会检查用户所在国家/地区是否包含在为商品指定的区域中。如果用户所在国家/地区不在该商品的区域范围内,则无法创建订单。

  1. 实现支付UI的打开逻辑,以便用户支付订单。

通用区域

操作
操作
操作
操作
操作