Open In App

How to create a GitHub Profile Search using HTML CSS and JavaScript ?

Last Updated : 25 Jul, 2024
Comments
Improve
Suggest changes
Like Article
Like
Report

In this article, we will be developing an interactive GitHub Profile Search application using HTML, CSS, and JavaScript Language. In this application, there is a search bar where users can enter the username that they want to view. After entering the username, an API call is been triggered, and the details of the inputted user are returned to the user along with the repositories.

Final Output

Screenshot-2023-09-22-at-13-32-53-GeeksforGeeks-Github-Profile-Searcher

Prerequisites

Approach

  • Create the GitHub Profile Search layout and structure using HTML tags. We have used the <input> tag to take the input from the user.
  • The entire styling of the application is done through the CSS file. All the colors, card layout, alignment, and heading are managed through the CSS file.
  • In JavaScript code, we define the API URL and axioms script in the variables, and then we store the reference of HTML elements like the search bar and in variables.
  • The user-defined function named "userGetFunction" makes an API call by taking the username as the parameter and also catches the error in case of profile is not present.
  • Then repoGetFunction is used to fetch the repos of the user searched through the search bar.
  • All this information is displayed in the attractive card component using the function "userCard".
  • In the "repoCardFunction", the repositories which are fetched can be visited by clicking on the repo. We are fetching and displaying 5 repositories of the user in the card.

Example: This example describes the basic implementation of the Github Profile Search application using HTML, CSS, and Javascript.

HTML
<!--index.html-->
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8" />
    <meta name="viewport" 
          content="width=device-width,
                    initial-scale=1.0" />
    <link rel="stylesheet" href="style.css" />
    <title>
        GeeksforGeeks Github
    </title>
</head>

<body>
    <form class="inputForm" id="userInput">
        <h1>
            GeeksforGeeks Github
        </h1>
        <input type="text" 
        id="inputBox" 
        autocomplete="off" 
        placeholder="Search a Github User" />
    </form>
    <main id="main"></main>
    <script src="./script.js"></script>
</body>

</html>
CSS JavaScript

Output:


Next Article

Similar Reads