book

Github API

The objective is to learn how to use Github's API to pull in real data. Your need to figure out how to compose an URL for accessing a particular API to grab the data you want.

Github provides a wide range of APIs. We will focus on these three for now.

Carefully go through the examples below.

What is the data of the first issue?

Data is loaded from https://api.github.com/repos/bigdatahci2015/forum/issues/1

The data is saved in data. It looks like below.

{
 "url": "https://api.github.com/repos/bigdatahci2015/forum/issues/1",
 "labels_url": "https://api.github.com/repos/bigdatahci2015/forum/issues/1/labels{/name}",
 "comments_url": "https://api.github.com/repos/bigdatahci2015/forum/issues/1/comments",
 "events_url": "https://api.github.com/repos/bigdatahci2015/forum/issues/1/events",
 "html_url": "https://github.com/bigdatahci2015/forum/issues/1",
 "id": 102129972,
 "number": 1,
 "title": "Introduction",
 "user": {
  "login": "doubleshow",
  "id": 129562,
  "avatar_url": "https://avatars.githubusercontent.com/u/129562?v=3",
  "gravatar_id": "",
  "url": "https://api.github.com/users/doubleshow",
  "html_url": "https://github.com/doubleshow",
  "followers_url": "https://api.github.com/users/doubleshow/followers",
  "following_url": "https://api.github.com/users/doubleshow/following{/other_user}",
  "gists_url": "https://api.github.com/users/doubleshow/gists{/gist_id}",
  "starred_url": "https://api.github.com/users/doubleshow/starred{/owner}{/repo}",
  "subscriptions_url": "https://api.github.com/users/doubleshow/subscriptions",
  "organizations_url": "https://api.github.com/users/doubleshow/orgs",
  "repos_url": "https://api.github.com/users/doubleshow/repos",
  "events_url": "https://api.github.com/users/doubleshow/events{/privacy}",
  "received_events_url": "https://api.github.com/users/doubleshow/received_events",
  "type": "User",
  "site_admin": false
 },
 "labels": [],
 "state": "open",
 "locked": false,
 "assignee": null,
 "milestone": null,
 "comments": 28,
 "created_at": "2015-08-20T12:43:48Z",
 "updated_at": "2015-09-11T13:57:02Z",
 "closed_at": null,
 "body": "Name: Tom Yeh\r\nDepartment: Computer Science\r\nFavorite Programming Language: Javascript\r\nFavorite Food: BBQ",
 "closed_by": null
}

What is the title of the first issue?

Introduction

Who created this issue?

doubleshow

What are the comments of this issue?

Data is loaded from https://api.github.com/repos/bigdatahci2015/forum/issues/1/comments

The comments data look like

[
 {
  "url": "https://api.github.com/repos/bigdatahci2015/forum/issues/comments/133203904",
  "html_url": "https://github.com/bigdatahci2015/forum/issues/1#issuecomment-133203904",
  "issue_url": "https://api.github.com/repos/bigdatahci2015/forum/issues/1",
  "id": 133203904,
  "user": {
   "login": "willzfarmer",
   "id": 546524,
   "avatar_url": "https://avatars.githubusercontent.com/u/546524?v=3",
   "gravatar_id": "",
   "url": "https://api.github.com/users/willzfarmer",
   "html_url": "https://github.com/willzfarmer",
   "followers_url": "https://api.github.com/users/willzfarmer/followers",
   "following_url": "https://api.github.com/users/willzfarmer/following{/other_user}",
   "gists_url": "https://api.github.com/users/willzfarmer/gists{/gist_id}",
   "starred_url": "https://api.github.com/users/willzfarmer/starred{/owner}{/repo}",
   "subscriptions_url": "https://api.github.com/users/willzfarmer/subscriptions",
   "organizations_url": "https://api.github.com/users/willzfarmer/orgs",
   "repos_url": "https://api.github.com/users/willzfarmer/repos",
   "events_url": "https://api.github.com/users/willzfarmer/events{/privacy}",
   "received_events_url": "https://api.github.com/users/willzfarmer/received_events",
   "type": "User",
   "site_admin": false
  },
  "created_at": "2015-08-20T22:39:50Z",
  "updated_at": "2015-08-20T22:39:50Z",
  "body": "Name: William Farmer\r\nMajor: Applied Math w/ Minor in Computer Science\r\nFavorite Programming Language: Python\r\nFavorite Food: Sushi"
 },
 {
  "url": "https://api.github.com/repos/bigdatahci2015/forum/issues/comments/133227037",
  "html_url": "https://github.com/bigdatahci2015/forum/issues/1#issuecomment-133227037",
  "issue_url": "https://api.github.com/repos/bigdatahci2015/forum/issues/1",
  "id": 133227037,
  "user": {
   "login": "twagar95",
   "id": 10174237,
   "avatar_url": "https://avatars.githubusercontent.com/u/10174237?v=3",
   "gravatar_id": "",
   "url": "https://api.github.com/users/twagar95",
   "html_url": "https://github.com/twagar95",
   "followers_url": "https://api.github.com/users/twagar95/followers",
   "following_url": "https://api.github.com/users/twagar95/following{/other_user}",
   "gists_url": "https://api.github.com/users/twagar95/gists{/gist_id}",
   "starred_url": "https://api.github.com/users/twagar95/starred{/owner}{/repo}",
   "subscriptions_url": "https://api.github.com/users/twagar95/subscriptions",
   "organizations_url": "https://api.github.com/users/twagar95/orgs",
   "repos_url": "https://api.github.com/users/twagar95/repos",
   "events_url": "https://api.github.com/users/twagar95/events{/privacy}",
   "received_events_url": "https://api.github.com/users/twagar95/received_events",
   "type": "User",
   "site_admin": false
  },
  "created_at": "2015-08-21T00:32:27Z",
  "updated_at": "2015-08-21T00:32:27Z",
  "body": "Name: Tristan Wagar\r\nMajor: Computer Science\r\nFavorite Programming Language: Javascript\r\nFavorite Food: Steak"
 },
 {
  "url": "https://api.github.com/repos/bigdatahci2015/forum/issues/comments/133571232",
  "html_url": "https://github.com/bigdatahci2015/forum/issues/1#issuecomment-133571232",
  "issue_url": "https://api.github.com/repos/bigdatahci2015/forum/issues/1",
  "id": 133571232,
  "user": {
   "login": "Malaokia",
   "id": 10319733,
   "avatar_url": "https://avatars.githubusercontent.com/u/10319733?v=3",
   "gravatar_id": "",
   "url": "https://api.github.com/users/Malaokia",
   "html_url": "https://github.com/Malaokia",
   "followers_url": "https://api.github.com/users/Malaokia/followers",
   "following_url": "https://api.github.com/users/Malaokia/following{/other_user}",
   "gists_url": "https://api.github.com/users/Malaokia/gists{/gist_id}",
   "starred_url": "https://api.github.com/users/Malaokia/starred{/owner}{/repo}",
   "subscriptions_url": "https://api.github.com/users/Malaokia/subscriptions",
   "organizations_url": "https://api.github.com/users/Malaokia/orgs",
   "repos_url": "https://api.github.com/users/Malaokia/repos",
   "events_url": "https://api.github.com/users/Malaokia/events{/privacy}",
   "received_events_url": "https://api.github.com/users/Malaokia/received_events",
   "type": "User",
   "site_admin": false
  },
  "created_at": "2015-08-21T21:44:26Z",
  "updated_at": "2015-08-21T21:44:26Z",
  "body": "Name: Mingqi Liew\r\nMajor: Computer Science\r\nFavorite Programming Language: C\r\nFavorite Food: Thai food"
 },
 {
  "url": "https://api.github.com/repos/bigdatahci2015/forum/issues/comments/133776171",
  "html_url": "https://github.com/bigdatahci2015/forum/issues/1#issuecomment-133776171",
  "issue_url": "https://api.github.com/repos/bigdatahci2015/forum/issues/1",
  "id": 133776171,
  "user": {
   "login": "fadhilfath",
   "id": 5599246,
   "avatar_url": "https://avatars.githubusercontent.com/u/5599246?v=3",
   "gravatar_id": "",
   "url": "https://api.github.com/users/fadhilfath",
   "html_url": "https://github.com/fadhilfath",
   "followers_url": "https://api.githu

There are 28 comments.

return _.pluck(data, 'user.login')

The github account names are willzfarmer,twagar95,Malaokia,fadhilfath,hswitte,ZachLamb,zhya215,jocr1627,drewdinger,94kazakov,nicolele,satchelspencer,tiro6090,Linenfelser,KevinKGifford,calebhsu,sumi6109,pail4944,DomoYeti,boanding,kjblakemore,SankethSukumarShetty,AndreyShprengel,co-bri,karisantos,anbe6083,jraesly,doubleshow.

Exercises

Now it's your turn to answer the following questions using the real data.

How many issues have been created to date in our class's forum repository?

Data is loaded from https://api.github.com/repos/bigdatahci2015/forum/issues

// add lodash code to process the data and generate the answer
return _.size(data)
There are 25 issues.

What are the titles of these issues?

Data is loaded from https://api.github.com/repos/bigdatahci2015/forum/issues
// add lodash code to process the data and generate the answer
return _.pluck(data, 'title')
The titles are All of my gitbook work is missing ,Question about using Mongo DB for the android app project,Trouble getting mongodb data,adding axes to SVG charts,Week 6 team homework is released,serving gitbook's specific pages,Viz drills are posted,Questions for the Birdstrike Hackathon,Corrupt file in .git,Converting JSON to Tableau ready (on OSX),Week 4 Learning Challenge ,Your FCQ question,Everyone's book,This week's challenge and next week's hackathon,Week 3 Learning Challenge Updated / Posted,Tableau,lodash variables,Week 2 Learning Challenge Updated / Posted,Week 2 Team Learning Clarification,Knowing Your Classmates Hackathon,Problems uploading book to github.io,Hackathons,First Learning Challenge (Update),Learning challenges,Introduction.

How many repository have been created to date for our class?

Our class's Github organization is bigdatahci2015.

Data is loaded from https://api.github.com/orgs/bigdatahci2015/repos

// add lodash code to process the data and generate the answer
return _.size(data)
There are 6 repositories.

What are the fork counts of our class's repositories?

// add lodash code to process the data and generate the answer
return _.pluck(data, 'forks_count')
The fork counts are 4,2,25,32,2,0.

How many public repositories does the user doubleshow have?

Data is loaded from https://api.github.com/users/doubleshow

// add lodash code to process the data and generate the answer
return data.public_repos
The numbers of public repos are 34.

How many public gists does the user doubleshow have?

// add lodash code to process the data and generate the answer
return data.public_gists
The numbers of public gists are 531.