首页 > 解决方案 > 在 github API 上访问 github 存储库的正确端点是什么?

问题描述

我正在向 github 的 API 发出请求以获取以下项目:repo 的名称、repo 所有者的名称、repo url、repo 描述、星数、许可证类型以及 repo 是否分叉。根据 github 的 API 文档,我有这个端点:https://api.github.com/search/repositories?q={query}{&page,per_page,sort,order}

但这似乎不起作用。我是不是忘记了什么?github API 在这里:https ://help.github.com/articles/searching-repositories 。这也是我提出的要求:

     getRepos = (repoinfo) => {
        return fetch(`https://api.github.com/search/repositories?q={query} {&page,per_page,sort,order}`)
        .then(respone => Response.json())
        .then(response => {
          return response
        })
     }

标签: javascriptapigithub

解决方案


为我工作。在这里,我在自述文件中搜索包含 Labyrinth 的 repos:

https://api.github.com/search/repositories?q=labyrinth+in:readme&type=repository

或者,如果您想要一个特定的 repo,请使用https://api.github.com/repos/:owner/:repo ,如下所示:

https://api.github.com/repos/draluy/labyrinth


推荐阅读