* **Easy**: Designed to be easy to use and learn. Less time reading docs.
* **Short**: Minimize code duplication. Multiple features from each parameter declaration. Fewer bugs.
* **Robust**: Get production-ready code. With automatic interactive documentation.
* **Standards-based**: Based on (and fully compatible with) the open standards for APIs: <ahref="https://github.com/OAI/OpenAPI-Specification"class="external-link"target="_blank">OpenAPI</a> (previously known as Swagger) and <ahref="http://json-schema.org/"class="external-link"target="_blank">JSON Schema</a>.
* **Standards-based**: Based on (and fully compatible with) the open standards for APIs: <ahref="https://github.com/OAI/OpenAPI-Specification"class="external-link"target="_blank">OpenAPI</a> (previously known as Swagger) and <ahref="https://json-schema.org/"class="external-link"target="_blank">JSON Schema</a>.
<small>* estimation based on tests on an internal development team, building production applications.</small>
@ -81,7 +81,7 @@ The key features are:
"_Honestly, what you've built looks super solid and polished. In many ways, it's what I wanted **Hug** to be - it's really inspiring to see someone build that._"
You will also need an ASGI server, for production such as <ahref="http://www.uvicorn.org"class="external-link"target="_blank">Uvicorn</a> or <ahref="https://gitlab.com/pgjones/hypercorn"class="external-link"target="_blank">Hypercorn</a>.
You will also need an ASGI server, for production such as <ahref="https://www.uvicorn.org"class="external-link"target="_blank">Uvicorn</a> or <ahref="https://gitlab.com/pgjones/hypercorn"class="external-link"target="_blank">Hypercorn</a>.
<divclass="termy">
@ -438,9 +438,9 @@ Used by Pydantic:
Used by Starlette:
* <ahref="http://docs.python-requests.org"target="_blank"><code>requests</code></a> - Required if you want to use the `TestClient`.
* <ahref="https://requests.readthedocs.io"target="_blank"><code>requests</code></a> - Required if you want to use the `TestClient`.
* <ahref="https://github.com/Tinche/aiofiles"target="_blank"><code>aiofiles</code></a> - Required if you want to use `FileResponse` or `StaticFiles`.
* <ahref="http://jinja.pocoo.org"target="_blank"><code>jinja2</code></a> - Required if you want to use the default template configuration.
* <ahref="https://jinja.palletsprojects.com"target="_blank"><code>jinja2</code></a> - Required if you want to use the default template configuration.
* <ahref="https://andrew-d.github.io/python-multipart/"target="_blank"><code>python-multipart</code></a> - Required if you want to support form <abbrtitle="converting the string that comes from an HTTP request into Python data">"parsing"</abbr>, with `request.form()`.
* <ahref="https://pythonhosted.org/itsdangerous/"target="_blank"><code>itsdangerous</code></a> - Required for `SessionMiddleware` support.
* <ahref="https://pyyaml.org/wiki/PyYAMLDocumentation"target="_blank"><code>pyyaml</code></a> - Required for Starlette's `SchemaGenerator` support (you probably don't need it with FastAPI).
@ -449,7 +449,7 @@ Used by Starlette:
Used by FastAPI / Starlette:
* <ahref="http://www.uvicorn.org"target="_blank"><code>uvicorn</code></a> - for the server that loads and serves your application.
* <ahref="https://www.uvicorn.org"target="_blank"><code>uvicorn</code></a> - for the server that loads and serves your application.
* <ahref="https://github.com/ijl/orjson"target="_blank"><code>orjson</code></a> - Required if you want to use `ORJSONResponse`.
You can install all of these with `pip install fastapi[all]`.
If you are starting a project from scratch, you are probably better off with SQLAlchemy ORM ([SQL (Relational) Databases](../tutorial/sql-databases.md){.internal-link target=_blank}), or any other async ORM.
If you already have a code base that uses <ahref="http://docs.peewee-orm.com/en/latest/"class="external-link"target="_blank">Peewee ORM</a>, you can check here how to use it with **FastAPI**.
If you already have a code base that uses <ahref="https://docs.peewee-orm.com/en/latest/"class="external-link"target="_blank">Peewee ORM</a>, you can check here how to use it with **FastAPI**.
!!! warning "Python 3.7+ required"
You will need Python 3.7 or above to safely use Peewee with FastAPI.
@ -25,7 +25,7 @@ But if you need to change some of the defaults, support more than one predefined
Nevertheless, it's possible to do it, and here you'll see exactly what code you have to add to be able to use Peewee with FastAPI.
!!! note "Technical Details"
You can read more about Peewee's stand about async in Python <ahref="http://docs.peewee-orm.com/en/latest/peewee/database.html#async-with-gevent"class="external-link"target="_blank">in the docs</a>, <ahref="https://github.com/coleifer/peewee/issues/263#issuecomment-517347032"class="external-link"target="_blank">an issue</a>, <ahref="https://github.com/coleifer/peewee/pull/2072#issuecomment-563215132"class="external-link"target="_blank">a PR</a>.
You can read more about Peewee's stand about async in Python <ahref="https://docs.peewee-orm.com/en/latest/peewee/database.html#async-with-gevent"class="external-link"target="_blank">in the docs</a>, <ahref="https://github.com/coleifer/peewee/issues/263#issuecomment-517347032"class="external-link"target="_blank">an issue</a>, <ahref="https://github.com/coleifer/peewee/pull/2072#issuecomment-563215132"class="external-link"target="_blank">a PR</a>.
## The same app
@ -306,7 +306,7 @@ For the **next request**, as we will reset that context variable again in the `a
#### Peewee Proxy
If you are using a <ahref="http://docs.peewee-orm.com/en/latest/peewee/database.html#dynamically-defining-a-database"class="external-link"target="_blank">Peewee Proxy</a>, the actual database is at `db.obj`.
If you are using a <ahref="https://docs.peewee-orm.com/en/latest/peewee/database.html#dynamically-defining-a-database"class="external-link"target="_blank">Peewee Proxy</a>, the actual database is at `db.obj`.
**FastAPI** is not actually an alternative to **Requests**. Their scope is very different.
@ -276,7 +276,7 @@ Routes are declared in a single place, using functions declared in other places
This actually inspired updating parts of Pydantic, to support the same validation declaration style (all this functionality is now already available in Pydantic).
Hug was one of the first frameworks to implement the declaration of API parameter types using Python type hints. This was a great idea that inspired other tools to do the same.
@ -334,7 +334,7 @@ This same syntax (or almost identical) was also included recently in modern vers
But before that, handling asynchronous code was quite more complex and difficult.
In previous versions of Python, you could have used threads or <ahref="http://www.gevent.org/"class="external-link"target="_blank">Gevent</a>. But the code is way more complex to understand, debug, and think about.
In previous versions of Python, you could have used threads or <ahref="https://www.gevent.org/"class="external-link"target="_blank">Gevent</a>. But the code is way more complex to understand, debug, and think about.
In previous versions of NodeJS / Browser JavaScript, you would have used "callbacks". Which leads to <ahref="http://callbackhell.com/"class="external-link"target="_blank">callback hell</a>.
* <ahref="https://github.com/OAI/OpenAPI-Specification"class="external-link"target="_blank"><strong>OpenAPI</strong></a> for API creation, including declarations of <abbrtitle="also known as: endpoints, routes">path</abbr><abbrtitle="also known as HTTP methods, as POST, GET, PUT, DELETE">operations</abbr>, parameters, body requests, security, etc.
* Automatic data model documentation with <ahref="http://json-schema.org/"class="external-link"target="_blank"><strong>JSON Schema</strong></a> (as OpenAPI itself is based on JSON Schema).
* Automatic data model documentation with <ahref="https://json-schema.org/"class="external-link"target="_blank"><strong>JSON Schema</strong></a> (as OpenAPI itself is based on JSON Schema).
* Designed around these standards, after a meticulous study. Instead of an afterthought layer on top.
* This also allows using automatic **client code generation** in many languages.
* **Easy**: Designed to be easy to use and learn. Less time reading docs.
* **Short**: Minimize code duplication. Multiple features from each parameter declaration. Fewer bugs.
* **Robust**: Get production-ready code. With automatic interactive documentation.
* **Standards-based**: Based on (and fully compatible with) the open standards for APIs: <ahref="https://github.com/OAI/OpenAPI-Specification"class="external-link"target="_blank">OpenAPI</a> (previously known as Swagger) and <ahref="http://json-schema.org/"class="external-link"target="_blank">JSON Schema</a>.
* **Standards-based**: Based on (and fully compatible with) the open standards for APIs: <ahref="https://github.com/OAI/OpenAPI-Specification"class="external-link"target="_blank">OpenAPI</a> (previously known as Swagger) and <ahref="https://json-schema.org/"class="external-link"target="_blank">JSON Schema</a>.
<small>* estimation based on tests on an internal development team, building production applications.</small>
@ -85,7 +85,7 @@ The key features are:
"_Honestly, what you've built looks super solid and polished. In many ways, it's what I wanted **Hug** to be - it's really inspiring to see someone build that._"
You will also need an ASGI server, for production such as <ahref="http://www.uvicorn.org"class="external-link"target="_blank">Uvicorn</a> or <ahref="https://gitlab.com/pgjones/hypercorn"class="external-link"target="_blank">Hypercorn</a>.
You will also need an ASGI server, for production such as <ahref="https://www.uvicorn.org"class="external-link"target="_blank">Uvicorn</a> or <ahref="https://gitlab.com/pgjones/hypercorn"class="external-link"target="_blank">Hypercorn</a>.
<divclass="termy">
@ -442,9 +442,9 @@ Used by Pydantic:
Used by Starlette:
* <ahref="http://docs.python-requests.org"target="_blank"><code>requests</code></a> - Required if you want to use the `TestClient`.
* <ahref="https://requests.readthedocs.io"target="_blank"><code>requests</code></a> - Required if you want to use the `TestClient`.
* <ahref="https://github.com/Tinche/aiofiles"target="_blank"><code>aiofiles</code></a> - Required if you want to use `FileResponse` or `StaticFiles`.
* <ahref="http://jinja.pocoo.org"target="_blank"><code>jinja2</code></a> - Required if you want to use the default template configuration.
* <ahref="https://jinja.palletsprojects.com"target="_blank"><code>jinja2</code></a> - Required if you want to use the default template configuration.
* <ahref="https://andrew-d.github.io/python-multipart/"target="_blank"><code>python-multipart</code></a> - Required if you want to support form <abbrtitle="converting the string that comes from an HTTP request into Python data">"parsing"</abbr>, with `request.form()`.
* <ahref="https://pythonhosted.org/itsdangerous/"target="_blank"><code>itsdangerous</code></a> - Required for `SessionMiddleware` support.
* <ahref="https://pyyaml.org/wiki/PyYAMLDocumentation"target="_blank"><code>pyyaml</code></a> - Required for Starlette's `SchemaGenerator` support (you probably don't need it with FastAPI).
@ -453,7 +453,7 @@ Used by Starlette:
Used by FastAPI / Starlette:
* <ahref="http://www.uvicorn.org"target="_blank"><code>uvicorn</code></a> - for the server that loads and serves your application.
* <ahref="https://www.uvicorn.org"target="_blank"><code>uvicorn</code></a> - for the server that loads and serves your application.
* <ahref="https://github.com/ijl/orjson"target="_blank"><code>orjson</code></a> - Required if you want to use `ORJSONResponse`.
You can install all of these with `pip install fastapi[all]`.
* **Easy**: Designed to be easy to use and learn. Less time reading docs.
* **Short**: Minimize code duplication. Multiple features from each parameter declaration.
* **Robust**: Get production-ready code. With automatic interactive documentation.
* **Standards-based**: Based on (and fully compatible with) the open standards for APIs: <ahref="https://github.com/OAI/OpenAPI-Specification"class="external-link"target="_blank">OpenAPI</a> and <ahref="http://json-schema.org/"class="external-link"target="_blank">JSON Schema</a>.
* **Standards-based**: Based on (and fully compatible with) the open standards for APIs: <ahref="https://github.com/OAI/OpenAPI-Specification"class="external-link"target="_blank">OpenAPI</a> and <ahref="https://json-schema.org/"class="external-link"target="_blank">JSON Schema</a>.
* <a href="https://fastapi.tiangolo.com/features/" class="external-link" target="_blank">**Many other features**</a> including automatic validation, serialization, interactive documentation, authentication with OAuth2 JWT tokens, etc.
@ -81,7 +81,7 @@ You can see more details in <a href="https://www.starlette.io/background/" class
## Caveat
If you need to perform heavy background computation and you don't necessarily need it to be run by the same process (for example, you don't need to share memory, variables, etc), you might benefit from using other bigger tools like <ahref="https://docs.celeryproject.org/"class="external-link"target="_blank">Celery</a>.
If you need to perform heavy background computation and you don't necessarily need it to be run by the same process (for example, you don't need to share memory, variables, etc), you might benefit from using other bigger tools like <ahref="https://docs.celeryproject.org"class="external-link"target="_blank">Celery</a>.
They tend to require more complex configurations, a message/job queue manager, like RabbitMQ or Redis, but they allow you to run background tasks in multiple processes, and especially, in multiple servers.
@ -75,7 +75,7 @@ With just that Python type declaration, **FastAPI** will:
* If the data is invalid, it will return a nice and clear error, indicating exactly where and what was the incorrect data.
* Give you the received data in the parameter `item`.
* As you declared it in the function to be of type `Item`, you will also have all the editor support (completion, etc) for all of the attributes and their types.
* Generate <ahref="http://json-schema.org"class="external-link"target="_blank">JSON Schema</a> definitions for your model, you can also use them anywhere else you like if it makes sense for your project.
* Generate <ahref="https://json-schema.org"class="external-link"target="_blank">JSON Schema</a> definitions for your model, you can also use them anywhere else you like if it makes sense for your project.
* Those schemas will be part of the generated OpenAPI schema, and used by the automatic documentation <abbrtitle="User Interfaces">UIs</abbr>.
@ -553,7 +553,7 @@ And as the code related to SQLAlchemy and the SQLAlchemy models lives in separat
The same way, you would be able to use the same SQLAlchemy models and utilities in other parts of your code that are not related to **FastAPI**.
For example, in a background task worker with <ahref="https://docs.celeryproject.org/"class="external-link"target="_blank">Celery</a>, <ahref="https://python-rq.org/"class="external-link"target="_blank">RQ</a>, or <ahref="https://arq-docs.helpmanual.io/"class="external-link"target="_blank">ARQ</a>.
For example, in a background task worker with <ahref="https://docs.celeryproject.org"class="external-link"target="_blank">Celery</a>, <ahref="https://python-rq.org/"class="external-link"target="_blank">RQ</a>, or <ahref="https://arq-docs.helpmanual.io/"class="external-link"target="_blank">ARQ</a>.
Thanks to <ahref="https://www.starlette.io/testclient/"class="external-link"target="_blank">Starlette</a>, testing **FastAPI** applications is easy and enjoyable.
It is based on <ahref="http://docs.python-requests.org"class="external-link"target="_blank">Requests</a>, so it's very familiar and intuitive.
It is based on <ahref="https://requests.readthedocs.io"class="external-link"target="_blank">Requests</a>, so it's very familiar and intuitive.
With it, you can use <ahref="https://docs.pytest.org/"class="external-link"target="_blank">pytest</a> directly with **FastAPI**.
@ -97,7 +97,7 @@ E.g.:
* To pass *headers*, use a `dict` in the `headers` parameter.
* For *cookies*, a `dict` in the `cookies` parameter.
For more information about how to pass data to the backend (using `requests` or the `TestClient`) check the <ahref="http://docs.python-requests.org"class="external-link"target="_blank">Requests documentation</a>.
For more information about how to pass data to the backend (using `requests` or the `TestClient`) check the <ahref="https://requests.readthedocs.io"class="external-link"target="_blank">Requests documentation</a>.
!!! info
Note that the `TestClient` receives data that can be converted to JSON, not Pydantic models.
@ -334,7 +334,7 @@ Esta misma sintaxis (o casi idéntica) también se incluyó recientemente en las
Pero antes de eso, manejar código asíncrono era bastante más complejo y difícil.
En versiones anteriores de Python, podrías haber utilizado <abbrtitle="En español: hilos.">threads</abbr> o <ahref="http://www.gevent.org/"class="external-link"target="_blank">Gevent</a>. Pero el código es mucho más complejo de entender, depurar y desarrollar.
En versiones anteriores de Python, podrías haber utilizado <abbrtitle="En español: hilos.">threads</abbr> o <ahref="https://www.gevent.org/"class="external-link"target="_blank">Gevent</a>. Pero el código es mucho más complejo de entender, depurar y desarrollar.
En versiones anteriores de NodeJS / Browser JavaScript, habrías utilizado "callbacks". Lo que conduce a <ahref="http://callbackhell.com/"class="external-link"target="_blank">callback hell</a>.
* <ahref="https://github.com/OAI/OpenAPI-Specification"class="external-link"target="_blank"><strong>OpenAPI</strong></a> para la creación de APIs, incluyendo declaraciones de <abbrtitle="en español: ruta. En inglés también conocido cómo: endpoints, routes">path</abbr><abbrtitle="también conocido como HTTP methods, cómo POST, GET, PUT, DELETE">operations</abbr>, parámetros, <abbrtitle="cuerpo del mensaje HTTP">body</abbr> requests, seguridad, etc.
* Documentación automática del modelo de datos con <ahref="http://json-schema.org/"class="external-link"target="_blank"><strong>JSON Schema</strong></a> (dado que OpenAPI mismo está basado en JSON Schema).
* Documentación automática del modelo de datos con <ahref="https://json-schema.org/"class="external-link"target="_blank"><strong>JSON Schema</strong></a> (dado que OpenAPI mismo está basado en JSON Schema).
* Diseñado alrededor de estos estándares después de un estudio meticuloso. En vez de ser una capa añadida a último momento.
* Esto también permite la **generación automática de código de cliente** para muchos lenguajes.
@ -38,7 +38,7 @@ Sus características principales son:
* **Fácil**: Está diseñado para ser fácil de usar y aprender. Gastando menos tiempo leyendo documentación.
* **Corto**: Minimiza la duplicación de código. Múltiples funcionalidades con cada declaración de parámetros. Menos errores.
* **Robusto**: Crea código listo para producción con documentación automática interactiva.
* **Basado en estándares**: Basado y totalmente compatible con los estándares abiertos para APIs: <ahref="https://github.com/OAI/OpenAPI-Specification"class="external-link"target="_blank">OpenAPI</a> (conocido previamente como Swagger) y <ahref="http://json-schema.org/"class="external-link"target="_blank">JSON Schema</a>.
* **Basado en estándares**: Basado y totalmente compatible con los estándares abiertos para APIs: <ahref="https://github.com/OAI/OpenAPI-Specification"class="external-link"target="_blank">OpenAPI</a> (conocido previamente como Swagger) y <ahref="https://json-schema.org/"class="external-link"target="_blank">JSON Schema</a>.
<small>* Esta estimación está basada en pruebas con un equipo de desarrollo interno contruyendo aplicaciones listas para producción.</small>
@ -84,7 +84,7 @@ Sus características principales son:
"_Honestly, what you've built looks super solid and polished. In many ways, it's what I wanted **Hug** to be - it's really inspiring to see someone build that._"
También vas a necesitar un servidor ASGI para producción cómo <ahref="http://www.uvicorn.org"class="external-link"target="_blank">Uvicorn</a> o <ahref="https://gitlab.com/pgjones/hypercorn"class="external-link"target="_blank">Hypercorn</a>.
También vas a necesitar un servidor ASGI para producción cómo <ahref="https://www.uvicorn.org"class="external-link"target="_blank">Uvicorn</a> o <ahref="https://gitlab.com/pgjones/hypercorn"class="external-link"target="_blank">Hypercorn</a>.
<divclass="termy">
@ -438,9 +438,9 @@ Usadas por Pydantic:
Usados por Starlette:
* <ahref="http://docs.python-requests.org"target="_blank"><code>requests</code></a> - Requerido si quieres usar el `TestClient`.
* <ahref="https://requests.readthedocs.io"target="_blank"><code>requests</code></a> - Requerido si quieres usar el `TestClient`.
* <ahref="https://github.com/Tinche/aiofiles"target="_blank"><code>aiofiles</code></a> - Requerido si quieres usar `FileResponse` o `StaticFiles`.
* <ahref="http://jinja.pocoo.org"target="_blank"><code>jinja2</code></a> - Requerido si quieres usar la configuración por defecto de templates.
* <ahref="https://jinja.palletsprojects.com"target="_blank"><code>jinja2</code></a> - Requerido si quieres usar la configuración por defecto de templates.
* <ahref="https://andrew-d.github.io/python-multipart/"target="_blank"><code>python-multipart</code></a> - Requerido si quieres dar soporte a <abbrtitle="convertir el string que viene de un HTTP request a datos de Python">"parsing"</abbr> de formularios, con `request.form()`.
* <ahref="https://pythonhosted.org/itsdangerous/"target="_blank"><code>itsdangerous</code></a> - Requerido para dar soporte a `SessionMiddleware`.
* <ahref="https://pyyaml.org/wiki/PyYAMLDocumentation"target="_blank"><code>pyyaml</code></a> - Requerido para dar soporte al `SchemaGenerator` de Starlette (probablemente no lo necesites con FastAPI).
@ -449,7 +449,7 @@ Usados por Starlette:
Usado por FastAPI / Starlette:
* <ahref="http://www.uvicorn.org"target="_blank"><code>uvicorn</code></a> - para el servidor que carga y sirve tu aplicación.
* <ahref="https://www.uvicorn.org"target="_blank"><code>uvicorn</code></a> - para el servidor que carga y sirve tu aplicación.
* <ahref="https://github.com/ijl/orjson"target="_blank"><code>orjson</code></a> - Requerido si quieres usar `ORJSONResponse`.
Puedes instalarlos con `pip install fastapi[all]`.
* **Easy**: Designed to be easy to use and learn. Less time reading docs.
* **Short**: Minimize code duplication. Multiple features from each parameter declaration. Fewer bugs.
* **Robust**: Get production-ready code. With automatic interactive documentation.
* **Standards-based**: Based on (and fully compatible with) the open standards for APIs: <ahref="https://github.com/OAI/OpenAPI-Specification"class="external-link"target="_blank">OpenAPI</a> (previously known as Swagger) and <ahref="http://json-schema.org/"class="external-link"target="_blank">JSON Schema</a>.
* **Standards-based**: Based on (and fully compatible with) the open standards for APIs: <ahref="https://github.com/OAI/OpenAPI-Specification"class="external-link"target="_blank">OpenAPI</a> (previously known as Swagger) and <ahref="https://json-schema.org/"class="external-link"target="_blank">JSON Schema</a>.
<small>* estimation based on tests on an internal development team, building production applications.</small>
@ -89,7 +89,7 @@ The key features are:
"_Honestly, what you've built looks super solid and polished. In many ways, it's what I wanted **Hug** to be - it's really inspiring to see someone build that._"
You will also need an ASGI server, for production such as <ahref="http://www.uvicorn.org"class="external-link"target="_blank">Uvicorn</a> or <ahref="https://gitlab.com/pgjones/hypercorn"class="external-link"target="_blank">Hypercorn</a>.
You will also need an ASGI server, for production such as <ahref="https://www.uvicorn.org"class="external-link"target="_blank">Uvicorn</a> or <ahref="https://gitlab.com/pgjones/hypercorn"class="external-link"target="_blank">Hypercorn</a>.
<divclass="termy">
@ -446,9 +446,9 @@ Used by Pydantic:
Used by Starlette:
* <ahref="http://docs.python-requests.org"target="_blank"><code>requests</code></a> - Required if you want to use the `TestClient`.
* <ahref="https://requests.readthedocs.io"target="_blank"><code>requests</code></a> - Required if you want to use the `TestClient`.
* <ahref="https://github.com/Tinche/aiofiles"target="_blank"><code>aiofiles</code></a> - Required if you want to use `FileResponse` or `StaticFiles`.
* <ahref="http://jinja.pocoo.org"target="_blank"><code>jinja2</code></a> - Required if you want to use the default template configuration.
* <ahref="https://jinja.palletsprojects.com"target="_blank"><code>jinja2</code></a> - Required if you want to use the default template configuration.
* <ahref="https://andrew-d.github.io/python-multipart/"target="_blank"><code>python-multipart</code></a> - Required if you want to support form <abbrtitle="converting the string that comes from an HTTP request into Python data">"parsing"</abbr>, with `request.form()`.
* <ahref="https://pythonhosted.org/itsdangerous/"target="_blank"><code>itsdangerous</code></a> - Required for `SessionMiddleware` support.
* <ahref="https://pyyaml.org/wiki/PyYAMLDocumentation"target="_blank"><code>pyyaml</code></a> - Required for Starlette's `SchemaGenerator` support (you probably don't need it with FastAPI).
@ -457,7 +457,7 @@ Used by Starlette:
Used by FastAPI / Starlette:
* <ahref="http://www.uvicorn.org"target="_blank"><code>uvicorn</code></a> - for the server that loads and serves your application.
* <ahref="https://www.uvicorn.org"target="_blank"><code>uvicorn</code></a> - for the server that loads and serves your application.
* <ahref="https://github.com/ijl/orjson"target="_blank"><code>orjson</code></a> - Required if you want to use `ORJSONResponse`.
You can install all of these with `pip install fastapi[all]`.
* **Easy**: Designed to be easy to use and learn. Less time reading docs.
* **Short**: Minimize code duplication. Multiple features from each parameter declaration. Fewer bugs.
* **Robust**: Get production-ready code. With automatic interactive documentation.
* **Standards-based**: Based on (and fully compatible with) the open standards for APIs: <ahref="https://github.com/OAI/OpenAPI-Specification"class="external-link"target="_blank">OpenAPI</a> (previously known as Swagger) and <ahref="http://json-schema.org/"class="external-link"target="_blank">JSON Schema</a>.
* **Standards-based**: Based on (and fully compatible with) the open standards for APIs: <ahref="https://github.com/OAI/OpenAPI-Specification"class="external-link"target="_blank">OpenAPI</a> (previously known as Swagger) and <ahref="https://json-schema.org/"class="external-link"target="_blank">JSON Schema</a>.
<small>* estimation based on tests on an internal development team, building production applications.</small>
@ -89,7 +89,7 @@ The key features are:
"_Honestly, what you've built looks super solid and polished. In many ways, it's what I wanted **Hug** to be - it's really inspiring to see someone build that._"
You will also need an ASGI server, for production such as <ahref="http://www.uvicorn.org"class="external-link"target="_blank">Uvicorn</a> or <ahref="https://gitlab.com/pgjones/hypercorn"class="external-link"target="_blank">Hypercorn</a>.
You will also need an ASGI server, for production such as <ahref="https://www.uvicorn.org"class="external-link"target="_blank">Uvicorn</a> or <ahref="https://gitlab.com/pgjones/hypercorn"class="external-link"target="_blank">Hypercorn</a>.
<divclass="termy">
@ -443,9 +443,9 @@ Used by Pydantic:
Used by Starlette:
* <ahref="http://docs.python-requests.org"target="_blank"><code>requests</code></a> - Required if you want to use the `TestClient`.
* <ahref="https://requests.readthedocs.io"target="_blank"><code>requests</code></a> - Required if you want to use the `TestClient`.
* <ahref="https://github.com/Tinche/aiofiles"target="_blank"><code>aiofiles</code></a> - Required if you want to use `FileResponse` or `StaticFiles`.
* <ahref="http://jinja.pocoo.org"target="_blank"><code>jinja2</code></a> - Required if you want to use the default template configuration.
* <ahref="https://jinja.palletsprojects.com"target="_blank"><code>jinja2</code></a> - Required if you want to use the default template configuration.
* <ahref="https://andrew-d.github.io/python-multipart/"target="_blank"><code>python-multipart</code></a> - Required if you want to support form <abbrtitle="converting the string that comes from an HTTP request into Python data">"parsing"</abbr>, with `request.form()`.
* <ahref="https://pythonhosted.org/itsdangerous/"target="_blank"><code>itsdangerous</code></a> - Required for `SessionMiddleware` support.
* <ahref="https://pyyaml.org/wiki/PyYAMLDocumentation"target="_blank"><code>pyyaml</code></a> - Required for Starlette's `SchemaGenerator` support (you probably don't need it with FastAPI).
@ -454,7 +454,7 @@ Used by Starlette:
Used by FastAPI / Starlette:
* <ahref="http://www.uvicorn.org"target="_blank"><code>uvicorn</code></a> - for the server that loads and serves your application.
* <ahref="https://www.uvicorn.org"target="_blank"><code>uvicorn</code></a> - for the server that loads and serves your application.
* <ahref="https://github.com/ijl/orjson"target="_blank"><code>orjson</code></a> - Required if you want to use `ORJSONResponse`.
You can install all of these with `pip install fastapi[all]`.
- <ahref="https://andrew-d.github.io/python-multipart/"target="_blank"><code>python-multipart</code></a> - <abbrtitle="converting the string that comes from an HTTP request into Python data">"parsing"</abbr>`request.form()`からの変換をサポートしたい場合は必要です。
**FastAPI** não é uma alternativa para **Requests**. O escopo deles é muito diferente.
@ -272,7 +272,7 @@ Rotas são declaradas em um único lugar, usando funções declaradas em outros
Isso na verdade inspirou a atualização de partes do Pydantic, para dar suporte ao mesmo estilo de declaração da validação (toda essa funcionalidade já está disponível no Pydantic).
Hug foi um dos primeiros frameworks a implementar a declaração de tipos de parâmetros usando Python _type hints_. Isso foi uma ótima idéia que inspirou outras ferramentas a fazer o mesmo.
* <ahref="https://github.com/OAI/OpenAPI-Specification"class="external-link"target="_blank"><strong>OpenAPI</strong></a> para criação de APIs, incluindo declarações de <abbrtitle="também conhecido como métodos HTTP, como POST, GET, PUT, DELETE">operações</abbr> de <abbrtitle="também conhecido como: endpoints, routes">caminho</abbr>, parâmetros, requisições de corpo, segurança etc.
* Modelo de documentação automática com <ahref="http://json-schema.org/"class="external-link"target="_blank"><strong>JSON Schema</strong></a> (já que o OpenAPI em si é baseado no JSON Schema).
* Modelo de documentação automática com <ahref="https://json-schema.org/"class="external-link"target="_blank"><strong>JSON Schema</strong></a> (já que o OpenAPI em si é baseado no JSON Schema).
* Projetado em cima desses padrões após um estudo meticuloso, em vez de uma reflexão breve.
* Isso também permite o uso de **geração de código do cliente** automaticamente em muitas linguagens.
* **Fácil**: Projetado para ser fácil de aprender e usar. Menos tempo lendo documentação.
* **Enxuto**: Minimize duplicação de código. Múltiplos recursos para cada declaração de parâmetro. Menos bugs.
* **Robusto**: Tenha código pronto para produção. E com documentação interativa automática.
* **Baseado em padrões**: Baseado em (e totalmente compatível com) os padrões abertos para APIs: <ahref="https://github.com/OAI/OpenAPI-Specification"class="external-link"target="_blank">OpenAPI</a> (anteriormente conhecido como Swagger) e <ahref="http://json-schema.org/"class="external-link"target="_blank">_JSON Schema_</a>.
* **Baseado em padrões**: Baseado em (e totalmente compatível com) os padrões abertos para APIs: <ahref="https://github.com/OAI/OpenAPI-Specification"class="external-link"target="_blank">OpenAPI</a> (anteriormente conhecido como Swagger) e <ahref="https://json-schema.org/"class="external-link"target="_blank">_JSON Schema_</a>.
<small>* estimativas baseadas em testes realizados com equipe interna de desenvolvimento, construindo aplicações em produção.</small>
@ -72,7 +72,7 @@ Os recursos chave são:
"*Honestamente, o que você construiu parece super sólido e rebuscado. De muitas formas, eu queria que o **Hug** fosse assim - é realmente inspirador ver alguém que construiu ele.*"
Você também precisará de um servidor ASGI para produção, tal como <ahref="http://www.uvicorn.org"class="external-link"target="_blank">Uvicorn</a> ou <ahref="https://gitlab.com/pgjones/hypercorn"class="external-link"target="_blank">Hypercorn</a>.
Você também precisará de um servidor ASGI para produção, tal como <ahref="https://www.uvicorn.org"class="external-link"target="_blank">Uvicorn</a> ou <ahref="https://gitlab.com/pgjones/hypercorn"class="external-link"target="_blank">Hypercorn</a>.
<divclass="termy">
@ -433,9 +433,9 @@ Usados por Pydantic:
Usados por Starlette:
* <ahref="http://docs.python-requests.org"target="_blank"><code>requests</code></a> - Necessário se você quiser utilizar o `TestClient`.
* <ahref="https://requests.readthedocs.io"target="_blank"><code>requests</code></a> - Necessário se você quiser utilizar o `TestClient`.
* <ahref="https://github.com/Tinche/aiofiles"target="_blank"><code>aiofiles</code></a> - Necessário se você quiser utilizar o `FileResponse` ou `StaticFiles`.
* <ahref="http://jinja.pocoo.org"target="_blank"><code>jinja2</code></a> - Necessário se você quiser utilizar a configuração padrão de templates.
* <ahref="https://jinja.palletsprojects.com"target="_blank"><code>jinja2</code></a> - Necessário se você quiser utilizar a configuração padrão de templates.
* <ahref="https://andrew-d.github.io/python-multipart/"target="_blank"><code>python-multipart</code></a> - Necessário se você quiser suporte com <abbrtitle="converte uma string que chega de uma requisição HTTP para dados Python">"parsing"</abbr> de formulário, com `request.form()`.
* <ahref="https://pythonhosted.org/itsdangerous/"target="_blank"><code>itsdangerous</code></a> - Necessário para suporte a `SessionMiddleware`.
* <ahref="https://pyyaml.org/wiki/PyYAMLDocumentation"target="_blank"><code>pyyaml</code></a> - Necessário para suporte a `SchemaGenerator` da Starlette (você provavelmente não precisará disso com o FastAPI).
@ -444,7 +444,7 @@ Usados por Starlette:
Usados por FastAPI / Starlette:
* <ahref="http://www.uvicorn.org"target="_blank"><code>uvicorn</code></a> - para o servidor que carrega e serve sua aplicação.
* <ahref="https://www.uvicorn.org"target="_blank"><code>uvicorn</code></a> - para o servidor que carrega e serve sua aplicação.
* <ahref="https://github.com/ijl/orjson"target="_blank"><code>orjson</code></a> - Necessário se você quer utilizar `ORJSONResponse`.
Você pode instalar todas essas dependências com `pip install fastapi[all]`.
* **Easy**: Designed to be easy to use and learn. Less time reading docs.
* **Short**: Minimize code duplication. Multiple features from each parameter declaration. Fewer bugs.
* **Robust**: Get production-ready code. With automatic interactive documentation.
* **Standards-based**: Based on (and fully compatible with) the open standards for APIs: <ahref="https://github.com/OAI/OpenAPI-Specification"class="external-link"target="_blank">OpenAPI</a> (previously known as Swagger) and <ahref="http://json-schema.org/"class="external-link"target="_blank">JSON Schema</a>.
* **Standards-based**: Based on (and fully compatible with) the open standards for APIs: <ahref="https://github.com/OAI/OpenAPI-Specification"class="external-link"target="_blank">OpenAPI</a> (previously known as Swagger) and <ahref="https://json-schema.org/"class="external-link"target="_blank">JSON Schema</a>.
<small>* estimation based on tests on an internal development team, building production applications.</small>
@ -89,7 +89,7 @@ The key features are:
"_Honestly, what you've built looks super solid and polished. In many ways, it's what I wanted **Hug** to be - it's really inspiring to see someone build that._"
You will also need an ASGI server, for production such as <ahref="http://www.uvicorn.org"class="external-link"target="_blank">Uvicorn</a> or <ahref="https://gitlab.com/pgjones/hypercorn"class="external-link"target="_blank">Hypercorn</a>.
You will also need an ASGI server, for production such as <ahref="https://www.uvicorn.org"class="external-link"target="_blank">Uvicorn</a> or <ahref="https://gitlab.com/pgjones/hypercorn"class="external-link"target="_blank">Hypercorn</a>.
<divclass="termy">
@ -446,9 +446,9 @@ Used by Pydantic:
Used by Starlette:
* <ahref="http://docs.python-requests.org"target="_blank"><code>requests</code></a> - Required if you want to use the `TestClient`.
* <ahref="https://requests.readthedocs.io"target="_blank"><code>requests</code></a> - Required if you want to use the `TestClient`.
* <ahref="https://github.com/Tinche/aiofiles"target="_blank"><code>aiofiles</code></a> - Required if you want to use `FileResponse` or `StaticFiles`.
* <ahref="http://jinja.pocoo.org"target="_blank"><code>jinja2</code></a> - Required if you want to use the default template configuration.
* <ahref="https://jinja.palletsprojects.com"target="_blank"><code>jinja2</code></a> - Required if you want to use the default template configuration.
* <ahref="https://andrew-d.github.io/python-multipart/"target="_blank"><code>python-multipart</code></a> - Required if you want to support form <abbrtitle="converting the string that comes from an HTTP request into Python data">"parsing"</abbr>, with `request.form()`.
* <ahref="https://pythonhosted.org/itsdangerous/"target="_blank"><code>itsdangerous</code></a> - Required for `SessionMiddleware` support.
* <ahref="https://pyyaml.org/wiki/PyYAMLDocumentation"target="_blank"><code>pyyaml</code></a> - Required for Starlette's `SchemaGenerator` support (you probably don't need it with FastAPI).
@ -457,7 +457,7 @@ Used by Starlette:
Used by FastAPI / Starlette:
* <ahref="http://www.uvicorn.org"target="_blank"><code>uvicorn</code></a> - for the server that loads and serves your application.
* <ahref="https://www.uvicorn.org"target="_blank"><code>uvicorn</code></a> - for the server that loads and serves your application.
* <ahref="https://github.com/ijl/orjson"target="_blank"><code>orjson</code></a> - Required if you want to use `ORJSONResponse`.
You can install all of these with `pip install fastapi[all]`.
* **Easy**: Designed to be easy to use and learn. Less time reading docs.
* **Short**: Minimize code duplication. Multiple features from each parameter declaration. Fewer bugs.
* **Robust**: Get production-ready code. With automatic interactive documentation.
* **Standards-based**: Based on (and fully compatible with) the open standards for APIs: <ahref="https://github.com/OAI/OpenAPI-Specification"class="external-link"target="_blank">OpenAPI</a> (previously known as Swagger) and <ahref="http://json-schema.org/"class="external-link"target="_blank">JSON Schema</a>.
* **Standards-based**: Based on (and fully compatible with) the open standards for APIs: <ahref="https://github.com/OAI/OpenAPI-Specification"class="external-link"target="_blank">OpenAPI</a> (previously known as Swagger) and <ahref="https://json-schema.org/"class="external-link"target="_blank">JSON Schema</a>.
<small>* estimation based on tests on an internal development team, building production applications.</small>
@ -89,7 +89,7 @@ The key features are:
"_Honestly, what you've built looks super solid and polished. In many ways, it's what I wanted **Hug** to be - it's really inspiring to see someone build that._"
You will also need an ASGI server, for production such as <ahref="http://www.uvicorn.org"class="external-link"target="_blank">Uvicorn</a> or <ahref="https://gitlab.com/pgjones/hypercorn"class="external-link"target="_blank">Hypercorn</a>.
You will also need an ASGI server, for production such as <ahref="https://www.uvicorn.org"class="external-link"target="_blank">Uvicorn</a> or <ahref="https://gitlab.com/pgjones/hypercorn"class="external-link"target="_blank">Hypercorn</a>.
<divclass="termy">
@ -446,9 +446,9 @@ Used by Pydantic:
Used by Starlette:
* <ahref="http://docs.python-requests.org"target="_blank"><code>requests</code></a> - Required if you want to use the `TestClient`.
* <ahref="https://requests.readthedocs.io"target="_blank"><code>requests</code></a> - Required if you want to use the `TestClient`.
* <ahref="https://github.com/Tinche/aiofiles"target="_blank"><code>aiofiles</code></a> - Required if you want to use `FileResponse` or `StaticFiles`.
* <ahref="http://jinja.pocoo.org"target="_blank"><code>jinja2</code></a> - Required if you want to use the default template configuration.
* <ahref="https://jinja.palletsprojects.com"target="_blank"><code>jinja2</code></a> - Required if you want to use the default template configuration.
* <ahref="https://andrew-d.github.io/python-multipart/"target="_blank"><code>python-multipart</code></a> - Required if you want to support form <abbrtitle="converting the string that comes from an HTTP request into Python data">"parsing"</abbr>, with `request.form()`.
* <ahref="https://pythonhosted.org/itsdangerous/"target="_blank"><code>itsdangerous</code></a> - Required for `SessionMiddleware` support.
* <ahref="https://pyyaml.org/wiki/PyYAMLDocumentation"target="_blank"><code>pyyaml</code></a> - Required for Starlette's `SchemaGenerator` support (you probably don't need it with FastAPI).
@ -457,7 +457,7 @@ Used by Starlette:
Used by FastAPI / Starlette:
* <ahref="http://www.uvicorn.org"target="_blank"><code>uvicorn</code></a> - for the server that loads and serves your application.
* <ahref="https://www.uvicorn.org"target="_blank"><code>uvicorn</code></a> - for the server that loads and serves your application.
* <ahref="https://github.com/ijl/orjson"target="_blank"><code>orjson</code></a> - Required if you want to use `ORJSONResponse`.
You can install all of these with `pip install fastapi[all]`.
* **Easy**: Designed to be easy to use and learn. Less time reading docs.
* **Short**: Minimize code duplication. Multiple features from each parameter declaration. Fewer bugs.
* **Robust**: Get production-ready code. With automatic interactive documentation.
* **Standards-based**: Based on (and fully compatible with) the open standards for APIs: <ahref="https://github.com/OAI/OpenAPI-Specification"class="external-link"target="_blank">OpenAPI</a> (previously known as Swagger) and <ahref="http://json-schema.org/"class="external-link"target="_blank">JSON Schema</a>.
* **Standards-based**: Based on (and fully compatible with) the open standards for APIs: <ahref="https://github.com/OAI/OpenAPI-Specification"class="external-link"target="_blank">OpenAPI</a> (previously known as Swagger) and <ahref="https://json-schema.org/"class="external-link"target="_blank">JSON Schema</a>.
<small>* estimation based on tests on an internal development team, building production applications.</small>
@ -89,7 +89,7 @@ The key features are:
"_Honestly, what you've built looks super solid and polished. In many ways, it's what I wanted **Hug** to be - it's really inspiring to see someone build that._"
You will also need an ASGI server, for production such as <ahref="http://www.uvicorn.org"class="external-link"target="_blank">Uvicorn</a> or <ahref="https://gitlab.com/pgjones/hypercorn"class="external-link"target="_blank">Hypercorn</a>.
You will also need an ASGI server, for production such as <ahref="https://www.uvicorn.org"class="external-link"target="_blank">Uvicorn</a> or <ahref="https://gitlab.com/pgjones/hypercorn"class="external-link"target="_blank">Hypercorn</a>.
<divclass="termy">
@ -446,9 +446,9 @@ Used by Pydantic:
Used by Starlette:
* <ahref="http://docs.python-requests.org"target="_blank"><code>requests</code></a> - Required if you want to use the `TestClient`.
* <ahref="https://requests.readthedocs.io"target="_blank"><code>requests</code></a> - Required if you want to use the `TestClient`.
* <ahref="https://github.com/Tinche/aiofiles"target="_blank"><code>aiofiles</code></a> - Required if you want to use `FileResponse` or `StaticFiles`.
* <ahref="http://jinja.pocoo.org"target="_blank"><code>jinja2</code></a> - Required if you want to use the default template configuration.
* <ahref="https://jinja.palletsprojects.com"target="_blank"><code>jinja2</code></a> - Required if you want to use the default template configuration.
* <ahref="https://andrew-d.github.io/python-multipart/"target="_blank"><code>python-multipart</code></a> - Required if you want to support form <abbrtitle="converting the string that comes from an HTTP request into Python data">"parsing"</abbr>, with `request.form()`.
* <ahref="https://pythonhosted.org/itsdangerous/"target="_blank"><code>itsdangerous</code></a> - Required for `SessionMiddleware` support.
* <ahref="https://pyyaml.org/wiki/PyYAMLDocumentation"target="_blank"><code>pyyaml</code></a> - Required for Starlette's `SchemaGenerator` support (you probably don't need it with FastAPI).
@ -457,7 +457,7 @@ Used by Starlette:
Used by FastAPI / Starlette:
* <ahref="http://www.uvicorn.org"target="_blank"><code>uvicorn</code></a> - for the server that loads and serves your application.
* <ahref="https://www.uvicorn.org"target="_blank"><code>uvicorn</code></a> - for the server that loads and serves your application.
* <ahref="https://github.com/ijl/orjson"target="_blank"><code>orjson</code></a> - Required if you want to use `ORJSONResponse`.
You can install all of these with `pip install fastapi[all]`.