Sheharyar Naseer

Github Trending Repos API


Well, it’s not really an API. It’s a nifty little gem that fetches Trending Repositories from Github. I needed to get a list of Top Github Repos each week for a project. I tried going with the Official Github API but there was no support for Trending Projects. I also tried getting data from Unofficial RSS Feeds (1, 2), but they weren’t working for some reason as well.

So before finally giving up and writing my own scraper, I came across this awesome command-line utility git-trend that lists top repos. I extracted most of the functionality and turned it into a gem. You can view it’s Source on Github. To use, add this to your Gemfile and bundle:

gem 'github-trending'

Or, you can install via:

$ gem install github-trending

Some things that you can do with it are:

require 'github-trending'

Github::Trending.get
Github::Trending.get :ruby
Github::Trending.get :scala, :week
Github::Trending.get nil, :month

Github::Trending.all_languages

Example Usage

js_repos = Github::Trending.get(:javascript, :month)
# Get top Javascript repos this month

js_repos.each do |r|
  puts "#{r.name} (#{r.star_count} stargazers)"
  puts "--- #{r.description}\n\n"
end

# MrSwitch/hello.js (393 stargazers)
# --- A Javascript RESTFUL API library for connecting with OAuth2 services
# 
# mrflix/dimensions (151 stargazers)
# --- A tool for designers to measure screen dimensions.
# 
# jmdobry/angular-data (107 stargazers)
# --- Data store for Angular.js.
#
# ...