create account

Python wrapper for the Fantasy Premier League API by amosbastian

View this thread on: hive.blogpeakd.comecency.com
· @amosbastian · (edited)
$127.19
Python wrapper for the Fantasy Premier League API
![fpl-python.png](https://res.cloudinary.com/hpiynhbhq/image/upload/v1515687734/tiq5siblff0yfqp7zgxa.png)

I was browsing https://utopian.io/ earlier in the week and came across a great post by @emrebeyler where he [showcased his Python wrapper for the Utopian API](https://steemit.com/utopian-io/@emrebeyler/python-client-of-utopian-api) and this inspired me to  make one for the Fantasy Premier League API!

The Fantasy Premier League is a game, with more than five million users,  in which users assemble their fantasy team consisting of real footballers and score points based on those players' performances in real life. The game is also huge on Steemit, with @acidyo and @arsenal49 doing great work!

Personally I do a lot of programming in Python with the Fantasy Premier League API and have made this wrapper to make my life and other people's lives easier when doing this, as there surprisingly isn't already one (at least from what I could find). I've never done something like this before, so I've used @emrebeyler's API as a huge example for my first, basic version `0.2.0`.

Installation
------------

```
pip install fpl
```

Usage
-----

```python
import fpl
fpl = fpl.FPL()
```

Documentation
-------------

* Get specific user
```python
print(fpl.user("3523615"))
```
* Get specific user's history
```python
print(fpl.user_history("3523615"))
```
* Get specific user's picks
```python
print(fpl.user_picks("3523615"))
```
* Get specific user's cup information
```python
print(fpl.user_cup("3523615"))
```
* Get specific user's transfers
```python
print(fpl.user_transfers("3523615"))
```
* Get specific user's entered leagues
```python
print(fpl.user_leagues_entered("3523615"))
```
* Get teams
```python
print(fpl.teams)
```
* Get players
```python
print(fpl.players)
```
* Get specific player
```python
print(fpl.player("123"))
```
* Get gameweeks
```python
print(fpl.gameweeks)
```
* Get specific gameweek
```python
print(fpl.gameweek(20))
```
* Get game settings
```python
print(fpl.game_settings)
```
* Get specific classic league information
```python
print(fpl.classic_league("743038"))
```
* Get specific h2h league information
```python
print(fpl.h2h_league("28281"))
```
Tests
-----

```
$ python test.py 
..............
----------------------------------------------------------------------
Ran 14 tests in 3.687s

OK
```
Improvements
------------

In the future I will be looking at other Python wrappers like `PRAW` and `python-twitter` and improving my own wrapper to (hopefully) be of a similar quality as those two.




<br /><hr/><em>Posted on <a href="https://utopian.io/utopian-io/@amosbastian/python-wrapper-for-the-fantasy-premier-league-api">Utopian.io -  Rewarding Open Source Contributors</a></em><hr/>
👍  , , , , , , , , , , , , , , , , , , , , , , ,
properties (23)
authoramosbastian
permlinkpython-wrapper-for-the-fantasy-premier-league-api
categoryutopian-io
json_metadata{"community":"utopian","app":"utopian/1.0.0","format":"markdown","repository":{"id":116973478,"name":"python-fpl","full_name":"amosbastian/python-fpl","html_url":"https://github.com/amosbastian/python-fpl","fork":false,"owner":{"login":"amosbastian"}},"pullRequests":[],"platform":"github","type":"development","tags":["utopian-io","python","steemdev","programming","sfpl"],"users":["emrebeyler","acidyo","arsenal49"],"links":["https://utopian.io/","https://steemit.com/utopian-io/@emrebeyler/python-client-of-utopian-api","https://utopian.io/utopian-io/@amosbastian/python-wrapper-for-the-fantasy-premier-league-api"],"image":["https://res.cloudinary.com/hpiynhbhq/image/upload/v1515687734/tiq5siblff0yfqp7zgxa.png"],"moderator":{"account":"ms10398","reviewed":true,"pending":false,"flagged":false}}
created2018-01-11 16:20:09
last_update2018-01-13 12:20:30
depth0
children6
last_payout2018-01-18 16:20:09
cashout_time1969-12-31 23:59:59
total_payout_value88.728 HBD
curator_payout_value38.463 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length2,743
author_reputation174,473,586,900,705
root_title"Python wrapper for the Fantasy Premier League API"
beneficiaries
0.
accountutopian.pay
weight2,500
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id28,792,286
net_rshares19,731,028,515,673
author_curate_reward""
vote details (24)
@ms10398 ·
Thank you for the contribution. It has been approved.

You can contact us on [Discord](https://discord.gg/UCvqCsx).
**[[utopian-moderator]](https://utopian.io/moderators)**
👍  
properties (23)
authorms10398
permlinkre-amosbastian-python-wrapper-for-the-fantasy-premier-league-api-20180112t115002915z
categoryutopian-io
json_metadata{"tags":["utopian-io"],"community":"utopian","app":"utopian/1.0.0"}
created2018-01-12 11:50:03
last_update2018-01-12 11:50:03
depth1
children1
last_payout2018-01-19 11:50:06
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length172
author_reputation27,572,487,973,390
root_title"Python wrapper for the Fantasy Premier League API"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id28,985,812
net_rshares1,753,535,568
author_curate_reward""
vote details (1)
@amosbastian ·
Thanks!
properties (22)
authoramosbastian
permlinkre-ms10398-re-amosbastian-python-wrapper-for-the-fantasy-premier-league-api-20180112t140332290z
categoryutopian-io
json_metadata{"tags":["utopian-io"],"app":"steemit/0.1"}
created2018-01-12 14:03:30
last_update2018-01-12 14:03:30
depth2
children0
last_payout2018-01-19 14:03:30
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length7
author_reputation174,473,586,900,705
root_title"Python wrapper for the Fantasy Premier League API"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id29,010,936
net_rshares0
@nilesh.katuwal ·
Great
properties (22)
authornilesh.katuwal
permlinkre-amosbastian-python-wrapper-for-the-fantasy-premier-league-api-20180114t105942532z
categoryutopian-io
json_metadata{"tags":["utopian-io"],"app":"steemit/0.1"}
created2018-01-14 11:00:36
last_update2018-01-14 11:00:36
depth1
children0
last_payout2018-01-21 11:00:36
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length5
author_reputation115,572,923,739
root_title"Python wrapper for the Fantasy Premier League API"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id29,432,519
net_rshares0
@utopian-io ·
### Hey @amosbastian I am @utopian-io. I have just upvoted you!
#### Achievements
- You have less than 500 followers. Just gave you a gift to help you succeed!
- Seems like you contribute quite often. AMAZING!
#### Community-Driven Witness!
I am the first and only Steem Community-Driven Witness. <a href="https://discord.gg/zTrEMqB">Participate on Discord</a>. Lets GROW TOGETHER!
- <a href="https://v2.steemconnect.com/sign/account-witness-vote?witness=utopian-io&approve=1">Vote for my Witness With SteemConnect</a>
- <a href="https://v2.steemconnect.com/sign/account-witness-proxy?proxy=utopian-io&approve=1">Proxy vote to Utopian Witness with SteemConnect</a>
- Or vote/proxy on <a href="https://steemit.com/~witnesses">Steemit Witnesses</a>

[![mooncryption-utopian-witness-gif](https://steemitimages.com/DQmYPUuQRptAqNBCQRwQjKWAqWU3zJkL3RXVUtEKVury8up/mooncryption-s-utopian-io-witness-gif.gif)](https://steemit.com/~witnesses)

**Up-vote this comment to grow my power and help Open Source contributions like this one. Want to chat? Join me on Discord https://discord.gg/Pc8HG9x**
👍  
properties (23)
authorutopian-io
permlinkre-amosbastian-python-wrapper-for-the-fantasy-premier-league-api-20180113t165318901z
categoryutopian-io
json_metadata{"tags":["utopian-io"],"community":"utopian","app":"utopian/1.0.0"}
created2018-01-13 16:53:18
last_update2018-01-13 16:53:18
depth1
children0
last_payout2018-01-20 16:53:18
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length1,087
author_reputation152,955,367,999,756
root_title"Python wrapper for the Fantasy Premier League API"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id29,269,344
net_rshares1,750,471,259
author_curate_reward""
vote details (1)
@xvz ·
Nice work
properties (22)
authorxvz
permlinkre-amosbastian-python-wrapper-for-the-fantasy-premier-league-api-20180113t171906554z
categoryutopian-io
json_metadata{"tags":["utopian-io"],"app":"steemit/0.1"}
created2018-01-13 17:19:06
last_update2018-01-13 17:19:06
depth1
children1
last_payout2018-01-20 17:19:06
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length9
author_reputation313,641,425,957
root_title"Python wrapper for the Fantasy Premier League API"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id29,274,546
net_rshares0
@amosbastian ·
Thanks!
properties (22)
authoramosbastian
permlinkre-xvz-re-amosbastian-python-wrapper-for-the-fantasy-premier-league-api-20180113t172152076z
categoryutopian-io
json_metadata{"tags":["utopian-io"],"app":"steemit/0.1"}
created2018-01-13 17:21:54
last_update2018-01-13 17:21:54
depth2
children0
last_payout2018-01-20 17:21:54
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length7
author_reputation174,473,586,900,705
root_title"Python wrapper for the Fantasy Premier League API"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id29,275,087
net_rshares0