Metadata-Version: 2.4
Name: ferroapi
Version: 0.0.1
Classifier: Development Status :: 2 - Pre-Alpha
Classifier: Intended Audience :: Developers
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Rust
Classifier: Topic :: Internet :: WWW/HTTP :: HTTP Servers
Requires-Dist: pydantic>=2.12
Requires-Dist: typing-extensions>=4.14
License-File: LICENSE
Summary: A Python web framework for building APIs, with its server and framework written in Rust.
Author-email: Marcelo Trylesinski <marcelotryle@gmail.com>
License-Expression: MIT
Requires-Python: >=3.11
Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
Project-URL: Repository, https://github.com/Kludex/ferroapi

<p align="center">
    <em>Python APIs with a Rust core, from the socket up.</em>
</p>

---

**Source Code**: <a href="https://github.com/Kludex/ferroapi" target="_blank">https://github.com/Kludex/ferroapi</a>

---

FerroAPI is a web framework for building APIs with Python, inspired by FastAPI.

The difference is underneath: the server, the routing, the validation and the serialization are written in Rust, in one process. There is no ASGI in between.

The key features are:

* **Fast**: Over **4x** the requests per second of FastAPI on Uvicorn with zttp and zuvloop, and over **5x** when streaming. 🚀
* **Familiar**: Inspired by FastAPI: `Depends`, `response_model`, parameter models, security and OpenAPI docs work the way you know them.
* **Streaming**: JSON Lines, Server-Sent Events, request bodies and uploads that never fill your memory.
* **Modern**: HTTP/2 and TLS built in. WebSockets too.
* **Compatible**: Most of FastAPI's own test suite runs against it unchanged.

## Performance

<p align="center">
    <img src="docs/assets/benchmark.svg" alt="FerroAPI against FastAPI on Uvicorn with zttp and zuvloop, in requests per second">
</p>

One process each, on the same machine. Reproduce it with `benchmarks/run.sh`.

## Installation

```console
$ pip install ferroapi
```

> [!NOTE]
> FerroAPI is not released yet.

## Example

Create a file `main.py` with:

```python
from ferroapi import FerroAPI

app = FerroAPI()


@app.get("/")
async def read_root():
    return {"Hello": "World"}


@app.get("/items/{item_id}")
async def read_item(item_id: int, q: str | None = None):
    return {"item_id": item_id, "q": q}


app.run()
```

Run it:

```console
$ python main.py
```

Open <a href="http://127.0.0.1:8000/items/5?q=somequery" class="external-link" target="_blank">http://127.0.0.1:8000/items/5?q=somequery</a>. You will see:

```JSON
{"item_id": 5, "q": "somequery"}
```

And the interactive API docs at <a href="http://127.0.0.1:8000/docs" class="external-link" target="_blank">http://127.0.0.1:8000/docs</a>. ✨

## License

This project is licensed under the terms of the MIT license.

