schoppax / php-sleeper-api
Sleeper API PHP library for consuming fantasy content
v1.2.0
2021-11-28 14:21 UTC
Requires
- php: >=7.3
- guzzlehttp/guzzle: ^7.0
Requires (Dev)
- php-coveralls/php-coveralls: ^2.4
- phpunit/phpunit: ^9.5
This package is auto-updated.
Last update: 2025-04-07 01:02:26 UTC
README
Sleeper API PHP library for consuming fantasy content from official read-only Sleeper HTTP API
Installation
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.*", }
Usage
use SchoppAx\Sleeper\SleeperClient; $client = new SleeperClient();
Examples
League
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) { }
User
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) { }
Implementation status
Sleeper Class | Status |
---|---|
Avatars | 100% |
Drafts | 100% |
Leagues | 100% |
Players | 100% |
Users | 100% |