Skip to content

Extend Rate and Rate Limiting with X-Ratelimit-Used and X-Ratelimit-Resource headers #3453

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

Merged
merged 2 commits into from
Jan 27, 2025

Conversation

andygrunwald
Copy link
Contributor

GitHub introduced two new headrs when it comes to rate limiting:

  • X-Ratelimit-Used
  • X-Ratelimit-Resource

See https://docs.github.com/en/rest/using-the-rest-api/rate-limits-for-the-rest-api?apiVersion=2022-11-28#checking-the-status-of-your-rate-limit

For which resources are available, see https://docs.github.com/en/rest/rate-limit/rate-limit?apiVersion=2022-11-28#get-rate-limit-status-for-the-authenticated-user

This Pull Request extends the Rate Limiting Header parsing and adds the two new information into the Rate response.
Additionally, the key used is added into the response from the /rate_limit API endpoint.

For the Rate type, the docs have been updated according to the original GitHub API docs.

@gmlewis gmlewis added the NeedsReview PR is awaiting a review before merging. label Jan 25, 2025
Copy link

codecov bot commented Jan 25, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 91.03%. Comparing base (3a72a02) to head (0c5dd33).
Report is 1 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #3453   +/-   ##
=======================================
  Coverage   91.02%   91.03%           
=======================================
  Files         179      179           
  Lines       15529    15535    +6     
=======================================
+ Hits        14136    14142    +6     
  Misses       1221     1221           
  Partials      172      172           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@gmlewis
Copy link
Collaborator

gmlewis commented Jan 25, 2025

Thank you, @andygrunwald ! Please run ./script/generate.sh and push the changes to this PR.

@andygrunwald
Copy link
Contributor Author

@gmlewis Done, see 0c5dd33

Copy link
Collaborator

@gmlewis gmlewis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, @andygrunwald!
LGTM.

Awaiting second LGTM+Approval from any other contributor to this repo before merging.

@stevehipwell - might you have time for a code review? Thank you!

Copy link
Contributor

@stevehipwell stevehipwell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@gmlewis
Copy link
Collaborator

gmlewis commented Jan 27, 2025

Thank you, @stevehipwell!
Merging.

@gmlewis gmlewis merged commit e8d69e7 into google:master Jan 27, 2025
7 checks passed
@andygrunwald andygrunwald deleted the rate-extend-used-resource branch January 27, 2025 13:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
NeedsReview PR is awaiting a review before merging.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants