Introducing football - A Python wrapper for the football-data API
I've created a Python wrapper for the football-data API called football
, which provides an easy way to get the information about the following resources in your Python programs
Repository
https://github.com/amosbastian/football
Why did I create it?
The Premier League has just ended today, and over the Summer I want to work on my Nutmega project before the next season starts. For this project I need some information that isn't available via the Fantasy Premier League API, so I tried looking for another Python package that would provide this instead. Unfortunately all I found was pyfootball, which hasn't been updated in 2 years and doesn't include filtering and soccer-cli, which isn't really a Python package, but a CLI, and hasn't been updated for 8 months either. So this left me with one option: create my own Python package!
Installing
The recommended way to install football
is with pip
pip install football
You can also use pip to install football
directly from GitHub
pip install git+https://github.com/amosbastian/football.git
or you can install the project in "editable" mode like so
git clone https://github.com/amosbastian/football.git
cd football
pip install -e .
Usage
Currently the way to use football
is to instantiate a Football
class using your API key (can also be used without), which can be requested here
from football import Football
football = Football("your_api_key")
manchester_united = football.team(66)
The following (sub) resources are available
Get all available competitions
# This year
competitions = football.competitions()
# Given year
competitions = football.competitions(2015)
Get all teams in the given competition
teams = football.teams()
Get the league table / current standings on the given competition
# Get the Premier League table
table = football.table("PL")
Get all fixtures of the given competition
# Get the fixtures of the Premier League
fixtures = football.competition_fixtures("PL")
Get all fixtures across competitions
fixtures = football.fixtures()
Get a single fixture
- Currently not working!
Get all fixtures of a given team
# Get Manchester United's fixtures
fixtures = football.team_fixtures(66)
Get a team
# Get Manchester United
team = football.team(66)
Get all players of the given team
# Get Manchester United's players
team = football.players(66)
Tests & linting
I have added 10 unit tests to make sure all functions return what is expected - you can run this with python tests/test_football.py
..........
----------------------------------------------------------------------
Ran 10 tests in 5.090s
OK
and everything is linted using pylint
and PEP8 compliant.
Contributing
Please read CONTRIBUTING.md for details on how to contribute to football
and what the best way to go about this is!
Roadmap
- Create classes for each (sub) resource
- Add helper functions
- Improve the use of filters
- Add utilities for team/league/competition codes, names etc.
- And more...
Commits
All commits are relevant to this contribution! For future updates I will be linking a PR instead.
GitHub Account
https://github.com/amosbastian
If you have any questions please don't hesitate to ask them below! Also any tips or help is very much appreciated!
Thank you for your contribution.
Link to the Answers of the Questionnaire -
Click here
Need help? Write a ticket on https://support.utopian.io/.
Chat with us on Discord.
[utopian-moderator]
Hey @amosbastian
Thanks for contributing on Utopian.
We’re already looking forward to your next contribution!
Contributing on Utopian
Learn how to contribute on our website or by watching this tutorial on Youtube.
Want to chat? Join us on Discord https://discord.gg/h52nFrV.
Vote for Utopian Witness!
It's great to develop apps that fit your hobbies (Football),
Congratulations :)