https://github.com/mahmoodhamdi/esports-flask
A comprehensive Flask REST API providing real-time data for the Esports World Cup, including tournaments, teams, players, matches, and news. Features advanced search, live data scraping, and a full admin interface.
https://github.com/mahmoodhamdi/esports-flask
api beautifulsoup4 cors cs2 data-scraping esports esports-api flask football liquipedia openapi python rest-api sqlite swagger valorant
Last synced: 3 months ago
JSON representation
A comprehensive Flask REST API providing real-time data for the Esports World Cup, including tournaments, teams, players, matches, and news. Features advanced search, live data scraping, and a full admin interface.
- Host: GitHub
- URL: https://github.com/mahmoodhamdi/esports-flask
- Owner: mahmoodhamdi
- Created: 2025-06-25T03:09:50.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2025-08-29T21:18:35.000Z (11 months ago)
- Last Synced: 2025-10-21T19:49:00.301Z (9 months ago)
- Topics: api, beautifulsoup4, cors, cs2, data-scraping, esports, esports-api, flask, football, liquipedia, openapi, python, rest-api, sqlite, swagger, valorant
- Language: Python
- Homepage: https://github.com/mahmoodhamdi/esports-flask
- Size: 4.06 MB
- Stars: 1
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: news.db
Awesome Lists containing this project
README
# ๐ฎ Esports World Cup API
A comprehensive Flask-based REST API for esports data, providing real-time information about tournaments, teams, players, matches, and news for the Esports World Cup and other major esports events.
## ๐ Features
- **๐ฐ News Management** - CRUD operations for esports news with image upload support
- **๐ Tournament Information** - Detailed data about EWC and other tournaments
- **๐ฅ Teams & Players** - Comprehensive player transfers, team rosters, and profiles
- **โ๏ธ Matches & Schedules** - Live and upcoming match data across multiple games
- **๐
Prize Distribution** - Prize pool information and distribution details
- **๐ Advanced Search** - Full-text and fuzzy search across all data types
- **๐ Rankings** - EWC club championship standings with weekly tracking
- **๐ Live Data Fetching** - Real-time data scraping from Liquipedia
- **๐ฑ Pagination & Filtering** - Efficient data retrieval with extensive filtering options
- **๐ Matches Dashboard** - Comprehensive match viewing interface
- **๐๏ธ Weekly Tracking** - Week-by-week EWC progress and statistics
## ๐ ๏ธ Technology Stack
- **Backend Framework**: Flask (Python)
- **Database**: SQLite with FTS5 for full-text search
- **API Documentation**: Flasgger/Swagger
- **CORS Support**: Flask-CORS
- **Data Scraping**: BeautifulSoup, Requests
- **Search**: FuzzyWuzzy for fuzzy search, SQLite FTS5 for full-text
- **Data Processing**: Pandas for data manipulation
- **Authentication**: (To be implemented based on requirements)
## ๐ฆ Installation & Setup
### Prerequisites
- Python 3.8+
- pip (Python package manager)
- Virtualenv (recommended)
### Installation Steps
1. **Clone the repository**
```bash
git clone https://github.com/mahmoodhamdi/esports-flask.git
cd esports-flask
```
2. **Create a virtual environment**
```bash
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
```
3. **Install dependencies**
```bash
pip install -r requirements.txt
```
4. **Initialize the database**
```bash
python -c "from app import create_app; app = create_app()"
```
5. **Run the application**
```bash
python run.py
```
The API will be available at `http://localhost:5000`
### Docker Installation (Alternative)
```bash
docker build -t esports-api .
docker run -p 5000:5000 esports-api
```
## ๐ API Documentation
Once the application is running, access the interactive Swagger documentation at:
`http://localhost:5000/apidocs`
## ๐๏ธ Project Structure
```
esports-flask/
โโโ app/
โ โโโ __init__.py # Application factory and setup
โ โโโ db.py # Database connection and initialization
โ โโโ enhanced_search.py # Advanced search functionality
โ โโโ ewc_info.py # EWC tournament information
โ โโโ ewc_rank.py # Club championship rankings
โ โโโ ewc_teams_players.py # Teams and players data
โ โโโ game_matches.py # Match data handling
โ โโโ fuzzy_search.py # Fuzzy search implementation
โ โโโ fts_search.py # Full-text search implementation
โ โโโ matches_mohamed.py # Match scraping functionality
โ โโโ news.py # News management
โ โโโ new_teams.py # Teams data handling
โ โโโ game_teams.py # Game teams management
โ โโโ game_teams_init_db.py # Database initialization for game teams
โโโ routes/ # API route handlers
โ โโโ news.py
โ โโโ games.py
โ โโโ prizes.py
โ โโโ info.py
โ โโโ player_transfers.py
โ โโโ ewc_rank_route.py
โ โโโ ewc_teams_players.py
โ โโโ team_information.py
โ โโโ player_information.py
โ โโโ search.py
โ โโโ search_extended.py
โ โโโ game_matches.py
โ โโโ game_teams.py
โ โโโ ewc_weeks.py
โโโ matches_dashborad/ # Matches dashboard functionality
โ โโโ reoute_matches_dashbord_test.py
โโโ static/ # Static files and uploads
โโโ requirements.txt # Python dependencies
โโโ README.md # Project documentation
```
## ๐ Complete API Endpoints
### News Management
- `GET /api/news` - Retrieve paginated news articles with filtering
- `POST /api/news` - Create a new news article
- `GET /api/news/{id}` - Get a specific news article
- `PUT /api/news/{id}` - Update a news article
- `DELETE /api/news/{id}` - Delete a news article
- `DELETE /api/news` - Delete all news articles
### Games Information
- `GET /api/games` - Get information about supported games
### Prize Distribution
- `GET /api/prizes` - Get prize pool information and distribution
### General Information
- `GET /api/info` - Get general EWC tournament information
### Player Transfers
- `GET /api/player-transfers` - Get player transfer information
### EWC Rankings
- `GET /api/ewc_rank` - Get club championship standings
### EWC Teams & Players
- `GET /api/ewc_teams_players` - Get team rosters and player data
### Team Information
- `GET /api/team_information` - Get detailed team profiles
### Player Information
- `GET /api/player_information` - Get detailed player profiles
### Search Functionality
- `GET /api/search` - Basic search across all data types
- `GET /api/extended/search` - Advanced search with filters
### Game Matches
- `GET /api/game_matches` - Get match data for specific games
- `GET /api/game_matches/{game}` - Get matches for a specific game
### Teams Data
- `GET /api/new_teams` - Get team information from JSON data
- `POST /api/new_teams` - Add new team data
- `GET /api/game_teams` - Get teams for specific games
### Matches Dashboard
- `GET /api/matches` - Get matches dashboard data with filtering
- `GET /api/matches/{game}` - Get matches for a specific game
### EWC Weeks
- `GET /api/weeks` - Get weekly EWC information and progress
### File Uploads
- `GET /uploads/{filename}` - Serve uploaded files
## ๐ง Configuration
The application can be configured through environment variables:
- `FLASK_ENV` - Environment (development/production)
- `FLASK_DEBUG` - Debug mode (0/1)
- `DATABASE_URL` - Database connection string
- `CORS_ORIGINS` - Allowed origins for CORS
- `HOST` - Host address to bind to (default: 0.0.0.0)
- `PORT` - Port to run on (default: 5000)
Example environment file (.env):
```env
FLASK_ENV=production
FLASK_DEBUG=0
DATABASE_URL=sqlite:///app.db
CORS_ORIGINS=*
HOST=0.0.0.0
PORT=5000
```
## ๐๏ธ Database Schema
The application uses SQLite with the following main tables:
- `news` - News articles with metadata
- `matches` - Match information across games
- `game_teams` - Team information for specific games
- `game_teams_fts` - Full-text search virtual table
## ๐ Search Features
### Full-Text Search
- Supports searching across team names, game names, and logo modes
- Uses SQLite FTS5 for efficient text searching
- Automatic synchronization with triggers
### Fuzzy Search
- Implemented using FuzzyWuzzy
- Handles typos and approximate matching
- Configurable similarity thresholds
### Extended Search
- Advanced filtering options
- Field-specific search capabilities
- Combined text and filter queries
## ๐ Data Sources
The API integrates with multiple data sources:
- **Liquipedia** - For live match data and tournament information
- **Local JSON files** - For team and game data
- **Manual input** - For news and custom content
## ๐ค Contributing
We welcome contributions! Please follow these steps:
1. Fork the repository
2. Create a feature branch (`git checkout -b feature/amazing-feature`)
3. Commit your changes (`git commit -m 'Add some amazing feature'`)
4. Push to the branch (`git push origin feature/amazing-feature`)
5. Open a Pull Request
### Development Guidelines
- Follow PEP 8 style guide for Python code
- Write tests for new functionality
- Update documentation for new features
- Use descriptive commit messages
## ๐งช Testing
Run the test suite with:
```bash
python -m pytest tests/ -v
```
Or run specific test files:
```bash
python -m pytest tests/test_news.py -v
```
## ๐ License
This project is licensed under the MIT License - see the LICENSE file for details.
## ๐ Troubleshooting
### Common Issues
1. **Database errors**: Try deleting the database file and reinitializing
2. **Missing dependencies**: Run `pip install -r requirements.txt`
3. **CORS issues**: Check the CORS_ORIGINS environment variable
4. **File upload issues**: Ensure the uploads directory exists and has proper permissions
### Getting Help
If you encounter issues not covered here, please:
1. Check the existing issues on GitHub
2. Create a new issue with detailed information
3. Include error logs and steps to reproduce
## ๐จโ๐ป Developer
**Mahmood Hamdi**
- Email: [hmdy7486@gmail.com](mailto:hmdy7486@gmail.com)
- WhatsApp: [+201019793768](https://wa.me/201019793768)
- GitHub: [https://github.com/mahmoodhamdi/](https://github.com/mahmoodhamdi/)
## ๐ Acknowledgments
- Liquipedia for providing comprehensive esports data
- Flask community for excellent documentation and resources
- All contributors who have helped improve this project
- The esports community for feedback and feature suggestions
---
**Note**: This API is actively maintained and updated regularly with new features and improvements. Check the GitHub repository for the latest updates and release notes.