是否有任何链接可以显示 GitHub 中的所有公共存储库?

tre*_*159 5 search-engine github repository

昨天,我试图获取 GitHub 中所有公共存储库的列表,但没有找到任何链接。

例如,在 Sourceforge 中,您可以按类别列出所有项目,或者在 Google 代码中,您可以搜索所有项目。

是的,我尝试使用“*”或“%”或空字符串等关键字进行搜索,但您只能看到此页面https://github.com/search?q=&type=Everything&repo=&langOverride=&start_value=1

ato*_*res 5

您可以使用以下请求列出 github 中的所有存储库:

\n\n

https://api.github.com/repositories?since=0

\n\n

它将返回 id>0 的前“n”个存储库作为 JSON 数组。\n您应该处理此“n”,存储“id”。当您到达“页面”末尾时,您只需再次点击since=lastId:\n例如:

\n\n

https://api.github.com/repositories?since=300

\n\n

这是我发现列出所有存储库的唯一方法,因为 SEARCH api 每次搜索的存储库限制为 1000 个。\n如果您打算处理所有存储库,则应该准备好应对速率限制:

\n\n

https://developer.github.com/v3/rate_limit/

\n\n

经过身份验证的用户可以获得更好的限制,您可以使用 access_token (查看文档)。请小心,不要\xc2\xb4T 推送太多请求。\n如果您需要过滤存储库,则需要为每个存储库执行额外的查询(以搜索 API)。准备好处理超过一千万个存储库。\nJava 示例:(使用 javax.json.Json)

\n\n
int id=0;\ndo {\n    URL url = new URL("https://api.github.com/repositories?since="+id+"&access_token="+oauth);\n    // implement callApi such as Json.createReader(url.openStream()), but please make it sleep for a minute if the limit got reached        \n    try (JsonReader rdr = callApi(url)) {\n        JsonArray results = rdr.readArray();\n        for (JsonObject result : results.getValuesAs(JsonObject.class)) {\n            id = result.getInt("id");\n            String name = result.getString("name");\n            boolean priv = result.getBoolean("private");\n            ... do whatever you want...\n        }\n    }\n} while (some stop condition);\n
Run Code Online (Sandbox Code Playgroud)\n\n

祝你好运,我花了一些时间才发现这一点。

\n


Mic*_*ler 2

看看这个搜索。我不确定这是否列出了所有公共存储库,但我打赌这是一个好的开始。(搜索可能需要几秒钟,请耐心等待)