获取github存储库中的所有子文件路径

问题描述:

我最近一直在使用github api(V3).我想在当前提交的主仓库中获取所有文件和子文件的列表.

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.

我可以跑步

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?

您需要向此端点发出请求:

You need to make a request to this endpoint:

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

因此,尝试一下:

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