© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
Cloudflare DevelopersCD
Cloudflare Developers•10mo ago•
6 replies
Marcel Overdijk

Rate Limiting API open beta feedback

The new Rate Limiting API for workers (https://developers.cloudflare.com/workers/runtime-apis/bindings/rate-limit/) is quite interesting to e.g. API a rate limiting mechanism to a API hosted on Cloudflare Workers.

However, I think there is a room for improvement to even offer more opportunities leveraging this API.

1) More Rate Limit result details like remaining and reset window

The
const result = await c.env.API_RATE_LIMITER.limit({ key: 'some-key' });
const result = await c.env.API_RATE_LIMITER.limit({ key: 'some-key' });

now only returns whether there is success or not:
{ success: true }
{ success: true }
as defined in the outcome interface:

interface RateLimitOutcome {
    success: boolean;
}
interface RateLimitOutcome {
    success: boolean;
}


It would be very nice to return as well how many tries are
remaining
remaining
and what the
reset
reset
time from now will be.
This would give API implementor the option to give feedback to the consumer, e.g. using the RateLimit header fields spec (https://datatracker.ietf.org/doc/html/draft-ietf-httpapi-ratelimit-headers-06) like:

HTTP/1.1 429 Too Many Requests
Content-Type: application/json
Date: Mon, 05 Aug 2019 09:27:00 GMT
Retry-After: Mon, 05 Aug 2019 09:27:05 GMT
RateLimit-Reset: 5
RateLimit-Limit: 100
Ratelimit-Remaining: 0

{
"title": "Too Many Requests",
"status": 429,
"detail": "You have exceeded your quota"
}
HTTP/1.1 429 Too Many Requests
Content-Type: application/json
Date: Mon, 05 Aug 2019 09:27:00 GMT
Retry-After: Mon, 05 Aug 2019 09:27:05 GMT
RateLimit-Reset: 5
RateLimit-Limit: 100
Ratelimit-Remaining: 0

{
"title": "Too Many Requests",
"status": 429,
"detail": "You have exceeded your quota"
}


2) Possibility to provide a cost option to the limit call.

Currently the
limit
limit
method only allow to provide a
key
key
in the options:

interface RateLimitOptions {
    key: string;
}
interface RateLimitOptions {
    key: string;
}


It would be very useful to provide a
cost
cost
option (default
1
1
if not provided) so based on request or request params the count can be dynamically.
This would be very useful for a GraphQL API, but also for a REST API with e.g. some
expand
expand
request param to include nested resources, which could be counted as more expensive then.

And as last, I'm wondering if there are more pricing details available for the Rate Limiting API when it gets out of beta?
How will this be calculated?
Cloudflare Docs
Rate Limiting · Cloudflare Workers docs
Define rate limits and interact with them directly from your Cloudflare Worker
Rate Limiting · Cloudflare Workers docs
IETF Datatracker
RateLimit header fields for HTTP
This document defines the RateLimit-Limit, RateLimit-Remaining, RateLimit-Reset and RateLimit-Policy HTTP header fields for servers to advertise their current service rate limits, thereby allowing clients to avoid being throttled.
RateLimit header fields for HTTP
Cloudflare Developers banner
Cloudflare DevelopersJoin
Welcome to the official Cloudflare Developers server. Here you can ask for help and stay updated with the latest news
85,042Members
Resources
Was this page helpful?

Similar Threads

Recent Announcements

Similar Threads

Rate Limiting
Cloudflare DevelopersCDCloudflare Developers / workers-and-pages-help
2y ago
rate limiting issues
Cloudflare DevelopersCDCloudflare Developers / workers-and-pages-help
16mo ago
Suggestion for rate limiting
Cloudflare DevelopersCDCloudflare Developers / workers-and-pages-help
2y ago
Implementing complex rate-limiting
Cloudflare DevelopersCDCloudflare Developers / workers-and-pages-help
4y ago