ratelimit
Val Town is a collaborative website to build and scale JavaScript apps.
Deploy APIs, crons, & store data – all from the browser, and deployed in milliseconds.
https://unkey--c253d77c707411f0a8c70224a6c84d84.web.val.run
Unkey’s ratelimit API provides a global low latency solution to limit your functions and protect upstream services.
Val Town users get limited free usage of unkey's rate limiting service, so you can import and start rate limiting immediately. No need to set up an unkey account or copy & paste an API key.
import { ratelimit } from "https://www.val.town/x/unkey/ratelimit/code/sdk.ts";
export default async function (req: Request): Promise<Response> {
const rl = await ratelimit({
identifier: "someone",
limit: 5,
duration: 60000,
});
if (!rl.success) {
return Response.json("back off", { status: 429 });
}
// Perform expensive operation here
return new Response("ok");
}
TODO - explain how much "free rate limiting" Val Town users get
If you need higher limits, sign up for your own unkey account here.