This script queries the ping endpoint 25 times, printing the count, the HTTP Status Code, and the X-RateLimit-Remaining header each time.
1. Increase the number of loops, do you start to get 429 errors?
2. Can you add in a step to make it wait a few seconds every iteration? Or every 100 iterations?
import requests, sys, time
server = "http://rest.ensembl.org/"
con = "application/json"
ext_ping = "/info/ping?"
x = 0
y = 0
while x < 1000:
# submit the query
ping = requests.get(server+ext_ping, headers={ "Accept" : con})
x += 1
y += 1
print ("count:", x, "status:", ping.status_code, "remaining:", ping.headers['X-RateLimit-Remaining'])
if y == 100:
time.sleep(1)
y = 0