4

I want to get a list of files from given git repository. For an example, I want to get all *.js files from a given git repository. How can I use GitHub API to satisfy above requirement? or is there any way to get the list of *.js files from a git repository?

Mathu
  • 63
  • 1
  • 7

1 Answers1

6

Here, what I did to find out all .js file in my own repository.

curl -i "https://api.github.com/search/code?q=extension:js+repo:vnation/NewsAggregator"

source: https://developer.github.com/v3/search/#search-code

EDIT

This is what I did to find out the path of ".classpath" file in the master branch of my repo.

curl -i "https://api.github.com/repos/vnation/NewsAggregator/contents/.classpath"

SOURCE: https://developer.github.com/v3/repos/contents/#get-contents

However, git response above API with base64 encoded content. So, to get raw data you should use below one.

curl -i "https://raw.githubusercontent.com/vnation/NewsAggregator/master/.classpath"
Vishal Patel
  • 554
  • 6
  • 15
  • Thanks. It works. can we use GitHub API to read a file content in repo temporary? That means if I want to get a list of dependencies mentioned in package.json file, can I read the package.json file using GitHub API? – Mathu Jan 12 '18 at 03:52