You can use the Spring Boot Actuator
to get the details. It will not only provide the count for the API hits but also provide the duration, status response code any many more details and you can filter them as required.
You just need to add the following dependency in the pom file:
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
</dependencies>
Then try hitting the below URL:
http://localhost:8080/actuator/metrics/http.server.requests
In the response you will get the required details.
To get the details for the last X days
you could store the data in a file or database (based on your requirements) and then query the same to get the desired result.
Hope that helps.
More details can be found here