tetzilla/sportmonks-football-api
PHP的简单SportMonks足球API客户端
1.0.5
2024-06-05 06:13 UTC
Requires
- php: ^7.3 | ^8
- symfony/http-client: ^5.4.31
This package is auto-updated.
Last update: 2024-09-28 22:56:31 UTC
README
PHP库,用于Sportmonks足球API v3。由Carsten Tetzlaff开发。此库深受https://github.com/joesaunderson/sportmonks-soccer的影响。
先决条件
PHP >= 7.3
安装
composer require tetzilla/sportmonks-football-api
设置
API客户端依赖于环境变量进行配置(设置API令牌和时区)。
先决条件
PHP >= 7.3
安装
composer require symfony/dotenv
使用
use Symfony\Component\Dotenv\Dotenv;
$dotenv = new Dotenv();
$dotenv->load(__DIR__.'/.env');
示例.env文件
# API TOKEN (Required) # https://docs.sportmonks.com/football/welcome/authentication SPORTMONKS_API_TOKEN=_YOUR_API_TOKEN_HERE # TIMEZONE (Optional) # https://docs.sportmonks.com/football/tutorials-and-guides/tutorials/introduction/set-your-time-zone SPORTMONKS_TIMEZONE=Europe/London
使用
use Sportmonks\Football\FootballApi; ... // Basic API call for all Bookmakers $response = FootballApi::bookmakers()->getAll();
分页、过滤、排序和数据丰富
Sportmonks API允许进行高级过滤和排序,以及通过关系添加数据。此客户端支持以下功能
分页
// API call for Fixtures with page specified $response = FootballApi::fixtures() ->setPage(3) ->getByDate('2023-03-19');
注意:可以使用分页($response['pagination'])循环遍历页面并构建结果集。
包括
// API call for Fixtures with includes $response = FootballApi::fixtures() ->setInclude(['scores', 'lineups', 'events']) ->getByDate('2023-03-19');
过滤
实体过滤器
// API call for Fixtures with filters $response = FootballApi::fixtures() ->setInclude(['events','statistics.type']) ->setFilters(['eventTypes' => [18,14]]) ->getByDate('2023-03-19');
已删除过滤器
// API call for Fixtures with deleted filter $response = FootballApi::fixtures() ->setFilters(['deleted']) ->all();
填充过滤器
// API call for Fixtures with populate (1000 per page) $response = FootballApi::fixtures() ->setFilters(['populate']) ->all();
注意:此客户端将不会验证正确端点的使用,也不会抛出错误。请参考Sportmonks文档以查看哪些端点支持上述参数。
完整端点示例
实时得分
获取所有 - 查看Sportmonks文档
$response = FootballApi::livescores()->all();
获取所有进行中的 - 查看Sportmonks文档
$response = FootballApi::livescores()->inplay();
获取最新 - 查看Sportmonks文档
$response = FootballApi::livescores()->latest();
比赛日程
获取所有 - 查看Sportmonks文档
$response = FootballApi::fixtures()->all();
按ID获取 - 查看Sportmonks文档
$response = FootballApi::fixtures()->getById($fixtureId);
按多个ID获取 - 查看Sportmonks文档
$response = FootballApi::fixtures()->getByMultipleIds([$fixtureId1,$fixtureIds2,...]);
按日期获取 - 查看Sportmonks文档
$response = FootballApi::fixtures()->getByDate($date);
按日期范围获取 - 查看Sportmonks文档
$response = FootballApi::fixtures()->getByDateRange($dateFrom, $dateTo);
按团队日期范围获取 - 查看Sportmonks文档
$response = FootballApi::fixtures()->getByDateRangeForTeam($dateFrom, $dateTo, $teamId);
按对决获取 - 查看Sportmonks文档
$response = FootballApi::fixtures()->getHeadToHead($teamId1, $teamId2);
按市场ID获取即将到来的比赛 - 查看Sportmonks文档
$response = FootballApi::fixtures()->getUpcommingByMarketId($marketId);
按名称搜索获取 - 查看Sportmonks文档
$response = FootballApi::fixtures()->search($searchQuery);
获取最后更新 - 查看Sportmonks文档
$response = FootballApi::fixtures()->getLastUpdated();
状态
获取所有状态 - 查看Sportmonks文档
$response = FootballApi::states()->all();
按ID获取 - 查看Sportmonks文档
$response = FootballApi::states()->getById();
联赛
获取所有 - 查看Sportmonks文档
$response = FootballApi::leagues()->all();
按ID获取 - 查看Sportmonks文档
$response = FootballApi::leagues()->getById($leagueId);
按实时获取 - 查看Sportmonks文档
$response = FootballApi::leagues()->live();
按比赛日期获取 - 查看Sportmonks文档
$response = FootballApi::leagues()->getByFixtureDate($date);
按国家ID获取 - 查看Sportmonks文档
$response = FootballApi::leagues()->getByCountryId($countryId);
按名称搜索获取 - 查看Sportmonks文档
$response = FootballApi::leagues()->search($searchQuery);
按团队ID获取所有 - 查看Sportmonks文档
$response = FootballApi::leagues()->getAllByTeamId($teamId);
按团队ID获取当前 - 查看Sportmonks文档
$response = FootballApi::leagues()->getCurrentByTeamId($teamId);
赛季
获取所有 - 查看Sportmonks文档
$response = FootballApi::season()->all();
按ID获取 - 查看Sportmonks文档
$response = FootballApi::season()->getById($seasonId);
按团队ID获取 - 查看Sportmonks文档
$response = FootballApi::season()->getByTeamId($teamId);
按名称搜索获取 - 查看Sportmonks文档
$response = FootballApi::season()->search($searchQuery);
赛程
按赛季ID获取 - 查看Sportmonks文档
$response = FootballApi::schedules()->bySeasonId($seasonId);
按赛季ID获取 - 查看Sportmonks文档
$response = FootballApi::schedules()->byTeamId($teamId);
按赛季ID和团队ID获取 - 查看Sportmonks文档
$response = FootballApi::schedules()->bySeasonAndTeamId($seasonId, $teamId);
阶段
获取所有 - 查看Sportmonks文档
$response = FootballApi::stages()->all();
按ID获取 - 查看Sportmonks文档
$response = FootballApi::stages()->getById($stageId);
按赛季ID获取 - 查看Sportmonks文档
$response = FootballApi::stages()->getBySeasonId($seasonId);
按名称搜索获取 - 查看Sportmonks文档
$response = FootballApi::stages()->search($searchQuery);
轮次
获取所有 - 查看Sportmonks文档
$response = FootballApi::rounds()->all();
按ID获取 - 查看Sportmonks文档
$response = FootballApi::rounds()->getById($roundId);
按赛季ID获取 - 查看Sportmonks文档
$response = FootballApi::rounds()->getBySeasonId($seasonId);
按名称搜索获取 - 查看Sportmonks文档
$response = FootballApi::rounds()->search($searchQuery);
排名
获取全部 - 查看Sportmonks文档
$response = FootballApi::standings()->all();
通过ID获取 - 查看Sportmonks文档
$response = FootballApi::standings()->getBySeasonId($seasonId);
通过轮次ID获取 - 查看Sportmonks文档
$response = FootballApi::standings()->getByRoundId($roundId);
通过赛季ID获取修正 - 查看Sportmonks文档
$response = FootballApi::standings()->getCorrectionsBySeasonId($seasonId);
通过联赛ID获取实时积分榜 - 查看Sportmonks文档
$response = FootballApi::standings()->getLiveByLeagueId($leagueId);
射手榜
通过赛季ID获取全部 - 查看Sportmonks文档
$response = FootballApi::topscorers()->getBySeasonId($seasonId);
通过阶段ID获取全部 - 查看Sportmonks文档
$response = FootballApi::topscorers()->getByStageId($stageId);
球队
获取全部 - 查看Sportmonks文档
$response = FootballApi::teams()->all();
通过ID获取 - 查看Sportmonks文档
$response = FootballApi::teams()->getById($teamId);
通过国家ID获取 - 查看Sportmonks文档
$response = FootballApi::teams()->getByCountryId($countryId);
通过赛季ID获取 - 查看Sportmonks文档
$response = FootballApi::teams()->getBySeasonId($seasonId);
通过名称搜索获取 - 查看Sportmonks文档
$response = FootballApi::teams()->search($searchQuery);
球队阵容
通过球队ID获取 - 查看Sportmonks文档
$response = FootballApi::teamSquads()->getByTeamId($teamId);
通过球队ID和赛季ID获取 - 查看Sportmonks文档
$response = FootballApi::teamSquads()->getByTeamAndSeasonId($teamId,$seasonId);
球员
获取全部 - 查看Sportmonks文档
$response = FootballApi::players()->all();
通过ID获取 - 查看Sportmonks文档
$response = FootballApi::players()->getById($playerId);
通过国家ID获取 - 查看Sportmonks文档
$response = FootballApi::players()->getByCountryId($countryId);
通过名称搜索获取 - 查看Sportmonks文档
$response = FootballApi::players()->search($searchQuery);
获取最后更新 - 查看Sportmonks文档
$response = FootballApi::players()->getLastUpdated();
教练
获取全部 - 查看Sportmonks文档
$response = FootballApi::coaches()->all();
通过ID获取 - 查看Sportmonks文档
$response = FootballApi::coaches()->getById($coachId);
通过国家ID获取 - 查看Sportmonks文档
$response = FootballApi::coaches()->getByCountryId($countryId);
通过名称搜索获取 - 查看Sportmonks文档
$response = FootballApi::coaches()->search($searchQuery);
获取最后更新 - 查看Sportmonks文档
$response = FootballApi::coaches()->getLastUpdated();
裁判
获取全部 - 查看Sportmonks文档
$response = FootballApi::referees()->all();
通过ID获取 - 查看Sportmonks文档
$response = FootballApi::referees()->getById($refereeId);
通过国家ID获取 - 查看Sportmonks文档
$response = FootballApi::referees()->getByCountryId($countryId);
通过赛季ID获取 - 查看Sportmonks文档
$response = FootballApi::referees()->getBySeasonId($countryId);
通过姓名搜索获取 - 查看Sportmonks文档
$response = FootballApi::referees()->search($searchQuery);
转会
获取全部 - 查看Sportmonks文档
$response = FootballApi::transfers()->all();
通过ID获取 - 查看Sportmonks文档
$response = FootballApi::transfers()->getById($transferId);
获取最新 - 查看Sportmonks文档
$response = FootballApi::transfers()->latest();
获取指定日期范围内的 - 查看Sportmonks文档
$response = FootballApi::transfers()->getByDateRange($dateFrom,$dateTo);
通过球队ID获取 - 查看Sportmonks文档
$response = FootballApi::transfers()->getByTeamId($teamId);
通过球员ID获取 - 查看Sportmonks文档
$response = FootballApi::transfers()->getByPlayerId($playerId);
场馆
获取全部 - 查看Sportmonks文档
$response = FootballApi::venues()->all();
通过ID获取 - 查看Sportmonks文档
$response = FootballApi::venues()->getById($venueId);
通过赛季ID获取 - 查看Sportmonks文档
$response = FootballApi::venues()->getBySeasonId($seasonId);
通过姓名搜索获取 - 查看Sportmonks文档
$response = FootballApi::venues()->search($searchQuery);
电视台
获取全部 - 查看Sportmonks文档
$response = FootballApi::tvStations()->all();
通过ID获取 - 查看Sportmonks文档
$response = FootballApi::tvStations()->getById($stationId);
通过比赛ID获取 - 查看Sportmonks文档
$response = FootballApi::tvStations()->getByFixtureId($fixtureId);
预测
获取可预测性 - 查看Sportmonks文档
$response = FootballApi::predictions()->probabilities();
通过联赛ID获取可预测性 - 查看Sportmonks文档
$response = FootballApi::predictions()->getPredictabilityByLeagueId($leagueId);
通过比赛ID获取可预测性 - 查看Sportmonks文档
$response = FootballApi::tvStations()->getPredictabilityByFixtureId($fixtureId);
获取价值投注 - 查看Sportmonks文档
$response = FootballApi::tvStations()->valueBets();
赛前赔率
获取全部 - 查看Sportmonks文档
$response = FootballApi::preMatchOdds()->all();
通过比赛ID获取 - 查看Sportmonks文档
$response = FootballApi::preMatchOdds()->getByFixtureId($fixtureId);
通过比赛ID和博彩公司ID获取 - 查看Sportmonks文档
$response = FootballApi::preMatchOdds()->getByFixtureAndBookmakerId($fixtureId,$bookmakerId);
通过比赛ID和市场ID获取 - 查看Sportmonks文档
$response = FootballApi::preMatchOdds()->getByFixtureAndMarketId($fixtureId,$marketId);
获取最后更新赔率 - 查看Sportmonks文档
$response = FootballApi::preMatchOdds()->getLastUpdated();
实时赔率
获取所有 - 查看Sportmonks文档
$response = FootballApi::inplayOdds()->all();
通过赛事ID获取 - 查看Sportmonks文档
$response = FootballApi::inplayOdds()->getByFixtureId($fixtureId);
通过赛事ID和博彩商ID获取 - 查看Sportmonks文档
$response = FootballApi::inplayOdds()->getByFixtureAndBookmakerId($fixtureId,$bookmakerId);
通过赛事ID和市场ID获取 - 查看Sportmonks文档
$response = FootballApi::inplayOdds()->getByFixtureAndMarketId($fixtureId,$marketId);
获取最后更新 - 查看Sportmonks文档
$response = FootballApi::inplayOdds()->getLastUpdated();
市场
获取所有 - 查看Sportmonks文档
$response = FootballApi::markets()->all();
通过市场ID获取 - 查看Sportmonks文档
$response = FootballApi::markets()->getById($marketId);
通过搜索获取 - 查看Sportmonks文档
$response = FootballApi::markets()->search($searchQuery);
博彩商
获取所有 - 查看Sportmonks文档
$response = FootballApi::bookmakers()->all();
通过博彩商ID获取 - 查看Sportmonks文档
$response = FootballApi::bookmakers()->getById($bookmakerId);
通过搜索获取 - 查看Sportmonks文档
$response = FootballApi::bookmakers()->search($searchQuery);
通过市场ID获取 - 查看Sportmonks文档
$response = FootballApi::bookmakers()->getByFixtureId($fixtureId);
新闻
获取赛前新闻 - 查看Sportmonks文档
$response = FootballApi::preMatchNews()->all();
通过赛季ID获取 - 查看Sportmonks文档
$response = FootballApi::preMatchNews()->getBySeasonId($seasonId);
获取即将进行的赛事的赛前新闻 - 查看Sportmonks文档
$response = FootballApi::preMatchNews()->upcomingFixtures();
竞争对手
获取所有竞争对手 - 查看Sportmonks文档
$response = FootballApi::rivals()->all();
通过球队ID获取 - 查看Sportmonks文档
$response = FootballApi::rivals()->getByTeamId($teamId);
解说
获取所有解说 - 查看Sportmonks文档
$response = FootballApi::commentaries()->all();
通过赛事ID获取 - 查看Sportmonks文档
$response = FootballApi::commentaries()->getByFixtureId($fixtureId);
核心端点
核心包含所有体育项目中使用的端点。
大洲 🗺️
获取所有大洲 - 查看Sportmonks文档
$response = FootballApi::continents()->all();
通过ID获取 - 查看Sportmonks文档
$response = FootballApi::continents()->getById();
国家
获取所有国家 - 查看Sportmonks文档
$response = FootballApi::countries()->all();
通过ID获取 - 查看Sportmonks文档
$response = FootballApi::countries()->getById();
通过搜索获取 - 查看Sportmonks文档
$response = FootballApi::countries()->search($searchQuery);
地区
获取所有地区 - 查看Sportmonks文档
$response = FootballApi::regions()->all();
通过ID获取 - 查看Sportmonks文档
$response = FootballApi::regions()->getById();
通过搜索获取 - 查看Sportmonks文档
$response = FootballApi::regions()->search($searchQuery);
城市 🏙️
获取所有城市 - 查看Sportmonks文档
$response = FootballApi::cities()->all();
通过ID获取 - 查看Sportmonks文档
$response = FootballApi::cities()->getById();
通过搜索获取 - 查看Sportmonks文档
$response = FootballApi::cities()->search($searchQuery);
类型 ⌨️
获取所有类型 - 查看Sportmonks文档
$response = FootballApi::types()->all();
通过ID获取 - 查看Sportmonks文档
$response = FootballApi::types()->getById();
通过实体获取 - 查看Sportmonks文档
$response = FootballApi::types()->getByEntity();
过滤器 ⚙️
获取所有实体过滤器 - 查看Sportmonks文档
$response = FootballApi::filters()->entity();
我的Sportmonks
获取您的订阅信息。
获取我的增强信息 - 查看Sportmonks文档
$response = FootballApi::my()->enrichments();
获取我的资源 - 查看Sportmonks文档
$response = FootballApi::my()->resources();
获取我的联赛 - 查看Sportmonks文档
$response = FootballApi::my()->leagues();