Getting File Content using GIT Hub API

The GIT Hub itself has a fairly complete tutorial for accessing GIT hub uploaded files.

However, I think it can still use some little extra explanation.

Make sure you get the following steps right for this:

  • Depending upon master/branch, get your URL for the repository ready first.
  • Next, get the correct header inserted into your HTTP request.
  • Make sure you are requesting data in ‘jsonp’ format
  • Extracting the content of your response can also get tricky. make sure to look into ‘data.contents’ value.
  • Finally, decode the encoded content.

Here’s my implementation API call:

var gitURL = '';
var gitAPIServiceOptions = {
url: gitURL + yourGitHubFilePath,
requestType: "GET",
dataType: "JSONP",
httpHeader: 'Accept',
callBack: function(result) {
if (result.success === true) {
var decodedResult = atob( ;