Skip to main content

SlowApi

A rate limiting library for Starlette and FastAPI adapted from flask-limiter.

This package is used in various production setups, handling millions of requests per month, and seems to behave as expected. There might be some API changes when changing the code to be fully async, but we will notify users via appropriate semver version changes.

The documentation is on read the docs.

Quick start

Installation

slowapi is available from pypi so you can install it as usual:

$ pip install slowapi

Features

Most feature are coming from FlaskLimiter and the underlying limits.

Supported now:

  • Single and multiple limit decorator on endpoint functions to apply limits
  • redis, memcached and memory backends to track your limits (memory as a fallback)
  • support for sync and async HTTP endpoints
  • Support for shared limits across a set of routes
  • The library aims to support all currently supported versions of python

Limitations and known issues

  • The request argument must be explicitly passed to your endpoint, or slowapi won't be able to hook into it. In other words, write:
    @limiter.limit("5/minute")
    async def myendpoint(request: Request)
        pass

and not:

    @limiter.limit("5/minute")
    async def myendpoint()
        pass
  • websocket endpoints are not supported yet.

Developing and contributing

PRs are more than welcome! Please include tests for your changes :)

The package uses poetry to manage dependencies. To setup your dev env:

$ poetry install

To run the tests:

$ pytest

Publishing a new release

  • bump version in `pyproject.toml
  • poetry publish --build to build and publish the package to pypi

Credits

Credits go to flask-limiter of which SlowApi is a (still partial) adaptation to Starlette and FastAPI. It's also important to mention that the actual rate limiting work is done by limits, slowapi is just a wrapper around it.

Metadata

Release files for slowapi 0.1.10

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for slowapi 0.1.10
File Size Uploaded
slowapi-0.1.10.tar.gz 13.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for slowapi 0.1.10
File Interpreter ABI Platform
slowapi-0.1.10-py3-none-any.whl Python 3 none any Details

Total release size: 28.8 kB

Release files / slowapi-0.1.10.tar.gz

Download URL slowapi-0.1.10.tar.gz
Size 13.8 kB
Tags Source
SHA-256 checksum
How to use checksums
d320d5bc04d9f171a77fb16700faf3036d85b00f420f22924c8a225f95bd14f9
BLAKE2b-256 checksum
How to use checksums
b95224527cf25a8b508926aff53350b0136561dfe86c7125f61526653666e1b2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.1.3 CPython/3.11.2 Linux/6.17.13+deb14-amd64

Release files / slowapi-0.1.10-py3-none-any.whl

Download URL slowapi-0.1.10-py3-none-any.whl
Size 14.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
3acb61561dc9d687e3d3669362ff6a439de9ba44e2fed3a9c165da26b4b83e28
BLAKE2b-256 checksum
How to use checksums
c48b1d359f38706b4097d9a943bf8bd22599f537de4cbaff1e622d3e3936e164
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.1.3 CPython/3.11.2 Linux/6.17.13+deb14-amd64

Release history Release notifications | RSS feed

This release

0.1.10 This release

2 release files

0.1.9

2 release files

0.1.8

2 release files

0.1.7

2 release files

0.1.6

2 release files

0.1.5

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page