bojkott
10/13/2025, 8:02 PMkapa.ai
10/13/2025, 8:02 PMbojkott
10/13/2025, 8:14 PMkapa.ai
10/13/2025, 8:14 PMkapa.ai
10/13/2025, 8:15 PMHttpAPIBudget and a rate policy (e.g., MovingWindowCallRatePolicy) in your stream's constructor. This will ensure that all requests, including those made per ID, respect the defined rate limit. Example (from the SurveyMonkey tutorial): python from airbyte_cdk.sources.streams.call_rate import MovingWindowCallRatePolicy, HttpAPIBudget, Rate class MyStream(HttpStream, ABC): def __init__(self, **kwargs): # Define your rate limit, e.g., 120 requests per minute policies = [ MovingWindowCallRatePolicy( rates=[Rate(limit=120, interval=datetime.timedelta(minutes=1))], matchers=[], ), ] api_budget = HttpAPIBudget(policies=policies) super().__init__(api_budget=api_budget, **kwargs) This setup ensures that every HTTP request made by the stream (including those in a loop over IDs) will be rate-limited according to your policy. You do not need to manually add sleep() calls or custom logic for rate limiting—Airbyte will handle it for you. 2. Iterate Over IDs in Your Stream Logic In your read_records or similar method, after fetching the list of IDs, loop over them and make a request for each. The rate limiting will be automatically enforced for each request. python def read_records(self, ...): ids = self.fetch_ids_somehow() for id in ids: response = self._send_request_for_id(id) yield self.parse_response(response) ### Key Points - The rate limit policy applies to all requests made by the stream, including those in per-ID loops. - No need to manually manage timing or sleep between requests. - This approach is supported in Airbyte CDK Python connectors as of recent versions. For a full example, see the SurveyMonkey connector tutorial, which demonstrates configuring a moving window rate limit policy in a custom Python connector [Concurrent](https://docs.airbyte.com/platform/connector-development/tutorials/custom-python-connector/concurrency). If you need to use a different rate limiting policy (e.g., fixed window), you can adjust the policy type and parameters accordingly. --- References: - [Custom Python Connector: Concurrency and Rate Limiting](https://docs.airbyte.com/platform/connector-development/tutorials/custom-python-connector/concurrency) - [API Budget and Rate Limiting in YAML](https://docs.airbyte.com/platform/connector-development/config-based/understanding-the-yaml-file/rate-limit-api-budget)