Urgent.News

What's breaking now, across thousands of outlets.

Tech

How to rate limit FastAPI in 2026

Rate limiting is the simplest defense against abuse. Here's how to add it to a FastAPI app in 2026, step by step. Install pip install drogue[fastapi] Basic rate limiting from fastapi import FastAPI from drogue.adapters.fastapi import DrogueLimiter app = FastAPI () limiter = DrogueLimiter ( app , default_limits = [ " 100/minute " ]) @app.get ( " /api/data " ) @limiter.limit ( " 10/minute " ) async…

Rate limiting is a crucial defense against abuse in web applications. This guide explains how to implement rate limiting in a FastAPI app in 2026, step by step. Begin by installing the drogue[fastapi] package with pip install drogue[fastapi].

First, create a FastAPI application instance and initialize the DrogueLimiter object with default limits. The default limit is set to 100 requests per minute. Once the limiter is created, apply it to specific routes using the @limiter.limit decorator. For example, the /api/public route is limited to 100 requests per minute, while the /api/login route is restricted to 5 requests per minute, providing strict protection against brute force attempts.

Using the FIXED_WINDOW algorithm can help enforce a hard cap per time window without allowing short bursts. Conversely, the SLIDING_WINDOW algorithm provides smooth rate limiting with no boundary spikes, making it ideal for fair API usage. GCRA and LEAKY_BUCKET algorithms offer additional options for high-throughput APIs and background jobs, respectively.

For custom identity and per-route limits, use the HeaderExtractor class from drogue.core.identity. Custom identity allows you to use attributes other than IP addresses for rate limiting. RedisStorage is useful when you need to enable rate limits across multiple processes and workers. With RedisStorage, rate limits are shared across all workers and processes.

In case you want to override default error responses, create a custom error renderer function that returns a 429 response with JSON data. Finally, for WebSocket rate limiting, use the @limiter.limit_ws decorator, specifying the desired limit in requests per minute.

Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.

Read the original at dev.to →

More in Tech

EU Chatbot Runtime Selection: Making Linguistic Nuance Auditable Per Tenant

EU Chatbot Runtime Selection: Making Linguistic Nuance Auditable Per Tenant A runtime choice for an EU chatbot should be made from two ledgers: one for language behavior and one for tenant-level…

  • Runtime selection crucial for EU chatbot linguistic nuance
  • Isolated runtime for tenant-level expenses and easy replacement
  • Test set evaluated by locale, tenant, and cost records

How Android VpnService Builds a Tunnel, and How TrumanDash Implements It

TrumanDash (楚门快跑) is a free Android VPN from Dockerpay LLC. The package is com.trumandash.android . The product page is trumandash.com . The install target is TrumanDash on Google Play .

  • TrumanDash uses Android's VpnService to create a network tunnel
  • Encryption and obfuscation handled by external process, not VpnService
  • No user registration required, no logs stored or tracked

Exporting HTML Presentations to PPTX in the Browser: Notes for Front-End Developers

Front-end developers often end up as the unofficial "slides person" on a team. We can build a beautiful deck with HTML and CSS in an hour, but the request that follows is almost always the same…

  • HTML presentations rise due to AI generation and design system alignment
  • Rendering slides in browser then capturing yields high-fidelity output but static slides
  • Use render-and-capture tools like SlideBeaver for fast, static PPTX exports

cloudline is live. analytics without cookies.

29 days ago i started writing about a tool i was building. today you can install it. i'm om yaduvanshi, 18, an applied ai developer. i built cloudline, a cookieless analytics tool.

  • Cloudline analytics tool launched without cookies
  • One script tag installation, under 2kb size
  • Collects page, referrer, screen size, visit time

I'm Too Lazy to Write Alt Text, So Gemma Does It For Me

This is a submission for the Hacktoberfest Open-Source AI Challenge Week 3: Slow and Steady What I Built Every codebase I've touched has the same line in it: <img src= "/imgs/cookie.png" alt= "" />…

  • Gemma creates VS Code extension to auto-generate alt text for images
  • Extension runs locally on user's machine, ensuring privacy and security
  • Tests show extension processes images faster than manual alt text creation

From 1,464 Unrouted Nets to Zero — But I'm Still Not Calling This Board Manufacturable

TL;DR Part 2 of letting an AI agent (Codex, driving KiCad through its CLI) design my Raspberry Pi CM4 Mini-ITX IO board. The board is now fully routed and adopted as the official design : ERC 0, DRC…

  • Raspberry Pi CM4 Mini-ITX IO board formally verified as routeable on October 25
  • Fault simulation leaves -1.35 V on power controller pin, not explained
  • Board labeled as engineering prototype, not to be fabricated

More from Sunday 25 October →