GithubHelp home page GithubHelp logo

github-rest-api's Introduction

GitHub API - Repositories and Branches by User's Login

Description

This Java application (built using Java 17 and Spring Boot 3) utilizes the GitHub API to search for repositories and their branches based on the provided user login in the URL. The API response will contain a list of repositories belonging to the specified user along with their branches and the last SHA for each. Only repositories that are not forks will be included in the response.

Run the application

Docker

docker run -p 8080:8080 ghcr.io/shair13/github-rest-api:v1

Application will run at

localhost:8080/json/Shair13

for json format or

localhost:8080/Shair13

for HTML format

Clone

Steps:

  1. Clone the Repository: Clone this repository to your local machine using the following command in your terminal:

    HTTPS

    git clone https://github.com/Shair13/GitHub-rest-api.git
    

    SSH

     git clone [email protected]:Shair13/GitHub-rest-api.git
    

    Optionally, to increase the number of possible requests after cloning the application, you can add your GitHub token to the application.properties file.

    token

  2. Build the Application: Navigate to the repository folder and use the Maven command to build the application:

    mvn package
  3. Run the Application: After building the application, navigate to the target folder and run the application using the following command:

    cd target
    java -jar GitHub-rest-api-0.0.1-SNAPSHOT.jar
  4. Access the Application: Once the application is running, you can access the API using the URLs specified below:

The API is divided into 2 endpoints:

Endpoint 1: JSON Format Data

URL: http://localhost:8080/json/{login}

Replace {login} with the GitHub username you want to search for.

Please use an application such as Postman to set the appropriate header:

  • Key: Accept
  • Value: application/json.

JSON-format

Otherwise, you will receive an error.

JSON-format

The same issue will occur when using a web browser.

JSON-format

In case the user login is not found, there will be an error response in JSON format.

JSON-format

It's also possible that your token may expire or you do not have a token. In those cases, you will receive an error.

JSON-format

Endpoint 2: HTML Format Data

URL: http://localhost:8080/{login}

Replace {login} with the GitHub username you want to search for.

This endpoint can be opened in any web browser.

HTML-format

In case the user login is not found, there will be an error response in JSON format.

User-not-found

Expired tokens may cause issues. In those cases, you will receive an error.

error-while-reaching

Contact

If you have any questions, feedback, or issues, feel free to reach out to me.

github-rest-api's People

Contributors

shair13 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.