Repository navigation
feat: add rate limiting to scraper to prevent API 429 errors - #3
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR implements rate limiting in the Hell Divers 2 API scraper to prevent 429 (Too Many Requests) errors by enforcing a 2-second delay between consecutive API requests, staying within the community API's limit of 5 requests per 10 seconds.
Key changes:
- Added
_rate_limit()method to track and enforce delays between requests - Applied rate limiting to all 10 scraper methods before HTTP calls
- Updated documentation to reflect rate limiting patterns and API details
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| src/scraper.py | Implements rate limiting with _rate_limit() method and adds delay tracking to all API request methods |
| .github/copilot-instructions.md | Documents rate limiting implementation details, API specifications, and updates component descriptions with accurate line counts |
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Implements rate limiting in the scraper to prevent hitting the Hell Divers 2 community API's 5 requests per 10 seconds limit, which was causing 429 (Too Many Requests) errors during data collection cycles.
Changes
Implementation
_rate_limit()method toHellDivers2Scraperclasslast_request_timeand calculates necessary sleep durationget_war_status()get_planets()get_statistics()get_factions()get_biomes()get_campaign_info()get_assignments()get_dispatches()get_planet_events()get_planet_status()Documentation
.github/copilot-instructions.mdwith rate limiting patternsTesting
Related Issues
Fixes 429 errors observed during data collection cycles when hitting API rate limits.
Checklist