如果没有可靠的体育项目 ID 列表可供集成的其他部分使用,构建体育项目选择器就会很困难。阅读本指南后,你将能够获取可用体育项目,使用返回的 ID 查找历史锦标赛,并找到已结束比赛和球队阵容的相关端点。
Zyla API Hub 上的 1xBet API 会返回体育项目目录,以及锦标赛历史、比赛结果和球队信息。它适用于体育数据面板、历史结果浏览器,以及需要先选择体育项目再查询锦标赛数据的应用程序。
开始使用 Zyla API Hub
打开本文末尾链接的 1xBet API 市场页面;如果你还没有 Zyla 账户,请创建一个免费账户。在 API 页面上,点击 Subscribe 或 Start Free Trial(如有),然后获取 API 密钥以调用端点。
Zyla 采用订阅和配额模式,而非按调用次数计费。首个 API 访问选项为 7 天试用或 50 次请求;请查看 API 页面了解当前的访问选项和价格。Hub 拥有超过 10,000 个公共 API,可通过一个账户和 API 密钥访问。
获取可用体育项目
All available sports 端点会返回体育项目的 ID、名称和相关图片字段。文档中的请求使用 GET,并提供 lang=en:
curl -s -X GET "https://zylalabs.com/api/14965/1xbet-api/39257/all-available-sports?lang=en" \
-H "Authorization: Bearer YOUR_API_KEY"
将 YOUR_API_KEY 替换为你的 Zyla API 密钥。下方的官方响应示例在发布的样例中经过截断;它展示了第一个体育项目对象和第二个对象的一部分,并非完整的 JSON 文档。
[
{
"sportId": 1,
"name": "Football",
"shortName": "Football",
"images": {
"background": "https://1xbet.com/genfiles/cms/desktop/sport/ef75857be13caf79c856da4a69658924.png",
"popular": "https://1xbet.com/genfiles/cms/desktop/sport/d71d0a5dd44adf804808b7cc6382adc9.png",
"small": "https://1xbet.com/genfiles/cms/desktop/test/1_Football_small.png",
"backgroundIpad": "https://1xbet.com/genfiles/cms/desktop/sport/a85833e934f3dd7f5ec1ed5fb133420e.png",
"defaultChampions": "https://1xbet.com/genfiles/cms/desktop/sport/bc9460f5f45658a9e9db7324e398371e.png",
"defaultChampTablet": "https://1xbet.com/genfiles/cms/desktop/sport/0bd0108c3bfadf50d4da742477990703.png",
"defaultChampHeader": "https://1xbet.com/genfiles/cms/desktop/sport/33e8d9cbe2a5d7e2f9f15f7ec4dd201f.png",
"defaultChampHeaderTablet": "https://1xbet.com/genfiles/cms/desktop/sport/1e7a69b168f155753208b6c12a53ff7e.png",
"gameBackground": "https://1xbet.com/genfiles/cms/desktop/sport/2465e3d5cd413ea0ff50136dd5848a04.png",
"smallBw": "https://1xbet.com/genfiles/cms/desktop/sport/6424730580148fd2e4dfc4279734da72.png"
},
"subSports": [],
"isCyber": false
},
{
"sportId": 2,
"name": "Ice Hockey",
"shortName": "Ice Hockey",
"images": {
"background": "https://1xbet.com/genfiles/cms/desktop/sport/2dee41cbeb0e558d2766336d1c2dc5b8.png",
"popular": "https://1xbet.com/genfiles/cms/desktop/sport/8fae2005456366d84ce0d8b5d147bbea.png",
"small": "https://1xbet.com/genfiles/cms/desktop/test/2_ice_hockey_small.png",
"backgroundIpad": "https://1xbet.com/genfiles/cms/desktop/sport/b10a4fc7bfc8985be915aee171f78fe5.png",
"defaultChampions": "https://1xbet.com/genfiles/cms/desktop/sport/4317695599c78c9f0287248e260ed0b1.png",
"defaultChampTablet": "https://1xbet.com/genfiles/cms/desktop/sport/381fae4b532eea30ef2861e07d797a07.png",
"defaultChampHeader": "https://1xbet.com/genfiles/cms/desktop/sport/147daf82872211920478d3dfe508b20d.png",
"defaultChampHeaderTablet": "https://1xbet.com/genfiles/cms/desktop/sport/ec81c60afd6f3740798ce614394a7e83.png",
"gameBackground": "https://1xbet.com/genfiles/cms/desktop/sport/ecc51fc66c82c88d56789b42953c4de7.png",
"smallBw": "https://1xbet.com/genfiles/cms/desktop/…
将 sportId 用作选择值,将 name 或 shortName 用作标签。样例还包含图片 URL、subSports 和 isCyber;Football 对象的 subSports 数组为空,且 isCyber 设置为 false。
在 Python 中读取目录
此示例使用相同的语言参数调用同一端点。它读取返回的数组,并打印体育项目选择器所需的 ID 和名称。运行前请替换密钥占位符。
import json
from urllib.request import Request, urlopen
url = "https://zylalabs.com/api/14965/1xbet-api/39257/all-available-sports?lang=en"
request = Request(
url,
headers={"Authorization": "Bearer YOUR_API_KEY"},
method="GET",
)
with urlopen(request) as response:
sports = json.load(response)
for sport in sports:
print(sport["sportId"], sport["name"])
请将 API 密钥保存在服务器上,不要将其嵌入发送到浏览器的应用程序中。如果请求失败,请先在 API 页面检查密钥和订阅,再重试;重复调用会消耗可用配额。
从体育项目转向历史结果
目录是历史结果工作流的起点。选择一个体育项目,按日期请求其锦标赛,然后使用锦标赛 ID 请求已结束的比赛。
历史锦标赛
GET https://zylalabs.com/api/14965/1xbet-api/39290/history-championships 会返回指定日期内该体育项目有已结束比赛的锦标赛。
date为必填项;文档示例为2026-11-13。sportId为必填项,且类型为字符串;文档示例为1。lang为可选项;文档示例为en。
样例响应包含锦标赛的 id、name、countryId 和 totalMatches。例如,其中包含 Friendlies. National Teams,锦标赛 ID 为 125983。从体育项目响应中获取 ID 后,请将其序列化为字符串,并作为此请求的 sportId 查询参数。
历史锦标赛比赛
GET https://zylalabs.com/api/14965/1xbet-api/39291/history-championship-matches 会返回指定日期的锦标赛已结束比赛,或返回从 date 到 dateTo 日期范围内的比赛。
date为必填项;文档示例为2026-11-13。championshipId为必填项,且类型为字符串;文档示例为125983。lang为可选项;文档示例为en。dateTo为可选项;文档示例为2026-11-15。
比赛响应包含数字类型的 id、球队名称、score.current 中的最终比分,以及 score.periods 中各阶段的比分。样例还包含 startTimestamp 和 additionalInformation,其中列出了角球、黄牌和射正次数。请使用比赛 ID 区分记录;不要将显示的球队名称视为唯一键。
球队阵容
GET https://zylalabs.com/api/14965/1xbet-api/39292/team-lineup 会返回特定球队当前的阵容或名单。此端点需要 teamHash;文档示例为 5ab63dbc494765f3ca605d5f。示例中显示可选参数 lang 的值为 en。
样例按 title 对球员分组,并包含 playerHash、name、country、number、age、matches、goals、yellowCards 和 redCards 等字段。请将其视为当前球队阵容端点,而不是特定已结束比赛的历史阵容。
实用集成模式
体育项目导航:根据可用体育项目响应填充下拉菜单,并将每个 sportId 与显示名称一同保存。如果使用图片字段进行导航,也应确保界面在没有图片时仍能正常显示。
结果浏览器:让用户选择体育项目和日期,显示返回的锦标赛及其 totalMatches,然后请求所选锦标赛的比赛。将所选日期和锦标赛 ID 与结果一同保存,以便用户了解这些结果对应的查询条件。
球队阵容视图:应用程序获取球队哈希值后,请求球队阵容,并显示球员姓名、球衣号码和可用统计数据。比赛样例显示球队名称和 ID,而阵容端点需要 teamHash;不要假设这些值可以互换。
可以根据应用程序的需求缓存体育项目目录,避免每次查看页面时都重新获取。请有计划地刷新目录,并妥善处理空结果,不要将其视为请求失败。显示本地日期或时间之前,请确认如何解读 startTimestamp;样例并未说明其单位或时区。
通过 AI 智能体调用 API
Zyla API 也可以通过 MCP,从 Claude Code、Cursor、Windsurf 或其他兼容 MCP 的客户端调用。将客户端配置为使用 https://mcp.zylalabs.com/mcp?apikey=YOUR_API_KEY,并将占位符替换为你的 Zyla 密钥。
智能体可以从可用体育项目目录开始,然后使用所选体育项目 ID 查找历史锦标赛。请将密钥保存在客户端配置中,不要在提示词或日志中分享。
常见问题
如何获取可用体育项目列表?
使用文档中所示的 lang=en 请求调用 All available sports 端点。从每个返回的体育项目对象中读取 sportId 和 name。
我可以查找某个体育项目的已结束比赛吗?
可以。首先使用体育项目 ID 和日期调用 History championships。然后将返回的锦标赛 ID 与 History championship matches 配合使用,以获取已结束比赛及比分。
我可以请求某个日期范围内的比赛吗?
可以。除了必填的 date 和 championshipId,History championship matches 还接受可选参数 dateTo。
阵容端点接受球队名称吗?
文档中的请求需要 teamHash。请使用应用程序可用的球队哈希值,不要用球队名称或数字类型的球队 ID 替代。
创建免费账户,获取 API 密钥,然后开始 1xBet API 的 7 天试用。订阅前,请查看列表页面了解当前的访问选项和价格。
官方 API 响应
[
{
"sportId": 1,
"name": "Football",
"shortName": "Football",
"images": {
"background": "https://1xbet.com/genfiles/cms/desktop/sport/ef75857be13caf79c856da4a69658924.png",
"popular": "https://1xbet.com/genfiles/cms/desktop/sport/d71d0a5dd44adf804808b7cc6382adc9.png",
"small": "https://1xbet.com/genfiles/cms/desktop/test/1_Football_small.png",
"backgroundIpad": "https://1xbet.com/genfiles/cms/desktop/sport/a85833e934f3dd7f5ec1ed5fb133420e.png",
"defaultChampions": "https://1xbet.com/genfiles/cms/desktop/sport/bc9460f5f45658a9e9db7324e398371e.png",
"defaultChampTablet": "https://1xbet.com/genfiles/cms/desktop/sport/0bd0108c3bfadf50d4da742477990703.png",
"defaultChampHeader": "https://1xbet.com/genfiles/cms/desktop/sport/33e8d9cbe2a5d7e2f9f15f7ec4dd201f.png",
"defaultChampHeaderTablet": "https://1xbet.com/genfiles/cms/desktop/sport/1e7a69b168f155753208b6c12a53ff7e.png",
"gameBackground": "https://1xbet.com/genfiles/cms/desktop/sport/2465e3d5cd413ea0ff50136dd5848a04.png",
"smallBw": "https://1xbet.com/genfiles/cms/desktop/sport/6424730580148fd2e4dfc4279734da72.png"
},
"subSports": [],
"isCyber": false
},
{
"sportId": 2,
"name": "Ice Hockey",
"shortName": "Ice Hockey",
"images": {
"background": "https://1xbet.com/genfiles/cms/desktop/sport/2dee41cbeb0e558d2766336d1c2dc5b8.png",
"popular": "https://1xbet.com/genfiles/cms/desktop/sport/8fae2005456366d84ce0d8b5d147bbea.png",
"small": "https://1xbet.com/genfiles/cms/desktop/test/2_ice_hockey_small.png",
"backgroundIpad": "https://1xbet.com/genfiles/cms/desktop/sport/b10a4fc7bfc8985be915aee171f78fe5.png",
"defaultChampions": "https://1xbet.com/genfiles/cms/desktop/sport/4317695599c78c9f0287248e260ed0b1.png",
"defaultChampTablet": "https://1xbet.com/genfiles/cms/desktop/sport/381fae4b532eea30ef2861e07d797a07.png",
"defaultChampHeader": "https://1xbet.com/genfiles/cms/desktop/sport/147daf82872211920478d3dfe508b20d.png",
"defaultChampHeaderTablet": "https://1xbet.com/genfiles/cms/desktop/sport/ec81c60afd6f3740798ce614394a7e83.png",
"gameBackground": "https://1xbet.com/genfiles/cms/desktop/sport/ecc51fc66c82c88d56789b42953c4de7.png",
"smallBw": "https://1xbet.com/genfiles/cms/desktop/…
官方 API 响应
[
{
"sportId": 1,
"name": "Football",
"shortName": "Football",
"images": {
"background": "https://1xbet.com/genfiles/cms/desktop/sport/ef75857be13caf79c856da4a69658924.png",
"popular": "https://1xbet.com/genfiles/cms/desktop/sport/d71d0a5dd44adf804808b7cc6382adc9.png",
"small": "https://1xbet.com/genfiles/cms/desktop/test/1_Football_small.png",
"backgroundIpad": "https://1xbet.com/genfiles/cms/desktop/sport/a85833e934f3dd7f5ec1ed5fb133420e.png",
"defaultChampions": "https://1xbet.com/genfiles/cms/desktop/sport/bc9460f5f45658a9e9db7324e398371e.png",
"defaultChampTablet": "https://1xbet.com/genfiles/cms/desktop/sport/0bd0108c3bfadf50d4da742477990703.png",
"defaultChampHeader": "https://1xbet.com/genfiles/cms/desktop/sport/33e8d9cbe2a5d7e2f9f15f7ec4dd201f.png",
"defaultChampHeaderTablet": "https://1xbet.com/genfiles/cms/desktop/sport/1e7a69b168f155753208b6c12a53ff7e.png",
"gameBackground": "https://1xbet.com/genfiles/cms/desktop/sport/2465e3d5cd413ea0ff50136dd5848a04.png",
"smallBw": "https://1xbet.com/genfiles/cms/desktop/sport/6424730580148fd2e4dfc4279734da72.png"
},
"subSports": [],
"isCyber": false
},
{
"sportId": 2,
"name": "Ice Hockey",
"shortName": "Ice Hockey",
"images": {
"background": "https://1xbet.com/genfiles/cms/desktop/sport/2dee41cbeb0e558d2766336d1c2dc5b8.png",
"popular": "https://1xbet.com/genfiles/cms/desktop/sport/8fae2005456366d84ce0d8b5d147bbea.png",
"small": "https://1xbet.com/genfiles/cms/desktop/test/2_ice_hockey_small.png",
"backgroundIpad": "https://1xbet.com/genfiles/cms/desktop/sport/b10a4fc7bfc8985be915aee171f78fe5.png",
"defaultChampions": "https://1xbet.com/genfiles/cms/desktop/sport/4317695599c78c9f0287248e260ed0b1.png",
"defaultChampTablet": "https://1xbet.com/genfiles/cms/desktop/sport/381fae4b532eea30ef2861e07d797a07.png",
"defaultChampHeader": "https://1xbet.com/genfiles/cms/desktop/sport/147daf82872211920478d3dfe508b20d.png",
"defaultChampHeaderTablet": "https://1xbet.com/genfiles/cms/desktop/sport/ec81c60afd6f3740798ce614394a7e83.png",
"gameBackground": "https://1xbet.com/genfiles/cms/desktop/sport/ecc51fc66c82c88d56789b42953c4de7.png",
"smallBw": "https://1xbet.com/genfiles/cms/desktop/…