Create a GitHub Profile Search using HTML CSS and JavaScript (original) (raw)

Last Updated : 2 May, 2026

This project demonstrates how to build an interactive GitHub Profile Search application using HTML, CSS, and JavaScript, allowing users to fetch and view GitHub user data in real time. It helps in understanding API integration and dynamic UI updates.

Preview

project preview

**Prerequisites: HTML CSS JavaScript

Approach

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

HTML `

GeeksforGeeks Github

GeeksforGeeks Github

CSS

/* styles.css */ @import url( "https://fonts.googleapis.com/css2?family=Pacifico&display=swap");

} h1:hover { transform: scale(1.1); }

.inputForm input { width: 80%; margin: auto; margin-top: 20px; display: block; background-color: #f0e1c6; border: 2px solid #00a136; border-radius: 7px; color: #333; font-weight: bold; padding: 10px; } .inputForm input::placeholder { color: #666; font-weight: bold; } .inputForm input:focus { outline: none; border-color: #007bff; box-shadow: 0 5px 10px rgba(0, 0, 0, 0.2); } .card { max-width: 50%; background-color: rgb( 141, 240, 243 ); border-radius: 20px; box-shadow: 0 5px 10px rgba(0, 0, 0, 0.1); display: flex; padding: 2rem; margin: auto; } .avatar { border-radius: 50%; border: 4px solid #00a136; height: 150px; width: 150px; transition: transform 0.3s ease-in-out; } .avatar:hover { transform: scale(1.1); } .user-info { color: #333; margin-left: 2rem; padding: 1rem; background-color: rgba( 255, 255, 255, 0.9 ); border-radius: 10px; box-shadow: 0 0 10px rgba(0, 0, 0, 0.2); } .user-info h2 { margin-top: 0; font-size: 1.5rem; color: #007bff; } .user-info p { font-size: 1rem; margin-top: 0.5rem; } .user-info ul { list-style-type: none; display: flex; justify-content: space-between; padding: 0; max-width: 400px; margin-top: 1rem; } .user-info ul li { display: flex; align-items: center; } .user-info ul li strong { font-size: 0.9rem; margin-left: 0.5rem; color: #007bff; } .repo { text-decoration: none; color: #fff; background-color: #ff1500; font-size: 0.9rem; padding: 0.4rem 0.8rem; margin-right: 0.5rem; margin-bottom: 0.5rem; display: inline-block; border-radius: 9px; transition: background-color 0.3s, transform 0.2s; } .repo:hover { background-color: #cc0c00; transform: scale(1.05); } @media (max-width: 500px) { .card { flex-direction: column; align-items: center; } .inputForm { max-width: 400px; } }

` JavaScript ``

// script.js

let api = "https://api.github.com/users/";

let fetch = document.createElement("script"); fetch.src = `https://cdnjs.cloudflare.com/ajax/libs/axios/0.21.0/axios.min.js%60;

fetch.integrity = ha512-DZqqY3PiOvTP9HkjIWgjO6ouCbq+dxqWoJZ/Q+zPYNHmlnI2dQnbJ5bxAHpAMw+LXRm4D72EIRXzvcHQtE8/VQ==;

fetch.crossOrigin = "anonymous"; document.head.appendChild(fetch); let main = document.getElementById("main"); let inputForm = document.getElementById("userInput"); let inputBox = document.getElementById("inputBox"); const userGetFunction = (name) => { axios(api + name) .then((response) => { userCard(response.data); repoGetFunction(name);}) .catch((err) => { if ( err.response.status == 404) { errorFunction( "No profile with this username");}});} const repoGetFunction = (name) => { axios( api + name + "/repos?sort=created") .then((response) => { repoCardFunction( response.data);}) .catch((err) => { errorFunction( "Problem fetching repos");});} const userCard = (user) => { let id = user.name || user.login; let info = user.bio ? <p>${user.bio}</p>: ""; let cardElement = `

${user.name}

${id}

${info}
  • ${user.followers} Followers
  • ${user.following} Following
  • ${user.public_repos} Repos
`; main.innerHTML = cardElement}

const errorFunction = (error) => { let cardHTML = `

${error}

`; main.innerHTML = cardHTML}

const repoCardFunction = (repos) => { let reposElement = document.getElementById( "repos"); for (let i = 0; i < 5 && i < repos.length; i++) { let repo = repos[i]; let repoEl = document.createElement("a"); repoEl.classList.add("repo"); repoEl.href = repo.html_url; repoEl.target = "_blank"; repoEl.innerText = repo.name; reposElement.appendChild(repoEl);}} inputForm.addEventListener("submit", (e) => { e.preventDefault(); let user = inputBox.value; if (user) { userGetFunction(user); inputBox.value = "";}});

``

**Output: