首页 > 解决方案 > 如何使用 github api 列出目录下的所有文件名?

问题描述

我需要列出我的存储库目录下的所有文件名。

以下 api 可以列出根目录中的文件名和目录。

https://api.github.com/repos/username/repo-name/git/trees/master?recursive=1

找不到合适的 api 来明智地列出目录!

标签: gitapigithub

解决方案


利用https://api.github.com/repos/{owner}/{repo}/contents/{path}

请参阅此处的文档:https ://docs.github.com/en/rest/reference/repos#get-repository-content


推荐阅读