Rate limiting and requests_respectful

Manaswini Das
Outreachy-Manaswini Das
2 min readJun 19, 2018

My internship period has been rewarding so far. I came across some really cool stuffs .i.e. Rate limiting and requests_respectful. This may seem new to you. I too was new to them.

Source: Google images

What is rate limiting?

Rate limiting is essentially employed to control the amount of traffic to or from a network. This ensures improvement in data flow and increase in security by reducing attacks.

This comes in handy when there is a need to control traffic which is indeed an issue. Diving deeper into this, I also came across the types of rate limits. They are:

User Rate Limiting:

This is the most popular type of rate limiting. This associates the number of requests a user is making to their API key or IP. In case the rate limit is reached, further requests or retrieval of data is suspended till a particular period of time to avoid network overloading till the rate limit timeframe resets. Otherwise, the users can always reach out the to the developer to increase the rate limit.

Geographic Rate Limiting:

Rate limits are also set for specific geographic regions and time periods for enhancing security. For example, if a developer knows that from midnight to 8:00 am users in a particular region won’t be active as compared to other time periods, then they can define lower rate limits. This can be used as a preventive measure to aid in reducing the risk of any suspicious activity.

Server Rate Limiting:

Developers can define rate limits on a server-level basis. This gives them freedom to decrease traffic limits on servers with respect to each other.

You can find rate limiting in documentation of APIs.

Requests_respectful

To exercise rate limiting, I came across requests_respectful, a wrapper that Open Humans is using in its API integrations. It is a rate-limiting wrapper built on top of Requests by SerpentAI. This enables users to work within rate limits(user rate limiting) of any amount of services simultaneously.

In addition to this, Requests_respectful maximizes allowed requests without going over rate limits. What’s more? It works with both Python 2 and 3 and can scale out a single thread, process or machine.

Want to implement requests_respectful in your project? Here are the details.

Happy coding!

--

--

Manaswini Das
Outreachy-Manaswini Das

SE @RedHat, DjangoCon Europe 2019 speaker, Outreachy intern at Open Humans(Round 16), Processing Foundation fellow 2019, ❤️open source