106 lines
2.4 KiB
ReStructuredText
106 lines
2.4 KiB
ReStructuredText
Installation
|
|
============
|
|
|
|
FastAPI Traffic supports Python 3.10 and above. You can install it using pip, uv, or
|
|
any other Python package manager.
|
|
|
|
Basic Installation
|
|
------------------
|
|
|
|
The basic installation includes the memory backend, which is perfect for development
|
|
and single-process applications:
|
|
|
|
.. tab-set::
|
|
|
|
.. tab-item:: pip
|
|
|
|
.. code-block:: bash
|
|
|
|
pip install git+https://gitlab.com/zanewalker/fastapi-traffic.git
|
|
|
|
.. tab-item:: uv
|
|
|
|
.. code-block:: bash
|
|
|
|
uv add git+https://gitlab.com/zanewalker/fastapi-traffic.git
|
|
|
|
.. tab-item:: poetry
|
|
|
|
.. code-block:: bash
|
|
|
|
poetry add git+https://gitlab.com/zanewalker/fastapi-traffic.git
|
|
|
|
With Redis Support
|
|
------------------
|
|
|
|
If you're running a distributed system with multiple application instances, you'll
|
|
want the Redis backend:
|
|
|
|
.. tab-set::
|
|
|
|
.. tab-item:: pip
|
|
|
|
.. code-block:: bash
|
|
|
|
pip install "git+https://gitlab.com/zanewalker/fastapi-traffic.git[redis]"
|
|
|
|
.. tab-item:: uv
|
|
|
|
.. code-block:: bash
|
|
|
|
uv add "git+https://gitlab.com/zanewalker/fastapi-traffic.git[redis]"
|
|
|
|
Everything
|
|
----------
|
|
|
|
Want it all? Install with the ``all`` extra:
|
|
|
|
.. code-block:: bash
|
|
|
|
pip install "git+https://gitlab.com/zanewalker/fastapi-traffic.git[all]"
|
|
|
|
This includes Redis support and ensures FastAPI is installed as well.
|
|
|
|
Dependencies
|
|
------------
|
|
|
|
FastAPI Traffic has minimal dependencies:
|
|
|
|
- **pydantic** (>=2.0) — For configuration validation
|
|
- **starlette** (>=0.27.0) — The ASGI framework that FastAPI is built on
|
|
|
|
Optional dependencies:
|
|
|
|
- **redis** (>=5.0.0) — Required for the Redis backend
|
|
- **fastapi** (>=0.100.0) — While not strictly required (we work with Starlette directly),
|
|
you probably want this
|
|
|
|
Verifying the Installation
|
|
--------------------------
|
|
|
|
After installation, you can verify everything is working:
|
|
|
|
.. code-block:: python
|
|
|
|
import fastapi_traffic
|
|
print(fastapi_traffic.__version__)
|
|
# Should print: 0.3.2
|
|
|
|
Or check which backends are available:
|
|
|
|
.. code-block:: python
|
|
|
|
from fastapi_traffic import MemoryBackend, SQLiteBackend
|
|
print("Memory and SQLite backends available!")
|
|
|
|
try:
|
|
from fastapi_traffic import RedisBackend
|
|
print("Redis backend available!")
|
|
except ImportError:
|
|
print("Redis backend not installed (install with [redis] extra)")
|
|
|
|
What's Next?
|
|
------------
|
|
|
|
Head over to the :doc:`quickstart` guide to start rate limiting your endpoints.
|