get all the sub file paths in a github repository

二次信任 提交于 2019-12-25 03:15:42

问题


I've been playing around with the github api (V3) recently. I would like to get a list of all files and sub files in the primary repo of the current commit.

I can run

https://api.github.com/repos/elasticsearch/elasticsearch/contents/

and send many more requests to crawl the directories. However the documentation mentions that I could use the tree api to get all the results. But

https://api.github.com/repos/elasticsearch/elasticsearch/contents/?recursive=1

returns the same contents. Can I get all the file paths in a single request?


回答1:


You need to make a request to this endpoint:

https://developer.github.com/v3/git/trees/#get-a-tree-recursively

So, give this a try:

https://api.github.com/repos/elasticsearch/elasticsearch/git/trees/master?recursive=1



来源:https://stackoverflow.com/questions/23506983/get-all-the-sub-file-paths-in-a-github-repository

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!