有没有办法提高GitHub的API速率限制或完全绕过它? [英] Is there a way to increase the API Rate limit or to bypass it altogether for GitHub?

查看:687
本文介绍了有没有办法提高GitHub的API速率限制或完全绕过它?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个Web应用程序,该应用程序需要向GitHub发送大量HTTP请求.在n个成功的请求之后,我收到HTTP 403: Forbidden并显示消息API Rate Limit Exceeded.

I am developing a web application which needs to send a lot of HTTP requests to GitHub. After n number of successful requests, I get HTTP 403: Forbidden with the message API Rate Limit Exceeded.

是否有提高GitHub的API速率限制或完全绕过它的方法?

Is there a way to increase the API Rate limit or to bypass it altogether for GitHub?

推荐答案

这是一个相对的解决方案,因为该限制仍然是每小时5000个API调用, 或每分钟约80个电话,这确实不算多.

This is a relative solution, because the limit is still 5000 API calls per hour, or ~80 calls per minute, which is really not that much.

我正在编写一种工具,可以比较组织中的350多个存储库, 找到它们的相关性. 好的,该工具使用python进行git/github访问,但是我认为 这里不重要.

I am writing a tool to compare over 350 repositories in an organization and to find their correlations. Ok, the tool uses python for git/github access, but I think that is not the relevant point, here.

在取得初步成功之后,我发现GitHub API的功能 如果您真的想问,那么通话次数和带宽都太有限了 仓库里有很多深层次的问题.

After some initial success, I found out that the capabilities of the GitHub API are too limited in # of calls and also in bandwidth, if you really want to ask the repos a lot of deep questions.

因此,我使用另一种方法切换了概念:

Therefore, I switched the concept, using a different approach:

我没有使用GitHub API进行任何操作,而是编写了GitHub Mirror脚本 能够使用我的工具在不到15分钟的时间内反映所有这些存储库 通过pygit2并行python脚本.

Instead of doing everything with the GitHub API, I wrote a GitHub Mirror script that is able to mirror all of those repos in less than 15 minutes using my parallel python script via pygit2.

然后,我使用本地存储库和pygit2编写了所有可能的东西. 由于既没有API也没有带宽瓶颈,因此该解决方案的速度提高了100倍甚至更多.

Then, I wrote everything possible using the local repositories and pygit2. This solution became faster by a factor of 100 or more, because there was neither an API nor a bandwidth bottle neck.

当然,这确实需要花费额外的精力,因为pygit2 API相当多 与我在GitHub解决方案部分中首选的github3.py不同.

Of course, this did cost extra effort, because the pygit2 API is quite a bit different from github3.py that I preferred for the GitHub solution part.

这实际上是我的结论/建议: 处理大量Git数据的最有效方法是:

And that is actually my conclusion/advice: The most efficient way to work with lots of Git data is:

  • 在本地克隆您感兴趣的所有存储库

  • clone all repos you are interested in, locally

使用pygit2在本地编写一切可能的

write everything possible using pygit2, locally

编写其他内容,例如公共/私人信息,拉取请求,访问 wiki页面,问题等使用github3.py API或您喜欢的内容.

write other things, like public/private info, pull requests, access to wiki pages, issues etc. using the github3.py API or what you prefer.

通过这种方式,您可以最大程度地提高吞吐量,而现在的限制是 您程序的质量. (也很重要)

This way, you can maximize your throughput, while your limitation is now the quality of your program. (also non-trivial)

这篇关于有没有办法提高GitHub的API速率限制或完全绕过它?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆