{"id":13819306,"url":"https://github.com/gofri/go-github-ratelimit","last_synced_at":"2026-02-27T03:02:16.845Z","repository":{"id":65552078,"uuid":"593710736","full_name":"gofri/go-github-ratelimit","owner":"gofri","description":"A GoLang middleware that handles GitHub API rate limits - primary rate limit \u0026 secondary rate limit","archived":false,"fork":false,"pushed_at":"2025-03-14T12:23:58.000Z","size":84,"stargazers_count":67,"open_issues_count":6,"forks_count":18,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-02-09T13:39:41.169Z","etag":null,"topics":["github","github-rate-limit","go-github","golang","rate-limit","ratelimit"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/gofri.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2023-01-26T17:06:52.000Z","updated_at":"2026-02-01T03:53:00.000Z","dependencies_parsed_at":"2023-02-18T00:01:22.083Z","dependency_job_id":"fe872263-ad6b-4be9-9abb-3ff05ab34148","html_url":"https://github.com/gofri/go-github-ratelimit","commit_stats":{"total_commits":45,"total_committers":7,"mean_commits":6.428571428571429,"dds":0.2666666666666667,"last_synced_commit":"9d9726540b07a6a728cc6beb4a28cdc8a3a8f91a"},"previous_names":[],"tags_count":13,"template":false,"template_full_name":null,"purl":"pkg:github/gofri/go-github-ratelimit","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gofri%2Fgo-github-ratelimit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gofri%2Fgo-github-ratelimit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gofri%2Fgo-github-ratelimit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gofri%2Fgo-github-ratelimit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gofri","download_url":"https://codeload.github.com/gofri/go-github-ratelimit/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gofri%2Fgo-github-ratelimit/sbom","scorecard":{"id":433784,"data":{"date":"2025-08-11","repo":{"name":"github.com/gofri/go-github-ratelimit","commit":"483ce26b8f82c066ba491da40cce700cf790c9bc"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":5.1,"checks":[{"name":"Dangerous-Workflow","score":10,"reason":"no dangerous workflow patterns detected","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Code-Review","score":1,"reason":"Found 1/10 approved changesets -- score normalized to 1","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 1 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Pinned-Dependencies","score":9,"reason":"dependency not pinned by hash detected -- score normalized to 9","details":["Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/contribution.yaml:18: update your workflow using https://app.stepsecurity.io/secureworkflow/gofri/go-github-ratelimit/contribution.yaml/main?enable=pin","Info:   6 out of   7 GitHub-owned GitHubAction dependencies pinned","Info:   2 out of   2 third-party GitHubAction dependencies pinned"],"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Token-Permissions","score":0,"reason":"detected GitHub workflow tokens with excessive permissions","details":["Warn: no topLevel permission defined: .github/workflows/lint.yaml:1","Warn: no topLevel permission defined: .github/workflows/test.yaml:1","Info: no jobLevel write permissions found"],"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":-1,"reason":"internal error: error during branchesHandler.setup: internal error: githubv4.Query: Resource not accessible by integration","details":null,"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"SAST","score":9,"reason":"SAST tool is not run on all commits -- score normalized to 9","details":["Warn: 29 commits out of 30 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}}]},"last_synced_at":"2025-08-19T04:05:22.643Z","repository_id":65552078,"created_at":"2025-08-19T04:05:22.643Z","updated_at":"2025-08-19T04:05:22.643Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29546744,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-17T13:00:00.370Z","status":"ssl_error","status_checked_at":"2026-02-17T12:57:14.072Z","response_time":100,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["github","github-rate-limit","go-github","golang","rate-limit","ratelimit"],"created_at":"2024-08-04T08:00:44.710Z","updated_at":"2026-02-27T03:02:16.824Z","avatar_url":"https://github.com/gofri.png","language":"Go","readme":"# go-github-ratelimit\n\n[![Go Report Card](https://goreportcard.com/badge/github.com/gofri/go-github-ratelimit)](https://goreportcard.com/report/github.com/gofri/go-github-ratelimit)\n\nPackage `go-github-ratelimit` provides a middleware (http.RoundTripper) that handles both [Primary Rate Limit](https://docs.github.com/en/rest/using-the-rest-api/rate-limits-for-the-rest-api?#about-primary-rate-limits) and [Secondary Rate Limit](https://docs.github.com/en/rest/using-the-rest-api/rate-limits-for-the-rest-api?#about-secondary-rate-limits) for the GitHub API.\n\n* Primary rate limits are handled by returning a detailed error.  \n* Secondary rate limits are handled by waiting in blocking mode (sleep) and then issuing/retrying requests.  \n* There is support for callbacks to be triggered when rate limits are detected/exceeded/etc. - see below.  \n\nThe module can be used with any HTTP client communicating with GitHub API. It is designed to have low overhead during good path.    \nIt is meant to complement [go-github](https://github.com/google/go-github), but there is no association between this repository and the go-github repository nor Google.\n\n## Recommended: Pagination Handling\n\nIf you like this package, please check out [go-github-pagination](https://github.com/gofri/go-github-pagination).  \nIt supports pagination out of the box, and plays well with the rate limit round-tripper.  \nIt is best to stack the pagination round-tripper on top of the rate limit round-tripper.  \n\n\n## Installation\n\n```go get github.com/gofri/go-github-ratelimit/v2```\n\n## Usage Example (with [go-github](https://github.com/google/go-github))\n\nsee [example/basic.go](example/basic.go) for a runnable example.\n```go\nrateLimiter := github_ratelimit.NewClient(nil)\nclient := github.NewClient(rateLimiter) // .WithAuthToken(\"your personal access token\")\n\n// disable go-github's built-in rate limiting\nctx := context.WithValue(context.Background(), github.BypassRateLimitCheck, true)\n\ntags, _, err := client.Repositories.ListTags(ctx, \"gofri\", \"go-github-ratelimit\", nil)\nif err != nil {\n  panic(err)\n}\n\nfor _, tag := range tags {\n  fmt.Printf(\"- %v\\n\", *tag.Name)\n}\n```\n\n## Client Options\n\nBoth RoundTrippers support a set of options to configure their behavior and set callbacks.  \nnil callbacks are treated as no-op.  \n\n### Primary Rate Limit Options (see [options.go](github_ratelimit/github_primary_ratelimit/options.go)):\n\n- `WithLimitDetectedCallback(callback)`: the callback is triggered when any primary rate limit is detected.\n- `WithRequestPreventedCallback(callback)`: the callback is triggered when a request is prevented due to an active rate limit.\n- `WithLimitResetCallback(callback)`: the callback is triggered when the rate limit is reset (deactived).\n- `WithUnknownCategoryCallback`: the callback is triggered when the rate limit category in the response is unknown. note: please open an issue if it happens.\n- `WithSharedState(state)`: share state between multiple clients (e.g., for a single user running concurrently).\n- `WithBypassLimit()`: bypass the rate limit mechanism, i.e., do not prevent requests when a rate limit is active.\n\n### Secondary Rate Limit Options (see [options.go](github_ratelimit/github_secondary_ratelimit/options.go)):\n\n- `WithLimitDetectedCallback(callback)`: the callback is triggered before a sleep.\n- `WithSingleSleepLimit(duration, callback)`: limit the sleep duration for a single secondary rate limit \u0026 trigger a callback when the limit is exceeded.\n- `WithTotalSleepLimit(duration, callback)`: limit the accumulated sleep duration for all secondary rate limits \u0026 trigger a callback when the limit is exceeded.\n- `WithNoSleep(callback)`: disable sleep for secondary rate limits \u0026 trigger a callback upon any secondary rate limit.\n\n## Per-Request Options\n\nUse `WithOverrideConfig(opts...)` to override the configuration for a specific request (using the request context).  \nPer-request overrides may be useful for special cases of user requests,\nas well as fine-grained policy control (e.g., for a sophisticated pagination mechanism).\n\n## Advanced Example\n\nSee [example/advanced.go](example/advanced.go) for a runnable example.\n```go\n\trateLimiter := github_ratelimit.New(nil,\n\t\tgithub_primary_ratelimit.WithLimitDetectedCallback(func(ctx *github_primary_ratelimit.CallbackContext) {\n\t\t\tfmt.Printf(\"Primary rate limit detected: category %s, reset time: %v\\n\", ctx.Category, ctx.ResetTime)\n\t\t}),\n\t\tgithub_secondary_ratelimit.WithLimitDetectedCallback(func(ctx *github_secondary_ratelimit.CallbackContext) {\n\t\t\tfmt.Printf(\"Secondary rate limit detected: reset time: %v, total sleep time: %v\\n\", ctx.ResetTime, ctx.TotalSleepTime)\n\t\t}),\n\t)\n\n\tpaginator := githubpagination.NewClient(rateLimiter,\n\t\tgithubpagination.WithPerPage(100), // default to 100 results per page\n\t)\n\tclient := github.NewClient(paginator) // .WithAuthToken(\"your personal access token\")\n\n\t// disable go-github's built-in rate limiting\n\tctx := context.WithValue(context.Background(), github.BypassRateLimitCheck, true)\n\n\t// list repository tags\n\ttags, _, err := client.Repositories.ListTags(ctx, \"gofri\", \"go-github-ratelimit\", nil)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tfor _, tag := range tags {\n\t\tfmt.Printf(\"- %v\\n\", *tag.Name)\n\t}\n```\n\n## Migration (V1 =\u003e V2)\n\nThe migraiton from v1 to v2 is relatively straight-forward once you check out the examples.  \nPlease open an issue if you have any trouble -  \nI'd be glad to help and add documetation per need.\n\n## Github Rate Limit References\n\n- [Primary Rate Limit](https://docs.github.com/en/rest/using-the-rest-api/rate-limits-for-the-rest-api?#about-primary-rate-limits)\n- [Secondary Rate Limit](https://docs.github.com/en/rest/using-the-rest-api/rate-limits-for-the-rest-api?#about-secondary-rate-limits)\n\n## License\n\nThis package is distributed under the MIT license found in the LICENSE file.  \n\n## Contribution\nContribution and feedback is welcome.  \nI'm trying to drink less coffee so don't buy me one, but please do star this repository if you find it useful.\n\n[![Star History Chart](https://api.star-history.com/svg?repos=gofri/go-github-ratelimit\u0026type=Date)](https://www.star-history.com/#gofri/go-github-ratelimit\u0026Date)\n","funding_links":[],"categories":["Go"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgofri%2Fgo-github-ratelimit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgofri%2Fgo-github-ratelimit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgofri%2Fgo-github-ratelimit/lists"}