🚰 Manage Rate Limits in HrFlow.ai SDK
Learn how to effectively manage API request limits and ensure smooth data processing.
A. What is Rate Limiting?
Rate limiting is a technique employed by API providers to regulate the number of requests made to their servers within a specified time period. This practice helps maintain optimal performance, ensuring consistent and reliable response times for all users.
Prerequisites
- ✨ Create a Workspace
- 🔑 Get your API Key
- HrFlow.ai Python SDK version 4.0.0 or above: Install it via pip with
pip install -U hrflow>=4.0.0
or conda withconda install hrflow>=4.0.0 -c conda-forge
.
B. Rate Limiting Parameters
The two main parameters used to manage rate limiting in HrFlow.ai's Python SDK are:
max_requests_per_minute
(int): This parameter sets the maximum number of requests that can be made per minute. By specifying this value, you can control the frequency of your API calls to avoid overloading the server.
Example: max_requests_per_minute=30
min_sleep_per_request
(float): This parameter sets the minimum time to wait between requests, in seconds. By adding a delay between API calls, you can ensure compliance with rate limiting guidelines and maintain a steady data processing workflow.
Example: min_sleep_per_request=1
C. Using Rate Limiting Parameters in API Calls
The HrFlow.ai Python SDK includes rate limiting options in all API calls related to parsing, storing, searching, scoring, and more. To apply rate limiting, simply specify the max_requests_per_minute
and/or min_sleep_per_request
parameters as arguments in your API calls.
Example 1: Using rate limiting with client.profile.parsing.add_folder()
client.profile.parsing.add_folder(
...
max_requests_per_minute=30,
min_sleep_per_request=1,
)
Example 2: Using rate limiting with client.profile.parsing.add_file()
client.profile.parsing.add_file(
...
max_requests_per_minute=30,
min_sleep_per_request=1,
)
Default behavior
By default, the HrFlow.ai Python SDK does not apply any rate limiting. It is essential to explicitly specify the rate limiting parameters to ensure optimal API usage and data processing.
D. Additional Resources
- HrFlow.ai Python SDK on PyPI
- HrFlow Cookbook: Repository containing helpful notebooks by the HrFlow.ai team
- API Authentication Documentation
Updated 2 months ago