-
-
Notifications
You must be signed in to change notification settings - Fork 203
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adds rate limit to APIProvider #227
Conversation
Code Coverage Report
SwiftLint found issues
Generated by 🚫 Danger Swift against ae3af97 |
It turns out there was a case sensitivity issue when looking up the rate limit header field name. Apparently Proxyman uppercases all header field names and since the API returns lowercased field names the solution only worked when Proxyman was running🤦♂️ I changed the solution to use |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks really good, you made it easy to review. Thanks for writing some tests as well!
APIProvider now exposes rate limit information from the
X-Rate-Limit
header field.Rate limits are included in the header for every response and are enforced for all requests using the same API Key.
The documentation defines that the header info includes:
user-hour-lim
, which indicates the number of requests you can make per hour with the same API key.user-hour-rem
, which shows the number of requests remaining.https://developer.apple.com/documentation/appstoreconnectapi/identifying_rate_limits
However certain endpoints will also include
user-minute-lim
anduser-minute-rem
. I have filed a feedback to ask that this is added to the documentation.Since this solution does not make assumptions about which entries are included in
X-Rate-Limit
this should not be an issue.Usage
Per endpoint limits
Rate limits apply to all requests, but it appears it is possible for certain endpoints have their own limits. Because of this I have added
requestURL
to RateLimit so you're able to see rate limits for specific endpoints.