API Rate Limiting with Upstash

With Vercel's Edge Middleware we're able to do API rate limiting by keeping a counter of requests by IP or API token. For the demo below you can send a maximum of 5 requests every 10 seconds, which increases if using an API token.

const res = await fetch('/api/ping')
  "latency": null,
  "status": null,
  "headers": {
    "X-upstash-latency": "",
    "X-RateLimit-Limit": "",
    "X-RateLimit-Remaining": "",
    "X-RateLimit-Reset": ""
  "data": {
    "done": false

You can select an API token from the list below to use it in the request

Loading API Keys...