Sleeper API PHP library for consuming fantasy content from official read-only Sleeper HTTP API
If you're using Composer to manage dependencies, you can run the following command:
$ composer require schoppax/php-sleeper-api
or add the following to your composer.json file:
"require": {
"schoppax/php-sleeper-api": "1.*",
}
use SchoppAx\Sleeper\SleeperClient;
$client = new SleeperClient();
Get a specific league by id:
try {
$league = $client->leagues()->find('289646328504385536');
echo $league['league_id'];
echo $league['name'];
echo $league['season'];
echo $league['roster_positions'];
} catch(BadMethodCallException $be) {
} catch(Exception $e) {
}
Get the user object by either providing the username or user_id:
try {
$user = $client->users()->find('2ksports');
echo $user['user_id'];
echo $user['username'];
echo $user['display_name'];
echo $user['avatar'];
} catch(BadMethodCallException $be) {
} catch(Exception $e) {
}
Sleeper Class | Status |
---|---|
Avatars | 100% |
Drafts | 100% |
Leagues | 100% |
Players | 100% |
Users | 100% |