PC 与主机 API 端点参考
面向 PC 和主机的 server-to-server 端点完整 API 参考,提供用于会话追踪和事件上报的详细参数说明及实现示例。
相关参考: PC 与主机使用与套件其余部分相同的 S2S 端点。有关移动端和 Web 端的对应内容,请参阅 SESSION 端点参考 和 EVENT 端点参考。本参考涵盖 PC 与主机的会话和事件端点。
企业版功能: PC 和主机游戏归因属于企业版功能。如需了解更多,请阅读 PC 和主机游戏归因常见问题解答 或联系您的 Customer Success Manager。
集成指南: 有关完整的实现说明和最佳实践,请参阅 PC 与主机 S2S 集成指南 。
会话通知端点
向 Singular 上报游戏启动和会话,用于安装归因、再互动追踪和用户留存分析。
端点规范
| 方法 | URL |
|---|---|
POST
|
https://s2s.singular.net/api/v1/launch
|
参数作为
application/x-www-form-urlencoded
请求体发送。请包含以下必需的请求头:
Content-Type: application/x-www-form-urlencoded
用途
使用会话通知端点近乎实时地上报所有游戏启动(首次会话和重复会话)。Singular 收到由 Singular Device ID 标识的安装的首次游戏启动时,会触发归因流程。
归因工作流程:
- 首次会话: 触发安装归因,与网页广告活动的点击进行匹配
- 后续会话: 用于追踪用户活动、留存和再互动分析
- 实时上报: 尽可能在游戏实际启动的同时发送会话通知
会话参数
必需参数
| 参数 | 详情 |
|---|---|
a |
类型: String
重要提示: 请勿使用 Reporting API 密钥。请求将被拒绝。
示例:
|
p
|
类型: String
|
i
|
类型: String
关键: 必须与 Web SDK Product ID 完全一致,归因才能正常工作。同一游戏在所有平台上使用相同的值。
示例:
|
sdid
|
类型: UUIDv4
|
os
|
类型: String
|
install_source
|
类型: String
|
ip
|
类型: String
替代方式:使用
示例:
|
可选参数
支持以下可选参数。
| 参数 | 详情 |
|---|---|
install_ref
|
类型: String
要求:
有关实现细节,请参阅
Google Play for Native PC Install Referrer 文档
。
|
match_id
|
类型: String
要求:
有关实现细节,请参阅
Match ID 归因
。
|
av
|
类型: String
|
global_properties
|
类型: JSON
|
install
|
类型: Boolean
|
utime
|
类型: Integer
|
umilisec
|
类型: Integer
|
ve |
类型: String
|
ua |
类型: String
|
use_ip |
类型: Boolean
限制:
示例:
|
data_sharing_options |
类型: JSON
|
custom_user_id |
类型: String
禁止 PII: 请勿传递个人身份信息。请使用经过哈希处理或以其他方式匿名化的内部标识符,而不是原始的电子邮件地址、电话号码或姓名。
示例:
|
请求示例
示例实现
基本会话请求
curl -X POST "https://s2s.singular.net/api/v1/launch" \
-H "Content-Type: application/x-www-form-urlencoded" \
--data-urlencode "a=your_sdk_key" \
--data-urlencode "i=com.singular.game" \
--data-urlencode "sdid=49c2d3a6-326e-4ec5-a16b-0a47e34ed953" \
--data-urlencode "p=PC" \
--data-urlencode "os=windows" \
--data-urlencode "install_source=steam" \
--data-urlencode "ip=172.58.29.235"
使用 Match ID 的首次启动
curl -X POST "https://s2s.singular.net/api/v1/launch" \
-H "Content-Type: application/x-www-form-urlencoded" \
--data-urlencode "a=your_sdk_key" \
--data-urlencode "i=com.singular.game" \
--data-urlencode "sdid=49c2d3a6-326e-4ec5-a16b-0a47e34ed953" \
--data-urlencode "p=PC" \
--data-urlencode "os=windows" \
--data-urlencode "install_source=steam" \
--data-urlencode "ip=172.58.29.235" \
--data-urlencode "match_id=abc123def456" \
--data-urlencode "install=true"
基本会话请求
import requests
def report_session(config):
url = "https://s2s.singular.net/api/v1/launch"
params = {
'a': config['sdk_key'],
'i': config['game_id'],
'sdid': config['device_id'],
'p': config['platform'],
'os': config['os_version'],
'install_source': config['store'],
'ip': config['ip_address']
}
response = requests.post(url, data=params, headers={'Content-Type': 'application/x-www-form-urlencoded'})
return response.json()
# Example usage
report_session({
'sdk_key': 'your_sdk_key',
'game_id': 'com.singular.game',
'device_id': '49c2d3a6-326e-4ec5-a16b-0a47e34ed953',
'platform': 'PC',
'os_version': 'windows',
'store': 'steam',
'ip_address': '172.58.29.235'
})
使用 Match ID 的首次启动
def report_first_launch(config):
url = "https://s2s.singular.net/api/v1/launch"
params = {
'a': config['sdk_key'],
'i': config['game_id'],
'sdid': config['device_id'],
'p': config['platform'],
'os': config['os_version'],
'install_source': config['store'],
'ip': config['ip_address'],
'match_id': config['match_id'],
'install': 'true'
}
response = requests.post(url, data=params, headers={'Content-Type': 'application/x-www-form-urlencoded'})
return response.json()
基本会话请求
async function reportSession(config) {
const url = 'https://s2s.singular.net/api/v1/launch';
const params = new URLSearchParams({
'a': config.sdkKey,
'i': config.gameId,
'sdid': config.deviceId,
'p': config.platform,
'os': config.osVersion,
'install_source': config.store,
'ip': config.ipAddress
});
const response = await fetch(url, {
method: 'POST',
headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
body: params.toString()
});
return await response.json();
}
// Example usage
reportSession({
sdkKey: 'your_sdk_key',
gameId: 'com.singular.game',
deviceId: '49c2d3a6-326e-4ec5-a16b-0a47e34ed953',
platform: 'PC',
osVersion: 'windows',
store: 'steam',
ipAddress: '172.58.29.235'
});
使用 Match ID 的首次启动
async function reportFirstLaunch(config) {
const url = 'https://s2s.singular.net/api/v1/launch';
const params = new URLSearchParams({
'a': config.sdkKey,
'i': config.gameId,
'sdid': config.deviceId,
'p': config.platform,
'os': config.osVersion,
'install_source': config.store,
'ip': config.ipAddress,
'match_id': config.matchId,
'install': 'true'
});
const response = await fetch(url, {
method: 'POST',
headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
body: params.toString()
});
return await response.json();
}
事件通知端点
合作伙伴 Conversion API 支持:
要通过 Singular 的 Conversion API 集成将这些事件转发给广告网络合作伙伴,请包含标准的可选事件属性(经过哈希处理的第一方数据,例如
eventId
和
ehash
)。请参阅
面向 Conversion API 集成的标准事件属性
。
向 Singular 上报游戏内事件,用于分析、广告活动优化和合作伙伴转发。
自 2026 年 7 月 15 日起必须使用 V2。 在 2026 年 7 月 15 日当天或之后创建的账户必须使用 Event Endpoint V2(基于 SDID);新账户无法使用 V1。已通过 V1 完成集成的现有客户不受影响。如需迁移到 V2,请联系您的 Singular Customer Success Manager。
端点规范
| 方法 | URL |
|---|---|
POST
|
https://s2s.singular.net/api/v2/evt
|
参数作为
application/x-www-form-urlencoded
请求体发送。请包含以下必需的请求头:
Content-Type: application/x-www-form-urlencoded
用途
使用事件通知端点近乎实时地上报所有所需的游戏内事件。事件数据用于分析、报告、合作伙伴优化和广告活动效果衡量。
事件最佳实践:
- 标准事件: 使用 Singular 标准事件名称 以实现自动的合作伙伴映射
- 实时上报: 尽可能在事件实际发生的同时发送事件
- 收入事件: 包含收入参数以进行购买追踪和 ROI 分析
事件参数
必需参数
| 参数 | 详情 |
|---|---|
a |
类型: String
重要提示: 请勿使用 Reporting API 密钥。请求将被拒绝。
示例:
|
p
|
类型: String
|
i
|
类型: String
|
sdid
|
类型: UUIDv4
|
n
|
类型: String
推荐: 使用 Singular 标准事件名称 以实现自动的合作伙伴集成。
示例:
|
os
|
类型: String
|
install_source
|
类型: String
|
ip
|
类型: String
|
可选参数
支持以下可选参数。
| 参数 | 详情 |
|---|---|
e
|
类型: JSON
推荐: 使用 Singular 标准属性名称 以实现合作伙伴兼容性。
示例:
|
is_revenue_event
|
类型: Boolean
|
amt
|
类型: Number
|
cur
|
类型: String
|
av
|
类型: String
|
global_properties
|
类型: JSON
|
utime
|
类型: Integer
|
umilisec
|
类型: Integer
|
ve |
类型: String
|
ua |
类型: String
|
use_ip |
类型: Boolean
限制:
示例:
|
data_sharing_options |
类型: JSON
|
custom_user_id |
类型: String
禁止 PII: 请勿传递个人身份信息。请使用经过哈希处理或以其他方式匿名化的内部标识符,而不是原始的电子邮件地址、电话号码或姓名。
示例:
|
请求示例
示例实现
标准事件
curl -X POST "https://s2s.singular.net/api/v2/evt" \
-H "Content-Type: application/x-www-form-urlencoded" \
--data-urlencode "a=your_sdk_key" \
--data-urlencode "i=com.singular.game" \
--data-urlencode "sdid=49c2d3a6-326e-4ec5-a16b-0a47e34ed953" \
--data-urlencode "p=PC" \
--data-urlencode "os=windows" \
--data-urlencode "install_source=steam" \
--data-urlencode "n=sng_level_achieved" \
--data-urlencode 'e={"sng_attr_level":"5","sng_attr_score":"1250"}' \
--data-urlencode "ip=172.58.29.235"
收入事件
curl -X POST "https://s2s.singular.net/api/v2/evt" \
-H "Content-Type: application/x-www-form-urlencoded" \
--data-urlencode "a=your_sdk_key" \
--data-urlencode "i=com.singular.game" \
--data-urlencode "sdid=49c2d3a6-326e-4ec5-a16b-0a47e34ed953" \
--data-urlencode "p=PC" \
--data-urlencode "os=windows" \
--data-urlencode "install_source=steam" \
--data-urlencode "n=__iap__" \
--data-urlencode "is_revenue_event=true" \
--data-urlencode "amt=9.99" \
--data-urlencode "cur=USD" \
--data-urlencode "ip=172.58.29.235"
标准事件
import requests
import json
def report_event(config):
url = "https://s2s.singular.net/api/v2/evt"
params = {
'a': config['sdk_key'],
'i': config['game_id'],
'sdid': config['device_id'],
'p': config['platform'],
'os': config['os_version'],
'install_source': config['store'],
'n': config['event_name'],
'ip': config['ip_address']
}
if 'attributes' in config:
params['e'] = json.dumps(config['attributes'])
response = requests.post(url, data=params, headers={'Content-Type': 'application/x-www-form-urlencoded'})
return response.json()
# Example usage
report_event({
'sdk_key': 'your_sdk_key',
'game_id': 'com.singular.game',
'device_id': '49c2d3a6-326e-4ec5-a16b-0a47e34ed953',
'platform': 'PC',
'os_version': 'windows',
'store': 'steam',
'event_name': 'sng_level_achieved',
'attributes': {
'sng_attr_level': '5',
'sng_attr_score': '1250'
},
'ip_address': '172.58.29.235'
})
收入事件
def report_revenue(config):
url = "https://s2s.singular.net/api/v2/evt"
params = {
'a': config['sdk_key'],
'i': config['game_id'],
'sdid': config['device_id'],
'p': config['platform'],
'os': config['os_version'],
'install_source': config['store'],
'n': '__iap__',
'is_revenue_event': 'true',
'amt': config['amount'],
'cur': config['currency'],
'ip': config['ip_address']
}
response = requests.post(url, data=params, headers={'Content-Type': 'application/x-www-form-urlencoded'})
return response.json()
# Example usage
report_revenue({
'sdk_key': 'your_sdk_key',
'game_id': 'com.singular.game',
'device_id': '49c2d3a6-326e-4ec5-a16b-0a47e34ed953',
'platform': 'PC',
'os_version': 'windows',
'store': 'steam',
'amount': 9.99,
'currency': 'USD',
'ip_address': '172.58.29.235'
})
标准事件
async function reportEvent(config) {
const url = 'https://s2s.singular.net/api/v2/evt';
const params = new URLSearchParams({
'a': config.sdkKey,
'i': config.gameId,
'sdid': config.deviceId,
'p': config.platform,
'os': config.osVersion,
'install_source': config.store,
'n': config.eventName,
'ip': config.ipAddress
});
if (config.attributes) {
params.append('e', JSON.stringify(config.attributes));
}
const response = await fetch(url, {
method: 'POST',
headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
body: params.toString()
});
return await response.json();
}
// Example usage
reportEvent({
sdkKey: 'your_sdk_key',
gameId: 'com.singular.game',
deviceId: '49c2d3a6-326e-4ec5-a16b-0a47e34ed953',
platform: 'PC',
osVersion: 'windows',
store: 'steam',
eventName: 'sng_level_achieved',
attributes: {
'sng_attr_level': '5',
'sng_attr_score': '1250'
},
ipAddress: '172.58.29.235'
});
收入事件
async function reportRevenue(config) {
const url = 'https://s2s.singular.net/api/v2/evt';
const params = new URLSearchParams({
'a': config.sdkKey,
'i': config.gameId,
'sdid': config.deviceId,
'p': config.platform,
'os': config.osVersion,
'install_source': config.store,
'n': '__iap__',
'is_revenue_event': 'true',
'amt': config.amount,
'cur': config.currency,
'ip': config.ipAddress
});
const response = await fetch(url, {
method: 'POST',
headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
body: params.toString()
});
return await response.json();
}
// Example usage
reportRevenue({
sdkKey: 'your_sdk_key',
gameId: 'com.singular.game',
deviceId: '49c2d3a6-326e-4ec5-a16b-0a47e34ed953',
platform: 'PC',
osVersion: 'windows',
store: 'steam',
amount: 9.99,
currency: 'USD',
ipAddress: '172.58.29.235'
});
响应处理
两个端点均返回一致的 JSON 响应,需要验证 status 字段以判断成功或错误。
响应格式
重要:
所有响应均返回 HTTP 200 状态码。请始终验证响应体的
status
字段以判断成功(
ok
)还是失败(
error
)。
有关完整的响应代码文档和错误处理策略,请参阅 S2S 响应代码与错误处理 。
其他资源
- 集成指南: PC 与主机 S2S 集成指南
- Web SDK: Web SDK 概述与入门
- 归因常见问题解答: PC 和主机游戏归因常见问题解答
- 标准事件: Singular 标准事件参考