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?

1 Answer 1

7

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"
Sign up to request clarification or add additional context in comments.

1 Comment

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?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.