Package Data | |
---|---|
Maintainer Username: | fpicosm |
Maintainer Contact: | fpicosm@gmail.com (Fernando Picos) |
Package Create Date: | 2022-10-10 |
Package Last Update: | 2024-12-16 |
Language: | PHP |
License: | MIT |
Last Refreshed: | 2024-12-18 03:02:02 |
Package Statistics | |
---|---|
Total Downloads: | 62 |
Monthly Downloads: | 2 |
Daily Downloads: | 0 |
Total Stars: | 1 |
Total Watchers: | 1 |
Total Forks: | 0 |
Total Open Issues: | 0 |
Require the package via composer:
composer require fpicosm/sportmonks-football-api
Update your .env
file adding:
SPORTMONKS_TOKEN=#YOUR_API_TOKEN#
SPORTMONKS_TIMEZONE=#YOUR_TIMEZONE#
SPORTMONKS_TIMEZONE
is optional. If not included, it is used the APP_TIMEZONE
value.
Register the ServiceProvider in config/app.php
, inside the providers
section:
Sportmonks\FootballApi\FootballApiServiceProvider::class,
Publish the config file
php artisan vendor:publish --provider="Sportmonks\FootballApi\FootballApiServiceProvider"
Create the folder config
at the root of the project (if not exists).
Create the file config/config_path.php
(if not exists) and paste:
<?php
if (!function_exists('config_path')) {
/**
* Get the configuration path.
*
* @param string $path
* @return string
*/
function config_path($path = '')
{
return app()->basePath() . '/config' . ($path ? "/$path" : $path);
}
}
Create the file config/football-api.php
and paste:
<?php
return [
'token' => env('SPORTMONKS_TOKEN'),
'timezone' => env('SPORTMONKS_TIMEZONE') ?: env('APP_TIMEZONE'),
];
Add the config files in bootstrap/app.php
, inside the Register Config Files
section:
$app->configure('config_path');
$app->configure('football-api');
Add the ServiceProvider in bootstrap/app.php
, inside the Register Service Providers
section:
$app->register(Sportmonks\FootballApi\FootballApiServiceProvider::class);
Uncomment the line $app->withFacades();
in bootstrap/app.php
When needed, add the dependency:
use Sportmonks\FootballApi\FootballApi;
Then, you can call to FootballApi::endpoint()->method($params)
:
To include relations in response, use the include
method. Example:
FootballApi::continents()->include('countries')->all();
You can pass an array, or a comma separated string:
FootballApi::countries()->include('leagues,continent')->all();
FootballApi::countries()->include(['leagues', 'continent'])->all();
If you want nested includes, use a single-dimension array:
FootballApi::seasons()->include(['fixtures.stage', 'fixtures.round', 'fixtures.group'])->find($id);
To set the page number, use the page
method:
FootballApi::countries()->page(2)->all();
To set the page size, use the perPage
method:
FootballApi::countries()->perPage(150)->all();
The page size must be between 10
and 150
(default value is 100
).
Documentation here
FootballApi::bookmakers()->all(?$params);
Documentation here
FootballApi::bookmakers()->find($id, ?$params);
Documentation here
FootballApi::coaches()->find($id, ?$params);
Documentation here
FootballApi::continents()->all(?$params);
Documentation here
FootballApi::continents()->find($id, ?$params);
Documentation here
FootballApi::countries()->all(?$params);
Documentation here
FootballApi::countries()->find($id, ?$params);
Documentation here
FootballApi::countries($id)->leagues(?$params);
Documentation here
FootballApi::countries($id)->players(?$params);
Documentation here
FootballApi::countries($id)->teams(?$params);
Documentation here
FootballApi::fixtures()->find($id, ?$params);
Documentation here
FootballApi::fixtures()->lastUpdated(?$params);
Documentation here
FootballApi::fixtures()->byDate($date, ?$params);
Documentation here
FootballApi::fixtures()->byDateRange($startDate, $endDate, ?$params);
Documentation here
FootballApi::fixtures()->multiple($list, ?$params);
The $list
could be an array [1, 2]
or a comma separated string 1,2
Documentation here
FootballApi::fixtures()->deleted(?$params);
Documentation here
FootballApi::fixtures($id)->bookmakers(?$params);
Documentation here
FootballApi::fixtures($id)->commentaries(?$params);
Documentation here
FootballApi::fixtures($id)->highlights(?$params);
Documentation here
FootballApi::fixtures($id)->tvStations(?$params);
Documentation here
FootballApi::leagues()->all(?$params);
Documentation here
FootballApi::leagues()->find($id, ?$params);
Documentation here
FootballApi::leagues()->search($name, ?$params);
Documentation here
FootballApi::livescores()->all(?$params);
Documentation here
FootballApi::livescores()->playing(?$params);
Documentation here
FootballApi::markets()->all(?$params);
Documentation here
FootballApi::markets()->find($id, ?$params);
Documentation here
FootballApi::markets($id)->fixtures(?$params);
Documentation here
FootballApi::news()->all(?$params);
Documentation here
FootballApi::news()->upcoming(?$params);
Documentation here
FootballApi::players()->find($id, ?$params);
Documentation here
FootballApi::players()->search($name, ?$params);
Documentation here
FootballApi::rounds()->find($id, ?$params);
Documentation here
FootballApi::rounds($id)->standings($seasonId, ?$params);
Documentation here
FootballApi::seasons()->all(?$params);
Documentation here
FootballApi::seasons()->find($id, ?$params);
Documentation here
FootballApi::seasons($id)->news(?$params);
Documentation here
FootballApi::seasons($id)->rounds(?$params);
Documentation here
FootballApi::seasons($id)->squad($teamId, ?$params);
Documentation here
FootballApi::seasons($id)->stages(?$params);
Documentation here
FootballApi::seasons($id)->standings(false, ?$params);
Documentation here
FootballApi::seasons($id)->standings(true, ?$params);
Documentation here
FootballApi::seasons($id)->standingsByDate($date, ?$params);
Documentation here
FootballApi::seasons($id)->standingsCorrection(?$params);
Documentation here
FootballApi::seasons($id)->teams(?$params);
Documentation here
FootballApi::seasons($id)->topscorers(false, ?$params);
Documentation here
FootballApi::seasons($id)->topscorers(true, ?$params);
Documentation here
FootballApi::seasons($id)->venues(?$params);
Documentation here
FootballApi::stages()->find($id, ?$params);
Documentation here
FootballApi::teams()->find($id, ?$params);
Documentation here
FootballApi::teams()->search($name, ?$params);
Documentation here
FootballApi::teams($id)->leagues(true, ?$params);
Documentation here
FootballApi::teams($id)->leagues(false, ?$params);
Documentation here
FootballApi::teams($id)->fixturesByDateRange($startDate, $endDate, ?$params);
Documentation here
FootballApi::teams($id)->headToHead($rivalId, ?$params);
Documentation here
FootballApi::teams($id)->rivals(?$params);
Documentation here
FootballApi::teams($id)->squad($seasonId, ?$params);
Documentation here
FootballApi::venues()->find($id, ?$params);