API 域名:https://api.pg-game.xyz(以实际分配为准,不要末尾 /)
本接口提供游戏代码列表、PG 电子游艺启动、额度转入转出、余额查询与注单拉取。运营商持有一对 agentToken + secretKey 即可对接自有大厅。
接口说明
- 所有接口都是 POST,Header 固定
Content-Type: application/json。 - 凭证放在 JSON 请求体,不放 Header。
agentToken、secretKey在代理后台开通后发放,请勿泄露。- 建议超时设置为 30 秒以上;超时后应用同一 orderId重试转账。
- 金额保留 2 位小数,须大于 0。
- 数据返回格式统一为 JSON。
- 时区按服务器本地时间(一般 UTC+8)。
- 玩家账号
user_code由你方保证唯一;首次转入会自动开户,无需单独注册。
请求返回正确示例
{
"status": 1,
"msg": "SUCCESS"
}
status = 1 表示成功,其它为失败(通常 status: 0)。启动游戏失败时偶发 status: "error"。
状态码
| msg | 说明 |
|---|---|
| SUCCESS | 成功 |
| INVALID_AGENT | agentToken / secretKey 错误 |
| INVALID_PARAMS | 缺少必填字段 |
| INVALID_TYPE | 转换类型不是 1 或 2 |
| INVALID_AMOUNT | 金额非法(须为大于 0 的数字) |
| INVALID_ORDER_ID | 缺少 orderId,或长度超过 128 |
| ORDER_CONFLICT | 同一 orderId 已存在,但 user_code / type / amount 不一致 |
| INVALID_USER | 转出时玩家不存在 |
| INVALID_TIME | 注单时间参数无法解析 |
| INSUFFICIENT_FUNDS | 玩家游戏余额不足(转出) |
| INSUFFICIENT_AGENT_FUNDS | 代理额度不足(转入) |
| TRANSFER_FAILED | 转换失败 |
| ERROR / ERRO | 服务异常 |
验签说明
Header:
| 字段 | 类型 | 必填 | 说明 |
|---|---|---|---|
| Content-Type | string | 是 | 固定 application/json |
请求体必须带商户凭证:
| 字段 | 类型 | 必填 | 说明 |
|---|---|---|---|
| agentToken | string | 是 | 商户标识 |
| secretKey | string | 是 | 商户密钥 |
{
"agentToken": "发放给你的 token",
"secretKey": "发放给你的密钥"
}
创建玩家
无需单独创建接口。调用 /api/v1/transfer 且 type=1 时,若 user_code 不存在会自动开户,初始游戏余额为转入金额。
建议 user_code 使用你方稳定唯一账号(字母数字,不要用会变化的会话 ID)。
查询余额
请求地址:/api/v1/user_balance
请求协议:POST
| 字段 | 类型 | 必填 | 说明 |
|---|---|---|---|
| agentToken | string | 是 | 商户标识 |
| secretKey | string | 是 | 商户密钥 |
| user_code | string | 是 | 玩家账号 |
返回示例:
{
"status": 1,
"msg": "SUCCESS",
"user_code": "player001",
"user_balance": 88.50,
"user_exists": true
}
玩家不存在时仍返回 status: 1,user_balance: 0,user_exists: false。
额度转换
请求地址:/api/v1/transfer
请求协议:POST
| 字段 | 类型 | 必填 | 说明 |
|---|---|---|---|
| agentToken / secretKey | string | 是 | 商户凭证 |
| user_code | string | 是 | 玩家账号 |
| type | number | 是 | 1 转入(主钱包→游戏),2 转出(游戏→主钱包) |
| amount | number | 是 | 金额,须大于 0,保留 2 位小数 |
| orderId | string | 是 | 幂等单号,同代理下唯一,≤128 字符 |
orderId 必填。同一 agent + orderId 只会成功记账一次。超时/网络抖动后用同一 orderId 重试是安全的:第二次返回首次成功结果且 replay: true,不会双倍扣款。同一 orderId 但 user_code / type / amount 不一致 → ORDER_CONFLICT。成功示例:
{
"status": 1,
"msg": "SUCCESS",
"user_code": "player001",
"type": 1,
"amount": 100,
"user_before_balance": 0,
"user_balance": 100,
"agent_before_balance": 1000,
"agent_balance": 900,
"orderId": "in-1710000000",
"replay": false
}
失败示例:
{ "status": 0, "msg": "INSUFFICIENT_FUNDS", "user_code": "player001", "user_balance": 12.3, "orderId": "out-1" }
{ "status": 0, "msg": "INSUFFICIENT_AGENT_FUNDS", "user_code": "player001", "agent_balance": 0, "orderId": "in-1" }
{ "status": 0, "msg": "INVALID_ORDER_ID" }
{ "status": 0, "msg": "ORDER_CONFLICT", "orderId": "in-1" }
- 转入会扣减代理额度池;转出会加回。局中 spin 只动玩家游戏余额,不直接动代理额度。
- 例:转入 500 → 代理 −500;玩家赢到 600 再转出 600 → 代理 −500 +600 = 净 +100。
- 代理额度不足返回
INSUFFICIENT_AGENT_FUNDS;转出超过玩家游戏余额返回INSUFFICIENT_FUNDS。 - 建议:你方先扣主钱包再调 type=1;type=2 成功后再加回主钱包。失败用同一 orderId重试,不要换单号盲目重发。
游戏代码列表
请求地址:/api/v1/gameCode
请求协议:POST
对接方应先调本接口拿到可启动游戏列表,再把返回的 gameCode(英文 slug)传给 /api/v1/game_launch。不要传 GI 数字。
| 字段 | 类型 | 必填 | 说明 |
|---|---|---|---|
| agentToken / secretKey | string | 是 | 商户凭证 |
| includeMod | number/bool | 否 | 默认包含自研/魔改;传 0 / false 则排除 |
返回示例:
{
"status": 1,
"code": 10000,
"msg": "SUCCESS",
"data": [
{
"platType": "mjhl",
"gameType": "2",
"gameCode": "mahjong-ways",
"gi": "65",
"ingress": "3",
"gameName": { "zh-hans": "麻将胡了", "en": "Mahjong Ways" },
"img": "zh-hans/65.webp",
"provider_code": "PGSOFT",
"game_type": "slot"
}
]
}
gameCode,不要传 gi。登录游戏
请求地址:/api/v1/game_launch
请求协议:POST
| 字段 | 类型 | 必填 | 说明 |
|---|---|---|---|
| agentToken / secretKey | string | 是 | 商户凭证 |
| user_code | string | 是 | 玩家账号 |
| game_code | string | 是 | 游戏 slug(来自 /api/v1/gameCode),不要传 GI 数字 |
| user_balance | number | 是 | 转入转出模式请固定传 0;不会覆盖已有余额,新用户初始也为 0,须先 transfer |
| provider_code | string | 否 | 默认 PGSOFT;另支持 PRAGMATIC(需代理侧已配置) |
| game_type | string | 否 | 默认 slot |
返回示例:
{
"status": 1,
"msg": "SUCCESS",
"launch_url": "https://xxx/65/index.html?operator_token=...&t=...",
"user_code": "player001",
"user_balance": 100.50,
"user_created": false,
"currency": "BRL"
}
currency 取自代理配置,未配置时默认 BRL。前端用 iframe / WebView / 新窗口打开 launch_url。游戏不存在时可能返回 {"status":"error","message":"Esse game não existe."}。
游戏记录
请求地址:/api/v1/bet_records
请求协议:POST
| 字段 | 类型 | 必填 | 说明 |
|---|---|---|---|
| agentToken / secretKey | string | 是 | 商户凭证 |
| startTime | string | 是 | yyyy-MM-dd HH:mm:ss 或时间戳(秒/毫秒) |
| endTime | string | 是 | 同上 |
| afterId | number | 否 | 游标,首次 0;下次传上次返回的 afterId |
| limit | number | 否 | 默认 200,最大 500 |
updated_at 过滤(不是 created_at),并仅返回当前代理下的玩家注单。{
"status": 1,
"msg": "SUCCESS",
"list": [
{
"id": 12345,
"user_id": 88,
"username": "player001",
"game_code": "mahjong-ways",
"gid": 65,
"tid": "txn-xxx",
"gtba": 1.6,
"gtwa": 3.2,
"gtwla": 1.6,
"currency": "BRL",
"created_at": 1710000000000,
"updated_at": 1710000005000
}
],
"afterId": 12345,
"hasMore": true
}
| list 字段 | 说明 |
|---|---|
| id | 注单主键,用作游标 |
| user_id / username | 玩家 ID / 账号(对应你方 user_code) |
| game_code / gid | 游戏 slug / GI |
| tid | 局/交易号 |
| gtba | 投注额 |
| gtwa | 派彩额 |
| gtwla | 盈亏(派彩 − 投注) |
| currency | 币种 |
| created_at / updated_at | 毫秒时间戳 |
hasMore === true 时用返回的 afterId 继续拉取,直到 false。
推荐接入流程
启动前可先:POST /api/v1/gameCode 缓存游戏列表(建议定时同步) 用户点游戏 │ ├─1─ POST /api/v1/transfer type=1 主钱包 → 游戏钱包(必带唯一 orderId) │ ├─2─ POST /api/v1/game_launch 拿 launch_url,前端打开(user_balance 传 0) │ │ (用户在游戏内下注,余额在本平台) │ ├─3─ 退出后 POST /api/v1/transfer type=2 游戏钱包 → 主钱包(新的唯一 orderId) │ └─4─ 定时 POST /api/v1/bet_records 同步注单(可选)
curl 示例:
BASE="https://api.qdd.asia"
TOKEN="你的agentToken"
SECRET="你的secretKey"
USER="demo_user_001"
curl -s -X POST "$BASE/api/v1/transfer" -H "Content-Type: application/json" -d "{
\"agentToken\":\"$TOKEN\",\"secretKey\":\"$SECRET\",
\"user_code\":\"$USER\",\"type\":1,\"amount\":100,\"orderId\":\"in-1\"
}"
curl -s -X POST "$BASE/api/v1/game_launch" -H "Content-Type: application/json" -d "{
\"agentToken\":\"$TOKEN\",\"secretKey\":\"$SECRET\",
\"user_code\":\"$USER\",\"user_balance\":0,
\"game_code\":\"mahjong-ways\",\"provider_code\":\"PGSOFT\",\"game_type\":\"slot\"
}"
curl -s -X POST "$BASE/api/v1/user_balance" -H "Content-Type: application/json" -d "{
\"agentToken\":\"$TOKEN\",\"secretKey\":\"$SECRET\",\"user_code\":\"$USER\"
}"
curl -s -X POST "$BASE/api/v1/bet_records" -H "Content-Type: application/json" -d "{
\"agentToken\":\"$TOKEN\",\"secretKey\":\"$SECRET\",
\"startTime\":\"2026-10-01 00:00:00\",\"endTime\":\"2026-10-01 23:59:59\",
\"afterId\":0,\"limit\":200
}"
自测清单
- 错误 token →
INVALID_AGENT - 新用户 transfer type=1 → 自动开户且余额正确
- 不传
orderId→INVALID_ORDER_ID - 同一
orderId调两次 → 第二次replay: true,余额只变一次 - 同一
orderId改 amount 再调 →ORDER_CONFLICT game_launch返回可打开 URL;user_balance传 0 不覆盖已有余额- 下注后
user_balance变化;退出 type=2 转回主钱包 bet_records能按时间窗拉到注单,并可用afterId翻页- 未知
game_code→ 明确错误,不返回空 URL
游戏代码
game_code 必须传英文 slug,不要传 GI 数字。请以 /api/v1/gameCode 实时返回为准;本表仅为对照速查,可能滞后。图标路径一般为 zh-hans/{GI}.webp,请本地缓存。
当前附录共 129 款(不含自研/魔改,生成时间 2026-10-12T06:02:21.248Z)。
| GI | game_code | 名称 |
|---|---|---|
| 20 | reel-love | 亲爱的 |
| 28 | hotpot | 麻辣火锅 |
| 31 | baccarat-deluxe | 至尊百家乐 |
| 33 | hip-hop-panda | 嘻哈熊猫 |
| 34 | legend-of-hou-yi | 后羿射日 |
| 35 | mr-hallow-jp | 万胜狂欢夜 |
| 39 | piggy-gold | 金猪报财 |
| 40 | jungle-delight | 水果丛林 |
| 42 | ganesha-gold | 象财神 |
| 44 | emperors-favour | 皇上吉祥 |
| 48 | double-fortune | 双囍临门 |
| 54 | captains-bounty | 赏金船长 |
| 58 | vampires-charm | 德古拉女爵 |
| 61 | flirting-scholar | 唐伯虎点秋香 |
| 63 | dragon-tiger-luck | 龙虎争霸 |
| 65 | mahjong-ways | 麻将胡了 |
| 67 | shaolin-soccer | 少林足球 |
| 68 | fortune-mouse | 鼠鼠福福 |
| 69 | bikini-paradise | 比基尼天堂 |
| 70 | candy-burst | 糖果连连爆 |
| 74 | mahjong-ways-2 | 麻将胡了2 |
| 79 | dreams-of-macau | 澳门壕梦 |
| 82 | phoenix-rises | 凤凰传奇 |
| 83 | wild-fireworks | 火树赢花 |
| 84 | queen-bounty | 赏金女王 |
| 86 | galactic-gems | 星旅淘金 |
| 87 | treasures-aztec | 寻宝黄金城 |
| 89 | lucky-neko | 招财喵 |
| 91 | gdn-ice-fire | 冰火双娇 |
| 92 | thai-river | 水上泰神奇 |
| 93 | opera-dynasty | 新国粹 |
| 94 | bali-vacation | 巴厘之旅 |
| 95 | majestic-ts | 宝石传奇 |
| 98 | fortune-ox | 十倍金牛 |
| 101 | rise-sun-god | 太阳神传说 |
| 102 | mermaid-riches | 人鱼公主 |
| 103 | crypto-gold | 比特淘金 |
| 104 | wild-bandito | 亡灵大盗 |
| 105 | heist-stakes | 霹雳神偷 |
| 106 | ways-of-qilin | 麒麟送宝 |
| 107 | lgd-monkey-kg | 美猴王传奇 |
| 108 | buffalo-win | 美洲野牛 |
| 110 | jurassic-kdm | 恐龙帝国 |
| 112 | oriental-pros | 江山美景图 |
| 113 | crypt-fortune | 丽影奇兵之探秘埃及 |
| 114 | emoji-riches | 钞级表情包 |
| 115 | sprmkt-spree | 超市大血拼 |
| 117 | cocktail-nite | 夜醉佳人 |
| 118 | mask-carnival | 假面嘉年华 |
| 119 | spirit-wonder | 百鬼夜行 |
| 120 | queen-banquet | 韩宫御宴 |
| 121 | dest-sun-moon | 日月星辰 |
| 122 | garuda-gems | 神鹰宝石 |
| 123 | rooster-rbl | 斗鸡 |
| 124 | battleground | 绝地大逃杀 |
| 125 | butterfly-blossom | 蝶恋花 |
| 126 | fortune-tiger | 虎虎生财 |
| 127 | speed-winner | 极速赢家 |
| 128 | legend-perseus | 珀尔修斯传奇 |
| 129 | win-win-fpc | 发财鱼虾蟹 |
| 130 | lucky-piggy | 电玩金猪 |
| 132 | wild-coaster | 疯赚过山车 |
| 135 | wild-bounty-sd | 赏金大对决 |
| 1312883 | prosper-ftree | 黄金摇钱树 |
| 1338274 | totem-wonders | 图腾奇迹 |
| 1368367 | alchemy-gold | 炼金工坊 |
| 1372643 | diner-delights | 美食美刻 |
| 1402846 | midas-fortune | 点石成金 |
| 1418544 | bakery-bonanza | 烘焙总动员 |
| 1448762 | songkran-spl | 泰嗨泼水节 |
| 1473388 | cruise-royale | 皇家游轮 |
| 1489936 | ultimate-striker | 金球射手 |
| 1492288 | pinata-wins | 墨西哥狂欢 |
| 1508783 | wild-ape-3258 | 猿宇宙#3258 |
| 1513328 | spr-golf-drive | 超级高尔夫 |
| 1529867 | ninja-raccoon | 忍者小浣熊 |
| 1543462 | fortune-rabbit | 金钱兔 |
| 1555350 | forge-wealth | 铸造大师 |
| 1568554 | wild-heist-co | 怪盗神偷 |
| 1572362 | gladi-glory | 角斗士荣耀 |
| 1580541 | mafia-mayhem | 黑帮风云 |
| 1594259 | safari-wilds | 非洲大冒险 |
| 1601012 | lucky-clover | 幸运草之恋 |
| 1615454 | werewolf-hunt | 狼人传奇 |
| 1623475 | anubis-wrath | 阿努比斯 |
| 1635221 | zombie-outbreak | 丧尸危机 |
| 1648578 | shark-bounty | 鲨鱼猎手 |
| 1655268 | tsar-treasures | 沙皇宝藏 |
| 1666445 | choc-deluxe | 真爱巧克力 |
| 1682240 | cash-mania | 快钱来了 |
| 1695365 | fortune-dragon | 金龙送宝 |
| 1702123 | geisha-revenge | 艺伎之刃 |
| 1717688 | mystic-potions | 魔法药水 |
| 1727711 | three-cz-pigs | 三只疯狂小猪 |
| 1738001 | chicky-run | 小鸡跑酷 |
| 1747549 | wings-iguazu | 南美之翼 |
| 1755623 | museum-wonders | 世界珍宝馆 |
| 1760238 | yakuza-honor | 极道荣耀 |
| 1778752 | futebol-fever | 热血足球 |
| 1786529 | rio-fantasia | 里约嘉年华 |
| 1799745 | mr-treasures-fortune | 宝藏大冒险 |
| 1804577 | graffiti-rush | 街头涂鸦 |
| 1815268 | oishi-delights | 美食夏日祭 |
| 1827457 | doomsday-rampg | 狂暴少女 |
| 1834850 | jack-giant-hunt | 魔豆传奇 |
| 1849515 | mythical-gdn | 四大神兽 |
| 1850016 | incan-wonders | 印加奇迹 |
| 1865521 | dead-man-riches | 宝藏船说 |
| 1879752 | fortune-snake | 金蛇招财 |
| 1881268 | knockout-rich | 拳击玫瑰 |
| 1897678 | dragons-treas | 寻龙宝藏 |
| 1903012 | grimm-bounty | 格林赏金:糖果巫 |
| 1918451 | galaxy-miner | 银河宝藏 |
| 1929177 | kraken-gold | 海怪传说 |
| 1935269 | diner-frenzy | 汉堡大升级 |
| 1940257 | alibaba-cave | 芝麻开门 |
| 1950910 | inferno-mayhem | 地狱狂响 |
| 1964781 | pharaoh-royals | 法老牌 |
| 1971587 | majestic-emp | 天竺王朝 |
| 1981965 | forbid-alchemy | 炼金术 |
| 1997301 | mayan-destiny | 玛雅黄金 |
| 2009635 | poker-kingdom | 扑克王国 |
| 2012025 | skylight-wonder | 宝石热气球 |
| 2024510 | perfect-strike | 保龄球之王 |
| 2035783 | funky-fortunez | 嘻哈派对 |
| 2040102 | super-wildrix | 超级百搭王 |
| 2058347 | reel-royale-sd | 擂台之王 |
| 2100928 | fortune-horse | 马上赢 |
| 2126622 | tornado-rampg | 直击龙卷风 |