0

I have a list of repositories, I want to receive the latest release through the github api. The code is working, but the error "HTTPError: rate limit exceeded" periodically appears there. I've read the documentation but don't understand how to do it. There's curl for Linux, but I only have the python interpreter itself.

Please explain how to solve this problem. Please show an example code for the python interpreter.

import urllib.request, json

url = 'https://api.github.com/repos/notepad-plus-plus/notepad-plus-plus/releases/latest'

try:
    u=json.loads(urllib.request.urlopen(url).read().decode()).get('assets', True)
except:
    print('HTTPError')    

for item in u:
    f = item['browser_download_url']
    ....
mrKaban
  • 1
  • 2
  • This answer https://stackoverflow.com/a/50441345/2800348 recommends using https://pypi.org/project/ratelimit/ – danielhoherd Jun 04 '22 at 16:58
  • I need this for a website, and visitors won't want to wait. I am ready to use it correctly, as they require, only I do not understand how to do it at all. – mrKaban Jun 04 '22 at 17:02
  • Many APIs that limit you allow you to pay money to increase your rate limit, but AFAIK Github does not. Look into caching your responses using https://pypi.org/project/cachier/ or something similar. – danielhoherd Jun 04 '22 at 17:12
  • If you have more than one webserver host, consider having them hit a common Redis cache: https://pypi.org/project/redis – J_H Jun 04 '22 at 20:25

0 Answers0