RATELIMIT
When creating a client, re-use that same client in all loops! Clients have built-in rate limiters and by re-using clients you’ll get built-in rate limit safety. If you recreate a client each time, you run the risk of abusing the API and getting your source IPs banned.
### THIS IS GOOD
import bgpstuff
c = bgpstuff.Client()
for i in range(5):
c.get_route(f"{i+1}.1.1.1")
print(f"The route for {i+1}.1.1.1 is {c.route}")
The route for 1.1.1.1 is 1.1.1.0/24
The route for 2.1.1.1 is 2.1.0.0/16
The route for 3.1.1.1 is 3.0.0.0/15
The route for 4.1.1.1 is 4.0.0.0/9
The route for 5.1.1.1 is 5.1.0.0/23
### THIS IS BAD!
import bgpstuff
for i in range(5):
c = bgpstuff.Client()
c.get_route(f"{i+1}.1.1.1")
print(f"The route for {i+1}.1.1.1 is {c.route}")
The route for 1.1.1.1 is 1.1.1.0/24
The route for 2.1.1.1 is 2.1.0.0/16
The route for 3.1.1.1 is 3.0.0.0/15
The route for 4.1.1.1 is 4.0.0.0/9
The route for 5.1.1.1 is 5.1.0.0/23
TODO
Invalids #
As noted on the invalids page, grabbing all invalids is a single call. Your client will then have a local copy of all invalids that you can query as any rate. Only calls to the REST API are rate-limited.