Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .python-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.13
20 changes: 20 additions & 0 deletions .zed/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// Folder-specific settings
//
// For a full list of overridable settings, and general information on folder-specific settings,
// see the documentation: https://zed.dev/docs/configuring-zed#folder-specific-settings
{
"lsp": {
"pyright": {
"settings": {
"python.analysis": {
"diagnosticMode": "workspace",
"typeCheckingMode": "strict"
},
"python": {
"pythonPath": "/Users/benclarke/miniforge3/envs/PLFixturesAPI/bin/python3.12"
}
}
}
}
}
}
12 changes: 0 additions & 12 deletions Pipfile

This file was deleted.

57 changes: 0 additions & 57 deletions Pipfile.lock

This file was deleted.

204 changes: 192 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,195 @@
# Premier League Fixtures API
This API will be designed to feed *up to date* fixture details to a webpage and Android/IOS app. I will keep the website and apps in different repos to keep maintainence easy

It will be built using:
- OpenFaaS as the provider
- MongoDB as the database
- Python as the main language

It will be built over time and I will update the below checklist according to the progress being made and the newer additions I think up.
- [ ] Populate MongoDB with per-team fixture information :thinking:
- Automating it obviously

This API provides up-to-date Premier League fixture details, gameweek information, and standings. It uses the free Fantasy Premier League API as the data source.

## Features

- **Full team schedules**: Get all fixtures for any Premier League team
- **Next game lookup**: Find the next upcoming game for a team
- **Gameweek information**: Get fixtures for specific gameweeks
- **League standings**: Calculate and display current league standings
- **Modern Python**: Built with Python 3.13, type hints, and best practices

## Technology Stack

- **Python 3.13**: Latest Python version
- **Fantasy Premier League API**: Free, no API key required
- **Pydantic**: Data validation and models
- **Requests**: HTTP client for API calls
- **Python-dateutil**: Advanced date/time handling

## Installation

1. Ensure you have Python 3.13 installed
2. Install the package in development mode:
```bash
pip install -e .
```

This will install the `fplapi` command-line tool and all dependencies.

Alternatively, you can install dependencies only:
```bash
pip install -r requirements.txt
```

## Project Structure

```
PLfixturesAPI/
├── utils/
│ ├── fpl_api.py # FPL API client
│ ├── models.py # Data models (Pydantic)
│ ├── fullSchedule.py # Get full team schedule
│ ├── nextGame.py # Get next game for a team
│ ├── gameweek.py # Gameweek utilities
│ └── standings.py # League standings
├── requirements.txt # Python dependencies
├── pyrightconfig.json # Type checking configuration
└── README.md # This file
```

## Usage Examples

### Command Line Interface (CLI)

After installation, use the `fplapi` command:

#### Get Next Game for a Team

```bash
fplapi nextGame "Man Utd"
fplapi nextGame Arsenal
fplapi next "Manchester United"
```

#### Get Full Schedule for a Team

```bash
fplapi fullSchedule Arsenal
fplapi schedule "Manchester United"
fplapi fullSchedule liverpool
```

#### Get Gameweek Information

```bash
# Show current gameweek fixtures (default)
fplapi gameweek

# Show fixtures for specific gameweek
fplapi gameweek --gameweek 5

# Show current gameweek number only
fplapi gameweek --current

# List all gameweeks in the season
fplapi gameweek --list
```

#### Get League Standings

```bash
# Show full league table
fplapi standings

# Get position for specific team
fplapi standings --team Arsenal
```

#### List Available Teams

```bash
fplapi nextGame --list-teams
fplapi fullSchedule --list-teams
```

All commands support `-v` or `--verbose` for detailed logging.

### Alternative: Python Module Usage

You can also use the modules directly:


### Python API Usage

You can also import and use the functions programmatically:

```python
from utils.fullSchedule import print_team_schedule
from utils.nextGame import print_next_game
from utils.gameweek import print_gameweek_fixtures, get_current_gameweek_number
from utils.standings import print_standings

# Get full schedule
print_team_schedule("Arsenal")

# Get next game
print_next_game("Manchester United")

# Get gameweek fixtures
print_gameweek_fixtures(5)

# Get current gameweek number
current_gw = get_current_gameweek_number()
print(f"Current gameweek: {current_gw}")

# Get standings
print_standings()
```

### Programmatic Usage

```python
from utils.fpl_api import get_client
from utils.models import MatchResult

client = get_client()

# Get all teams
teams = client.get_teams()
for team in teams:
print(f"{team.id}: {team.name}")

# Get fixtures for a specific gameweek
fixtures = client.get_fixtures(gameweek=1)

# Get fixtures for a team
team_fixtures = client.get_fixtures_for_team_by_name("Liverpool")
```

## API Endpoints Used

The project uses the following free Fantasy Premier League API endpoints:

- `https://fantasy.premierleague.com/api/bootstrap-static/` - Teams, gameweeks, season info
- `https://fantasy.premierleague.com/api/fixtures/` - All fixtures
- `https://fantasy.premierleague.com/api/fixtures/?event={gameweek}` - Specific gameweek fixtures

## Data Models

The project uses Pydantic models for type safety and validation:

- `Team`: Team information
- `Fixture`: Match fixture data
- `Gameweek`: Gameweek information
- `MatchResult`: Formatted match result for display

## Future Enhancements

- [ ] Populate MongoDB with per-team fixture information
- Automating it obviously
- [ ] Clean up returned data into a per-team basis in MongoDB styling
- [ ] Write script to push gathered information to MongoDB
- [ ] Setup CI workflow for data comparison :partying_face:
- [ ] Choose a provider
- [ ] Setup CI workflow for data comparison
- [ ] Choose a provider
- [ ] Add OpenFaaS deployment configuration
- [ ] Add caching layer for improved performance
- [ ] Add unit tests

## Notes

- The FPL API is free and doesn't require authentication
- API responses are cached for 5 minutes by default to reduce API calls
- Team names are matched case-insensitively and support partial matches
- All date/time handling is timezone-aware
Loading