Using the GitHub REST API to fetch your repos.

Most of us use GitHub services frequently if not on a daily basis.

If you are a student, GitHub offers student packages with great tools and freebies you could use. Check my article on Github's Developer Pack for students.

In this article, I will take you through using GitHub REST API to display your repos on your portfolio website. I will use postman to test the API.

GitHub REST API Documentation.

Playing With The API

I'll use postman to show you what the API can offer for your own personal use. For this, I'll be using the endpoint to fetch a user's repositories.{github_username}{github_username}/repos

Postman Screenshot

Postman Screenshot

Using the GitHub User endpoint:{github_username}


This returns GitHub user details:

    "login": "",
    "id": ,
    "node_id": "",
    "avatar_url": "",
    "gravatar_id": "",
    "url": "",
    "html_url": "",
    "followers_url": "",
    "following_url": "{/other_user}",
    "gists_url": "{/gist_id}",
    "starred_url": "{/owner}{/repo}",
    "subscriptions_url": "",
    "organizations_url": "",
    "repos_url": "",
    "events_url": "{/privacy}",
    "received_events_url": "",
    "type": "User",
    "site_admin": false,
    "name": "chrisdevcode",
    "company": null,
    "blog": "",
    "location": "Kenya",
    "email": null,
    "hireable": null,
    "bio": "React | Next | Node | C#(dotnet)\r\n\r\nTech Community Lover",
    "twitter_username": null,
    "public_repos": 211,
    "public_gists": 15,
    "followers": 91,
    "following": 117,
    "created_at": "2019-04-29T22:17:15Z",
    "updated_at": "2021-07-15T06:56:22Z"

You could use this to display:

  1. Public respos and gists
  2. Date you created your GitHub account
  3. GitHub bio
  4. Number of people you follow and followers too.

Using the GitHub User Repos endpoint:{github_username}/repos


The results returned:

PS - It also returns the user details plus all the repos:

        "id": 300814209,
        "node_id": "MDEwOlJlcG9zaXRvcnkzMDA4MTQyMDk=",
        "name": "AI-ML-Bootcamp",
        "full_name": "achingachris/AI-ML-Bootcamp",
        "private": false,
        "owner": {
            "login": "achingachris",
            "id": 50122165,
            "node_id": "MDQ6VXNlcjUwMTIyMTY1",
            "avatar_url": "",
            "gravatar_id": "",
            "url": "",
            "html_url": "",
            "followers_url": "",
            "following_url": "{/other_user}",
            "gists_url": "{/gist_id}",
            "starred_url": "{/owner}{/repo}",
            "subscriptions_url": "",
            "organizations_url": "",
            "repos_url": "",
            "events_url": "{/privacy}",
            "received_events_url": "",
            "type": "User",
            "site_admin": false
        "html_url": "",
        "description": "Artificial Intelligence and Machine Learning Bootcamp - Strathmore University",
        "fork": false,
        "url": "",
        "forks_url": "",
        "keys_url": "{/key_id}",
        "collaborators_url": "{/collaborator}",
        "teams_url": "",
        "hooks_url": "",
        "issue_events_url": "{/number}",
        "events_url": "",
        "assignees_url": "{/user}",
        "branches_url": "{/branch}",
        "tags_url": "",
        "blobs_url": "{/sha}",
        "git_tags_url": "{/sha}",
        "git_refs_url": "{/sha}",
        "trees_url": "{/sha}",
        "statuses_url": "{sha}",
        "languages_url": "",
        "stargazers_url": "",
        "contributors_url": "",
        "subscribers_url": "",
        "subscription_url": "",
        "commits_url": "{/sha}",
        "git_commits_url": "{/sha}",
        "comments_url": "{/number}",
        "issue_comment_url": "{/number}",
        "contents_url": "{+path}",
        "compare_url": "{base}...{head}",
        "merges_url": "",
        "archive_url": "{archive_format}{/ref}",
        "downloads_url": "",
        "issues_url": "{/number}",
        "pulls_url": "{/number}",
        "milestones_url": "{/number}",
        "notifications_url": "{?since,all,participating}",
        "labels_url": "{/name}",
        "releases_url": "{/id}",
        "deployments_url": "",
        "created_at": "2020-10-03T06:39:03Z",
        "updated_at": "2020-10-07T19:30:57Z",
        "pushed_at": "2020-10-07T19:30:54Z",
        "git_url": "git://",
        "ssh_url": "",
        "clone_url": "",
        "svn_url": "",
        "homepage": "",
        "size": 140,
        "stargazers_count": 1,
        "watchers_count": 1,
        "language": "Jupyter Notebook",
        "has_issues": true,
        "has_projects": true,
        "has_downloads": true,
        "has_wiki": true,
        "has_pages": false,
        "forks_count": 0,
        "mirror_url": null,
        "archived": false,
        "disabled": false,
        "open_issues_count": 0,
        "license": {
            "key": "mit",
            "name": "MIT License",
            "spdx_id": "MIT",
            "url": "",
            "node_id": "MDc6TGljZW5zZTEz"
        "forks": 0,
        "open_issues": 0,
        "watchers": 1,
        "default_branch": "main"

From this, you could use this to show your GitHub repos' details with much ease.

To explore more on using the GitHub REST API for Users, visit:

Next Step

Check out my Blog for a tutorial on using the GitHub API in a NEXTJS app.