{"id":28629806,"url":"https://github.com/codebox/rate-limited-service-manager","last_synced_at":"2025-10-29T14:06:29.610Z","repository":{"id":15080008,"uuid":"17806429","full_name":"codebox/rate-limited-service-manager","owner":"codebox","description":"A JavaScript library for managing access to rate-limited web services","archived":false,"fork":false,"pushed_at":"2015-11-14T10:25:21.000Z","size":128,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-06-12T12:13:40.240Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","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/codebox.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}},"created_at":"2014-03-16T18:50:15.000Z","updated_at":"2015-11-14T10:24:59.000Z","dependencies_parsed_at":"2022-08-24T22:12:52.916Z","dependency_job_id":null,"html_url":"https://github.com/codebox/rate-limited-service-manager","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/codebox/rate-limited-service-manager","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codebox%2Frate-limited-service-manager","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codebox%2Frate-limited-service-manager/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codebox%2Frate-limited-service-manager/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codebox%2Frate-limited-service-manager/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/codebox","download_url":"https://codeload.github.com/codebox/rate-limited-service-manager/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codebox%2Frate-limited-service-manager/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":281633140,"owners_count":26534806,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-29T02:00:06.901Z","response_time":59,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":[],"created_at":"2025-06-12T12:13:39.199Z","updated_at":"2025-10-29T14:06:29.572Z","avatar_url":"https://github.com/codebox.png","language":"JavaScript","readme":"## Rate Limited Web Service Library\n\nThis library provides a simple method for managing JavaScript access to rate-limited web services. \n\nMany web-based services enforce usage limits, restricting how many service requests can be performed within a given period of time (for example the Google Geocoding API permits [2,500 requests per 24 hour period](https://developers.google.com/maps/documentation/geocoding/#Limits) for non-paying customers). By using this library to manage access to such a service, you can ensure that whatever limits have been imposed by the provider are never exceeded.\n\nThe library can manage multiple services at once, transparently load-balancing requests between them, so that whichever service has the largest usage quota remaining is the one that will be used.\n\nAn access strategy can be specified for each service, to determine how it will be managed.\n\n* The _Greedy Strategy_ will send as many requests to the service as possible, as quickly as possible, until the usage limit is reached. Once the limit has been reached no further requests will be sent until sufficient time has passed for the quota to be renewed.\n* The _Smoothing Strategy_ will attempt to distribute requests more evenly. Rather than considering the entire span of the rate-limited interval, it will divide the interval up into 'time buckets' and ensure that during each time bucket only the appropriate proportion of the quota is used.\n\nThe behaviors of the 2 strategies are illustrated in the diagram below, where multiple requests are made over a period of 1 minute, for a service that permits only 5 requests per minute. The vertical grey lines represent incoming requests, and the green ticks indicate which of those requests would be forwarded on to the service by each strategy:\n\n![Rate Limiting Strategy Behaviors](http://codebox.org.uk/graphics/ratelimit.png)\n\nObviously the Smoothing Strategy gives a much more uniform distribution of service calls over the interval, however it runs the risk of not fully utilising the available quota (for example, if there were no incoming requests for the final 2 time buckets, then 2 service requests out of the available 5 would be unused, effectively wasting them).\n\nWhen multiple services are used, load-balancing is performed based on the proportion of the available quota which remains for each service (where the Smoothing Strategy is used), or on the priority assigned to each service (where the Greedy Strategy is used).\n\n### Example:\n\n    var manager = buildServiceManager();\n\tvar quota = manager.buildGreedyQuota(60, 100); // allow 100 requests per minute\n\n\tmanager.add(accessAllowed, quota);\n\n\t// Some code somewhere else calls this when we want to use the remote service\n\tfunction callTheServiceIfQuotaAllows(){\n\t    manager.call(undefined, accessDenied);\n\t}\n\n\t// These 2 functions are called by the library when it is determined that a request is to be allowed/disallowed \n\t// from accessing the managed service \n\tfunction accessAllowed(){\n\t    accessTheService();\n\t    log('request forwarded to service');\n\t}\n\tfunction accessDenied(){\n\t    log('request not forwarded to service');\n\t}\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodebox%2Frate-limited-service-manager","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcodebox%2Frate-limited-service-manager","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodebox%2Frate-limited-service-manager/lists"}