|
1 | | -# sleeper-api-php-lib |
2 | | -======================== |
3 | | - |
4 | | -Sleeper API PHP library for consuming fantasy content from [official read-only Sleeper HTTP API](https://docs.sleeper.app/) |
| 1 | +sleeper-api-php-lib |
| 2 | +=================== |
5 | 3 |
|
6 | 4 | [](https://www.travis-ci.org/SchoppAx/sleeper-api-php-lib) |
7 | 5 | [](https://scrutinizer-ci.com/g/SchoppAx/sleeper-api-php-lib/?branch=master) |
8 | 6 | [](https://coveralls.io/github/SchoppAx/sleeper-api-php-lib?branch=master) |
| 7 | + |
| 8 | +[](https://packagist.org/packages/schoppax/sleeper-api-php-lib) |
9 | 9 | [](https://packagist.org/packages/schoppax/sleeper-api-php-lib) |
10 | 10 | [](https://packagist.org/packages/schoppax/sleeper-api-php-lib) |
11 | | -[](https://packagist.org/packages/schoppax/sleeper-api-php-lib) |
12 | 11 | [](https://packagist.org/packages/schoppax/sleeper-api-php-lib) |
13 | 12 |
|
| 13 | +Sleeper API PHP library for consuming fantasy content from [official read-only Sleeper HTTP API](https://docs.sleeper.app/) |
14 | 14 |
|
15 | | -## Install |
| 15 | +# Installation |
16 | 16 |
|
17 | | -* If you're using Composer to manage dependencies, you can use |
| 17 | +If you're using Composer to manage dependencies, you can run the following command: |
18 | 18 |
|
19 | 19 | ```sh |
20 | | -composer require schoppax/sleeper-api-php-lib |
| 20 | +$ composer require schoppax/sleeper-api-php-lib |
21 | 21 | ``` |
22 | 22 |
|
23 | | -or add to your composer.json file: |
24 | | - |
25 | | - "require": { |
26 | | - "schoppax/sleeper-api-php-lib": "1.*", |
27 | | - } |
| 23 | +or add the following to your composer.json file: |
| 24 | +```json |
| 25 | +"require": { |
| 26 | + "schoppax/sleeper-api-php-lib": "1.*", |
| 27 | +} |
| 28 | +``` |
28 | 29 |
|
29 | | -# Example |
| 30 | +# Usage |
30 | 31 |
|
31 | 32 | ``` php |
32 | | - |
33 | 33 | use SchoppAx\Sleeper\SleeperClient; |
34 | 34 |
|
35 | 35 | $client = new SleeperClient(); |
| 36 | +``` |
| 37 | + |
| 38 | +## Examples |
36 | 39 |
|
| 40 | +### League |
| 41 | +Get a specific league by id: |
| 42 | +``` php |
37 | 43 | try { |
38 | | - $league = (object) $client->leagues()->find('289646328504385536'); |
| 44 | + $league = $client->leagues()->find('289646328504385536'); |
| 45 | + echo $league['league_id']; |
| 46 | + echo $league['name']; |
| 47 | + echo $league['season']; |
| 48 | + echo $league['roster_positions']; |
39 | 49 | } catch(BadMethodCallException $be) { |
40 | 50 |
|
41 | 51 | } catch(Exception $e) { |
42 | 52 |
|
43 | 53 | } |
| 54 | +``` |
| 55 | + |
| 56 | +### User |
| 57 | +Get the user object by either providing the username or user_id: |
| 58 | +``` php |
| 59 | +try { |
| 60 | + $user = $client->users()->find('2ksports'); |
| 61 | + echo $user['user_id']; |
| 62 | + echo $user['username']; |
| 63 | + echo $user['display_name']; |
| 64 | + echo $user['avatar']; |
| 65 | +} catch(BadMethodCallException $be) { |
44 | 66 |
|
| 67 | +} catch(Exception $e) { |
| 68 | + |
| 69 | +} |
45 | 70 | ``` |
| 71 | + |
| 72 | +## Implementation status |
| 73 | + |
| 74 | +| Sleeper Class | Status | |
| 75 | +| ------------- | :-----:| |
| 76 | +| Avatars | 100% | |
| 77 | +| Drafts | 100% | |
| 78 | +| Leagues | 78% | |
| 79 | +| Players | 100% | |
| 80 | +| Users | 100% | |
0 commit comments