beta GetEvents push - Saba-sports/OddsDirectAPI_CN GitHub Wiki
此API用于获取赛事相关信息包含部分盘口信息
- 通过此API在一个请求中订阅更新和检索数据。
GET /sports/stream/{version}/GetEvents?query=$filter=sporttype eq 1&includeMarkets=$filter=bettype eq 128&language=cs
Accept: text/event-stream
Accept-Encoding: br, gzip, deflate(如果可以使用Header)| Parameter | Description |
|---|---|
| query | 使用Odata指定特定格式的查询 |
| from | 指定赛事开始日期,可以单独输入 |
| until | 指定赛事结束日期,可以单独输入 |
| language | 指定欲回应的数据语系,请参阅Language Table |
| includeMarkets | 此参数仅在 /GetEvents 中使用,指定是否有必要回传market讯息。 如果includeMarkets未指定,则默认回传。 includeMarkets = $filter=bettype eq 128; 仅筛选指定条件Market信息。 includeMarkets = none; 将不回传Market信息。 |
| token | 透过 /login或/refreshToken 获得JWT token |
id: string\r\n
data: {
"status": int,
"message":string,
"payload": {
"events":{
"add": Event[],
"change":EventChange[],
"remove":[eventId1,eventId2...]
},
"markets": {
"add": Market[],
"change":MarketChange[],
"remove":[marketId1,marketId2...]
}
}
}\r\n\r\n
| Name | Format | Description |
|---|---|---|
| id | string | Server Sent Event的序列号码 |
| data | json |
| Name | Format | Description |
|---|---|---|
| status | int | 回应的状态代码 |
| message | string | 回应的状态信息 |
| payload | object |
| Name | Format | Description |
|---|---|---|
| events | object | 赛事信息列表 |
| markets | object | 盘口信息列表 |
| Name | Format | Description |
|---|---|---|
| add | Event array | 新添加的赛事信息 - Event 请参阅GetEvents |
| change | EventChange array | 更新的赛事信息 - EventChange 请参阅EventChange. |
| remove | int array | 删除的赛事ID列表 |
| Name | Format | Description |
|---|---|---|
| add | Market array | 新添加的盘口信息 - Market 请参阅GetMarkets |
| change | MarketChange array | 更新的盘口信息 - MarketChange 请参阅MarketChange. |
| remove | int array | 删除的盘口ID列表 |
| status状态代码 | message显示讯息 | Description说明描述 |
|---|---|---|
| 0 | Success | 成功 |
| 1 | InitialData | 初始数据 |
| 3 | Reset | 重新连接 |
| 97 | Invalid Accept-Encoding | Http Status Code = 400 无效的編碼压缩格式 |
| 98 | Invalid OData query attributes | Http Status Code = 400 Odata查询属性无效或不支援 |
| 99 | System under maintenance | Http Status Code = 503 系统正在维护中 |
| 100 | Internal Server Error | Http Status Code = 500 服务器发生非预期错误 |
- 第一次连线成功会回传status=1, add為初始数据; 接着陆续收到status=0的更新數據add/change/remove
- 若中途使用者因网路问题或者其他因素断线:
- 如果是使用 browser 的 native javascript EventSource api,不关闭页面的情境下 browser 会自动重连并且自动在 header 带入 Last-Event-Id, Server 端会根据该 Last-Event-Id 透过内部资料缓存机制尝试发送该重连之 client 遗漏的更新数据
- 如果是其他语言开发的使用者, 需自行实作重新连线机制且于header带入Last-Event-Id
- 若缓存中找不到可发送的更新数据,则会重新产生连线status=3,且资料内容为初始数据