简体   繁体   中英

Using GitHub API to retrieve files with specific extension

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?

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"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM