Skip to content

Commit bfdf593

Browse files
committed
Add examples and implementation status
1 parent 279268c commit bfdf593

File tree

1 file changed

+51
-16
lines changed

1 file changed

+51
-16
lines changed

README.md

Lines changed: 51 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,80 @@
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+
===================
53

64
[![Build Status](https://www.travis-ci.org/SchoppAx/sleeper-api-php-lib.svg?branch=master)](https://www.travis-ci.org/SchoppAx/sleeper-api-php-lib)
75
[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/SchoppAx/sleeper-api-php-lib/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/SchoppAx/sleeper-api-php-lib/?branch=master)
86
[![Coverage Status](https://coveralls.io/repos/github/SchoppAx/sleeper-api-php-lib/badge.svg?branch=master)](https://coveralls.io/github/SchoppAx/sleeper-api-php-lib?branch=master)
7+
8+
[![PHP from Packagist](https://poser.pugx.org/schoppax/sleeper-api-php-lib/require/php)](https://packagist.org/packages/schoppax/sleeper-api-php-lib)
99
[![Latest Stable Version](https://poser.pugx.org/schoppax/sleeper-api-php-lib/v/stable)](https://packagist.org/packages/schoppax/sleeper-api-php-lib)
1010
[![Total Downloads](https://poser.pugx.org/schoppax/sleeper-api-php-lib/downloads)](https://packagist.org/packages/schoppax/sleeper-api-php-lib)
11-
[![PHP from Packagist](https://poser.pugx.org/schoppax/sleeper-api-php-lib/require/php)](https://packagist.org/packages/schoppax/sleeper-api-php-lib)
1211
[![License](https://poser.pugx.org/schoppax/sleeper-api-php-lib/license.png)](https://packagist.org/packages/schoppax/sleeper-api-php-lib)
1312

13+
Sleeper API PHP library for consuming fantasy content from [official read-only Sleeper HTTP API](https://docs.sleeper.app/)
1414

15-
## Install
15+
# Installation
1616

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:
1818

1919
```sh
20-
composer require schoppax/sleeper-api-php-lib
20+
$ composer require schoppax/sleeper-api-php-lib
2121
```
2222

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+
```
2829

29-
# Example
30+
# Usage
3031

3132
``` php
32-
3333
use SchoppAx\Sleeper\SleeperClient;
3434

3535
$client = new SleeperClient();
36+
```
37+
38+
## Examples
3639

40+
### League
41+
Get a specific league by id:
42+
``` php
3743
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'];
3949
} catch(BadMethodCallException $be) {
4050

4151
} catch(Exception $e) {
4252

4353
}
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) {
4466

67+
} catch(Exception $e) {
68+
69+
}
4570
```
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

Comments
 (0)