To show up your github repositories in your website use following code and change the username in the url https://api.github.com/users/rupaknepali/repos to your username of github. In the given link “rupaknepali” is my username of github.

<script src="https://code.jquery.com/jquery-2.2.4.js" 
integrity="sha256-iT6Q9iMJYuQiMWNd9lDyBUStIq/8PuOW33aOqmvFpqI=" 
crossorigin="anonymous"></script>

<ul id="repoList"></ul>
<br /><br />

<div id="repoCount"></div>

<script type="text/javascript">
    (function ($) {
        $(document).ready(function() {
            $.ajax({
                type: "GET",
                url: "https://api.github.com/users/rupaknepali/repos",
                dataType: "json",
                success: function(result) {
                    for (var i in result) {
                        var date = result[i].updated_at.substring(0, 10);
                        var content = "<li><h2><a href='" + result[i].html_url + "' target='_blank'>" + result[i].name + "</a></h2>";

                        if (result[i].description) {
                            content += "<p>" + result[i].description + "</p>";
                        }
                        content = content + "</li>";

                        $("#repoList").append(content);

                    }
                    //console.log(result);
                    $("#repoCount").append("Total Repos: " + result.length);
                }
            });
        });
    })(jQuery);
</script>

Following image shows the listing of my github public repositories:

Like this simple get request we can show github repositories.

 

 

LEAVE A REPLY

Please enter your comment!
Please enter your name here