# 17真人百家樂 API ## 環境 | | 網址 | | -------- | -------- | | 測試 | https://staging.17gaming.vip/ | | 正式 | https://17gaming.vip/ | ## 認證資訊 請聯繫我司代理取得測試環境與正式環境連線資訊 ## API ### 登入取得 JWT Token #### Request `POST /authenticate` #### Parameter | 參數 | 說明 | 其他 | | -------- | -------- | -------- | | username | 帳號 | String(必填) | | password | 密碼 | String(必填) | #### Response ```json= { "data": { "id": "1022ebec-bb41-4c37-9952-99516a4d8cb3", "name": "jb", "username": "jb", "nickname": "jb", "wallet_type": "basic", "status": "active", "jwt_token": "eyJhbGciOiJIUzI1NiJ9.eyJwbGF0Zm9ybV9pZCI6MSwiZXhwIjoxNjI3NjMxNjk4fQ.1RDlAt7nViKwfyEzzPWCfCtBxa93RnxPL9Jbo37EndU", "jwt_token_expires_at": 1627631698, "secure_token": "62a10326-d67d-47d4-a2dd-28ec52ef620c", "login_url": null, "niuniu_min_bet": 100, "niuniu_max_bet": 10000, "baccarat_min_bet": 100, "baccarat_max_bet": 10000 }, "meta": { "request_id": "2d9994c9-413f-42bf-8498-1e8ef09317d8" } } ``` ### 取得百家樂桌列表 #### Request `GET /baccarats` #### Headers `Authorization: Bearer 你的JWT_TOKEN` #### Response ```json= { "data": [ { "id": "1757a34d-61b0-4353-8179-3e4481b1d67e", "name": "傳統百家樂01", "href": "https://17gaming.vip/baccarat_rooms/1757a34d-61b0-4353-8179-3e4481b1d67e?platform_id=1", "info": { "big_odds": 0.53, "small_odds": 1.45, "dealer_odds": 1.0, "player_odds": 1.0, "dealer_pair_odds": 11.0, "player_pair_odds": 11.0, "tie_odds": 8.0, "girl": { "name": "比比", "avatar": "https://real17-app.s3.ap-northeast-1.amazonaws.com/fb9f6fd82d5a3d89cd66d4f187f44ff0.jpg?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAQLRELICUFB5BAEGX%2F20210806%2Fap-northeast-1%2Fs3%2Faws4_request&X-Amz-Date=20210806T163526Z&X-Amz-Expires=900&X-Amz-SignedHeaders=host&X-Amz-Signature=d42087b91a53b472ab152903d871c2f0abbc2422c32c064463abe0a44e9fb29e" } }, "socket_url": "wss://17gaming.vip/cable?platform_token=eyJhbGciOiJIUzI1NiJ9.eyJwbGF0Zm9ybV9pZCI6MSwiZXhwIjoxNjI4MzU0MDQyfQ.5Hwei2Ij0kSBh6AjQKwwaOX-zptyiS0jzV7CIBKLpPc", "live_url": "https://live.17gaming.vip/baccarats/3" }, ], "meta": { "request_id": "cc66e105-55da-458f-a724-ba35ef1f2ddc" } } ``` ### 取得房間遊戲歷史 #### Request `GET /baccarats/{房間ID}/baccarat_game_records` #### Parameter | 參數 | 說明 | 其他 | | -------- | -------- | -------- | | start_at | 開始時間 | UNIX_TIMESTAMP(非必填,預設為24小時前,最多也僅可查詢一天內的紀錄,對應 closed_at 遊戲結算時間欄位) | | end_at | 結束時間 | UNIX_TIMESTAMP(非必填,預設為當下,對應 closed_at 遊戲結算時間欄位) | | page | 頁數 | Integer(非必填,預設為第一頁) | | per_page | 單頁筆數 | Integer(非必填,預設為50筆,最大 100 筆) | #### Headers `Authorization: Bearer 你的JWT_TOKEN` #### Response ```json= { "data": [ { "game_no": "8113D676F490BC5A", // 遊戲局號 "status": "draw", // 遊戲狀態,請參考下方 status 事件說明 "draw": { "banker": [ // 莊家牌面 "club1", "heart7" ], "player": [ // 閒家牌面 "club7", "spade6" ] }, "rounds": "234/1", // 局數 "result": { "banker": 8, // 莊家點數 "player": 3 // 閒家點數 }, "created_at": 1632243484, // 遊戲開始時間 "closed_at": 1632243767 // 遊戲結算時間 "video": "https://real17-videos.s3.ap-northeast-1.amazonaws.com/071A85D03B8C43B1.mp4?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAQLRELICUFB5BAEGX%2F20211108%2Fap-northeast-1%2Fs3%2Faws4_request&X-Amz-Date=20211108T143708Z&X-Amz-Expires=86400&X-Amz-SignedHeaders=host&X-Amz-Signature=81ca564ef8b489dc88879796f986a29e3fd07dd7520a4b9f5260a98207feaca3" // 當局遊戲開牌到結算的錄影 }, ], "meta": { "total_pages": 1, // 總頁數 "page": 1, // 當前頁數 "total_size": 1 // 本頁筆數 } } ``` ## 房間視訊源 1. 視訊源為 http-flv 格式,請使用[牌桌列表 API](#取得百家樂桌列表)中取得的的 `live_url` ## Websocket 連線方式 1. 連線至在[牌桌列表 API](#取得百家樂桌列表)中的 `socket_url` 2. 向 socket 發送下方訂閱資訊,其中 `identifier` 的內容型態為字串,`channel` 內容固定是 `PlatformBaccaratRoomChannel`,`roomId`請帶入[牌桌列表 API](#取得推筒子桌列表)中取得的`id` ```json= { "command": "subscribe", "identifier": "{\"channel\":\"PlatformBaccaratRoomChannel\",\"roomId\":\"1\"}" } ``` 3. 收到以下資訊表示訂閱成功 ```json= { "identifier":"{\"channel\":\"PlatformBaccaratRoomChannel\",\"roomId\":\"1\"}", "type":"confirm_subscription" } ``` 4. 收到以下資訊表示訂閱失敗 ```json= { "identifier":"{\"channel\":\"PlatformBaccaratRoomChannel\",\"roomId\":\"1\"}", "type":"reject_subscription" } ``` 5. 你可以發送 ping 訊息來確認連線是否正常 ```json= { "command": "message", "identifier": "{\"channel\":\"PlatformBaccaratRoomChannel\",\"roomId\":\"1\"}", "data": "{\"type\":\"ping\"}" } ``` 若是連線正常則會回傳 pong 訊息 ```json= { "identifier":"{\"channel\":\"PlatformBaccaratRoomChannel\",\"roomId\":\"1\"}", "message":{"data":"pong"}} ``` 7. ## 牌面 1. 在 Websocket 傳送資訊中,會以`draw`來呈現該門的牌面,牌面以英文+數字呈現花色與點數 2. 在牌局結束時可在`result`中得到各門的點數計算 | 牌面 | 對應API牌面 | | -------- | -------- | | ♠️ | spade | | ♥️ | heart | | ♦️ | diamond | | ♣️ | club | ## Websocket 事件 socket 資訊中會收到類似以下格式的資訊 ```json= { "identifier":"{\"channel\":\"BaccaratRoomChannel\",\"roomId\":\"1\"}", "message":{ "data":{ "status":"startBet", "gameNo":"CDAD597A59B715FA", "rounds":"123/45" } } } ``` 其中`identifier` 作為辨識訂閱房間的資訊,`message`為每次傳送的事件資訊,資訊都將包裝在`data`欄位中,在`data`中會固定有以下三個資訊:都將有`status`作為事件類型以及`gameNo`為每一局局號 | key | 說明 | | -------- | -------- | | status | 事件類型 | | gameNo | 遊戲局號 | | rounds | 遊戲牌靴局數,會以 23/4 這樣的型態顯示,前面代表第幾次的牌靴,後面代表本牌靴第幾局 | ### status 事件 `data`中皆有`status`作為事件類型,詳列如下: #### `startBet` 開始下注(目前下注事件為30秒,每隔 5 秒會再發送一次,seconds 欄位代表剩餘秒數) ```json= { "status":"startBet", "gameNo":"3DC1D2084687FF5F", "rounds":"123/45", "seconds":30 } ``` #### `stopBet` 停止下注 ```json= { "status":"stopBet", "gameNo":"3DC1D2084687FF5F", "rounds":"123/45" } ``` #### `bankerDraw` 莊家開牌 ```json= { "status":"bankerDraw", "draw":["club2","spade2"], "gameNo":"CDAD597A59B715FA", "rounds":"123/45" } ``` #### `playerDraw` 閒家開牌 ```json= { "status":"playerDraw", "draw":["club2","spade2"], "gameNo":"CDAD597A59B715FA", "rounds":"123/45" } ``` #### `bankerThirdDraw` 莊家補牌 ```json= { "status":"bankerThirdDraw", "draw":["club2","spade2","heart3"], "gameNo":"CDAD597A59B715FA", "rounds":"123/45" } ``` #### `playerThirdDraw` 閒家補牌 ```json= { "status":"playerThirdDraw", "draw":["club2","spade2","heart3"], "gameNo":"CDAD597A59B715FA", "rounds":"123/45" } ``` #### `draw` 本局結算,該事件會隔一秒再發一次,共發兩次 ```json= { "status":"draw", "gameNo":"CDAD597A59B715FA", "rounds":"123/45", "draw": { "banker":["club2","spade2"], "player":["club2","spade2"], }, "result":{ "banker":4, "player":4, } } ``` #### `shuffle` 洗牌,該事件會隔一秒再發一次,共發兩次 ```json= { "status":"shuffle", "gameNo":"CDAD597A59B715FA", "rounds":"123/45" ```