游戏价格、评分、在线人数查询接口 — 提供 REST API(推荐,API Key 鉴权)与 AJAX 兼容接口两套接入方式
/wp-json/yz/v1/*
| 方法 | 端点 | 说明 | 参数 |
|---|---|---|---|
GET | /games/search | 游戏搜索 | keyword(必填) |
GET | /games/compare | 游戏对比(2-6 款) | ids=42,58,100 |
GET | /games/{id}/price-history | 价格历史(含版本事件标注) | — |
GET | /games/{id}/rating-history | 好评率历史 | — |
GET | /games/{id}/player-history | 在线人数历史 | — |
POST | /alerts | 创建价格预警 | game_id、alert_type、target_price 等 |
# Header 鉴权(推荐) curl -H "X-YZ-API-Key: 你的KEY" \ "https://www.zhuhaiyun.cn/wp-json/yz/v1/games/compare?ids=42,58,100" # 查询参数鉴权(简单场景) curl "https://www.zhuhaiyun.cn/wp-json/yz/v1/games/search?keyword=巫师&api_key=你的KEY"
action=get_price_history
返回某款游戏的价格历史数据(含原价、折扣、史低价),按时间升序排列。
| 参数名 | 类型 / 说明 |
|---|---|
game_id | int(必填)— 游戏文章 ID |
nonce | string(必填)— 安全令牌 |
{"code":0,"dates":["2026-01-01 00:00:00"],"prices":[29.00],"original_prices":[59.00],"discounts":[50],"hist_low":29.00,"hist_low_date":"2026-01-01 00:00:00"}
fetch('https://www.zhuhaiyun.cn/wp-admin/admin-ajax.php', {
method: 'POST',
headers: {'Content-Type': 'application/x-www-form-urlencoded'},
body: new URLSearchParams({
action: 'get_price_history',
nonce: yzGameData.nonce,
game_id: /* 你的值 */ })
})
.then(r => r.json())
.then(data => console.log(data));
action=get_rating_history
返回某款游戏的好评率及评论数历史数据。
| 参数名 | 类型 / 说明 |
|---|---|
game_id | int(必填)— 游戏文章 ID |
nonce | string(必填)— 安全令牌 |
{"code":0,"dates":["2026-01-01 00:00:00"],"ratings":[92],"reviews":[154823]}
fetch('https://www.zhuhaiyun.cn/wp-admin/admin-ajax.php', {
method: 'POST',
headers: {'Content-Type': 'application/x-www-form-urlencoded'},
body: new URLSearchParams({
action: 'get_rating_history',
nonce: yzGameData.nonce,
game_id: /* 你的值 */ })
})
.then(r => r.json())
.then(data => console.log(data));
action=get_player_history
返回某款游戏的在线人数历史。近 7 天返回小时级数据,更早返回日级聚合(取每日最大值)。
| 参数名 | 类型 / 说明 |
|---|---|
game_id | int(必填)— 游戏文章 ID |
nonce | string(必填)— 安全令牌 |
{"code":0,"dates":["2026-01-01","2026-09-10 12:00:00"],"players":[52318,48211]}
fetch('https://www.zhuhaiyun.cn/wp-admin/admin-ajax.php', {
method: 'POST',
headers: {'Content-Type': 'application/x-www-form-urlencoded'},
body: new URLSearchParams({
action: 'get_player_history',
nonce: yzGameData.nonce,
game_id: /* 你的值 */ })
})
.then(r => r.json())
.then(data => console.log(data));
action=subscribe_price_alert
创建价格预警。支持 5 种类型:target_price(目标价)、historical_low(史低)、discount_threshold(折扣阈值)、price_drop(降价通知)、any_discount(折扣提醒)。
| 参数名 | 类型 / 说明 |
|---|---|
game_id | int(必填)— 游戏文章 ID |
alert_type | string(必填)— 预警类型 |
target_price | float — 目标价(alert_type=target_price 时必填) |
threshold_value | float — 折扣阈值(alert_type=discount_threshold 时必填) |
notify_channels | string — 通知渠道,逗号分隔(email,site,webhook,wechat) |
webhook_url | string — Webhook URL(notify_channels 含 webhook 时必填) |
email | string — 邮箱(未登录用户必填) |
nonce | string(必填)— 安全令牌 |
{"code":0,"msg":"订阅成功!降价时将自动通知您"}
fetch('https://www.zhuhaiyun.cn/wp-admin/admin-ajax.php', {
method: 'POST',
headers: {'Content-Type': 'application/x-www-form-urlencoded'},
body: new URLSearchParams({
action: 'subscribe_price_alert',
nonce: yzGameData.nonce,
game_id: /* 你的值 */
alert_type: /* 你的值 */
target_price: /* 你的值 */
threshold_value: /* 你的值 */
notify_channels: /* 你的值 */
webhook_url: /* 你的值 */
email: /* 你的值 */ })
})
.then(r => r.json())
.then(data => console.log(data));
action=search_games
按关键词搜索游戏,返回最多 10 条结果。
| 参数名 | 类型 / 说明 |
|---|---|
keyword | string(必填)— 搜索关键词 |
nonce | string(必填)— 安全令牌 |
{"code":0,"data":[{"id":42,"appid":730,"name":"Counter-Strike 2","header":"https://...","price":0,"is_free":true}]}
fetch('https://www.zhuhaiyun.cn/wp-admin/admin-ajax.php', {
method: 'POST',
headers: {'Content-Type': 'application/x-www-form-urlencoded'},
body: new URLSearchParams({
action: 'search_games',
nonce: yzGameData.nonce,
keyword: /* 你的值 */ })
})
.then(r => r.json())
.then(data => console.log(data));
action=compare_games
批量获取多款游戏的对比数据。支持 2-6 款游戏。
| 参数名 | 类型 / 说明 |
|---|---|
game_ids | string(必填)— 游戏 ID 列表,逗号分隔(如 "42,58,100") |
nonce | string(必填)— 安全令牌 |
{"code":0,"data":[{"id":42,"name":"...","price_final":29,"discount":50,"rating":92,"players":52318,"genres":["FPS","动作"],...}]}
fetch('https://www.zhuhaiyun.cn/wp-admin/admin-ajax.php', {
method: 'POST',
headers: {'Content-Type': 'application/x-www-form-urlencoded'},
body: new URLSearchParams({
action: 'compare_games',
nonce: yzGameData.nonce,
game_ids: /* 你的值 */ })
})
.then(r => r.json())
.then(data => console.log(data));
所有数据来源于 Steam 官方 API,仅供学习与研究参考。请勿高频请求(建议每次间隔 ≥ 0.8 秒)。价格预警每日最多检查一次,同一预警 24 小时内最多通知一次。商业使用需获得 Valve Corporation 授权。