The League API is a Spring Boot application that allows you to import football league data from the football-data.org API into a MySQL database. The API provides endpoints to retrieve information about competitions, teams, players, and coaches.
- Java 11 or later
- MySQL database
- football-data.org API key (sign up here)
-
Clone the repository:
git clone https://github.com/yourusername/league-api.git cd league-api -
Set up the MySQL database. Create a database named
league_dband configure the database connection in theapplication.propertiesfile. -
(Pending - currently key hardcoded) Obtain a football-data.org API key and update the
application.propertiesfile with your API key:football-data.api-key=your-api-key -
Build and run the application:
./mvnw spring-boot:run
The application will be accessible at http://localhost:8080.
To import a league, use the importLeague endpoint by providing a leagueCode:
GET /api/importer/{leagueCode}This endpoint fetches competition details and teams from football-data.org and imports them into the MySQL database.
Retrieve players and coaches from teams participating in a given league:
GET /api/v1/players/{leagueCode}?teamName={teamName}leagueCode(required): Code of the league.teamName(optional): Name of the team to filter players.
Retrieve information about a specific team, optionally resolving members (players or coaches):
GET /api/v1/teams/{teamName}?resolveMembers={true|false}teamName(required): Name of the team.resolveMembers(optional): Set totrueto include player or coach information.
- If no players are available in team squads, only coaches are imported.
- Tests
- Docker
- Limit frequency to the requests performed with a free-token
The League API application is designed to manage and provide information about football leagues, teams, players, and coaches. The application utilizes a Spring Boot backend with a MySQL database to store and retrieve data.
Spring Boot is chosen as the primary framework for building the application due to its simplicity, convention over configuration, and comprehensive ecosystem. It provides robust support for building RESTful APIs and integrates seamlessly with various libraries.
MySQL is selected as the relational database management system to store structured data efficiently. It is widely used, stable, and has good community support. The relational nature of the data (teams, players, competitions) makes MySQL a suitable choice.
JPA is used for object-relational mapping, simplifying the interaction between Java objects and the database. This choice enhances data manipulation and persistence, allowing the application to work with entities like Team, Player, Competition, and Coach as Java objects.
Lombok is used to reduce boilerplate code in Java classes. With annotations like @Getter, @Setter, and @Builder, it enhances code readability and maintainability. This is especially beneficial in entities and DTOs where repetitive code can be minimized.
The project follows a modular structure, separating concerns into different packages. This promotes maintainability and readability. The controllers, services, models, and repositories are organized logically, making it easier to navigate and understand the codebase.
RESTful endpoints are created using Spring MVC to expose APIs for data manipulation and retrieval. This architectural style is chosen for its simplicity, statelessness, and compatibility with a wide range of clients.