A simple REST API that fetches a list of a specified user's public, non-forked GitHub repositories, along with branch information for each.
This application provides a single REST endpoint that interacts with the public GitHub API. When given a GitHub username, the service retrieves a list of their repositories that are not forks. For each repository, the API also appends a list of its branches, including the branch name and the SHA of its latest commit.
- Java 21 or newer
- GitHub Personal Access Token for more requestes
To avoid hitting the GitHub API's strict rate limits for unauthenticated requests, the application accepts a Personal Access Token.
You can configure the token in one of the following ways:
-
Environment Variable (Recommended): Set an environment variable named
GIT_API_KEYwith your token value.export GIT_API_KEY="ghp_YourPersonalAccessToken"
-
Properties File: Add the following line to the
src/main/resources/application.propertiesandtest/main/resources/application-test.properties:passwd.gittoken=ghp_YourPersonalAccessToken -
Additional step for caching If you want version which contains caching, switch to branch feature/caching and enter settings you want for caching.
spring.cache.caffeine.spec=maximumSize=500,expireAfterWrite=1m
- Clone the repository
git clone https://github.com/PsaiduPL/Atiperia_task.git cd Atiperia_task
Main Version is on branch main.
- Run the application using the Maven wrapper
The application will start on the default port
./mvnw spring-boot:run
8080.
Retrieves a list of non-forked repositories and their branches for a given GitHub user.
- URL:
/api/{nickname} - Method:
GET - URL Params:
| Parameter | Type | Description |
|---|---|---|
nickname |
String |
Required. The GitHub username. |
curl http://localhost:8080/api/ExamplReturns a JSON array of repository objects.
[
{
"login": "Exampl",
"repositoryName": "ExamCI",
"branches": [
{
"name": "master",
"sha": "3891d715ad0f4903d1eab5877e05a721fe2553a7"
}
]
}
]-
Code:
404 Not Found
Reason: The user with the providednicknamedoes not exist on GitHub.{ "status": 404, "message": "User doesn't exists" } -
Code:
500 Internal Server Error
Reason: An unexpected server-side error occurred while processing the request. -
Code:
503 Service Unavailable
Reason: The service is temporarily unavailable, likely due to issues communicating with the GitHub API.
- **Spring Boot ** - Core framework
- Java 21 - Programming language
- Maven - Dependency management and build tool
- Spring Web (RestTemplate) - For communicating with the external REST API