Speed up development with full-stack environments for every branch.

Learn More

Search popular repositories on GitHub [Node.js]

Forked from Hello World for Node.js.

276 Runs 918 Views 147 Copies

Uses the GitHub v3 API to gather the most starred public repositories on GitHub



sundip 66

published 4 years ago

var express = require('express')
  , request = require('request')
  , qs = require('qs');

var app = express();

// The API endpoint to search repositories on GitHub
var url = 'https://api.github.com/search/repositories';

// The params which will search for JavaScript repositories by number of stars
var querystring = '?q=language=javascript&sort=stars&order=desc';

app.get('/', function(req, res) {
    url: url+querystring, 
    // Need to pass in this header while GitHub's search API is in preview-mode
    headers: {'Accept': 'application/vnd.github.preview'}}, function(err, resp, body) {
      if (err)
      if (body) {
        body = JSON.parse(body);
        var output = '';
        for(i=0; i<body.items.length; i++) {
          output += "Name: " + body.items[i].name;
          output += "\nURL: " + body.items[i].html_url;
          output += "\n-----------------------------------------\n";

Please login/signup to get access to the terminal.

Your session has timed out.

Dismiss (the page may not function properly).