---
# System prepended metadata

title: Morgan水源對接文件

---

# Morgan水源對接文件

Morgan水源將提供6大玩法的數據，即時賠率推送將透過Kafka通知，當前數據則透過API獲取

## API
透過http api取得數據，將會提供一組api access key，在每次發起API Request的時候，需要將Key帶入Header "X-AUTH"

API URL: (待補)
API Access Key: (待補)

### Request Header
```
Content-Type: application/json
X-AUTH: qweqwequiweuqjldfkasdlfsjfsldkfjsl
```
### Response基本格式
```
{
  "code":9002,                //錯誤代碼
  "message":"",               //文字說明
  "data":{} 
}
```
### 取得賽事的玩法＆賠率
POST /getOdds
#### Request
```
{
  matchId:[]                  //欲查詢的賽事id列表，單次請求最多100
}
```

#### Response
```
[
  {
    "matchId": "1234567",       //賽事id
    "status": "Open"            //Open, Pause, Close
    "markets" : [               //玩法
      { 
        "name": "ah",           //玩法名
        "status": "Open",       //Open, Pause, Close
        "lines":[               //盤口array
          {  
            "alias":"Main"      //Main, FirstSub, SecondSub
            "condition":"-1",   //k值
            "status":"Open",    //Open, Pause, Close
            "outcomes":[        //投注項array
              {
                "name":"home",  //投注項名
                "odds": "0.56", //賠率
                "status":"Open" //Open, Pause, Close
              }, 
              {
                "name":"away",  //投注項名
                "odds": "1.56", //賠率
                "status":"Open" //Open, Pause, Close
              }
            ]
          }
        ]
      }
    ]
  }
]
```

## Kafka推送資料
賽事最新的數據透過Kafka推送，推送的資料以一場賽事為單位，會包括多個Market, 多個Line，推送的內容僅提供有更新的Market&Line的資訊

ah玩法，推送的condition為"絕對"讓球數
1x2玩法，推送的賠率為"歐洲"賠率
ah、ou玩法，推送的賠率為"香港"賠率

Kafka server: (待補)
topic: morgan.platform.odds
```
{
  "matchId": "1234567",         //賽事id
  "status": "Open"              //Open, Pause, Close
  "markets" : [                 //玩法
    {                           
      "name": "ah",             //玩法名
      "status": "Open",         //Open, Pause, Close
      "lines":[                 //盤口
        {  
          "alias":"Main"        //Main, FirstSub, SecondSub
          "condition":"-1",     //k值
          "status":"Open",      //Open, Pause, Close
          "outcomes":[          //投注項
            {
              "name":"home",    //投注項名
              "odds": "0.56",   //賠率
              "status":"Open" //Open, Pause, Close
            },
            {
              "name":"away",    //投注項名
              "odds": "1.56",   //賠率
              "status":"Open" //Open, Pause, Close
            }
          ]
        }
      ]
    }
  ]
  "eventTimestamp": 1010101010101   //推送數據出來的時間
}
```


## 附件
### 附件1 欄位對照

| 欄位 | 中文意思 | 說明 |
| -------- | -------- | -------- |
| Market     | 玩法     | 全場讓球、上半場大小、波膽     |
| Line| 盤口 | |
| Condition | 盤口識別值 | 1x2玩法時為空，AH玩法為主隊讓球數，大小玩法為總進球數 |
| Outcome| 投注項 | |

### 附件2 Market列表
| Id | Value | Name   |
| -------- | --------  | --------  |
| 1 | 1x2      | 獨贏       |
| 60 | 1x2_1st  | 獨贏-上半場 |
| 16 | ah  | 讓球   | 
| 66 | ah_1st  | 讓球-上半場   | 
| 18 | ou | 大小 | 
| 68 | ou_1st | 大小-上半場|

### 附件3 OutcomeId對照表
| Id | Name   |
| -------- | -------- |
| 1  | home   |
| 2  | draw   | 
| 3  | away   | 
| 12 | over   |
| 13 | under  |

### 附件4 API 錯誤代碼對照表(待補)
### 附件5 對接假資料(待補)