This API manages information about Dota 2 game matches, including match details and hero data. The API offers CRUD operations for two main entities: Hero and Match.
To set up the project locally using Docker and Docker Compose, follow these steps:
- Clone the repository to your local machine.
- Ensure Docker and Docker Compose are installed and running.
- Navigate to the project directory in your terminal.
- Run the following command to start the application and the required services defined in the docker-compose.yml file:
docker-compose up -d
- Wait for the containers to be built and started. The application and the associated MongoDB and Mongo Express services should now be running.
- Configure the database connection in the application properties file to connect to the MongoDB container.
- Build the project using Maven or Gradle.
- Run the application using the appropriate command.
The API offers various endpoints to interact with hero and match data. To access
the endpoints, you need to authenticate by providing a email and password to obtain a JWT
token from the next endpoint: /dota2matches/api/v1/auth/register
.
The information is obtained directly from the game. At the end of a match, fields appear to save the data into the database.
The hero information is extracted from the in-game heroes section. The hero's win rate is updated based on the information from the stored matches.
The API is secured with authentication and authorization using Spring Security and JWT (JSON Web Tokens). This ensures that only authenticated users with the proper access rights can interact with the endpoints.
To access the API endpoints, follow these steps:
- Register as a user by providing an email address and password.
- Send a POST request to the
/dota2matches/api/v1/auth/register
endpoint with the registration details. - Upon successful registration, a JWT token will be returned in the response.
- Include the JWT token in the Authorization header of subsequent requests to the protected endpoints.
- Set the header key as Authorization and the value as Bearer {your_token}.
- The API will validate the token and grant access to the requested resources based on the user's roles and permissions.
- Unauthorized users or those without the necessary permissions will receive a 403 Forbidden status code.
Please note that the API does not provide user management functionalities beyond registration.
The API documentation is available using OpenAPI and Swagger. It provides detailed information about each endpoint and their respective request and response structures. To access the API documentation, follow these steps:
- Ensure that the application is running locally or on a server.
- Open a web browser and navigate to the following URL:
http://localhost:8080/dota2matches/api/v1/swagger-ui/index.html
- The Swagger UI will be displayed, showcasing a list of all available endpoints and their descriptions.
- Explore the endpoints, their parameters, and example requests and responses.
- Use the documentation to understand the API's functionality and how to interact with it.
The API documentation serves as a valuable resource for developers to understand the available endpoints and their usage. It provides a convenient way to test the API directly from the browser and facilitates the integration of the API into other applications.