diff --git a/README.md b/README.md
index 16d149f8fe..c11dc0480f 100644
--- a/README.md
+++ b/README.md
@@ -38,7 +38,7 @@ The key features are:
* **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: OpenAPI (previously known as Swagger) and JSON Schema.
+* **Standards-based**: Based on (and fully compatible with) the open standards for APIs: OpenAPI (previously known as Swagger) and JSON Schema.
* estimation based on tests conducted by an internal development team, building production applications.
@@ -72,7 +72,7 @@ The key features are:
-Other sponsors
+Other sponsors
## Opinions
@@ -122,7 +122,7 @@ The key features are:
## FastAPI mini documentary
-There's a FastAPI mini documentary released at the end of 2025, you can watch it online:
+There's a FastAPI mini documentary released at the end of 2025, you can watch it online:
@@ -130,7 +130,7 @@ There's a
-If you are building a CLI app to be used in the terminal instead of a web API, check out **Typer**.
+If you are building a CLI app to be used in the terminal instead of a web API, check out **Typer**.
**Typer** is FastAPI's little sibling. And it's intended to be the **FastAPI of CLIs**. β¨οΈ π
@@ -138,12 +138,12 @@ If you are building a CLI app to be
FastAPI stands on the shoulders of giants:
-* Starlette for the web parts.
-* Pydantic for the data parts.
+* Starlette for the web parts.
+* Pydantic for the data parts.
## Installation
-Create and activate a virtual environment and then install FastAPI:
+Create and activate a virtual environment and then install FastAPI:
fastapi dev main.py...uvicorn - for the server that loads and serves your application. This includes `uvicorn[standard]`, which includes some dependencies (e.g. `uvloop`) needed for high performance serving.
* `fastapi-cli[standard]` - to provide the `fastapi` command.
- * This includes `fastapi-cloud-cli`, which allows you to deploy your FastAPI application to FastAPI Cloud.
+ * This includes `fastapi-cloud-cli`, which allows you to deploy your FastAPI application to FastAPI Cloud.
### Without `standard` Dependencies
diff --git a/docs/en/docs/_llm-test.md b/docs/en/docs/_llm-test.md
index cdca5857e6..f8dbe018f7 100644
--- a/docs/en/docs/_llm-test.md
+++ b/docs/en/docs/_llm-test.md
@@ -11,7 +11,7 @@ Use as follows:
* Check if things are okay in the translation.
* If necessary, improve your language specific prompt, the general prompt, or the English document.
* Then manually fix the remaining issues in the translation, so that it is a good translation.
-* Retranslate, having the good translation in place. The ideal result would be that the LLM makes no changes anymore to the translation. That means that the general prompt and your language specific prompt are as good as they can be (It will sometimes make a few seemingly random changes, the reason is that LLMs are not deterministic algorithms).
+* Retranslate, having the good translation in place. The ideal result would be that the LLM makes no changes anymore to the translation. That means that the general prompt and your language specific prompt are as good as they can be (It will sometimes make a few seemingly random changes, the reason is that [LLMs are not deterministic algorithms](https://doublespeak.chat/#/handbook#deterministic-output){target=_blank}).
The tests:
@@ -169,15 +169,15 @@ See sections `### Special blocks` and `### Tab blocks` in the general prompt in
The link text should get translated, the link address should remain unchanged:
* [Link to heading above](#code-snippets)
-* [Internal link](index.md#installation){.internal-link target=_blank}
-* External link
-* Link to a style
-* Link to a script
-* Link to an image
+* [Internal link](index.md#installation){target=_blank}
+* [External link](https://sqlmodel.tiangolo.com/){target=_blank}
+* [Link to a style](https://fastapi.tiangolo.com/css/styles.css){target=_blank}
+* [Link to a script](https://fastapi.tiangolo.com/js/logic.js){target=_blank}
+* [Link to an image](https://fastapi.tiangolo.com/img/foo.jpg){target=_blank}
The link text should get translated, the link address should point to the translation:
-* FastAPI link
+* [FastAPI link](https://fastapi.tiangolo.com/){target=_blank}
////
diff --git a/docs/en/docs/advanced/additional-responses.md b/docs/en/docs/advanced/additional-responses.md
index 6306bd1f9a..9b61c09d7e 100644
--- a/docs/en/docs/advanced/additional-responses.md
+++ b/docs/en/docs/advanced/additional-responses.md
@@ -243,5 +243,5 @@ For example:
To see what exactly you can include in the responses, you can check these sections in the OpenAPI specification:
-* OpenAPI Responses Object, it includes the `Response Object`.
-* OpenAPI Response Object, you can include anything from this directly in each response inside your `responses` parameter. Including `description`, `headers`, `content` (inside of this is that you declare different media types and JSON Schemas), and `links`.
+* [OpenAPI Responses Object](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.1.0.md#responses-object){target=_blank}, it includes the `Response Object`.
+* [OpenAPI Response Object](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.1.0.md#response-object){target=_blank}, you can include anything from this directly in each response inside your `responses` parameter. Including `description`, `headers`, `content` (inside of this is that you declare different media types and JSON Schemas), and `links`.
diff --git a/docs/en/docs/advanced/additional-status-codes.md b/docs/en/docs/advanced/additional-status-codes.md
index 23bcd13c32..9e1b95f124 100644
--- a/docs/en/docs/advanced/additional-status-codes.md
+++ b/docs/en/docs/advanced/additional-status-codes.md
@@ -38,4 +38,4 @@ You could also use `from starlette.responses import JSONResponse`.
If you return additional status codes and responses directly, they won't be included in the OpenAPI schema (the API docs), because FastAPI doesn't have a way to know beforehand what you are going to return.
-But you can document that in your code, using: [Additional Responses](additional-responses.md){.internal-link target=_blank}.
+But you can document that in your code, using: [Additional Responses](additional-responses.md){target=_blank}.
diff --git a/docs/en/docs/advanced/advanced-dependencies.md b/docs/en/docs/advanced/advanced-dependencies.md
index 3a23a6d1ad..6704e80610 100644
--- a/docs/en/docs/advanced/advanced-dependencies.md
+++ b/docs/en/docs/advanced/advanced-dependencies.md
@@ -132,7 +132,7 @@ If you have this specific use case using SQLModel (or SQLAlchemy), you could exp
That way the session would release the database connection, so other requests could use it.
-If you have a different use case that needs to exit early from a dependency with `yield`, please create a GitHub Discussion Question with your specific use case and why you would benefit from having early closing for dependencies with `yield`.
+If you have a different use case that needs to exit early from a dependency with `yield`, please create a [GitHub Discussion Question](https://github.com/fastapi/fastapi/discussions/new?category=questions){target=_blank} with your specific use case and why you would benefit from having early closing for dependencies with `yield`.
If there are compelling use cases for early closing in dependencies with `yield`, I would consider adding a new way to opt in to early closing.
@@ -144,7 +144,7 @@ This was changed in version 0.110.0 to fix unhandled memory consumption from for
### Background Tasks and Dependencies with `yield`, Technical Details { #background-tasks-and-dependencies-with-yield-technical-details }
-Before FastAPI 0.106.0, raising exceptions after `yield` was not possible, the exit code in dependencies with `yield` was executed *after* the response was sent, so [Exception Handlers](../tutorial/handling-errors.md#install-custom-exception-handlers){.internal-link target=_blank} would have already run.
+Before FastAPI 0.106.0, raising exceptions after `yield` was not possible, the exit code in dependencies with `yield` was executed *after* the response was sent, so [Exception Handlers](../tutorial/handling-errors.md#install-custom-exception-handlers){target=_blank} would have already run.
This was designed this way mainly to allow using the same objects "yielded" by dependencies inside of background tasks, because the exit code would be executed after the background tasks were finished.
diff --git a/docs/en/docs/advanced/async-tests.md b/docs/en/docs/advanced/async-tests.md
index cefb1d1841..0495a93c36 100644
--- a/docs/en/docs/advanced/async-tests.md
+++ b/docs/en/docs/advanced/async-tests.md
@@ -16,11 +16,11 @@ Even if your **FastAPI** application uses normal `def` functions instead of `asy
The `TestClient` does some magic inside to call the asynchronous FastAPI application in your normal `def` test functions, using standard pytest. But that magic doesn't work anymore when we're using it inside asynchronous functions. By running our tests asynchronously, we can no longer use the `TestClient` inside our test functions.
-The `TestClient` is based on HTTPX, and luckily, we can use it directly to test the API.
+The `TestClient` is based on [HTTPX](https://www.python-httpx.org){target=_blank}, and luckily, we can use it directly to test the API.
## Example { #example }
-For a simple example, let's consider a file structure similar to the one described in [Bigger Applications](../tutorial/bigger-applications.md){.internal-link target=_blank} and [Testing](../tutorial/testing.md){.internal-link target=_blank}:
+For a simple example, let's consider a file structure similar to the one described in [Bigger Applications](../tutorial/bigger-applications.md){target=_blank} and [Testing](../tutorial/testing.md){target=_blank}:
```
.
@@ -84,7 +84,7 @@ Note that we're using async/await with the new `AsyncClient` - the request is as
/// warning
-If your application relies on lifespan events, the `AsyncClient` won't trigger these events. To ensure they are triggered, use `LifespanManager` from florimondmanca/asgi-lifespan.
+If your application relies on lifespan events, the `AsyncClient` won't trigger these events. To ensure they are triggered, use `LifespanManager` from [florimondmanca/asgi-lifespan](https://github.com/florimondmanca/asgi-lifespan#usage){target=_blank}.
///
@@ -94,6 +94,6 @@ As the testing function is now asynchronous, you can now also call (and `await`)
/// tip
-If you encounter a `RuntimeError: Task attached to a different loop` when integrating asynchronous function calls in your tests (e.g. when using MongoDB's MotorClient), remember to instantiate objects that need an event loop only within async functions, e.g. an `@app.on_event("startup")` callback.
+If you encounter a `RuntimeError: Task attached to a different loop` when integrating asynchronous function calls in your tests (e.g. when using [MongoDB's MotorClient](https://stackoverflow.com/questions/41584243/runtimeerror-task-attached-to-a-different-loop){target=_blank}), remember to instantiate objects that need an event loop only within async functions, e.g. an `@app.on_event("startup")` callback.
///
diff --git a/docs/en/docs/advanced/behind-a-proxy.md b/docs/en/docs/advanced/behind-a-proxy.md
index 770e9cd3ca..95bbc06b9e 100644
--- a/docs/en/docs/advanced/behind-a-proxy.md
+++ b/docs/en/docs/advanced/behind-a-proxy.md
@@ -16,9 +16,9 @@ But for security, as the server doesn't know it is behind a trusted proxy, it wo
The proxy headers are:
-* X-Forwarded-For
-* X-Forwarded-Proto
-* X-Forwarded-Host
+* [X-Forwarded-For](https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/X-Forwarded-For){target=_blank}
+* [X-Forwarded-Proto](https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/X-Forwarded-Proto){target=_blank}
+* [X-Forwarded-Host](https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/X-Forwarded-Host){target=_blank}
///
@@ -60,7 +60,7 @@ https://mysuperapp.com/items/
/// tip
-If you want to learn more about HTTPS, check the guide [About HTTPS](../deployment/https.md){.internal-link target=_blank}.
+If you want to learn more about HTTPS, check the guide [About HTTPS](../deployment/https.md){target=_blank}.
///
@@ -228,7 +228,7 @@ Passing the `root_path` to `FastAPI` would be the equivalent of passing the `--r
Keep in mind that the server (Uvicorn) won't use that `root_path` for anything else than passing it to the app.
-But if you go with your browser to http://127.0.0.1:8000/app you will see the normal response:
+But if you go with your browser to [http://127.0.0.1:8000/app](http://127.0.0.1:8000/app){target=_blank} you will see the normal response:
```JSON
{
@@ -251,9 +251,9 @@ In a case like that (without a stripped path prefix), the proxy would listen on
## Testing locally with Traefik { #testing-locally-with-traefik }
-You can easily run the experiment locally with a stripped path prefix using Traefik.
+You can easily run the experiment locally with a stripped path prefix using [Traefik](https://docs.traefik.io/){target=_blank}.
-Download Traefik, it's a single binary, you can extract the compressed file and run it directly from the terminal.
+[Download Traefik](https://github.com/containous/traefik/releases){target=_blank}, it's a single binary, you can extract the compressed file and run it directly from the terminal.
Then create a file `traefik.toml` with:
@@ -330,7 +330,7 @@ $ fastapi run main.py --forwarded-allow-ips="*" --root-path /api/v1
### Check the responses { #check-the-responses }
-Now, if you go to the URL with the port for Uvicorn: http://127.0.0.1:8000/app, you will see the normal response:
+Now, if you go to the URL with the port for Uvicorn: [http://127.0.0.1:8000/app](http://127.0.0.1:8000/app){target=_blank}, you will see the normal response:
```JSON
{
@@ -345,7 +345,7 @@ Notice that even though you are accessing it at `http://127.0.0.1:8000/app` it s
///
-And now open the URL with the port for Traefik, including the path prefix: http://127.0.0.1:9999/api/v1/app.
+And now open the URL with the port for Traefik, including the path prefix: [http://127.0.0.1:9999/api/v1/app](http://127.0.0.1:9999/api/v1/app){target=_blank}.
We get the same response:
@@ -370,13 +370,13 @@ But here's the fun part. β¨
The "official" way to access the app would be through the proxy with the path prefix that we defined. So, as we would expect, if you try the docs UI served by Uvicorn directly, without the path prefix in the URL, it won't work, because it expects to be accessed through the proxy.
-You can check it at http://127.0.0.1:8000/docs:
+You can check it at [http://127.0.0.1:8000/docs](http://127.0.0.1:8000/docs){target=_blank}:
But if we access the docs UI at the "official" URL using the proxy with port `9999`, at `/api/v1/docs`, it works correctly! π
-You can check it at http://127.0.0.1:9999/api/v1/docs:
+You can check it at [http://127.0.0.1:9999/api/v1/docs](http://127.0.0.1:9999/api/v1/docs){target=_blank}:
@@ -433,7 +433,7 @@ Notice the auto-generated server with a `url` value of `/api/v1`, taken from the
///
-In the docs UI at http://127.0.0.1:9999/api/v1/docs it would look like:
+In the docs UI at [http://127.0.0.1:9999/api/v1/docs](http://127.0.0.1:9999/api/v1/docs){target=_blank} it would look like:
@@ -461,6 +461,6 @@ and then it won't include it in the OpenAPI schema.
## Mounting a sub-application { #mounting-a-sub-application }
-If you need to mount a sub-application (as described in [Sub Applications - Mounts](sub-applications.md){.internal-link target=_blank}) while also using a proxy with `root_path`, you can do it normally, as you would expect.
+If you need to mount a sub-application (as described in [Sub Applications - Mounts](sub-applications.md){target=_blank}) while also using a proxy with `root_path`, you can do it normally, as you would expect.
FastAPI will internally use the `root_path` smartly, so it will just work. β¨
diff --git a/docs/en/docs/advanced/custom-response.md b/docs/en/docs/advanced/custom-response.md
index e0fafa5dfe..5f47517d4f 100644
--- a/docs/en/docs/advanced/custom-response.md
+++ b/docs/en/docs/advanced/custom-response.md
@@ -2,7 +2,7 @@
By default, **FastAPI** will return JSON responses.
-You can override it by returning a `Response` directly as seen in [Return a Response directly](response-directly.md){.internal-link target=_blank}.
+You can override it by returning a `Response` directly as seen in [Return a Response directly](response-directly.md){target=_blank}.
But if you return a `Response` directly (or any subclass, like `JSONResponse`), the data won't be automatically converted (even if you declare a `response_model`), and the documentation won't be automatically generated (for example, including the specific "media type", in the HTTP header `Content-Type` as part of the generated OpenAPI).
@@ -20,15 +20,15 @@ If you use a response class with no media type, FastAPI will expect your respons
By default FastAPI returns JSON responses.
-If you declare a [Response Model](../tutorial/response-model.md){.internal-link target=_blank} FastAPI will use it to serialize the data to JSON, using Pydantic.
+If you declare a [Response Model](../tutorial/response-model.md){target=_blank} FastAPI will use it to serialize the data to JSON, using Pydantic.
-If you don't declare a response model, FastAPI will use the `jsonable_encoder` explained in [JSON Compatible Encoder](../tutorial/encoder.md){.internal-link target=_blank} and put it in a `JSONResponse`.
+If you don't declare a response model, FastAPI will use the `jsonable_encoder` explained in [JSON Compatible Encoder](../tutorial/encoder.md){target=_blank} and put it in a `JSONResponse`.
If you declare a `response_class` with a JSON media type (`application/json`), like is the case with the `JSONResponse`, the data you return will be automatically converted (and filtered) with any Pydantic `response_model` that you declared in the *path operation decorator*. But the data won't be serialized to JSON bytes with Pydantic, instead it will be converted with the `jsonable_encoder` and then passed to the `JSONResponse` class, which will serialize it to bytes using the standard JSON library in Python.
### JSON Performance { #json-performance }
-In short, if you want the maximum performance, use a [Response Model](../tutorial/response-model.md){.internal-link target=_blank} and don't declare a `response_class` in the *path operation decorator*.
+In short, if you want the maximum performance, use a [Response Model](../tutorial/response-model.md){target=_blank} and don't declare a `response_class` in the *path operation decorator*.
{* ../../docs_src/response_model/tutorial001_01_py310.py ln[15:17] hl[16] *}
@@ -53,7 +53,7 @@ And it will be documented as such in OpenAPI.
### Return a `Response` { #return-a-response }
-As seen in [Return a Response directly](response-directly.md){.internal-link target=_blank}, you can also override the response directly in your *path operation*, by returning it.
+As seen in [Return a Response directly](response-directly.md){target=_blank}, you can also override the response directly in your *path operation*, by returning it.
The same example from above, returning an `HTMLResponse`, could look like:
@@ -189,9 +189,9 @@ This would be even more important with large or infinite streams.
/// tip
-Instead of returning a `StreamingResponse` directly, you should probably follow the style in [Stream Data](./stream-data.md){.internal-link target=_blank}, it's much more convenient and handles cancellation behind the scenes for you.
+Instead of returning a `StreamingResponse` directly, you should probably follow the style in [Stream Data](./stream-data.md){target=_blank}, it's much more convenient and handles cancellation behind the scenes for you.
-If you are streaming JSON Lines, follow the [Stream JSON Lines](../tutorial/stream-json-lines.md){.internal-link target=_blank} tutorial.
+If you are streaming JSON Lines, follow the [Stream JSON Lines](../tutorial/stream-json-lines.md){target=_blank} tutorial.
///
@@ -220,7 +220,7 @@ In this case, you can return the file path directly from your *path operation* f
You can create your own custom response class, inheriting from `Response` and using it.
-For example, let's say that you want to use `orjson` with some settings.
+For example, let's say that you want to use [`orjson`](https://github.com/ijl/orjson){target=_blank} with some settings.
Let's say you want it to return indented and formatted JSON, so you want to use the orjson option `orjson.OPT_INDENT_2`.
@@ -246,7 +246,7 @@ Of course, you will probably find much better ways to take advantage of this tha
### `orjson` or Response Model { #orjson-or-response-model }
-If what you are looking for is performance, you are probably better off using a [Response Model](../tutorial/response-model.md){.internal-link target=_blank} than an `orjson` response.
+If what you are looking for is performance, you are probably better off using a [Response Model](../tutorial/response-model.md){target=_blank} than an `orjson` response.
With a response model, FastAPI will use Pydantic to serialize the data to JSON, without using intermediate steps, like converting it with `jsonable_encoder`, which would happen in any other case.
@@ -270,4 +270,4 @@ You can still override `response_class` in *path operations* as before.
## Additional documentation { #additional-documentation }
-You can also declare the media type and many other details in OpenAPI using `responses`: [Additional Responses in OpenAPI](additional-responses.md){.internal-link target=_blank}.
+You can also declare the media type and many other details in OpenAPI using `responses`: [Additional Responses in OpenAPI](additional-responses.md){target=_blank}.
diff --git a/docs/en/docs/advanced/dataclasses.md b/docs/en/docs/advanced/dataclasses.md
index be85303bfb..242636fb31 100644
--- a/docs/en/docs/advanced/dataclasses.md
+++ b/docs/en/docs/advanced/dataclasses.md
@@ -2,11 +2,11 @@
FastAPI is built on top of **Pydantic**, and I have been showing you how to use Pydantic models to declare requests and responses.
-But FastAPI also supports using `dataclasses` the same way:
+But FastAPI also supports using [`dataclasses`](https://docs.python.org/3/library/dataclasses.html){target=_blank} the same way:
{* ../../docs_src/dataclasses_/tutorial001_py310.py hl[1,6:11,18:19] *}
-This is still supported thanks to **Pydantic**, as it has internal support for `dataclasses`.
+This is still supported thanks to **Pydantic**, as it has [internal support for `dataclasses`](https://docs.pydantic.dev/latest/concepts/dataclasses/#use-of-stdlib-dataclasses-with-basemodel){target=_blank}.
So, even with the code above that doesn't use Pydantic explicitly, FastAPI is using Pydantic to convert those standard dataclasses to Pydantic's own flavor of dataclasses.
@@ -74,7 +74,7 @@ In that case, you can simply swap the standard `dataclasses` with `pydantic.data
As always, in FastAPI you can combine `def` and `async def` as needed.
- If you need a refresher about when to use which, check out the section _"In a hurry?"_ in the docs about [`async` and `await`](../async.md#in-a-hurry){.internal-link target=_blank}.
+ If you need a refresher about when to use which, check out the section _"In a hurry?"_ in the docs about [`async` and `await`](../async.md#in-a-hurry){target=_blank}.
9. This *path operation function* is not returning dataclasses (although it could), but a list of dictionaries with internal data.
@@ -88,7 +88,7 @@ Check the in-code annotation tips above to see more specific details.
You can also combine `dataclasses` with other Pydantic models, inherit from them, include them in your own models, etc.
-To learn more, check the Pydantic docs about dataclasses.
+To learn more, check the [Pydantic docs about dataclasses](https://docs.pydantic.dev/latest/concepts/dataclasses/){target=_blank}.
## Version { #version }
diff --git a/docs/en/docs/advanced/events.md b/docs/en/docs/advanced/events.md
index 302e963251..64a07c9a73 100644
--- a/docs/en/docs/advanced/events.md
+++ b/docs/en/docs/advanced/events.md
@@ -150,11 +150,11 @@ Because of that, it's now recommended to instead use the `lifespan` as explained
Just a technical detail for the curious nerds. π€
-Underneath, in the ASGI technical specification, this is part of the Lifespan Protocol, and it defines events called `startup` and `shutdown`.
+Underneath, in the ASGI technical specification, this is part of the [Lifespan Protocol](https://asgi.readthedocs.io/en/latest/specs/lifespan.html){target=_blank}, and it defines events called `startup` and `shutdown`.
/// info
-You can read more about the Starlette `lifespan` handlers in Starlette's Lifespan' docs.
+You can read more about the Starlette `lifespan` handlers in [Starlette's Lifespan' docs](https://www.starlette.dev/lifespan/){target=_blank}.
Including how to handle lifespan state that can be used in other areas of your code.
@@ -162,4 +162,4 @@ Including how to handle lifespan state that can be used in other areas of your c
## Sub Applications { #sub-applications }
-π¨ Keep in mind that these lifespan events (startup and shutdown) will only be executed for the main application, not for [Sub Applications - Mounts](sub-applications.md){.internal-link target=_blank}.
+π¨ Keep in mind that these lifespan events (startup and shutdown) will only be executed for the main application, not for [Sub Applications - Mounts](sub-applications.md){target=_blank}.
diff --git a/docs/en/docs/advanced/generate-clients.md b/docs/en/docs/advanced/generate-clients.md
index 1e6173c9ae..5d6af3d9db 100644
--- a/docs/en/docs/advanced/generate-clients.md
+++ b/docs/en/docs/advanced/generate-clients.md
@@ -8,11 +8,11 @@ In this guide, you'll learn how to generate a **TypeScript SDK** for your FastAP
## Open Source SDK Generators { #open-source-sdk-generators }
-A versatile option is the OpenAPI Generator, which supports **many programming languages** and can generate SDKs from your OpenAPI specification.
+A versatile option is the [OpenAPI Generator](https://openapi-generator.tech/){target=_blank}, which supports **many programming languages** and can generate SDKs from your OpenAPI specification.
-For **TypeScript clients**, Hey API is a purpose-built solution, providing an optimized experience for the TypeScript ecosystem.
+For **TypeScript clients**, [Hey API](https://heyapi.dev/){target=_blank} is a purpose-built solution, providing an optimized experience for the TypeScript ecosystem.
-You can discover more SDK generators on OpenAPI.Tools.
+You can discover more SDK generators on [OpenAPI.Tools](https://openapi.tools/#sdk){target=_blank}.
/// tip
@@ -24,15 +24,15 @@ FastAPI automatically generates **OpenAPI 3.1** specifications, so any tool you
This section highlights **venture-backed** and **company-supported** solutions from companies that sponsor FastAPI. These products provide **additional features** and **integrations** on top of high-quality generated SDKs.
-By β¨ [**sponsoring FastAPI**](../help-fastapi.md#sponsor-the-author){.internal-link target=_blank} β¨, these companies help ensure the framework and its **ecosystem** remain healthy and **sustainable**.
+By β¨ [**sponsoring FastAPI**](../help-fastapi.md#sponsor-the-author){target=_blank} β¨, these companies help ensure the framework and its **ecosystem** remain healthy and **sustainable**.
Their sponsorship also demonstrates a strong commitment to the FastAPI **community** (you), showing that they care not only about offering a **great service** but also about supporting a **robust and thriving framework**, FastAPI. π
For example, you might want to try:
-* Speakeasy
-* Stainless
-* liblab
+* [Speakeasy](https://speakeasy.com/editor?utm_source=fastapi+repo&utm_medium=github+sponsorship){target=_blank}
+* [Stainless](https://www.stainless.com/?utm_source=fastapi&utm_medium=referral){target=_blank}
+* [liblab](https://developers.liblab.com/tutorials/sdk-for-fastapi?utm_source=fastapi){target=_blank}
Some of these solutions may also be open source or offer free tiers, so you can try them without a financial commitment. Other commercial SDK generators are available and can be found online. π€
@@ -66,7 +66,7 @@ npx @hey-api/openapi-ts -i http://localhost:8000/openapi.json -o src/client
This will generate a TypeScript SDK in `./src/client`.
-You can learn how to install `@hey-api/openapi-ts` and read about the generated output on their website.
+You can learn how to [install `@hey-api/openapi-ts`](https://heyapi.dev/openapi-ts/get-started){target=_blank} and read about the [generated output](https://heyapi.dev/openapi-ts/output){target=_blank} on their website.
### Using the SDK { #using-the-sdk }
diff --git a/docs/en/docs/advanced/index.md b/docs/en/docs/advanced/index.md
index 9355516fb4..458f0301fe 100644
--- a/docs/en/docs/advanced/index.md
+++ b/docs/en/docs/advanced/index.md
@@ -2,7 +2,7 @@
## Additional Features { #additional-features }
-The main [Tutorial - User Guide](../tutorial/index.md){.internal-link target=_blank} should be enough to give you a tour through all the main features of **FastAPI**.
+The main [Tutorial - User Guide](../tutorial/index.md){target=_blank} should be enough to give you a tour through all the main features of **FastAPI**.
In the next sections you will see other options, configurations, and additional features.
@@ -16,6 +16,6 @@ And it's possible that for your use case, the solution is in one of them.
## Read the Tutorial first { #read-the-tutorial-first }
-You could still use most of the features in **FastAPI** with the knowledge from the main [Tutorial - User Guide](../tutorial/index.md){.internal-link target=_blank}.
+You could still use most of the features in **FastAPI** with the knowledge from the main [Tutorial - User Guide](../tutorial/index.md){target=_blank}.
And the next sections assume you already read it, and assume that you know those main ideas.
diff --git a/docs/en/docs/advanced/json-base64-bytes.md b/docs/en/docs/advanced/json-base64-bytes.md
index c0dfec72b9..870b3d4863 100644
--- a/docs/en/docs/advanced/json-base64-bytes.md
+++ b/docs/en/docs/advanced/json-base64-bytes.md
@@ -4,7 +4,7 @@ If your app needs to receive and send JSON data, but you need to include binary
## Base64 vs Files { #base64-vs-files }
-Consider first if you can use [Request Files](../tutorial/request-files.md){.internal-link target=_blank} for uploading binary data and [Custom Response - FileResponse](./custom-response.md#fileresponse--fileresponse-){.internal-link target=_blank} for sending binary data, instead of encoding it in JSON.
+Consider first if you can use [Request Files](../tutorial/request-files.md){target=_blank} for uploading binary data and [Custom Response - FileResponse](./custom-response.md#fileresponse--fileresponse-){target=_blank} for sending binary data, instead of encoding it in JSON.
JSON can only contain UTF-8 encoded strings, so it can't contain raw bytes.
diff --git a/docs/en/docs/advanced/middleware.md b/docs/en/docs/advanced/middleware.md
index b448f5c520..4d10f78bd2 100644
--- a/docs/en/docs/advanced/middleware.md
+++ b/docs/en/docs/advanced/middleware.md
@@ -1,8 +1,8 @@
# Advanced Middleware { #advanced-middleware }
-In the main tutorial you read how to add [Custom Middleware](../tutorial/middleware.md){.internal-link target=_blank} to your application.
+In the main tutorial you read how to add [Custom Middleware](../tutorial/middleware.md){target=_blank} to your application.
-And then you also read how to handle [CORS with the `CORSMiddleware`](../tutorial/cors.md){.internal-link target=_blank}.
+And then you also read how to handle [CORS with the `CORSMiddleware`](../tutorial/cors.md){target=_blank}.
In this section we'll see how to use other middlewares.
@@ -91,7 +91,7 @@ There are many other ASGI middlewares.
For example:
-* Uvicorn's `ProxyHeadersMiddleware`
-* MessagePack
+* [Uvicorn's `ProxyHeadersMiddleware`](https://github.com/encode/uvicorn/blob/master/uvicorn/middleware/proxy_headers.py){target=_blank}
+* [MessagePack](https://github.com/florimondmanca/msgpack-asgi){target=_blank}
-To see other available middlewares check Starlette's Middleware docs and the ASGI Awesome List.
+To see other available middlewares check [Starlette's Middleware docs](https://www.starlette.dev/middleware/){target=_blank} and the [ASGI Awesome List](https://github.com/florimondmanca/awesome-asgi){target=_blank}.
diff --git a/docs/en/docs/advanced/openapi-callbacks.md b/docs/en/docs/advanced/openapi-callbacks.md
index 5bd7c2cfd4..df9183fd10 100644
--- a/docs/en/docs/advanced/openapi-callbacks.md
+++ b/docs/en/docs/advanced/openapi-callbacks.md
@@ -35,7 +35,7 @@ This part is pretty normal, most of the code is probably already familiar to you
/// tip
-The `callback_url` query parameter uses a Pydantic Url type.
+The `callback_url` query parameter uses a Pydantic [Url](https://docs.pydantic.dev/latest/api/networks/){target=_blank} type.
///
@@ -66,7 +66,7 @@ This example doesn't implement the callback itself (that could be just a line of
The actual callback is just an HTTP request.
-When implementing the callback yourself, you could use something like HTTPX or Requests.
+When implementing the callback yourself, you could use something like [HTTPX](https://www.python-httpx.org){target=_blank} or [Requests](https://requests.readthedocs.io/){target=_blank}.
///
@@ -106,11 +106,11 @@ It should look just like a normal FastAPI *path operation*:
There are 2 main differences from a normal *path operation*:
* It doesn't need to have any actual code, because your app will never call this code. It's only used to document the *external API*. So, the function could just have `pass`.
-* The *path* can contain an OpenAPI 3 expression (see more below) where it can use variables with parameters and parts of the original request sent to *your API*.
+* The *path* can contain an [OpenAPI 3 expression](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.1.0.md#key-expression){target=_blank} (see more below) where it can use variables with parameters and parts of the original request sent to *your API*.
### The callback path expression { #the-callback-path-expression }
-The callback *path* can have an OpenAPI 3 expression that can contain parts of the original request sent to *your API*.
+The callback *path* can have an [OpenAPI 3 expression](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.1.0.md#key-expression){target=_blank} that can contain parts of the original request sent to *your API*.
In this case, it's the `str`:
@@ -179,7 +179,7 @@ Notice that you are not passing the router itself (`invoices_callback_router`) t
### Check the docs { #check-the-docs }
-Now you can start your app and go to http://127.0.0.1:8000/docs.
+Now you can start your app and go to [http://127.0.0.1:8000/docs](http://127.0.0.1:8000/docs){target=_blank}.
You will see your docs including a "Callbacks" section for your *path operation* that shows how the *external API* should look like:
diff --git a/docs/en/docs/advanced/openapi-webhooks.md b/docs/en/docs/advanced/openapi-webhooks.md
index d9b73ea4a2..2b48e82f32 100644
--- a/docs/en/docs/advanced/openapi-webhooks.md
+++ b/docs/en/docs/advanced/openapi-webhooks.md
@@ -48,7 +48,7 @@ This is because it is expected that **your users** would define the actual **URL
### Check the docs { #check-the-docs }
-Now you can start your app and go to http://127.0.0.1:8000/docs.
+Now you can start your app and go to [http://127.0.0.1:8000/docs](http://127.0.0.1:8000/docs){target=_blank}.
You will see your docs have the normal *path operations* and now also some **webhooks**:
diff --git a/docs/en/docs/advanced/path-operation-advanced-configuration.md b/docs/en/docs/advanced/path-operation-advanced-configuration.md
index fdc77c8a25..311e4b250a 100644
--- a/docs/en/docs/advanced/path-operation-advanced-configuration.md
+++ b/docs/en/docs/advanced/path-operation-advanced-configuration.md
@@ -60,7 +60,7 @@ That defines the metadata about the main response of a *path operation*.
You can also declare additional responses with their models, status codes, etc.
-There's a whole chapter here in the documentation about it, you can read it at [Additional Responses in OpenAPI](additional-responses.md){.internal-link target=_blank}.
+There's a whole chapter here in the documentation about it, you can read it at [Additional Responses in OpenAPI](additional-responses.md){target=_blank}.
## OpenAPI Extra { #openapi-extra }
@@ -68,7 +68,7 @@ When you declare a *path operation* in your application, **FastAPI** automatical
/// note | Technical details
-In the OpenAPI specification it is called the Operation Object.
+In the OpenAPI specification it is called the [Operation Object](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#operation-object){target=_blank}.
///
@@ -82,7 +82,7 @@ This *path operation*-specific OpenAPI schema is normally generated automaticall
This is a low level extension point.
-If you only need to declare additional responses, a more convenient way to do it is with [Additional Responses in OpenAPI](additional-responses.md){.internal-link target=_blank}.
+If you only need to declare additional responses, a more convenient way to do it is with [Additional Responses in OpenAPI](additional-responses.md){target=_blank}.
///
diff --git a/docs/en/docs/advanced/response-change-status-code.md b/docs/en/docs/advanced/response-change-status-code.md
index 8aa601e7bd..e611d1c65f 100644
--- a/docs/en/docs/advanced/response-change-status-code.md
+++ b/docs/en/docs/advanced/response-change-status-code.md
@@ -1,6 +1,6 @@
# Response - Change Status Code { #response-change-status-code }
-You probably read before that you can set a default [Response Status Code](../tutorial/response-status-code.md){.internal-link target=_blank}.
+You probably read before that you can set a default [Response Status Code](../tutorial/response-status-code.md){target=_blank}.
But in some cases you need to return a different status code than the default.
diff --git a/docs/en/docs/advanced/response-cookies.md b/docs/en/docs/advanced/response-cookies.md
index cfc615d7e4..f2394a17a6 100644
--- a/docs/en/docs/advanced/response-cookies.md
+++ b/docs/en/docs/advanced/response-cookies.md
@@ -20,7 +20,7 @@ You can also declare the `Response` parameter in dependencies, and set cookies (
You can also create cookies when returning a `Response` directly in your code.
-To do that, you can create a response as described in [Return a Response Directly](response-directly.md){.internal-link target=_blank}.
+To do that, you can create a response as described in [Return a Response Directly](response-directly.md){target=_blank}.
Then set Cookies in it, and then return it:
@@ -48,4 +48,4 @@ And as the `Response` can be used frequently to set headers and cookies, **FastA
///
-To see all the available parameters and options, check the documentation in Starlette.
+To see all the available parameters and options, check the [documentation in Starlette](https://www.starlette.dev/responses/#set-cookie){target=_blank}.
diff --git a/docs/en/docs/advanced/response-directly.md b/docs/en/docs/advanced/response-directly.md
index dd0e63c396..acc4b310c4 100644
--- a/docs/en/docs/advanced/response-directly.md
+++ b/docs/en/docs/advanced/response-directly.md
@@ -2,15 +2,15 @@
When you create a **FastAPI** *path operation* you can normally return any data from it: a `dict`, a `list`, a Pydantic model, a database model, etc.
-If you declare a [Response Model](../tutorial/response-model.md){.internal-link target=_blank} FastAPI will use it to serialize the data to JSON, using Pydantic.
+If you declare a [Response Model](../tutorial/response-model.md){target=_blank} FastAPI will use it to serialize the data to JSON, using Pydantic.
-If you don't declare a response model, FastAPI will use the `jsonable_encoder` explained in [JSON Compatible Encoder](../tutorial/encoder.md){.internal-link target=_blank} and put it in a `JSONResponse`.
+If you don't declare a response model, FastAPI will use the `jsonable_encoder` explained in [JSON Compatible Encoder](../tutorial/encoder.md){target=_blank} and put it in a `JSONResponse`.
You could also create a `JSONResponse` directly and return it.
/// tip
-You will normally have much better performance using a [Response Model](../tutorial/response-model.md){.internal-link target=_blank} than returning a `JSONResponse` directly, as that way it serializes the data using Pydantic, in Rust.
+You will normally have much better performance using a [Response Model](../tutorial/response-model.md){target=_blank} than returning a `JSONResponse` directly, as that way it serializes the data using Pydantic, in Rust.
///
@@ -56,7 +56,7 @@ The example above shows all the parts you need, but it's not very useful yet, as
Now, let's see how you could use that to return a custom response.
-Let's say that you want to return an XML response.
+Let's say that you want to return an [XML](https://en.wikipedia.org/wiki/XML){target=_blank} response.
You could put your XML content in a string, put that in a `Response`, and return it:
@@ -64,7 +64,7 @@ You could put your XML content in a string, put that in a `Response`, and return
## How a Response Model Works { #how-a-response-model-works }
-When you declare a [Response Model - Return Type](../tutorial/response-model.md){.internal-link target=_blank} in a path operation, **FastAPI** will use it to serialize the data to JSON, using Pydantic.
+When you declare a [Response Model - Return Type](../tutorial/response-model.md){target=_blank} in a path operation, **FastAPI** will use it to serialize the data to JSON, using Pydantic.
{* ../../docs_src/response_model/tutorial001_01_py310.py hl[16,21] *}
@@ -78,6 +78,6 @@ Instead it takes the JSON bytes generated with Pydantic using the response model
When you return a `Response` directly its data is not validated, converted (serialized), or documented automatically.
-But you can still document it as described in [Additional Responses in OpenAPI](additional-responses.md){.internal-link target=_blank}.
+But you can still document it as described in [Additional Responses in OpenAPI](additional-responses.md){target=_blank}.
You can see in later sections how to use/declare these custom `Response`s while still having automatic data conversion, documentation, etc.
diff --git a/docs/en/docs/advanced/response-headers.md b/docs/en/docs/advanced/response-headers.md
index ebc96d5dd0..65cc3c8b35 100644
--- a/docs/en/docs/advanced/response-headers.md
+++ b/docs/en/docs/advanced/response-headers.md
@@ -20,7 +20,7 @@ You can also declare the `Response` parameter in dependencies, and set headers (
You can also add headers when you return a `Response` directly.
-Create a response as described in [Return a Response Directly](response-directly.md){.internal-link target=_blank} and pass the headers as an additional parameter:
+Create a response as described in [Return a Response Directly](response-directly.md){target=_blank} and pass the headers as an additional parameter:
{* ../../docs_src/response_headers/tutorial001_py310.py hl[10:12] *}
@@ -36,6 +36,6 @@ And as the `Response` can be used frequently to set headers and cookies, **FastA
## Custom Headers { #custom-headers }
-Keep in mind that custom proprietary headers can be added using the `X-` prefix.
+Keep in mind that custom proprietary headers can be added [using the `X-` prefix](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers){target=_blank}.
-But if you have custom headers that you want a client in a browser to be able to see, you need to add them to your CORS configurations (read more in [CORS (Cross-Origin Resource Sharing)](../tutorial/cors.md){.internal-link target=_blank}), using the parameter `expose_headers` documented in Starlette's CORS docs.
+But if you have custom headers that you want a client in a browser to be able to see, you need to add them to your CORS configurations (read more in [CORS (Cross-Origin Resource Sharing)](../tutorial/cors.md){target=_blank}), using the parameter `expose_headers` documented in [Starlette's CORS docs](https://www.starlette.dev/middleware/#corsmiddleware){target=_blank}.
diff --git a/docs/en/docs/advanced/security/http-basic-auth.md b/docs/en/docs/advanced/security/http-basic-auth.md
index c066cc63a4..fba906605f 100644
--- a/docs/en/docs/advanced/security/http-basic-auth.md
+++ b/docs/en/docs/advanced/security/http-basic-auth.md
@@ -32,7 +32,7 @@ Here's a more complete example.
Use a dependency to check if the username and password are correct.
-For this, use the Python standard module `secrets` to check the username and password.
+For this, use the Python standard module [`secrets`](https://docs.python.org/3/library/secrets.html){target=_blank} to check the username and password.
`secrets.compare_digest()` needs to take `bytes` or a `str` that only contains ASCII characters (the ones in English), this means it wouldn't work with characters like `Γ‘`, as in `SebastiΓ‘n`.
diff --git a/docs/en/docs/advanced/security/index.md b/docs/en/docs/advanced/security/index.md
index 996d716b4c..8dfe14b411 100644
--- a/docs/en/docs/advanced/security/index.md
+++ b/docs/en/docs/advanced/security/index.md
@@ -2,7 +2,7 @@
## Additional Features { #additional-features }
-There are some extra features to handle security apart from the ones covered in the [Tutorial - User Guide: Security](../../tutorial/security/index.md){.internal-link target=_blank}.
+There are some extra features to handle security apart from the ones covered in the [Tutorial - User Guide: Security](../../tutorial/security/index.md){target=_blank}.
/// tip
@@ -14,6 +14,6 @@ And it's possible that for your use case, the solution is in one of them.
## Read the Tutorial first { #read-the-tutorial-first }
-The next sections assume you already read the main [Tutorial - User Guide: Security](../../tutorial/security/index.md){.internal-link target=_blank}.
+The next sections assume you already read the main [Tutorial - User Guide: Security](../../tutorial/security/index.md){target=_blank}.
They are all based on the same concepts, but allow some extra functionalities.
diff --git a/docs/en/docs/advanced/security/oauth2-scopes.md b/docs/en/docs/advanced/security/oauth2-scopes.md
index 67c927cd08..db279a62e4 100644
--- a/docs/en/docs/advanced/security/oauth2-scopes.md
+++ b/docs/en/docs/advanced/security/oauth2-scopes.md
@@ -60,7 +60,7 @@ For OAuth2 they are just strings.
## Global view { #global-view }
-First, let's quickly see the parts that change from the examples in the main **Tutorial - User Guide** for [OAuth2 with Password (and hashing), Bearer with JWT tokens](../../tutorial/security/oauth2-jwt.md){.internal-link target=_blank}. Now using OAuth2 scopes:
+First, let's quickly see the parts that change from the examples in the main **Tutorial - User Guide** for [OAuth2 with Password (and hashing), Bearer with JWT tokens](../../tutorial/security/oauth2-jwt.md){target=_blank}. Now using OAuth2 scopes:
{* ../../docs_src/security/tutorial005_an_py310.py hl[5,9,13,47,65,106,108:116,122:126,130:136,141,157] *}
@@ -271,4 +271,4 @@ But in the end, they are implementing the same OAuth2 standard.
## `Security` in decorator `dependencies` { #security-in-decorator-dependencies }
-The same way you can define a `list` of `Depends` in the decorator's `dependencies` parameter (as explained in [Dependencies in path operation decorators](../../tutorial/dependencies/dependencies-in-path-operation-decorators.md){.internal-link target=_blank}), you could also use `Security` with `scopes` there.
+The same way you can define a `list` of `Depends` in the decorator's `dependencies` parameter (as explained in [Dependencies in path operation decorators](../../tutorial/dependencies/dependencies-in-path-operation-decorators.md){target=_blank}), you could also use `Security` with `scopes` there.
diff --git a/docs/en/docs/advanced/settings.md b/docs/en/docs/advanced/settings.md
index 61a6ac8bc1..c132e80992 100644
--- a/docs/en/docs/advanced/settings.md
+++ b/docs/en/docs/advanced/settings.md
@@ -8,7 +8,7 @@ For this reason it's common to provide them in environment variables that are re
/// tip
-To understand environment variables you can read [Environment Variables](../environment-variables.md){.internal-link target=_blank}.
+To understand environment variables you can read [Environment Variables](../environment-variables.md){target=_blank}.
///
@@ -20,11 +20,11 @@ That means that any value read in Python from an environment variable will be a
## Pydantic `Settings` { #pydantic-settings }
-Fortunately, Pydantic provides a great utility to handle these settings coming from environment variables with Pydantic: Settings management.
+Fortunately, Pydantic provides a great utility to handle these settings coming from environment variables with [Pydantic: Settings management](https://docs.pydantic.dev/latest/concepts/pydantic_settings/){target=_blank}.
### Install `pydantic-settings` { #install-pydantic-settings }
-First, make sure you create your [virtual environment](../virtual-environments.md){.internal-link target=_blank}, activate it, and then install the `pydantic-settings` package:
+First, make sure you create your [virtual environment](../virtual-environments.md){target=_blank}, activate it, and then install the `pydantic-settings` package:
-And then, open the docs for the sub-application, at http://127.0.0.1:8000/subapi/docs.
+And then, open the docs for the sub-application, at [http://127.0.0.1:8000/subapi/docs](http://127.0.0.1:8000/subapi/docs){target=_blank}.
You will see the automatic API docs for the sub-application, including only its own _path operations_, all under the correct sub-path prefix `/subapi`:
@@ -64,4 +64,4 @@ That way, the sub-application will know to use that path prefix for the docs UI.
And the sub-application could also have its own mounted sub-applications and everything would work correctly, because FastAPI handles all these `root_path`s automatically.
-You will learn more about the `root_path` and how to use it explicitly in the section about [Behind a Proxy](behind-a-proxy.md){.internal-link target=_blank}.
+You will learn more about the `root_path` and how to use it explicitly in the section about [Behind a Proxy](behind-a-proxy.md){target=_blank}.
diff --git a/docs/en/docs/advanced/templates.md b/docs/en/docs/advanced/templates.md
index 71c8f73c03..82842be150 100644
--- a/docs/en/docs/advanced/templates.md
+++ b/docs/en/docs/advanced/templates.md
@@ -8,7 +8,7 @@ There are utilities to configure it easily that you can use directly in your **F
## Install dependencies { #install-dependencies }
-Make sure you create a [virtual environment](../virtual-environments.md){.internal-link target=_blank}, activate it, and install `jinja2`:
+Make sure you create a [virtual environment](../virtual-environments.md){target=_blank}, activate it, and install `jinja2`:
@@ -44,7 +44,7 @@ Then I spent some time designing the developer "API" I wanted to have as a user I tested several ideas in the most popular Python editors: PyCharm, VS Code, Jedi based editors. -By the last Python Developer Survey, that covers about 80% of the users. +By the last [Python Developer Survey](https://www.jetbrains.com/research/python-developers-survey-2018/#development-tools){target=_blank}, that covers about 80% of the users. It means that **FastAPI** was specifically tested with the editors used by 80% of the Python developers. And as most of the other editors tend to work similarly, all its benefits should work for virtually all editors. @@ -54,11 +54,11 @@ All in a way that provided the best development experience for all the developer ## Requirements { #requirements } -After testing several alternatives, I decided that I was going to use **Pydantic** for its advantages. +After testing several alternatives, I decided that I was going to use [**Pydantic**](https://docs.pydantic.dev/){target=_blank} for its advantages. Then I contributed to it, to make it fully compliant with JSON Schema, to support different ways to define constraint declarations, and to improve editor support (type checks, autocompletion) based on the tests in several editors. -During the development, I also contributed to **Starlette**, the other key requirement. +During the development, I also contributed to [**Starlette**](https://www.starlette.dev/){target=_blank}, the other key requirement. ## Development { #development } @@ -76,4 +76,4 @@ But still, there are many improvements and features to come. **FastAPI** has a great future ahead. -And [your help](help-fastapi.md){.internal-link target=_blank} is greatly appreciated. +And [your help](help-fastapi.md){target=_blank} is greatly appreciated. diff --git a/docs/en/docs/how-to/authentication-error-status-code.md b/docs/en/docs/how-to/authentication-error-status-code.md index b15298e736..de4cdb215a 100644 --- a/docs/en/docs/how-to/authentication-error-status-code.md +++ b/docs/en/docs/how-to/authentication-error-status-code.md @@ -2,7 +2,7 @@ Before FastAPI version `0.122.0`, when the integrated security utilities returned an error to the client after a failed authentication, they used the HTTP status code `403 Forbidden`. -Starting with FastAPI version `0.122.0`, they use the more appropriate HTTP status code `401 Unauthorized`, and return a sensible `WWW-Authenticate` header in the response, following the HTTP specifications, RFC 7235, RFC 9110. +Starting with FastAPI version `0.122.0`, they use the more appropriate HTTP status code `401 Unauthorized`, and return a sensible `WWW-Authenticate` header in the response, following the HTTP specifications, [RFC 7235](https://datatracker.ietf.org/doc/html/rfc7235#section-3.1){target=_blank}, [RFC 9110](https://datatracker.ietf.org/doc/html/rfc9110#name-401-unauthorized){target=_blank}. But if for some reason your clients depend on the old behavior, you can revert to it by overriding the method `make_not_authenticated_error` in your security classes. diff --git a/docs/en/docs/how-to/conditional-openapi.md b/docs/en/docs/how-to/conditional-openapi.md index b2a7f812f7..c2325055a6 100644 --- a/docs/en/docs/how-to/conditional-openapi.md +++ b/docs/en/docs/how-to/conditional-openapi.md @@ -10,7 +10,7 @@ That doesn't add any extra security to your API, the *path operations* will stil If there's a security flaw in your code, it will still exist. -Hiding the documentation just makes it more difficult to understand how to interact with your API, and could make it more difficult for you to debug it in production. It could be considered simply a form of Security through obscurity. +Hiding the documentation just makes it more difficult to understand how to interact with your API, and could make it more difficult for you to debug it in production. It could be considered simply a form of [Security through obscurity](https://en.wikipedia.org/wiki/Security_through_obscurity){target=_blank}. If you want to secure your API, there are several better things you can do, for example: diff --git a/docs/en/docs/how-to/configure-swagger-ui.md b/docs/en/docs/how-to/configure-swagger-ui.md index ad9c01556d..905c153698 100644 --- a/docs/en/docs/how-to/configure-swagger-ui.md +++ b/docs/en/docs/how-to/configure-swagger-ui.md @@ -1,6 +1,6 @@ # Configure Swagger UI { #configure-swagger-ui } -You can configure some extra Swagger UI parameters. +You can configure some extra [Swagger UI parameters](https://swagger.io/docs/open-source-tools/swagger-ui/usage/configuration/){target=_blank}. To configure them, pass the `swagger_ui_parameters` argument when creating the `FastAPI()` app object or to the `get_swagger_ui_html()` function. @@ -50,7 +50,7 @@ For example, to disable `deepLinking` you could pass these settings to `swagger_ ## Other Swagger UI Parameters { #other-swagger-ui-parameters } -To see all the other possible configurations you can use, read the official docs for Swagger UI parameters. +To see all the other possible configurations you can use, read the official [docs for Swagger UI parameters](https://swagger.io/docs/open-source-tools/swagger-ui/usage/configuration/){target=_blank}. ## JavaScript-only settings { #javascript-only-settings } diff --git a/docs/en/docs/how-to/custom-docs-ui-assets.md b/docs/en/docs/how-to/custom-docs-ui-assets.md index d3e505040a..5115a6e045 100644 --- a/docs/en/docs/how-to/custom-docs-ui-assets.md +++ b/docs/en/docs/how-to/custom-docs-ui-assets.md @@ -54,7 +54,7 @@ Now, to be able to test that everything works, create a *path operation*: ### Test it { #test-it } -Now, you should be able to go to your docs at http://127.0.0.1:8000/docs, and reload the page, it will load those assets from the new CDN. +Now, you should be able to go to your docs at [http://127.0.0.1:8000/docs](http://127.0.0.1:8000/docs){target=_blank}, and reload the page, it will load those assets from the new CDN. ## Self-hosting JavaScript and CSS for docs { #self-hosting-javascript-and-css-for-docs } @@ -93,12 +93,12 @@ You can probably right-click each link and select an option similar to "Save lin **Swagger UI** uses the files: -* `swagger-ui-bundle.js` -* `swagger-ui.css` +* [`swagger-ui-bundle.js`](https://cdn.jsdelivr.net/npm/swagger-ui-dist@5/swagger-ui-bundle.js){target=_blank} +* [`swagger-ui.css`](https://cdn.jsdelivr.net/npm/swagger-ui-dist@5/swagger-ui.css){target=_blank} And **ReDoc** uses the file: -* `redoc.standalone.js` +* [`redoc.standalone.js`](https://cdn.jsdelivr.net/npm/redoc@2/bundles/redoc.standalone.js){target=_blank} After that, your file structure could look like: @@ -122,7 +122,7 @@ After that, your file structure could look like: ### Test the static files { #test-the-static-files } -Start your application and go to http://127.0.0.1:8000/static/redoc.standalone.js. +Start your application and go to [http://127.0.0.1:8000/static/redoc.standalone.js](http://127.0.0.1:8000/static/redoc.standalone.js){target=_blank}. You should see a very long JavaScript file for **ReDoc**. @@ -180,6 +180,6 @@ Now, to be able to test that everything works, create a *path operation*: ### Test Static Files UI { #test-static-files-ui } -Now, you should be able to disconnect your WiFi, go to your docs at http://127.0.0.1:8000/docs, and reload the page. +Now, you should be able to disconnect your WiFi, go to your docs at [http://127.0.0.1:8000/docs](http://127.0.0.1:8000/docs){target=_blank}, and reload the page. And even without Internet, you would be able to see the docs for your API and interact with it. diff --git a/docs/en/docs/how-to/custom-request-and-route.md b/docs/en/docs/how-to/custom-request-and-route.md index bfc60729f8..3bedc8e4ab 100644 --- a/docs/en/docs/how-to/custom-request-and-route.md +++ b/docs/en/docs/how-to/custom-request-and-route.md @@ -18,7 +18,7 @@ If you are just starting with **FastAPI** you might want to skip this section. Some use cases include: -* Converting non-JSON request bodies to JSON (e.g. `msgpack`). +* Converting non-JSON request bodies to JSON (e.g. [`msgpack`](https://msgpack.org/index.html){target=_blank}). * Decompressing gzip-compressed request bodies. * Automatically logging all request bodies. @@ -32,7 +32,7 @@ And an `APIRoute` subclass to use that custom request class. /// tip -This is a toy example to demonstrate how it works, if you need Gzip support, you can use the provided [`GzipMiddleware`](../advanced/middleware.md#gzipmiddleware){.internal-link target=_blank}. +This is a toy example to demonstrate how it works, if you need Gzip support, you can use the provided [`GzipMiddleware`](../advanced/middleware.md#gzipmiddleware){target=_blank}. /// @@ -66,7 +66,7 @@ The `scope` `dict` and `receive` function are both part of the ASGI specificatio And those two things, `scope` and `receive`, are what is needed to create a new `Request` instance. -To learn more about the `Request` check Starlette's docs about Requests. +To learn more about the `Request` check [Starlette's docs about Requests](https://www.starlette.dev/requests/){target=_blank}. /// @@ -82,7 +82,7 @@ But because of our changes in `GzipRequest.body`, the request body will be autom /// tip -To solve this same problem, it's probably a lot easier to use the `body` in a custom handler for `RequestValidationError` ([Handling Errors](../tutorial/handling-errors.md#use-the-requestvalidationerror-body){.internal-link target=_blank}). +To solve this same problem, it's probably a lot easier to use the `body` in a custom handler for `RequestValidationError` ([Handling Errors](../tutorial/handling-errors.md#use-the-requestvalidationerror-body){target=_blank}). But this example is still valid and it shows how to interact with the internal components. diff --git a/docs/en/docs/how-to/extending-openapi.md b/docs/en/docs/how-to/extending-openapi.md index b480223bf0..389acba801 100644 --- a/docs/en/docs/how-to/extending-openapi.md +++ b/docs/en/docs/how-to/extending-openapi.md @@ -37,7 +37,7 @@ The parameter `summary` is available in OpenAPI 3.1.0 and above, supported by Fa Using the information above, you can use the same utility function to generate the OpenAPI schema and override each part that you need. -For example, let's add ReDoc's OpenAPI extension to include a custom logo. +For example, let's add [ReDoc's OpenAPI extension to include a custom logo](https://github.com/Rebilly/ReDoc/blob/master/docs/redoc-vendor-extensions.md#x-logo){target=_blank}. ### Normal **FastAPI** { #normal-fastapi } @@ -75,6 +75,6 @@ Now you can replace the `.openapi()` method with your new function. ### Check it { #check-it } -Once you go to http://127.0.0.1:8000/redoc you will see that you are using your custom logo (in this example, **FastAPI**'s logo): +Once you go to [http://127.0.0.1:8000/redoc](http://127.0.0.1:8000/redoc){target=_blank} you will see that you are using your custom logo (in this example, **FastAPI**'s logo):diff --git a/docs/en/docs/how-to/general.md b/docs/en/docs/how-to/general.md index 4f611dab05..f4c31a9e66 100644 --- a/docs/en/docs/how-to/general.md +++ b/docs/en/docs/how-to/general.md @@ -4,40 +4,40 @@ Here are several pointers to other places in the docs, for general or frequent q ## Filter Data - Security { #filter-data-security } -To ensure that you don't return more data than you should, read the docs for [Tutorial - Response Model - Return Type](../tutorial/response-model.md){.internal-link target=_blank}. +To ensure that you don't return more data than you should, read the docs for [Tutorial - Response Model - Return Type](../tutorial/response-model.md){target=_blank}. ## Optimize Response Performance - Response Model - Return Type { #optimize-response-performance-response-model-return-type } -To optimize performance when returning JSON data, use a return type or response model, that way Pydantic will handle the serialization to JSON on the Rust side, without going through Python. Read more in the docs for [Tutorial - Response Model - Return Type](../tutorial/response-model.md){.internal-link target=_blank}. +To optimize performance when returning JSON data, use a return type or response model, that way Pydantic will handle the serialization to JSON on the Rust side, without going through Python. Read more in the docs for [Tutorial - Response Model - Return Type](../tutorial/response-model.md){target=_blank}. ## Documentation Tags - OpenAPI { #documentation-tags-openapi } -To add tags to your *path operations*, and group them in the docs UI, read the docs for [Tutorial - Path Operation Configurations - Tags](../tutorial/path-operation-configuration.md#tags){.internal-link target=_blank}. +To add tags to your *path operations*, and group them in the docs UI, read the docs for [Tutorial - Path Operation Configurations - Tags](../tutorial/path-operation-configuration.md#tags){target=_blank}. ## Documentation Summary and Description - OpenAPI { #documentation-summary-and-description-openapi } -To add a summary and description to your *path operations*, and show them in the docs UI, read the docs for [Tutorial - Path Operation Configurations - Summary and Description](../tutorial/path-operation-configuration.md#summary-and-description){.internal-link target=_blank}. +To add a summary and description to your *path operations*, and show them in the docs UI, read the docs for [Tutorial - Path Operation Configurations - Summary and Description](../tutorial/path-operation-configuration.md#summary-and-description){target=_blank}. ## Documentation Response description - OpenAPI { #documentation-response-description-openapi } -To define the description of the response, shown in the docs UI, read the docs for [Tutorial - Path Operation Configurations - Response description](../tutorial/path-operation-configuration.md#response-description){.internal-link target=_blank}. +To define the description of the response, shown in the docs UI, read the docs for [Tutorial - Path Operation Configurations - Response description](../tutorial/path-operation-configuration.md#response-description){target=_blank}. ## Documentation Deprecate a *Path Operation* - OpenAPI { #documentation-deprecate-a-path-operation-openapi } -To deprecate a *path operation*, and show it in the docs UI, read the docs for [Tutorial - Path Operation Configurations - Deprecation](../tutorial/path-operation-configuration.md#deprecate-a-path-operation){.internal-link target=_blank}. +To deprecate a *path operation*, and show it in the docs UI, read the docs for [Tutorial - Path Operation Configurations - Deprecation](../tutorial/path-operation-configuration.md#deprecate-a-path-operation){target=_blank}. ## Convert any Data to JSON-compatible { #convert-any-data-to-json-compatible } -To convert any data to JSON-compatible, read the docs for [Tutorial - JSON Compatible Encoder](../tutorial/encoder.md){.internal-link target=_blank}. +To convert any data to JSON-compatible, read the docs for [Tutorial - JSON Compatible Encoder](../tutorial/encoder.md){target=_blank}. ## OpenAPI Metadata - Docs { #openapi-metadata-docs } -To add metadata to your OpenAPI schema, including a license, version, contact, etc, read the docs for [Tutorial - Metadata and Docs URLs](../tutorial/metadata.md){.internal-link target=_blank}. +To add metadata to your OpenAPI schema, including a license, version, contact, etc, read the docs for [Tutorial - Metadata and Docs URLs](../tutorial/metadata.md){target=_blank}. ## OpenAPI Custom URL { #openapi-custom-url } -To customize the OpenAPI URL (or remove it), read the docs for [Tutorial - Metadata and Docs URLs](../tutorial/metadata.md#openapi-url){.internal-link target=_blank}. +To customize the OpenAPI URL (or remove it), read the docs for [Tutorial - Metadata and Docs URLs](../tutorial/metadata.md#openapi-url){target=_blank}. ## OpenAPI Docs URLs { #openapi-docs-urls } -To update the URLs used for the automatically generated docs user interfaces, read the docs for [Tutorial - Metadata and Docs URLs](../tutorial/metadata.md#docs-urls){.internal-link target=_blank}. +To update the URLs used for the automatically generated docs user interfaces, read the docs for [Tutorial - Metadata and Docs URLs](../tutorial/metadata.md#docs-urls){target=_blank}. diff --git a/docs/en/docs/how-to/graphql.md b/docs/en/docs/how-to/graphql.md index 426b2e9821..bf0892cadb 100644 --- a/docs/en/docs/how-to/graphql.md +++ b/docs/en/docs/how-to/graphql.md @@ -18,18 +18,18 @@ Make sure you evaluate if the **benefits** for your use case compensate the **dr Here are some of the **GraphQL** libraries that have **ASGI** support. You could use them with **FastAPI**: -* Strawberry π - * With docs for FastAPI -* Ariadne - * With docs for FastAPI -* Tartiflette - * With Tartiflette ASGI to provide ASGI integration -* Graphene - * With starlette-graphene3 +* [Strawberry](https://strawberry.rocks/){target=_blank} π + * With [docs for FastAPI](https://strawberry.rocks/docs/integrations/fastapi){target=_blank} +* [Ariadne](https://ariadnegraphql.org/){target=_blank} + * With [docs for FastAPI](https://ariadnegraphql.org/docs/fastapi-integration){target=_blank} +* [Tartiflette](https://tartiflette.io/){target=_blank} + * With [Tartiflette ASGI](https://tartiflette.github.io/tartiflette-asgi/){target=_blank} to provide ASGI integration +* [Graphene](https://graphene-python.org/){target=_blank} + * With [starlette-graphene3](https://github.com/ciscorn/starlette-graphene3){target=_blank} ## GraphQL with Strawberry { #graphql-with-strawberry } -If you need or want to work with **GraphQL**, **Strawberry** is the **recommended** library as it has the design closest to **FastAPI's** design, it's all based on **type annotations**. +If you need or want to work with **GraphQL**, [**Strawberry**](https://strawberry.rocks/){target=_blank} is the **recommended** library as it has the design closest to **FastAPI's** design, it's all based on **type annotations**. Depending on your use case, you might prefer to use a different library, but if you asked me, I would probably suggest you try **Strawberry**. @@ -37,24 +37,24 @@ Here's a small preview of how you could integrate Strawberry with FastAPI: {* ../../docs_src/graphql_/tutorial001_py310.py hl[3,22,25] *} -You can learn more about Strawberry in the Strawberry documentation. +You can learn more about Strawberry in the [Strawberry documentation](https://strawberry.rocks/){target=_blank}. -And also the docs about Strawberry with FastAPI. +And also the docs about [Strawberry with FastAPI](https://strawberry.rocks/docs/integrations/fastapi){target=_blank}. ## Older `GraphQLApp` from Starlette { #older-graphqlapp-from-starlette } -Previous versions of Starlette included a `GraphQLApp` class to integrate with Graphene. +Previous versions of Starlette included a `GraphQLApp` class to integrate with [Graphene](https://graphene-python.org/){target=_blank}. -It was deprecated from Starlette, but if you have code that used it, you can easily **migrate** to starlette-graphene3, that covers the same use case and has an **almost identical interface**. +It was deprecated from Starlette, but if you have code that used it, you can easily **migrate** to [starlette-graphene3](https://github.com/ciscorn/starlette-graphene3){target=_blank}, that covers the same use case and has an **almost identical interface**. /// tip -If you need GraphQL, I still would recommend you check out Strawberry, as it's based on type annotations instead of custom classes and types. +If you need GraphQL, I still would recommend you check out [Strawberry](https://strawberry.rocks/){target=_blank}, as it's based on type annotations instead of custom classes and types. /// ## Learn More { #learn-more } -You can learn more about **GraphQL** in the official GraphQL documentation. +You can learn more about **GraphQL** in the [official GraphQL documentation](https://graphql.org/){target=_blank}. You can also read more about each those libraries described above in their links. diff --git a/docs/en/docs/how-to/index.md b/docs/en/docs/how-to/index.md index 5a8ce08de7..362bae417c 100644 --- a/docs/en/docs/how-to/index.md +++ b/docs/en/docs/how-to/index.md @@ -8,6 +8,6 @@ If something seems interesting and useful to your project, go ahead and check it /// tip -If you want to **learn FastAPI** in a structured way (recommended), go and read the [Tutorial - User Guide](../tutorial/index.md){.internal-link target=_blank} chapter by chapter instead. +If you want to **learn FastAPI** in a structured way (recommended), go and read the [Tutorial - User Guide](../tutorial/index.md){target=_blank} chapter by chapter instead. /// diff --git a/docs/en/docs/how-to/migrate-from-pydantic-v1-to-pydantic-v2.md b/docs/en/docs/how-to/migrate-from-pydantic-v1-to-pydantic-v2.md index fc90220b89..ccf3cc9c96 100644 --- a/docs/en/docs/how-to/migrate-from-pydantic-v1-to-pydantic-v2.md +++ b/docs/en/docs/how-to/migrate-from-pydantic-v1-to-pydantic-v2.md @@ -22,7 +22,7 @@ If you have an old FastAPI app with Pydantic v1, here I'll show you how to migra ## Official Guide { #official-guide } -Pydantic has an official Migration Guide from v1 to v2. +Pydantic has an official [Migration Guide](https://docs.pydantic.dev/latest/migration/){target=_blank} from v1 to v2. It also includes what has changed, how validations are now more correct and strict, possible caveats, etc. @@ -30,7 +30,7 @@ You can read it to understand better what has changed. ## Tests { #tests } -Make sure you have [tests](../tutorial/testing.md){.internal-link target=_blank} for your app and you run them on continuous integration (CI). +Make sure you have [tests](../tutorial/testing.md){target=_blank} for your app and you run them on continuous integration (CI). This way, you can do the upgrade and make sure everything is still working as expected. @@ -38,7 +38,7 @@ This way, you can do the upgrade and make sure everything is still working as ex In many cases, when you use regular Pydantic models without customizations, you will be able to automate most of the process of migrating from Pydantic v1 to Pydantic v2. -You can use `bump-pydantic` from the same Pydantic team. +You can use [`bump-pydantic`](https://github.com/pydantic/bump-pydantic){target=_blank} from the same Pydantic team. This tool will help you to automatically change most of the code that needs to be changed. diff --git a/docs/en/docs/how-to/testing-database.md b/docs/en/docs/how-to/testing-database.md index 400fdcfc64..39a9e8eebf 100644 --- a/docs/en/docs/how-to/testing-database.md +++ b/docs/en/docs/how-to/testing-database.md @@ -1,7 +1,7 @@ # Testing a Database { #testing-a-database } -You can study about databases, SQL, and SQLModel in the SQLModel docs. π€ +You can study about databases, SQL, and SQLModel in the [SQLModel docs](https://sqlmodel.tiangolo.com/){target=_blank}. π€ -There's a mini tutorial on using SQLModel with FastAPI. β¨ +There's a mini [tutorial on using SQLModel with FastAPI](https://sqlmodel.tiangolo.com/tutorial/fastapi/){target=_blank}. β¨ -That tutorial includes a section about testing SQL databases. π +That tutorial includes a section about [testing SQL databases](https://sqlmodel.tiangolo.com/tutorial/fastapi/tests/){target=_blank}. π diff --git a/docs/en/docs/index.md b/docs/en/docs/index.md index 7f9d5efbf2..5d16911698 100644 --- a/docs/en/docs/index.md +++ b/docs/en/docs/index.md @@ -44,7 +44,7 @@ The key features are: * **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: OpenAPI (previously known as Swagger) and JSON Schema. +* **Standards-based**: Based on (and fully compatible with) the open standards for APIs: OpenAPI (previously known as Swagger) and JSON Schema. * estimation based on tests conducted by an internal development team, building production applications. @@ -69,7 +69,7 @@ The key features are: -Other sponsors +Other sponsors ## Opinions { #opinions } @@ -119,7 +119,7 @@ The key features are: ## FastAPI mini documentary { #fastapi-mini-documentary } -There's a FastAPI mini documentary released at the end of 2025, you can watch it online: +There's a FastAPI mini documentary released at the end of 2025, you can watch it online:
@@ -127,7 +127,7 @@ There's a
-If you are building a CLI app to be used in the terminal instead of a web API, check out **Typer**. +If you are building a CLI app to be used in the terminal instead of a web API, check out **Typer**. **Typer** is FastAPI's little sibling. And it's intended to be the **FastAPI of CLIs**. β¨οΈ π @@ -135,12 +135,12 @@ If you are building a CLI app to be FastAPI stands on the shoulders of giants: -* Starlette for the web parts. -* Pydantic for the data parts. +* Starlette for the web parts. +* Pydantic for the data parts. ## Installation { #installation } -Create and activate a virtual environment and then install FastAPI: +Create and activate a virtual environment and then install FastAPI:
@@ -237,7 +237,7 @@ INFO: Application startup complete.-And open the docs at http://127.0.0.1:8000/docs. +And open the docs at [http://127.0.0.1:8000/docs](http://127.0.0.1:8000/docs){target=_blank}. You will see the automatic API docs, including the paths from all the submodules, using the correct paths (and prefixes) and the correct tags: diff --git a/docs/en/docs/tutorial/body-nested-models.md b/docs/en/docs/tutorial/body-nested-models.md index b84c9242e9..2edcdd5b6e 100644 --- a/docs/en/docs/tutorial/body-nested-models.md +++ b/docs/en/docs/tutorial/body-nested-models.md @@ -96,7 +96,7 @@ Again, doing just that declaration, with **FastAPI** you get: Apart from normal singular types like `str`, `int`, `float`, etc. you can use more complex singular types that inherit from `str`. -To see all the options you have, checkout Pydantic's Type Overview. You will see some examples in the next chapter. +To see all the options you have, checkout [Pydantic's Type Overview](https://docs.pydantic.dev/latest/concepts/types/){target=_blank}. You will see some examples in the next chapter. For example, as in the `Image` model we have a `url` field, we can declare it to be an instance of Pydantic's `HttpUrl` instead of a `str`: diff --git a/docs/en/docs/tutorial/body-updates.md b/docs/en/docs/tutorial/body-updates.md index 1b7fd70661..73a63c26ad 100644 --- a/docs/en/docs/tutorial/body-updates.md +++ b/docs/en/docs/tutorial/body-updates.md @@ -2,7 +2,7 @@ ## Update replacing with `PUT` { #update-replacing-with-put } -To update an item you can use the HTTP `PUT` operation. +To update an item you can use the [HTTP `PUT`](https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/PUT){target=_blank} operation. You can use the `jsonable_encoder` to convert the input data to data that can be stored as JSON (e.g. with a NoSQL database). For example, converting `datetime` to `str`. @@ -28,7 +28,7 @@ And the data would be saved with that "new" `tax` of `10.5`. ## Partial updates with `PATCH` { #partial-updates-with-patch } -You can also use the HTTP `PATCH` operation to *partially* update data. +You can also use the [HTTP `PATCH`](https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/PATCH){target=_blank} operation to *partially* update data. This means that you can send only the data that you want to update, leaving the rest intact. @@ -95,6 +95,6 @@ Notice that the input model is still validated. So, if you want to receive partial updates that can omit all the attributes, you need to have a model with all the attributes marked as optional (with default values or `None`). -To distinguish from the models with all optional values for **updates** and models with required values for **creation**, you can use the ideas described in [Extra Models](extra-models.md){.internal-link target=_blank}. +To distinguish from the models with all optional values for **updates** and models with required values for **creation**, you can use the ideas described in [Extra Models](extra-models.md){target=_blank}. /// diff --git a/docs/en/docs/tutorial/body.md b/docs/en/docs/tutorial/body.md index fb4471836e..c872e331d6 100644 --- a/docs/en/docs/tutorial/body.md +++ b/docs/en/docs/tutorial/body.md @@ -6,7 +6,7 @@ A **request** body is data sent by the client to your API. A **response** body i Your API almost always has to send a **response** body. But clients don't necessarily need to send **request bodies** all the time, sometimes they only request a path, maybe with some query parameters, but don't send a body. -To declare a **request** body, you use Pydantic models with all their power and benefits. +To declare a **request** body, you use [Pydantic](https://docs.pydantic.dev/){target=_blank} models with all their power and benefits. /// info @@ -73,7 +73,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 JSON Schema definitions for your model, you can also use them anywhere else you like if it makes sense for your project. +* Generate [JSON Schema](https://json-schema.org){target=_blank} 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 UIs. ## Automatic docs { #automatic-docs } @@ -102,15 +102,15 @@ And it was thoroughly tested at the design phase, before any implementation, to There were even some changes to Pydantic itself to support this. -The previous screenshots were taken with Visual Studio Code. +The previous screenshots were taken with [Visual Studio Code](https://code.visualstudio.com){target=_blank}. -But you would get the same editor support with PyCharm and most of the other Python editors: +But you would get the same editor support with [PyCharm](https://www.jetbrains.com/pycharm/){target=_blank} and most of the other Python editors:About the command
-The command `fastapi dev` reads your `main.py` file, detects the **FastAPI** app in it, and starts a server using Uvicorn. +The command `fastapi dev` reads your `main.py` file, detects the **FastAPI** app in it, and starts a server using Uvicorn. By default, `fastapi dev` will start with auto-reload enabled for local development. @@ -247,7 +247,7 @@ You can read more about it in the http://127.0.0.1:8000/items/5?q=somequery. +Open your browser at http://127.0.0.1:8000/items/5?q=somequery. You will see the JSON response as: @@ -264,17 +264,17 @@ You already created an API that: ### Interactive API docs { #interactive-api-docs } -Now go to http://127.0.0.1:8000/docs. +Now go to http://127.0.0.1:8000/docs. -You will see the automatic interactive API documentation (provided by Swagger UI): +You will see the automatic interactive API documentation (provided by Swagger UI):  ### Alternative API docs { #alternative-api-docs } -And now, go to http://127.0.0.1:8000/redoc. +And now, go to http://127.0.0.1:8000/redoc. -You will see the alternative automatic documentation (provided by ReDoc): +You will see the alternative automatic documentation (provided by ReDoc):  @@ -316,7 +316,7 @@ The `fastapi dev` server should reload automatically. ### Interactive API docs upgrade { #interactive-api-docs-upgrade } -Now go to http://127.0.0.1:8000/docs. +Now go to http://127.0.0.1:8000/docs. * The interactive API documentation will be automatically updated, including the new body: @@ -332,7 +332,7 @@ Now go to http://127.0.0.1:8000/redoc. +And now, go to http://127.0.0.1:8000/redoc. * The alternative documentation will also reflect the new query parameter and body: @@ -442,7 +442,7 @@ For a more complete example including more features, see the Dependency Injection** system. * Security and authentication, including support for **OAuth2** with **JWT tokens** and **HTTP Basic** auth. * More advanced (but equally easy) techniques for declaring **deeply nested JSON models** (thanks to Pydantic). -* **GraphQL** integration with Strawberry and other libraries. +* **GraphQL** integration with Strawberry and other libraries. * Many extra features (thanks to Starlette) as: * **WebSockets** * extremely easy tests based on HTTPX and `pytest` @@ -452,7 +452,7 @@ For a more complete example including more features, see the FastAPI Cloud, go and join the waiting list if you haven't. π +You can optionally deploy your FastAPI app to FastAPI Cloud, go and join the waiting list if you haven't. π If you already have a **FastAPI Cloud** account (we invited you from the waiting list π), you can deploy your application with one command. @@ -488,7 +488,7 @@ That's it! Now you can access your app at that URL. β¨ #### About FastAPI Cloud { #about-fastapi-cloud } -**FastAPI Cloud** is built by the same author and team behind **FastAPI**. +**FastAPI Cloud** is built by the same author and team behind **FastAPI**. It streamlines the process of **building**, **deploying**, and **accessing** an API with minimal effort. @@ -504,9 +504,9 @@ Follow your cloud provider's guides to deploy FastAPI apps with them. π€ ## Performance { #performance } -Independent TechEmpower benchmarks show **FastAPI** applications running under Uvicorn as one of the fastest Python frameworks available, only below Starlette and Uvicorn themselves (used internally by FastAPI). (*) +Independent TechEmpower benchmarks show **FastAPI** applications running under Uvicorn as one of the fastest Python frameworks available, only below Starlette and Uvicorn themselves (used internally by FastAPI). (*) -To understand more about it, see the section Benchmarks. +To understand more about it, see the section Benchmarks. ## Dependencies { #dependencies } @@ -530,7 +530,7 @@ Used by FastAPI: *fastapi dev main.py...uvicorn- for the server that loads and serves your application. This includes `uvicorn[standard]`, which includes some dependencies (e.g. `uvloop`) needed for high performance serving. * `fastapi-cli[standard]` - to provide the `fastapi` command. - * This includes `fastapi-cloud-cli`, which allows you to deploy your FastAPI application to FastAPI Cloud. + * This includes `fastapi-cloud-cli`, which allows you to deploy your FastAPI application to FastAPI Cloud. ### Without `standard` Dependencies { #without-standard-dependencies } diff --git a/docs/en/docs/management-tasks.md b/docs/en/docs/management-tasks.md index fc6e1eb280..763a0b55f8 100644 --- a/docs/en/docs/management-tasks.md +++ b/docs/en/docs/management-tasks.md @@ -1,6 +1,6 @@ # Repository Management Tasks -These are the tasks that can be performed to manage the FastAPI repository by [team members](./fastapi-people.md#team){.internal-link target=_blank}. +These are the tasks that can be performed to manage the FastAPI repository by [team members](./fastapi-people.md#team){target=_blank}. /// tip @@ -8,9 +8,9 @@ This section is useful only to a handful of people, team members with permission /// -...so, you are a [team member of FastAPI](./fastapi-people.md#team){.internal-link target=_blank}? Wow, you are so cool! π +...so, you are a [team member of FastAPI](./fastapi-people.md#team){target=_blank}? Wow, you are so cool! π -You can help with everything on [Help FastAPI - Get Help](./help-fastapi.md){.internal-link target=_blank} the same ways as external contributors. But additionally, there are some tasks that only you (as part of the team) can perform. +You can help with everything on [Help FastAPI - Get Help](./help-fastapi.md){target=_blank} the same ways as external contributors. But additionally, there are some tasks that only you (as part of the team) can perform. Here are the general instructions for the tasks you can perform. @@ -40,7 +40,7 @@ For conversations that are more difficult, for example to reject a PR, you can a ## Edit PR Titles -* Edit the PR title to start with an emoji from gitmoji. +* Edit the PR title to start with an emoji from [gitmoji](https://gitmoji.dev/){target=_blank}. * Use the emoji character, not the GitHub code. So, use `π` instead of `:bug:`. This is so that it shows up correctly outside of GitHub, for example in the release notes. * For translations use the `π` emoji ("globe with meridians"). * Start the title with a verb. For example `Add`, `Refactor`, `Fix`, etc. This way the title will say the action that the PR does. Like `Add support for teleporting`, instead of `Teleporting wasn't working, so this PR fixes it`. @@ -53,15 +53,15 @@ For conversations that are more difficult, for example to reject a PR, you can a π Add Spanish translation for `docs/es/docs/teleporting.md` ``` -Once the PR is merged, a GitHub Action (latest-changes) will use the PR title to update the latest changes automatically. +Once the PR is merged, a GitHub Action ([latest-changes](https://github.com/tiangolo/latest-changes){target=_blank}) will use the PR title to update the latest changes automatically. So, having a nice PR title will not only look nice in GitHub, but also in the release notes. π ## Add Labels to PRs -The same GitHub Action latest-changes uses one label in the PR to decide the section in the release notes to put this PR in. +The same GitHub Action [latest-changes](https://github.com/tiangolo/latest-changes){target=_blank} uses one label in the PR to decide the section in the release notes to put this PR in. -Make sure you use a supported label from the latest-changes list of labels: +Make sure you use a supported label from the [latest-changes list of labels](https://github.com/tiangolo/latest-changes#using-labels){target=_blank}: * `breaking`: Breaking Changes * Existing code will break if they update the version without changing their code. This rarely happens, so this label is not frequently used. @@ -108,7 +108,7 @@ This way, we can notice when there are new translations ready, because they have Translations are generated automatically with LLMs and scripts. -There's one GitHub Action that can be manually run to add or update translations for a language: `translate.yml`. +There's one GitHub Action that can be manually run to add or update translations for a language: [`translate.yml`](https://github.com/fastapi/fastapi/actions/workflows/translate.yml){target=_blank}. For these language translation PRs, confirm that: @@ -140,7 +140,7 @@ For these language translation PRs, confirm that: ## FastAPI People PRs -Every month, a GitHub Action updates the FastAPI People data. Those PRs look like this one: π₯ Update FastAPI People. +Every month, a GitHub Action updates the FastAPI People data. Those PRs look like this one: [π₯ Update FastAPI People](https://github.com/fastapi/fastapi/pull/11669){target=_blank}. If the tests are passing, you can merge it right away. @@ -155,4 +155,4 @@ Dependabot will create PRs to update dependencies for several things, and those When a question in GitHub Discussions has been answered, mark the answer by clicking "Mark as answer". -You can filter discussions by `Questions` that are `Unanswered`. +You can filter discussions by [`Questions` that are `Unanswered`](https://github.com/tiangolo/fastapi/discussions/categories/questions?discussions_q=category:Questions+is:open+is:unanswered){target=_blank}. diff --git a/docs/en/docs/management.md b/docs/en/docs/management.md index 085a1756f8..55a0c7e4ce 100644 --- a/docs/en/docs/management.md +++ b/docs/en/docs/management.md @@ -6,13 +6,13 @@ Here's a short description of how the FastAPI repository is managed and maintain I, @tiangolo, am the creator and owner of the FastAPI repository. π€ -I normally give the final review to each PR before merging them. I make the final decisions on the project, I'm the BDFL. π +I normally give the final review to each PR before merging them. I make the final decisions on the project, I'm the BDFL. π ## Team There's a team of people that help manage and maintain the project. π -They have different levels of permissions and [specific instructions](./management-tasks.md){.internal-link target=_blank}. +They have different levels of permissions and [specific instructions](./management-tasks.md){target=_blank}. Some of the tasks they can perform include: @@ -22,13 +22,13 @@ Some of the tasks they can perform include: * Mark answers in GitHub Discussions questions, etc. * Merge some specific types of PRs. -You can see the current team members in [FastAPI People - Team](./fastapi-people.md#team){.internal-link target=_blank}. +You can see the current team members in [FastAPI People - Team](./fastapi-people.md#team){target=_blank}. Joining the team is by invitation only, and I could update or remove permissions, instructions, or membership. ## FastAPI Experts -The people that help others the most in GitHub Discussions can become [**FastAPI Experts**](./fastapi-people.md#fastapi-experts){.internal-link target=_blank}. +The people that help others the most in GitHub Discussions can become [**FastAPI Experts**](./fastapi-people.md#fastapi-experts){target=_blank}. This is normally the best way to contribute to the project. @@ -36,4 +36,4 @@ This is normally the best way to contribute to the project. External contributions are very welcome and appreciated, including answering questions, submitting PRs, etc. πββοΈ -There are many ways to [help maintain FastAPI](./help-fastapi.md#help-maintain-fastapi){.internal-link target=_blank}. +There are many ways to [help maintain FastAPI](./help-fastapi.md#help-maintain-fastapi){target=_blank}. diff --git a/docs/en/docs/project-generation.md b/docs/en/docs/project-generation.md index 610d23ccb1..56aecad089 100644 --- a/docs/en/docs/project-generation.md +++ b/docs/en/docs/project-generation.md @@ -4,7 +4,7 @@ Templates, while typically come with a specific setup, are designed to be flexib You can use this template to get started, as it includes a lot of the initial set up, security, database and some API endpoints already done for you. -GitHub Repository: Full Stack FastAPI Template +GitHub Repository: [Full Stack FastAPI Template](https://github.com/tiangolo/full-stack-fastapi-template){target=_blank} ## Full Stack FastAPI Template - Technology Stack and Features { #full-stack-fastapi-template-technology-stack-and-features } diff --git a/docs/en/docs/python-types.md b/docs/en/docs/python-types.md index 90c32cec8c..b68c3315e4 100644 --- a/docs/en/docs/python-types.md +++ b/docs/en/docs/python-types.md @@ -269,7 +269,7 @@ It doesn't mean "`one_person` is the **class** called `Person`". ## Pydantic models { #pydantic-models } -Pydantic is a Python library to perform data validation. +[Pydantic](https://docs.pydantic.dev/){target=_blank} is a Python library to perform data validation. You declare the "shape" of the data as classes with attributes. @@ -285,13 +285,13 @@ An example from the official Pydantic docs: /// info -To learn more about Pydantic, check its docs. +To learn more about [Pydantic, check its docs](https://docs.pydantic.dev/){target=_blank}. /// **FastAPI** is all based on Pydantic. -You will see a lot more of all this in practice in the [Tutorial - User Guide](tutorial/index.md){.internal-link target=_blank}. +You will see a lot more of all this in practice in the [Tutorial - User Guide](tutorial/index.md){target=_blank}. ## Type Hints with Metadata Annotations { #type-hints-with-metadata-annotations } @@ -337,12 +337,12 @@ With **FastAPI** you declare parameters with type hints and you get: * **Document** the API using OpenAPI: * which is then used by the automatic interactive documentation user interfaces. -This might all sound abstract. Don't worry. You'll see all this in action in the [Tutorial - User Guide](tutorial/index.md){.internal-link target=_blank}. +This might all sound abstract. Don't worry. You'll see all this in action in the [Tutorial - User Guide](tutorial/index.md){target=_blank}. The important thing is that by using standard Python types, in a single place (instead of adding more classes, decorators, etc), **FastAPI** will do a lot of the work for you. /// info -If you already went through all the tutorial and came back to see more about types, a good resource is the "cheat sheet" from `mypy`. +If you already went through all the tutorial and came back to see more about types, a good resource is [the "cheat sheet" from `mypy`](https://mypy.readthedocs.io/en/latest/cheat_sheet_py3.html){target=_blank}. /// diff --git a/docs/en/docs/release-notes.md b/docs/en/docs/release-notes.md index e867130822..71c6e0c60b 100644 --- a/docs/en/docs/release-notes.md +++ b/docs/en/docs/release-notes.md @@ -3609,10 +3609,10 @@ There are **tests for both Pydantic v1 and v2**, and test **coverage** is kept a ### Features * β¨ Add support for OpenAPI 3.1.0. PR [#9770](https://github.com/tiangolo/fastapi/pull/9770) by [@tiangolo](https://github.com/tiangolo). - * New support for documenting **webhooks**, read the new docs here: Advanced User Guide: OpenAPI Webhooks. + * New support for documenting **webhooks**, read the new docs here: [Advanced User Guide: OpenAPI Webhooks](https://fastapi.tiangolo.com/advanced/openapi-webhooks/). * Upgrade OpenAPI 3.1.0, this uses JSON Schema 2020-12. * Upgrade Swagger UI to version 5.x.x, that supports OpenAPI 3.1.0. - * Updated `examples` field in `Query()`, `Cookie()`, `Body()`, etc. based on the latest JSON Schema and OpenAPI. Now it takes a list of examples and they are included directly in the JSON Schema, not outside. Read more about it (including the historical technical details) in the updated docs: Tutorial: Declare Request Example Data. + * Updated `examples` field in `Query()`, `Cookie()`, `Body()`, etc. based on the latest JSON Schema and OpenAPI. Now it takes a list of examples and they are included directly in the JSON Schema, not outside. Read more about it (including the historical technical details) in the updated docs: [Tutorial: Declare Request Example Data](https://fastapi.tiangolo.com/tutorial/schema-extra-example/). * β¨ Add support for `deque` objects and children in `jsonable_encoder`. PR [#9433](https://github.com/tiangolo/fastapi/pull/9433) by [@cranium](https://github.com/cranium). @@ -5545,10 +5545,10 @@ Note: all the previous parameters are still there, so it's still possible to dec ### Docs * PR [#2434](https://github.com/tiangolo/fastapi/pull/2434) (above) includes new or updated docs: - * Advanced User Guide - OpenAPI Callbacks. - * Tutorial - Bigger Applications. - * Tutorial - Dependencies - Dependencies in path operation decorators. - * Tutorial - Dependencies - Global Dependencies. + * [Advanced User Guide - OpenAPI Callbacks](https://fastapi.tiangolo.com/advanced/openapi-callbacks/). + * [Tutorial - Bigger Applications](https://fastapi.tiangolo.com/tutorial/bigger-applications/). + * [Tutorial - Dependencies - Dependencies in path operation decorators](https://fastapi.tiangolo.com/tutorial/dependencies/dependencies-in-path-operation-decorators/){target=_blank}. + * [Tutorial - Dependencies - Global Dependencies](https://fastapi.tiangolo.com/tutorial/dependencies/global-dependencies/). * π Add FastAPI monitoring blog post to External Links. PR [#2324](https://github.com/tiangolo/fastapi/pull/2324) by [@louisguitton](https://github.com/louisguitton). * βοΈ Fix typo in Deta tutorial. PR [#2320](https://github.com/tiangolo/fastapi/pull/2320) by [@tiangolo](https://github.com/tiangolo). diff --git a/docs/en/docs/tutorial/background-tasks.md b/docs/en/docs/tutorial/background-tasks.md index 163070d3d3..c5cfe15f90 100644 --- a/docs/en/docs/tutorial/background-tasks.md +++ b/docs/en/docs/tutorial/background-tasks.md @@ -63,7 +63,7 @@ And then another background task generated at the *path operation function* will ## Technical Details { #technical-details } -The class `BackgroundTasks` comes directly from `starlette.background`. +The class `BackgroundTasks` comes directly from [`starlette.background`](https://www.starlette.dev/background/){target=_blank}. It is imported/included directly into FastAPI so that you can import it from `fastapi` and avoid accidentally importing the alternative `BackgroundTask` (without the `s` at the end) from `starlette.background`. @@ -71,11 +71,11 @@ By only using `BackgroundTasks` (and not `BackgroundTask`), it's then possible t It's still possible to use `BackgroundTask` alone in FastAPI, but you have to create the object in your code and return a Starlette `Response` including it. -You can see more details in Starlette's official docs for Background Tasks. +You can see more details in [Starlette's official docs for Background Tasks](https://www.starlette.dev/background/){target=_blank}. ## Caveat { #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 Celery. +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 [Celery](https://docs.celeryq.dev){target=_blank}. 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. diff --git a/docs/en/docs/tutorial/bigger-applications.md b/docs/en/docs/tutorial/bigger-applications.md index 7fe83c0635..a79c5290ac 100644 --- a/docs/en/docs/tutorial/bigger-applications.md +++ b/docs/en/docs/tutorial/bigger-applications.md @@ -123,7 +123,7 @@ We will now use a simple dependency to read a custom `X-Token` header: We are using an invented header to simplify this example. -But in real cases you will get better results using the integrated [Security utilities](security/index.md){.internal-link target=_blank}. +But in real cases you will get better results using the integrated [Security utilities](security/index.md){target=_blank}. /// @@ -169,7 +169,7 @@ And we can add a list of `dependencies` that will be added to all the *path oper /// tip -Note that, much like [dependencies in *path operation decorators*](dependencies/dependencies-in-path-operation-decorators.md){.internal-link target=_blank}, no value will be passed to your *path operation function*. +Note that, much like [dependencies in *path operation decorators*](dependencies/dependencies-in-path-operation-decorators.md){target=_blank}, no value will be passed to your *path operation function*. /// @@ -185,8 +185,8 @@ The end result is that the item paths are now: * All of them will include the predefined `responses`. * All these *path operations* will have the list of `dependencies` evaluated/executed before them. * If you also declare dependencies in a specific *path operation*, **they will be executed too**. - * The router dependencies are executed first, then the [`dependencies` in the decorator](dependencies/dependencies-in-path-operation-decorators.md){.internal-link target=_blank}, and then the normal parameter dependencies. - * You can also add [`Security` dependencies with `scopes`](../advanced/security/oauth2-scopes.md){.internal-link target=_blank}. + * The router dependencies are executed first, then the [`dependencies` in the decorator](dependencies/dependencies-in-path-operation-decorators.md){target=_blank}, and then the normal parameter dependencies. + * You can also add [`Security` dependencies with `scopes`](../advanced/security/oauth2-scopes.md){target=_blank}. /// tip @@ -303,7 +303,7 @@ And as most of your logic will now live in its own specific module, the main fil You import and create a `FastAPI` class as normally. -And we can even declare [global dependencies](dependencies/global-dependencies.md){.internal-link target=_blank} that will be combined with the dependencies for each `APIRouter`: +And we can even declare [global dependencies](dependencies/global-dependencies.md){target=_blank} that will be combined with the dependencies for each `APIRouter`: {* ../../docs_src/bigger_applications/app_an_py310/main.py hl[1,3,7] title["app/main.py"] *} @@ -353,7 +353,7 @@ The second version is an "absolute import": from app.routers import items, users ``` -To learn more about Python Packages and Modules, read the official Python documentation about Modules. +To learn more about Python Packages and Modules, read [the official Python documentation about Modules](https://docs.python.org/3/tutorial/modules.html){target=_blank}. /// @@ -479,7 +479,7 @@ $ fastapi dev app/main.py/// tip -If you use PyCharm as your editor, you can use the Pydantic PyCharm Plugin. +If you use [PyCharm](https://www.jetbrains.com/pycharm/){target=_blank} as your editor, you can use the [Pydantic PyCharm Plugin](https://github.com/koxudaxi/pydantic-pycharm-plugin/){target=_blank}. It improves editor support for Pydantic models, with: @@ -163,4 +163,4 @@ But adding the type annotations will allow your editor to give you better suppor ## Without Pydantic { #without-pydantic } -If you don't want to use Pydantic models, you can also use **Body** parameters. See the docs for [Body - Multiple Parameters: Singular values in body](body-multiple-params.md#singular-values-in-body){.internal-link target=_blank}. +If you don't want to use Pydantic models, you can also use **Body** parameters. See the docs for [Body - Multiple Parameters: Singular values in body](body-multiple-params.md#singular-values-in-body){target=_blank}. diff --git a/docs/en/docs/tutorial/cors.md b/docs/en/docs/tutorial/cors.md index 61aaa56360..6251a03e35 100644 --- a/docs/en/docs/tutorial/cors.md +++ b/docs/en/docs/tutorial/cors.md @@ -1,6 +1,6 @@ # CORS (Cross-Origin Resource Sharing) { #cors-cross-origin-resource-sharing } -CORS or "Cross-Origin Resource Sharing" refers to the situations when a frontend running in a browser has JavaScript code that communicates with a backend, and the backend is in a different "origin" than the frontend. +[CORS or "Cross-Origin Resource Sharing"](https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS){target=_blank} refers to the situations when a frontend running in a browser has JavaScript code that communicates with a backend, and the backend is in a different "origin" than the frontend. ## Origin { #origin } @@ -56,10 +56,10 @@ The following arguments are supported: * `allow_origins` - A list of origins that should be permitted to make cross-origin requests. E.g. `['https://example.org', 'https://www.example.org']`. You can use `['*']` to allow any origin. * `allow_origin_regex` - A regex string to match against origins that should be permitted to make cross-origin requests. e.g. `'https://.*\.example\.org'`. * `allow_methods` - A list of HTTP methods that should be allowed for cross-origin requests. Defaults to `['GET']`. You can use `['*']` to allow all standard methods. -* `allow_headers` - A list of HTTP request headers that should be supported for cross-origin requests. Defaults to `[]`. You can use `['*']` to allow all headers. The `Accept`, `Accept-Language`, `Content-Language` and `Content-Type` headers are always allowed for simple CORS requests. +* `allow_headers` - A list of HTTP request headers that should be supported for cross-origin requests. Defaults to `[]`. You can use `['*']` to allow all headers. The `Accept`, `Accept-Language`, `Content-Language` and `Content-Type` headers are always allowed for [simple CORS requests](https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS#simple_requests){target=_blank}. * `allow_credentials` - Indicate that cookies should be supported for cross-origin requests. Defaults to `False`. - None of `allow_origins`, `allow_methods` and `allow_headers` can be set to `['*']` if `allow_credentials` is set to `True`. All of them must be explicitly specified. + None of `allow_origins`, `allow_methods` and `allow_headers` can be set to `['*']` if `allow_credentials` is set to `True`. All of them must be [explicitly specified](https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS#credentialed_requests_and_wildcards){target=_blank}. * `expose_headers` - Indicate any response headers that should be made accessible to the browser. Defaults to `[]`. * `max_age` - Sets a maximum time in seconds for browsers to cache CORS responses. Defaults to `600`. @@ -78,7 +78,7 @@ Any request with an `Origin` header. In this case the middleware will pass the r ## More info { #more-info } -For more info about CORS, check the Mozilla CORS documentation. +For more info about CORS, check the [Mozilla CORS documentation](https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS){target=_blank}. /// note | Technical Details diff --git a/docs/en/docs/tutorial/debugging.md b/docs/en/docs/tutorial/debugging.md index 89bfb702a6..bd3345eed8 100644 --- a/docs/en/docs/tutorial/debugging.md +++ b/docs/en/docs/tutorial/debugging.md @@ -74,7 +74,7 @@ will not be executed. /// info -For more information, check the official Python docs. +For more information, check [the official Python docs](https://docs.python.org/3/library/__main__.html){target=_blank}. /// diff --git a/docs/en/docs/tutorial/dependencies/dependencies-in-path-operation-decorators.md b/docs/en/docs/tutorial/dependencies/dependencies-in-path-operation-decorators.md index c57c608d2b..8be9f81f67 100644 --- a/docs/en/docs/tutorial/dependencies/dependencies-in-path-operation-decorators.md +++ b/docs/en/docs/tutorial/dependencies/dependencies-in-path-operation-decorators.md @@ -32,7 +32,7 @@ It might also help avoid confusion for new developers that see an unused paramet In this example we use invented custom headers `X-Key` and `X-Token`. -But in real cases, when implementing security, you would get more benefits from using the integrated [Security utilities (the next chapter)](../security/index.md){.internal-link target=_blank}. +But in real cases, when implementing security, you would get more benefits from using the integrated [Security utilities (the next chapter)](../security/index.md){target=_blank}. /// @@ -62,7 +62,7 @@ So, you can reuse a normal dependency (that returns a value) you already use som ## Dependencies for a group of *path operations* { #dependencies-for-a-group-of-path-operations } -Later, when reading about how to structure bigger applications ([Bigger Applications - Multiple Files](../../tutorial/bigger-applications.md){.internal-link target=_blank}), possibly with multiple files, you will learn how to declare a single `dependencies` parameter for a group of *path operations*. +Later, when reading about how to structure bigger applications ([Bigger Applications - Multiple Files](../../tutorial/bigger-applications.md){target=_blank}), possibly with multiple files, you will learn how to declare a single `dependencies` parameter for a group of *path operations*. ## Global Dependencies { #global-dependencies } diff --git a/docs/en/docs/tutorial/dependencies/dependencies-with-yield.md b/docs/en/docs/tutorial/dependencies/dependencies-with-yield.md index 24a2076431..54b31ca92a 100644 --- a/docs/en/docs/tutorial/dependencies/dependencies-with-yield.md +++ b/docs/en/docs/tutorial/dependencies/dependencies-with-yield.md @@ -14,8 +14,8 @@ Make sure to use `yield` one single time per dependency. Any function that is valid to use with: -* `@contextlib.contextmanager` or -* `@contextlib.asynccontextmanager` +* [`@contextlib.contextmanager`](https://docs.python.org/3/library/contextlib.html#contextlib.contextmanager){target=_blank} or +* [`@contextlib.asynccontextmanager`](https://docs.python.org/3/library/contextlib.html#contextlib.asynccontextmanager){target=_blank} would be valid to use as a **FastAPI** dependency. @@ -87,7 +87,7 @@ You can have any combinations of dependencies that you want. /// note | Technical Details -This works thanks to Python's Context Managers. +This works thanks to Python's [Context Managers](https://docs.python.org/3/library/contextlib.html){target=_blank}. **FastAPI** uses them internally to achieve this. @@ -111,7 +111,7 @@ But it's there for you if you need it. π€ {* ../../docs_src/dependencies/tutorial008b_an_py310.py hl[18:22,31] *} -If you want to catch exceptions and create a custom response based on that, create a [Custom Exception Handler](../handling-errors.md#install-custom-exception-handlers){.internal-link target=_blank}. +If you want to catch exceptions and create a custom response based on that, create a [Custom Exception Handler](../handling-errors.md#install-custom-exception-handlers){target=_blank}. ## Dependencies with `yield` and `except` { #dependencies-with-yield-and-except } @@ -233,14 +233,14 @@ participant operation as Path Operation Dependencies with `yield` have evolved over time to cover different use cases and fix some issues. -If you want to see what has changed in different versions of FastAPI, you can read more about it in the advanced guide, in [Advanced Dependencies - Dependencies with `yield`, `HTTPException`, `except` and Background Tasks](../../advanced/advanced-dependencies.md#dependencies-with-yield-httpexception-except-and-background-tasks){.internal-link target=_blank}. +If you want to see what has changed in different versions of FastAPI, you can read more about it in the advanced guide, in [Advanced Dependencies - Dependencies with `yield`, `HTTPException`, `except` and Background Tasks](../../advanced/advanced-dependencies.md#dependencies-with-yield-httpexception-except-and-background-tasks){target=_blank}. ## Context Managers { #context-managers } ### What are "Context Managers" { #what-are-context-managers } "Context Managers" are any of those Python objects that you can use in a `with` statement. -For example, you can use `with` to read a file: +For example, [you can use `with` to read a file](https://docs.python.org/3/tutorial/inputoutput.html#reading-and-writing-files){target=_blank}: ```Python with open("./somefile.txt") as f: @@ -264,7 +264,7 @@ If you are just starting with **FastAPI** you might want to skip it for now. /// -In Python, you can create Context Managers by creating a class with two methods: `__enter__()` and `__exit__()`. +In Python, you can create Context Managers by [creating a class with two methods: `__enter__()` and `__exit__()`](https://docs.python.org/3/reference/datamodel.html#context-managers){target=_blank}. You can also use them inside of **FastAPI** dependencies with `yield` by using `with` or `async with` statements inside of the dependency function: @@ -275,8 +275,8 @@ You can also use them inside of **FastAPI** dependencies with `yield` by using Another way to create a context manager is with: -* `@contextlib.contextmanager` or -* `@contextlib.asynccontextmanager` +* [`@contextlib.contextmanager`](https://docs.python.org/3/library/contextlib.html#contextlib.contextmanager){target=_blank} or +* [`@contextlib.asynccontextmanager`](https://docs.python.org/3/library/contextlib.html#contextlib.asynccontextmanager){target=_blank} using them to decorate a function with a single `yield`. diff --git a/docs/en/docs/tutorial/dependencies/global-dependencies.md b/docs/en/docs/tutorial/dependencies/global-dependencies.md index 6feda0bc82..f4fc6cfb81 100644 --- a/docs/en/docs/tutorial/dependencies/global-dependencies.md +++ b/docs/en/docs/tutorial/dependencies/global-dependencies.md @@ -2,15 +2,15 @@ For some types of applications you might want to add dependencies to the whole application. -Similar to the way you can [add `dependencies` to the *path operation decorators*](dependencies-in-path-operation-decorators.md){.internal-link target=_blank}, you can add them to the `FastAPI` application. +Similar to the way you can [add `dependencies` to the *path operation decorators*](dependencies-in-path-operation-decorators.md){target=_blank}, you can add them to the `FastAPI` application. In that case, they will be applied to all the *path operations* in the application: {* ../../docs_src/dependencies/tutorial012_an_py310.py hl[17] *} -And all the ideas in the section about [adding `dependencies` to the *path operation decorators*](dependencies-in-path-operation-decorators.md){.internal-link target=_blank} still apply, but in this case, to all of the *path operations* in the app. +And all the ideas in the section about [adding `dependencies` to the *path operation decorators*](dependencies-in-path-operation-decorators.md){target=_blank} still apply, but in this case, to all of the *path operations* in the app. ## Dependencies for groups of *path operations* { #dependencies-for-groups-of-path-operations } -Later, when reading about how to structure bigger applications ([Bigger Applications - Multiple Files](../../tutorial/bigger-applications.md){.internal-link target=_blank}), possibly with multiple files, you will learn how to declare a single `dependencies` parameter for a group of *path operations*. +Later, when reading about how to structure bigger applications ([Bigger Applications - Multiple Files](../../tutorial/bigger-applications.md){target=_blank}), possibly with multiple files, you will learn how to declare a single `dependencies` parameter for a group of *path operations*. diff --git a/docs/en/docs/tutorial/dependencies/index.md b/docs/en/docs/tutorial/dependencies/index.md index 4a1bb774d9..72a40d21fa 100644 --- a/docs/en/docs/tutorial/dependencies/index.md +++ b/docs/en/docs/tutorial/dependencies/index.md @@ -57,7 +57,7 @@ FastAPI added support for `Annotated` (and started recommending it) in version 0 If you have an older version, you would get errors when trying to use `Annotated`. -Make sure you [Upgrade the FastAPI version](../../deployment/versions.md#upgrading-the-fastapi-versions){.internal-link target=_blank} to at least 0.95.1 before using `Annotated`. +Make sure you [Upgrade the FastAPI version](../../deployment/versions.md#upgrading-the-fastapi-versions){target=_blank} to at least 0.95.1 before using `Annotated`. /// @@ -152,7 +152,7 @@ It doesn't matter. **FastAPI** will know what to do. /// note -If you don't know, check the [Async: *"In a hurry?"*](../../async.md#in-a-hurry){.internal-link target=_blank} section about `async` and `await` in the docs. +If you don't know, check the [Async: *"In a hurry?"*](../../async.md#in-a-hurry){target=_blank} section about `async` and `await` in the docs. /// diff --git a/docs/en/docs/tutorial/encoder.md b/docs/en/docs/tutorial/encoder.md index 17982e9d79..64ad1c01e2 100644 --- a/docs/en/docs/tutorial/encoder.md +++ b/docs/en/docs/tutorial/encoder.md @@ -12,7 +12,7 @@ Let's imagine that you have a database `fake_db` that only receives JSON compati For example, it doesn't receive `datetime` objects, as those are not compatible with JSON. -So, a `datetime` object would have to be converted to a `str` containing the data in ISO format. +So, a `datetime` object would have to be converted to a `str` containing the data in [ISO format](https://en.wikipedia.org/wiki/ISO_8601){target=_blank}. The same way, this database wouldn't receive a Pydantic model (an object with attributes), only a `dict`. @@ -24,7 +24,7 @@ It receives an object, like a Pydantic model, and returns a JSON compatible vers In this example, it would convert the Pydantic model to a `dict`, and the `datetime` to a `str`. -The result of calling it is something that can be encoded with the Python standard `json.dumps()`. +The result of calling it is something that can be encoded with the Python standard [`json.dumps()`](https://docs.python.org/3/library/json.html#json.dumps){target=_blank}. It doesn't return a large `str` containing the data in JSON format (as a string). It returns a Python standard data structure (e.g. a `dict`) with values and sub-values that are all compatible with JSON. diff --git a/docs/en/docs/tutorial/extra-data-types.md b/docs/en/docs/tutorial/extra-data-types.md index a41f7c5fc4..c7c2965472 100644 --- a/docs/en/docs/tutorial/extra-data-types.md +++ b/docs/en/docs/tutorial/extra-data-types.md @@ -36,7 +36,7 @@ Here are some of the additional data types you can use: * `datetime.timedelta`: * A Python `datetime.timedelta`. * In requests and responses will be represented as a `float` of total seconds. - * Pydantic also allows representing it as a "ISO 8601 time diff encoding", see the docs for more info. + * Pydantic also allows representing it as a "ISO 8601 time diff encoding", [see the docs for more info](https://docs.pydantic.dev/latest/concepts/serialization/#custom-serializers){target=_blank}. * `frozenset`: * In requests and responses, treated the same as a `set`: * In requests, a list will be read, eliminating duplicates and converting it to a `set`. @@ -49,7 +49,7 @@ Here are some of the additional data types you can use: * `Decimal`: * Standard Python `Decimal`. * In requests and responses, handled the same as a `float`. -* You can check all the valid Pydantic data types here: Pydantic data types. +* You can check all the valid Pydantic data types here: [Pydantic data types](https://docs.pydantic.dev/latest/usage/types/types/){target=_blank}. ## Example { #example } diff --git a/docs/en/docs/tutorial/extra-models.md b/docs/en/docs/tutorial/extra-models.md index da4f8f2bda..f5137dd5c1 100644 --- a/docs/en/docs/tutorial/extra-models.md +++ b/docs/en/docs/tutorial/extra-models.md @@ -12,7 +12,7 @@ This is especially the case for user models, because: Never store user's plaintext passwords. Always store a "secure hash" that you can then verify. -If you don't know, you will learn what a "password hash" is in the [security chapters](security/simple-oauth2.md#password-hashing){.internal-link target=_blank}. +If you don't know, you will learn what a "password hash" is in the [security chapters](security/simple-oauth2.md#password-hashing){target=_blank}. /// @@ -162,11 +162,11 @@ You can declare a response to be the `Union` of two or more types, that means, t It will be defined in OpenAPI with `anyOf`. -To do that, use the standard Python type hint `typing.Union`: +To do that, use the standard Python type hint [`typing.Union`](https://docs.python.org/3/library/typing.html#typing.Union){target=_blank}: /// note -When defining a `Union`, include the most specific type first, followed by the less specific type. In the example below, the more specific `PlaneItem` comes before `CarItem` in `Union[PlaneItem, CarItem]`. +When defining a [`Union`](https://docs.pydantic.dev/latest/concepts/types/#unions){target=_blank}, include the most specific type first, followed by the less specific type. In the example below, the more specific `PlaneItem` comes before `CarItem` in `Union[PlaneItem, CarItem]`. /// diff --git a/docs/en/docs/tutorial/first-steps.md b/docs/en/docs/tutorial/first-steps.md index 84751d9d82..0eac40893d 100644 --- a/docs/en/docs/tutorial/first-steps.md +++ b/docs/en/docs/tutorial/first-steps.md @@ -58,7 +58,7 @@ That line shows the URL where your app is being served on your local machine. ### Check it { #check-it } -Open your browser at http://127.0.0.1:8000. +Open your browser at [http://127.0.0.1:8000](http://127.0.0.1:8000){target=_blank}. You will see the JSON response as: @@ -68,17 +68,17 @@ You will see the JSON response as: ### Interactive API docs { #interactive-api-docs } -Now go to http://127.0.0.1:8000/docs. +Now go to [http://127.0.0.1:8000/docs](http://127.0.0.1:8000/docs){target=_blank}. -You will see the automatic interactive API documentation (provided by Swagger UI): +You will see the automatic interactive API documentation (provided by [Swagger UI](https://github.com/swagger-api/swagger-ui){target=_blank}):  ### Alternative API docs { #alternative-api-docs } -And now, go to http://127.0.0.1:8000/redoc. +And now, go to [http://127.0.0.1:8000/redoc](http://127.0.0.1:8000/redoc){target=_blank}. -You will see the alternative automatic documentation (provided by ReDoc): +You will see the alternative automatic documentation (provided by [ReDoc](https://github.com/Rebilly/ReDoc){target=_blank}):  @@ -92,7 +92,7 @@ A "schema" is a definition or description of something. Not the code that implem #### API "schema" { #api-schema } -In this case, OpenAPI is a specification that dictates how to define a schema of your API. +In this case, [OpenAPI](https://github.com/OAI/OpenAPI-Specification){target=_blank} is a specification that dictates how to define a schema of your API. This schema definition includes your API paths, the possible parameters they take, etc. @@ -110,7 +110,7 @@ OpenAPI defines an API schema for your API. And that schema includes definitions If you are curious about how the raw OpenAPI schema looks like, FastAPI automatically generates a JSON (schema) with the descriptions of all your API. -You can see it directly at: http://127.0.0.1:8000/openapi.json. +You can see it directly at: [http://127.0.0.1:8000/openapi.json](http://127.0.0.1:8000/openapi.json){target=_blank}. It will show a JSON starting with something like: @@ -145,7 +145,7 @@ You could also use it to generate code automatically, for clients that communica ### Deploy your app (optional) { #deploy-your-app-optional } -You can optionally deploy your FastAPI app to FastAPI Cloud, go and join the waiting list if you haven't. π +You can optionally deploy your FastAPI app to [FastAPI Cloud](https://fastapicloud.com){target=_blank}, go and join the waiting list if you haven't. π If you already have a **FastAPI Cloud** account (we invited you from the waiting list π), you can deploy your application with one command. @@ -191,7 +191,7 @@ That's it! Now you can access your app at that URL. β¨ `FastAPI` is a class that inherits directly from `Starlette`. -You can use all the Starlette functionality with `FastAPI` too. +You can use all the [Starlette](https://www.starlette.dev/){target=_blank} functionality with `FastAPI` too. /// @@ -336,7 +336,7 @@ You could also define it as a normal function instead of `async def`: /// note -If you don't know the difference, check the [Async: *"In a hurry?"*](../async.md#in-a-hurry){.internal-link target=_blank}. +If you don't know the difference, check the [Async: *"In a hurry?"*](../async.md#in-a-hurry){target=_blank}. /// @@ -352,11 +352,11 @@ There are many other objects and models that will be automatically converted to ### Step 6: Deploy it { #step-6-deploy-it } -Deploy your app to **FastAPI Cloud** with one command: `fastapi deploy`. π +Deploy your app to **[FastAPI Cloud](https://fastapicloud.com){target=_blank}** with one command: `fastapi deploy`. π #### About FastAPI Cloud { #about-fastapi-cloud } -**FastAPI Cloud** is built by the same author and team behind **FastAPI**. +**[FastAPI Cloud](https://fastapicloud.com){target=_blank}** is built by the same author and team behind **FastAPI**. It streamlines the process of **building**, **deploying**, and **accessing** an API with minimal effort. diff --git a/docs/en/docs/tutorial/handling-errors.md b/docs/en/docs/tutorial/handling-errors.md index f1db17bb2e..8789a880ac 100644 --- a/docs/en/docs/tutorial/handling-errors.md +++ b/docs/en/docs/tutorial/handling-errors.md @@ -81,7 +81,7 @@ But in case you needed it for an advanced scenario, you can add custom headers: ## Install custom exception handlers { #install-custom-exception-handlers } -You can add custom exception handlers with the same exception utilities from Starlette. +You can add custom exception handlers with [the same exception utilities from Starlette](https://www.starlette.dev/exceptions/){target=_blank}. Let's say you have a custom exception `UnicornException` that you (or a library you use) might `raise`. diff --git a/docs/en/docs/tutorial/index.md b/docs/en/docs/tutorial/index.md index acd1a2d017..b031d48927 100644 --- a/docs/en/docs/tutorial/index.md +++ b/docs/en/docs/tutorial/index.md @@ -62,7 +62,7 @@ Using it in your editor is what really shows you the benefits of FastAPI, seeing The first step is to install FastAPI. -Make sure you create a [virtual environment](../virtual-environments.md){.internal-link target=_blank}, activate it, and then **install FastAPI**: +Make sure you create a [virtual environment](../virtual-environments.md){target=_blank}, activate it, and then **install FastAPI**:
@@ -76,7 +76,7 @@ $ pip install "fastapi[standard]" /// note -When you install with `pip install "fastapi[standard]"` it comes with some default optional standard dependencies, including `fastapi-cloud-cli`, which allows you to deploy to FastAPI Cloud. +When you install with `pip install "fastapi[standard]"` it comes with some default optional standard dependencies, including `fastapi-cloud-cli`, which allows you to deploy to [FastAPI Cloud](https://fastapicloud.com){target=_blank}. If you don't want to have those optional dependencies, you can instead install `pip install fastapi`. @@ -86,7 +86,7 @@ If you want to install the standard dependencies but without the `fastapi-cloud- /// tip -FastAPI has an official extension for VS Code (and Cursor), which provides a lot of features, including a path operation explorer, path operation search, CodeLens navigation in tests (jump to definition from tests), and FastAPI Cloud deployment and logs, all from your editor. +FastAPI has an [official extension for VS Code](https://marketplace.visualstudio.com/items?itemName=FastAPILabs.fastapi-vscode){target=_blank} (and Cursor), which provides a lot of features, including a path operation explorer, path operation search, CodeLens navigation in tests (jump to definition from tests), and FastAPI Cloud deployment and logs, all from your editor. /// diff --git a/docs/en/docs/tutorial/metadata.md b/docs/en/docs/tutorial/metadata.md index 5cf0dfca01..c0daffd231 100644 --- a/docs/en/docs/tutorial/metadata.md +++ b/docs/en/docs/tutorial/metadata.md @@ -14,7 +14,7 @@ You can set the following fields that are used in the OpenAPI specification and | `version` | `string` | The version of the API. This is the version of your own application, not of OpenAPI. For example `2.5.0`. | | `terms_of_service` | `str` | A URL to the Terms of Service for the API. If provided, this has to be a URL. | | `contact` | `dict` | The contact information for the exposed API. It can contain several fields.| -| `license_info` | `dict` | The license information for the exposed API. It can contain several fields.
contactfields
Parameter Type Description namestrThe identifying name of the contact person/organization. urlstrThe URL pointing to the contact information. MUST be in the format of a URL. strThe email address of the contact person/organization. MUST be in the format of an email address. | +| `license_info` | `dict` | The license information for the exposed API. It can contain several fields.
license_infofields
Parameter Type Description namestrREQUIRED (if a license_infois set). The license name used for the API.identifierstrAn SPDX license expression for the API. The identifierfield is mutually exclusive of theurlfield. Available since OpenAPI 3.1.0, FastAPI 0.99.0.urlstrA URL to the license used for the API. MUST be in the format of a URL. | You can set them as follows: @@ -76,7 +76,7 @@ Use the `tags` parameter with your *path operations* (and `APIRouter`s) to assig /// info -Read more about tags in [Path Operation Configuration](path-operation-configuration.md#tags){.internal-link target=_blank}. +Read more about tags in [Path Operation Configuration](path-operation-configuration.md#tags){target=_blank}. /// diff --git a/docs/en/docs/tutorial/middleware.md b/docs/en/docs/tutorial/middleware.md index 123ce3a683..0c2ff96108 100644 --- a/docs/en/docs/tutorial/middleware.md +++ b/docs/en/docs/tutorial/middleware.md @@ -15,7 +15,7 @@ A "middleware" is a function that works with every **request** before it is proc If you have dependencies with `yield`, the exit code will run *after* the middleware. -If there were any background tasks (covered in the [Background Tasks](background-tasks.md){.internal-link target=_blank} section, you will see it later), they will run *after* all the middleware. +If there were any background tasks (covered in the [Background Tasks](background-tasks.md){target=_blank} section, you will see it later), they will run *after* all the middleware. /// @@ -35,9 +35,9 @@ The middleware function receives: /// tip -Keep in mind that custom proprietary headers can be added using the `X-` prefix. +Keep in mind that custom proprietary headers can be added [using the `X-` prefix](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers){target=_blank}. -But if you have custom headers that you want a client in a browser to be able to see, you need to add them to your CORS configurations ([CORS (Cross-Origin Resource Sharing)](cors.md){.internal-link target=_blank}) using the parameter `expose_headers` documented in Starlette's CORS docs. +But if you have custom headers that you want a client in a browser to be able to see, you need to add them to your CORS configurations ([CORS (Cross-Origin Resource Sharing)](cors.md){target=_blank}) using the parameter `expose_headers` documented in [Starlette's CORS docs](https://www.starlette.dev/middleware/#corsmiddleware){target=_blank}. /// @@ -61,7 +61,7 @@ For example, you could add a custom header `X-Process-Time` containing the time /// tip -Here we use `time.perf_counter()` instead of `time.time()` because it can be more precise for these use cases. π€ +Here we use [`time.perf_counter()`](https://docs.python.org/3/library/time.html#time.perf_counter){target=_blank} instead of `time.time()` because it can be more precise for these use cases. π€ /// @@ -90,6 +90,6 @@ This stacking behavior ensures that middlewares are executed in a predictable an ## Other middlewares { #other-middlewares } -You can later read more about other middlewares in the [Advanced User Guide: Advanced Middleware](../advanced/middleware.md){.internal-link target=_blank}. +You can later read more about other middlewares in the [Advanced User Guide: Advanced Middleware](../advanced/middleware.md){target=_blank}. You will read about how to handle CORS with a middleware in the next section. diff --git a/docs/en/docs/tutorial/path-operation-configuration.md b/docs/en/docs/tutorial/path-operation-configuration.md index 2c545dc1a9..0b8c7d738a 100644 --- a/docs/en/docs/tutorial/path-operation-configuration.md +++ b/docs/en/docs/tutorial/path-operation-configuration.md @@ -58,7 +58,7 @@ You can add a `summary` and `description`: As descriptions tend to be long and cover multiple lines, you can declare the *path operation* description in the function docstring and **FastAPI** will read it from there. -You can write Markdown in the docstring, it will be interpreted and displayed correctly (taking into account docstring indentation). +You can write [Markdown](https://en.wikipedia.org/wiki/Markdown){target=_blank} in the docstring, it will be interpreted and displayed correctly (taking into account docstring indentation). {* ../../docs_src/path_operation_configuration/tutorial004_py310.py hl[17:25] *} diff --git a/docs/en/docs/tutorial/path-params-numeric-validations.md b/docs/en/docs/tutorial/path-params-numeric-validations.md index de63a51f59..878f911bbd 100644 --- a/docs/en/docs/tutorial/path-params-numeric-validations.md +++ b/docs/en/docs/tutorial/path-params-numeric-validations.md @@ -14,7 +14,7 @@ FastAPI added support for `Annotated` (and started recommending it) in version 0 If you have an older version, you would get errors when trying to use `Annotated`. -Make sure you [Upgrade the FastAPI version](../deployment/versions.md#upgrading-the-fastapi-versions){.internal-link target=_blank} to at least 0.95.1 before using `Annotated`. +Make sure you [Upgrade the FastAPI version](../deployment/versions.md#upgrading-the-fastapi-versions){target=_blank} to at least 0.95.1 before using `Annotated`. /// @@ -122,7 +122,7 @@ And the same for
license_infofields
Parameter Type Description namestrREQUIRED (if a license_infois set). The license name used for the API.identifierstrAn [SPDX](https://spdx.org/licenses/){target=_blank} license expression for the API. The identifierfield is mutually exclusive of theurlfield. Available since OpenAPI 3.1.0, FastAPI 0.99.0.urlstrA URL to the license used for the API. MUST be in the format of a URL. lt. ## Recap { #recap } -With `Query`, `Path` (and others you haven't seen yet) you can declare metadata and string validations in the same ways as with [Query Parameters and String Validations](query-params-str-validations.md){.internal-link target=_blank}. +With `Query`, `Path` (and others you haven't seen yet) you can declare metadata and string validations in the same ways as with [Query Parameters and String Validations](query-params-str-validations.md){target=_blank}. And you can also declare numeric validations: diff --git a/docs/en/docs/tutorial/path-params.md b/docs/en/docs/tutorial/path-params.md index 8adbbcfa1b..31293ace92 100644 --- a/docs/en/docs/tutorial/path-params.md +++ b/docs/en/docs/tutorial/path-params.md @@ -6,7 +6,7 @@ You can declare path "parameters" or "variables" with the same syntax used by Py The value of the path parameter `item_id` will be passed to your function as the argument `item_id`. -So, if you run this example and go to http://127.0.0.1:8000/items/foo, you will see a response of: +So, if you run this example and go to [http://127.0.0.1:8000/items/foo](http://127.0.0.1:8000/items/foo){target=_blank}, you will see a response of: ```JSON {"item_id":"foo"} @@ -28,7 +28,7 @@ This will give you editor support inside of your function, with error checks, co ## Data conversion { #data-conversion } -If you run this example and open your browser at http://127.0.0.1:8000/items/3, you will see a response of: +If you run this example and open your browser at [http://127.0.0.1:8000/items/3](http://127.0.0.1:8000/items/3){target=_blank}, you will see a response of: ```JSON {"item_id":3} @@ -44,7 +44,7 @@ So, with that type declaration, **FastAPI** gives you automatic request http://127.0.0.1:8000/items/foo, you will see a nice HTTP error of: +But if you go to the browser at [http://127.0.0.1:8000/items/foo](http://127.0.0.1:8000/items/foo){target=_blank}, you will see a nice HTTP error of: ```JSON { @@ -64,7 +64,7 @@ But if you go to the browser at http://127.0.0.1:8000/items/4.2 +The same error would appear if you provided a `float` instead of an `int`, as in: [http://127.0.0.1:8000/items/4.2](http://127.0.0.1:8000/items/4.2){target=_blank} /// check @@ -78,7 +78,7 @@ This is incredibly helpful while developing and debugging code that interacts wi ## Documentation { #documentation } -And when you open your browser at http://127.0.0.1:8000/docs, you will see an automatic, interactive, API documentation like: +And when you open your browser at [http://127.0.0.1:8000/docs](http://127.0.0.1:8000/docs){target=_blank}, you will see an automatic, interactive, API documentation like:@@ -92,9 +92,9 @@ Notice that the path parameter is declared to be an integer. ## Standards-based benefits, alternative documentation { #standards-based-benefits-alternative-documentation } -And because the generated schema is from the OpenAPI standard, there are many compatible tools. +And because the generated schema is from the [OpenAPI](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.1.0.md){target=_blank} standard, there are many compatible tools. -Because of this, **FastAPI** itself provides an alternative API documentation (using ReDoc), which you can access at http://127.0.0.1:8000/redoc: +Because of this, **FastAPI** itself provides an alternative API documentation (using ReDoc), which you can access at [http://127.0.0.1:8000/redoc](http://127.0.0.1:8000/redoc){target=_blank}:
@@ -102,7 +102,7 @@ The same way, there are many compatible tools. Including code generation tools f ## Pydantic { #pydantic } -All the data validation is performed under the hood by Pydantic, so you get all the benefits from it. And you know you are in good hands. +All the data validation is performed under the hood by [Pydantic](https://docs.pydantic.dev/){target=_blank}, so you get all the benefits from it. And you know you are in good hands. You can use the same type declarations with `str`, `float`, `bool` and many other complex data types. diff --git a/docs/en/docs/tutorial/query-params-str-validations.md b/docs/en/docs/tutorial/query-params-str-validations.md index 7ae94fb0a8..1aa7a17504 100644 --- a/docs/en/docs/tutorial/query-params-str-validations.md +++ b/docs/en/docs/tutorial/query-params-str-validations.md @@ -35,13 +35,13 @@ FastAPI added support for `Annotated` (and started recommending it) in version 0 If you have an older version, you would get errors when trying to use `Annotated`. -Make sure you [Upgrade the FastAPI version](../deployment/versions.md#upgrading-the-fastapi-versions){.internal-link target=_blank} to at least 0.95.1 before using `Annotated`. +Make sure you [Upgrade the FastAPI version](../deployment/versions.md#upgrading-the-fastapi-versions){target=_blank} to at least 0.95.1 before using `Annotated`. /// ## Use `Annotated` in the type for the `q` parameter { #use-annotated-in-the-type-for-the-q-parameter } -Remember I told you before that `Annotated` can be used to add metadata to your parameters in the [Python Types Intro](../python-types.md#type-hints-with-metadata-annotations){.internal-link target=_blank}? +Remember I told you before that `Annotated` can be used to add metadata to your parameters in the [Python Types Intro](../python-types.md#type-hints-with-metadata-annotations){target=_blank}? Now it's the time to use it with FastAPI. π @@ -158,7 +158,7 @@ You could **call** that same function in **other places** without FastAPI, and i When you don't use `Annotated` and instead use the **(old) default value style**, if you call that function without FastAPI in **other places**, you have to **remember** to pass the arguments to the function for it to work correctly, otherwise the values will be different from what you expect (e.g. `QueryInfo` or something similar instead of `str`). And your editor won't complain, and Python won't complain running that function, only when the operations inside error out. -Because `Annotated` can have more than one metadata annotation, you could now even use the same function with other tools, like Typer. π +Because `Annotated` can have more than one metadata annotation, you could now even use the same function with other tools, like [Typer](https://typer.tiangolo.com/){target=_blank}. π ## Add more validations { #add-more-validations } @@ -370,11 +370,11 @@ There could be cases where you need to do some **custom validation** that can't In those cases, you can use a **custom validator function** that is applied after the normal validation (e.g. after validating that the value is a `str`). -You can achieve that using Pydantic's `AfterValidator` inside of `Annotated`. +You can achieve that using [Pydantic's `AfterValidator`](https://docs.pydantic.dev/latest/concepts/validators/#field-after-validator){target=_blank} inside of `Annotated`. /// tip -Pydantic also has `BeforeValidator` and others. π€ +Pydantic also has [`BeforeValidator`](https://docs.pydantic.dev/latest/concepts/validators/#field-before-validator){target=_blank} and others. π€ /// diff --git a/docs/en/docs/tutorial/query-params.md b/docs/en/docs/tutorial/query-params.md index 9408168cf1..b78e634d92 100644 --- a/docs/en/docs/tutorial/query-params.md +++ b/docs/en/docs/tutorial/query-params.md @@ -183,6 +183,6 @@ In this case, there are 3 query parameters: /// tip -You could also use `Enum`s the same way as with [Path Parameters](path-params.md#predefined-values){.internal-link target=_blank}. +You could also use `Enum`s the same way as with [Path Parameters](path-params.md#predefined-values){target=_blank}. /// diff --git a/docs/en/docs/tutorial/request-files.md b/docs/en/docs/tutorial/request-files.md index 93c27df3fe..f386da3068 100644 --- a/docs/en/docs/tutorial/request-files.md +++ b/docs/en/docs/tutorial/request-files.md @@ -4,9 +4,9 @@ You can define files to be uploaded by the client using `File`. /// info -To receive uploaded files, first install `python-multipart`. +To receive uploaded files, first install [`python-multipart`](https://github.com/Kludex/python-multipart){target=_blank}. -Make sure you create a [virtual environment](../virtual-environments.md){.internal-link target=_blank}, activate it, and then install it, for example: +Make sure you create a [virtual environment](../virtual-environments.md){target=_blank}, activate it, and then install it, for example: ```console $ pip install python-multipart @@ -63,8 +63,8 @@ Using `UploadFile` has several advantages over `bytes`: * A file stored in memory up to a maximum size limit, and after passing this limit it will be stored in disk. * This means that it will work well for large files like images, videos, large binaries, etc. without consuming all the memory. * You can get metadata from the uploaded file. -* It has a file-like `async` interface. -* It exposes an actual Python `SpooledTemporaryFile` object that you can pass directly to other libraries that expect a file-like object. +* It has a [file-like](https://docs.python.org/3/glossary.html#term-file-like-object){target=_blank} `async` interface. +* It exposes an actual Python [`SpooledTemporaryFile`](https://docs.python.org/3/library/tempfile.html#tempfile.SpooledTemporaryFile){target=_blank} object that you can pass directly to other libraries that expect a file-like object. ### `UploadFile` { #uploadfile } @@ -72,7 +72,7 @@ Using `UploadFile` has several advantages over `bytes`: * `filename`: A `str` with the original file name that was uploaded (e.g. `myimage.jpg`). * `content_type`: A `str` with the content type (MIME type / media type) (e.g. `image/jpeg`). -* `file`: A `SpooledTemporaryFile` (a file-like object). This is the actual Python file object that you can pass directly to other functions or libraries that expect a "file-like" object. +* `file`: A [`SpooledTemporaryFile`](https://docs.python.org/3/library/tempfile.html#tempfile.SpooledTemporaryFile){target=_blank} (a [file-like](https://docs.python.org/3/glossary.html#term-file-like-object){target=_blank} object). This is the actual Python file object that you can pass directly to other functions or libraries that expect a "file-like" object. `UploadFile` has the following `async` methods. They all call the corresponding file methods underneath (using the internal `SpooledTemporaryFile`). @@ -121,7 +121,7 @@ Data from forms is normally encoded using the "media type" `application/x-www-fo But when the form includes files, it is encoded as `multipart/form-data`. If you use `File`, **FastAPI** will know it has to get the files from the correct part of the body. -If you want to read more about these encodings and form fields, head to the MDN web docs for
POST. +If you want to read more about these encodings and form fields, head to the MDN web docs forPOST. /// diff --git a/docs/en/docs/tutorial/request-form-models.md b/docs/en/docs/tutorial/request-form-models.md index 37e764c136..a3cda2f27b 100644 --- a/docs/en/docs/tutorial/request-form-models.md +++ b/docs/en/docs/tutorial/request-form-models.md @@ -4,9 +4,9 @@ You can use **Pydantic models** to declare **form fields** in FastAPI. /// info -To use forms, first install `python-multipart`. +To use forms, first install [`python-multipart`](https://github.com/Kludex/python-multipart){target=_blank}. -Make sure you create a [virtual environment](../virtual-environments.md){.internal-link target=_blank}, activate it, and then install it, for example: +Make sure you create a [virtual environment](../virtual-environments.md){target=_blank}, activate it, and then install it, for example: ```console $ pip install python-multipart diff --git a/docs/en/docs/tutorial/request-forms-and-files.md b/docs/en/docs/tutorial/request-forms-and-files.md index 75f30bd2a9..36f2d44c35 100644 --- a/docs/en/docs/tutorial/request-forms-and-files.md +++ b/docs/en/docs/tutorial/request-forms-and-files.md @@ -4,9 +4,9 @@ You can define files and form fields at the same time using `File` and `Form`. /// info -To receive uploaded files and/or form data, first install `python-multipart`. +To receive uploaded files and/or form data, first install [`python-multipart`](https://github.com/Kludex/python-multipart){target=_blank}. -Make sure you create a [virtual environment](../virtual-environments.md){.internal-link target=_blank}, activate it, and then install it, for example: +Make sure you create a [virtual environment](../virtual-environments.md){target=_blank}, activate it, and then install it, for example: ```console $ pip install python-multipart diff --git a/docs/en/docs/tutorial/request-forms.md b/docs/en/docs/tutorial/request-forms.md index 3f160504f6..20967db79c 100644 --- a/docs/en/docs/tutorial/request-forms.md +++ b/docs/en/docs/tutorial/request-forms.md @@ -4,9 +4,9 @@ When you need to receive form fields instead of JSON, you can use `Form`. /// info -To use forms, first install `python-multipart`. +To use forms, first install [`python-multipart`](https://github.com/Kludex/python-multipart){target=_blank}. -Make sure you create a [virtual environment](../virtual-environments.md){.internal-link target=_blank}, activate it, and then install it, for example: +Make sure you create a [virtual environment](../virtual-environments.md){target=_blank}, activate it, and then install it, for example: ```console $ pip install python-multipart @@ -56,7 +56,7 @@ Data from forms is normally encoded using the "media type" `application/x-www-fo But when the form includes files, it is encoded as `multipart/form-data`. You'll read about handling files in the next chapter. -If you want to read more about these encodings and form fields, head to the MDN web docs forPOST. +If you want to read more about these encodings and form fields, head to the MDN web docs forPOST. /// diff --git a/docs/en/docs/tutorial/response-model.md b/docs/en/docs/tutorial/response-model.md index c8312d92c6..922467f9ba 100644 --- a/docs/en/docs/tutorial/response-model.md +++ b/docs/en/docs/tutorial/response-model.md @@ -74,9 +74,9 @@ Here we are declaring a `UserIn` model, it will contain a plaintext password: /// info -To use `EmailStr`, first install `email-validator`. +To use `EmailStr`, first install [`email-validator`](https://github.com/JoshData/python-email-validator){target=_blank}. -Make sure you create a [virtual environment](../virtual-environments.md){.internal-link target=_blank}, activate it, and then install it, for example: +Make sure you create a [virtual environment](../virtual-environments.md){target=_blank}, activate it, and then install it, for example: ```console $ pip install email-validator @@ -182,7 +182,7 @@ There might be cases where you return something that is not a valid Pydantic fie ### Return a Response Directly { #return-a-response-directly } -The most common case would be [returning a Response directly as explained later in the advanced docs](../advanced/response-directly.md){.internal-link target=_blank}. +The most common case would be [returning a Response directly as explained later in the advanced docs](../advanced/response-directly.md){target=_blank}. {* ../../docs_src/response_model/tutorial003_02_py310.py hl[8,10:11] *} @@ -258,7 +258,7 @@ You can also use: * `response_model_exclude_defaults=True` * `response_model_exclude_none=True` -as described in the Pydantic docs for `exclude_defaults` and `exclude_none`. +as described in [the Pydantic docs](https://docs.pydantic.dev/1.10/usage/exporting_models/#modeldict){target=_blank} for `exclude_defaults` and `exclude_none`. /// diff --git a/docs/en/docs/tutorial/response-status-code.md b/docs/en/docs/tutorial/response-status-code.md index dcb35dff54..836c3b4d86 100644 --- a/docs/en/docs/tutorial/response-status-code.md +++ b/docs/en/docs/tutorial/response-status-code.md @@ -20,7 +20,7 @@ The `status_code` parameter receives a number with the HTTP status code. /// info -`status_code` can alternatively also receive an `IntEnum`, such as Python's `http.HTTPStatus`. +`status_code` can alternatively also receive an `IntEnum`, such as Python's [`http.HTTPStatus`](https://docs.python.org/3/library/http.html#http.HTTPStatus){target=_blank}. /// @@ -66,7 +66,7 @@ In short: /// tip -To know more about each status code and which code is for what, check the MDN documentation about HTTP status codes. +To know more about each status code and which code is for what, check the MDN documentation about HTTP status codes. /// @@ -98,4 +98,4 @@ You could also use `from starlette import status`. ## Changing the default { #changing-the-default } -Later, in the [Advanced User Guide](../advanced/response-change-status-code.md){.internal-link target=_blank}, you will see how to return a different status code than the default you are declaring here. +Later, in the [Advanced User Guide](../advanced/response-change-status-code.md){target=_blank}, you will see how to return a different status code than the default you are declaring here. diff --git a/docs/en/docs/tutorial/schema-extra-example.md b/docs/en/docs/tutorial/schema-extra-example.md index 432f58b1e3..6ef0fbf1cf 100644 --- a/docs/en/docs/tutorial/schema-extra-example.md +++ b/docs/en/docs/tutorial/schema-extra-example.md @@ -12,7 +12,7 @@ You can declare `examples` for a Pydantic model that will be added to the genera That extra info will be added as-is to the output **JSON Schema** for that model, and it will be used in the API docs. -You can use the attribute `model_config` that takes a `dict` as described in Pydantic's docs: Configuration. +You can use the attribute `model_config` that takes a `dict` as described in [Pydantic's docs: Configuration](https://docs.pydantic.dev/latest/api/config/){target=_blank}. You can set `"json_schema_extra"` with a `dict` containing any additional data you would like to show up in the generated JSON Schema, including `examples`. @@ -145,12 +145,12 @@ JSON Schema didn't have `examples`, so OpenAPI added its own `example` field to OpenAPI also added `example` and `examples` fields to other parts of the specification: -* `Parameter Object` (in the specification) that was used by FastAPI's: +* [`Parameter Object` (in the specification)](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#parameter-object){target=_blank} that was used by FastAPI's: * `Path()` * `Query()` * `Header()` * `Cookie()` -* `Request Body Object`, in the field `content`, on the `Media Type Object` (in the specification) that was used by FastAPI's: +* [`Request Body Object`, in the field `content`, on the `Media Type Object` (in the specification)](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#media-type-object){target=_blank} that was used by FastAPI's: * `Body()` * `File()` * `Form()` @@ -163,7 +163,7 @@ This old OpenAPI-specific `examples` parameter is now `openapi_examples` since F ### JSON Schema's `examples` field { #json-schemas-examples-field } -But then JSON Schema added an `examples` field to a new version of the specification. +But then JSON Schema added an [`examples`](https://json-schema.org/draft/2019-09/json-schema-validation.html#rfc.section.9.5){target=_blank} field to a new version of the specification. And then the new OpenAPI 3.1.0 was based on the latest version (JSON Schema 2020-12) that included this new field `examples`. diff --git a/docs/en/docs/tutorial/security/first-steps.md b/docs/en/docs/tutorial/security/first-steps.md index 4fbb5e0903..c9b7eb304c 100644 --- a/docs/en/docs/tutorial/security/first-steps.md +++ b/docs/en/docs/tutorial/security/first-steps.md @@ -26,11 +26,11 @@ Copy the example in a file `main.py`: /// info -The `python-multipart` package is automatically installed with **FastAPI** when you run the `pip install "fastapi[standard]"` command. +The [`python-multipart`](https://github.com/Kludex/python-multipart){target=_blank} package is automatically installed with **FastAPI** when you run the `pip install "fastapi[standard]"` command. However, if you use the `pip install fastapi` command, the `python-multipart` package is not included by default. -To install it manually, make sure you create a [virtual environment](../../virtual-environments.md){.internal-link target=_blank}, activate it, and then install it with: +To install it manually, make sure you create a [virtual environment](../../virtual-environments.md){target=_blank}, activate it, and then install it with: ```console $ pip install python-multipart @@ -54,7 +54,7 @@ $ fastapi dev main.py ## Check it { #check-it } -Go to the interactive docs at: http://127.0.0.1:8000/docs. +Go to the interactive docs at: [http://127.0.0.1:8000/docs](http://127.0.0.1:8000/docs){target=_blank}. You will see something like this: @@ -140,7 +140,7 @@ Here `tokenUrl="token"` refers to a relative URL `token` that we haven't created Because we are using a relative URL, if your API was located at `https://example.com/`, then it would refer to `https://example.com/token`. But if your API was located at `https://example.com/api/v1/`, then it would refer to `https://example.com/api/v1/token`. -Using a relative URL is important to make sure your application keeps working even in an advanced use case like [Behind a Proxy](../../advanced/behind-a-proxy.md){.internal-link target=_blank}. +Using a relative URL is important to make sure your application keeps working even in an advanced use case like [Behind a Proxy](../../advanced/behind-a-proxy.md){target=_blank}. /// diff --git a/docs/en/docs/tutorial/security/oauth2-jwt.md b/docs/en/docs/tutorial/security/oauth2-jwt.md index 26894ab287..175ed64eef 100644 --- a/docs/en/docs/tutorial/security/oauth2-jwt.md +++ b/docs/en/docs/tutorial/security/oauth2-jwt.md @@ -24,13 +24,13 @@ That way, you can create a token with an expiration of, let's say, 1 week. And t After a week, the token will be expired and the user will not be authorized and will have to sign in again to get a new token. And if the user (or a third party) tried to modify the token to change the expiration, you would be able to discover it, because the signatures would not match. -If you want to play with JWT tokens and see how they work, check https://jwt.io. +If you want to play with JWT tokens and see how they work, check [https://jwt.io](https://jwt.io/){target=_blank}. ## Install `PyJWT` { #install-pyjwt } We need to install `PyJWT` to generate and verify the JWT tokens in Python. -Make sure you create a [virtual environment](../../virtual-environments.md){.internal-link target=_blank}, activate it, and then install `pyjwt`: +Make sure you create a [virtual environment](../../virtual-environments.md){target=_blank}, activate it, and then install `pyjwt`:@@ -46,7 +46,7 @@ $ pip install pyjwt If you are planning to use digital signature algorithms like RSA or ECDSA, you should install the cryptography library dependency `pyjwt[crypto]`. -You can read more about it in the PyJWT Installation docs. +You can read more about it in the [PyJWT Installation docs](https://pyjwt.readthedocs.io/en/latest/installation.html){target=_blank}. /// @@ -72,7 +72,7 @@ It supports many secure hashing algorithms and utilities to work with them. The recommended algorithm is "Argon2". -Make sure you create a [virtual environment](../../virtual-environments.md){.internal-link target=_blank}, activate it, and then install pwdlib with Argon2: +Make sure you create a [virtual environment](../../virtual-environments.md){target=_blank}, activate it, and then install pwdlib with Argon2:@@ -200,7 +200,7 @@ The important thing to keep in mind is that the `sub` key should have a unique i ## Check it { #check-it } -Run the server and go to the docs: http://127.0.0.1:8000/docs. +Run the server and go to the docs: [http://127.0.0.1:8000/docs](http://127.0.0.1:8000/docs){target=_blank}. You'll see the user interface like: diff --git a/docs/en/docs/tutorial/security/simple-oauth2.md b/docs/en/docs/tutorial/security/simple-oauth2.md index 296e0e2950..1079660bf3 100644 --- a/docs/en/docs/tutorial/security/simple-oauth2.md +++ b/docs/en/docs/tutorial/security/simple-oauth2.md @@ -146,7 +146,7 @@ UserInDB( /// info -For a more complete explanation of `**user_dict` check back in [the documentation for **Extra Models**](../extra-models.md#about-user-in-dict){.internal-link target=_blank}. +For a more complete explanation of `**user_dict` check back in [the documentation for **Extra Models**](../extra-models.md#about-user-in-dict){target=_blank}. /// @@ -216,7 +216,7 @@ That's the benefit of standards... ## See it in action { #see-it-in-action } -Open the interactive docs: http://127.0.0.1:8000/docs. +Open the interactive docs: [http://127.0.0.1:8000/docs](http://127.0.0.1:8000/docs){target=_blank}. ### Authenticate { #authenticate } diff --git a/docs/en/docs/tutorial/server-sent-events.md b/docs/en/docs/tutorial/server-sent-events.md index 0a4bed2660..059298eda4 100644 --- a/docs/en/docs/tutorial/server-sent-events.md +++ b/docs/en/docs/tutorial/server-sent-events.md @@ -2,7 +2,7 @@ You can stream data to the client using **Server-Sent Events** (SSE). -This is similar to [Stream JSON Lines](stream-json-lines.md){.internal-link target=_blank}, but uses the `text/event-stream` format, which is supported natively by browsers with the `EventSource` API. +This is similar to [Stream JSON Lines](stream-json-lines.md){target=_blank}, but uses the `text/event-stream` format, which is supported natively by browsers with the [`EventSource` API](https://developer.mozilla.org/en-US/docs/Web/API/EventSource){target=_blank}. /// info @@ -29,7 +29,7 @@ SSE is commonly used for AI chat streaming, live notifications, logs and observa /// tip -If you want to stream binary data, for example video or audio, check the advanced guide: [Stream Data](../advanced/stream-data.md){.internal-link target=_blank}. +If you want to stream binary data, for example video or audio, check the advanced guide: [Stream Data](../advanced/stream-data.md){target=_blank}. /// @@ -65,7 +65,7 @@ As in this case the function is not async, the right return type would be `Itera ### No Return Type { #no-return-type } -You can also omit the return type. FastAPI will use the [`jsonable_encoder`](./encoder.md){.internal-link target=_blank} to convert the data and send it. +You can also omit the return type. FastAPI will use the [`jsonable_encoder`](./encoder.md){target=_blank} to convert the data and send it. {* ../../docs_src/server_sent_events/tutorial001_py310.py ln[34:37] hl[35] *} @@ -105,7 +105,7 @@ You can read it as a header parameter and use it to resume the stream from where SSE works with **any HTTP method**, not just `GET`. -This is useful for protocols like MCP that stream SSE over `POST`: +This is useful for protocols like [MCP](https://modelcontextprotocol.io){target=_blank} that stream SSE over `POST`: {* ../../docs_src/server_sent_events/tutorial005_py310.py hl[14] *} @@ -113,7 +113,7 @@ This is useful for protocols like HTML specification: Server-Sent Events. +* Send a **"keep alive" `ping` comment** every 15 seconds when there hasn't been any message, to prevent some proxies from closing the connection, as suggested in the [HTML specification: Server-Sent Events](https://html.spec.whatwg.org/multipage/server-sent-events.html#authoring-notes){target=_blank}. * Set the `Cache-Control: no-cache` header to **prevent caching** of the stream. * Set a special header `X-Accel-Buffering: no` to **prevent buffering** in some proxies like Nginx. diff --git a/docs/en/docs/tutorial/sql-databases.md b/docs/en/docs/tutorial/sql-databases.md index b42e9ba2f2..d5b9b51d3d 100644 --- a/docs/en/docs/tutorial/sql-databases.md +++ b/docs/en/docs/tutorial/sql-databases.md @@ -2,9 +2,9 @@ **FastAPI** doesn't require you to use a SQL (relational) database. But you can use **any database** that you want. -Here we'll see an example using SQLModel. +Here we'll see an example using [SQLModel](https://sqlmodel.tiangolo.com/){target=_blank}. -**SQLModel** is built on top of SQLAlchemy and Pydantic. It was made by the same author of **FastAPI** to be the perfect match for FastAPI applications that need to use **SQL databases**. +**SQLModel** is built on top of [SQLAlchemy](https://www.sqlalchemy.org/){target=_blank} and Pydantic. It was made by the same author of **FastAPI** to be the perfect match for FastAPI applications that need to use **SQL databases**. /// tip @@ -26,15 +26,15 @@ Later, for your production application, you might want to use a database server /// tip -There is an official project generator with **FastAPI** and **PostgreSQL** including a frontend and more tools: https://github.com/fastapi/full-stack-fastapi-template +There is an official project generator with **FastAPI** and **PostgreSQL** including a frontend and more tools: [https://github.com/fastapi/full-stack-fastapi-template](https://github.com/fastapi/full-stack-fastapi-template){target=_blank} /// -This is a very simple and short tutorial, if you want to learn about databases in general, about SQL, or more advanced features, go to the SQLModel docs. +This is a very simple and short tutorial, if you want to learn about databases in general, about SQL, or more advanced features, go to the [SQLModel docs](https://sqlmodel.tiangolo.com/){target=_blank}. ## Install `SQLModel` { #install-sqlmodel } -First, make sure you create your [virtual environment](../virtual-environments.md){.internal-link target=_blank}, activate it, and then install `sqlmodel`: +First, make sure you create your [virtual environment](../virtual-environments.md){target=_blank}, activate it, and then install `sqlmodel`:@@ -65,7 +65,7 @@ There are a few differences: * `Field(primary_key=True)` tells SQLModel that the `id` is the **primary key** in the SQL database (you can learn more about SQL primary keys in the SQLModel docs). - **Note:** We use `int | None` for the primary key field so that in Python code we can *create an object without an `id`* (`id=None`), assuming the database will *generate it when saving*. SQLModel understands that the database will provide the `id` and *defines the column as a non-null `INTEGER`* in the database schema. See SQLModel docs on primary keys for details. + **Note:** We use `int | None` for the primary key field so that in Python code we can *create an object without an `id`* (`id=None`), assuming the database will *generate it when saving*. SQLModel understands that the database will provide the `id` and *defines the column as a non-null `INTEGER`* in the database schema. See [SQLModel docs on primary keys](https://sqlmodel.tiangolo.com/tutorial/create-db-and-table/#primary-key-id){target=_blank} for details. * `Field(index=True)` tells SQLModel that it should create a **SQL index** for this column, that would allow faster lookups in the database when reading data filtered by this column. @@ -111,7 +111,7 @@ For production you would probably use a migration script that runs before you st /// tip -SQLModel will have migration utilities wrapping Alembic, but for now, you can use Alembic directly. +SQLModel will have migration utilities wrapping Alembic, but for now, you can use [Alembic](https://alembic.sqlalchemy.org/en/latest/){target=_blank} directly. /// @@ -352,6 +352,6 @@ If you go to the `/docs` API UI, you will see that it is now updated, and it won ## Recap { #recap } -You can use **SQLModel** to interact with a SQL database and simplify the code with *data models* and *table models*. +You can use [**SQLModel**](https://sqlmodel.tiangolo.com/){target=_blank} to interact with a SQL database and simplify the code with *data models* and *table models*. -You can learn a lot more at the **SQLModel** docs, there's a longer mini tutorial on using SQLModel with **FastAPI**. π +You can learn a lot more at the **SQLModel** docs, there's a longer mini [tutorial on using SQLModel with **FastAPI**](https://sqlmodel.tiangolo.com/tutorial/fastapi/){target=_blank}. π diff --git a/docs/en/docs/tutorial/static-files.md b/docs/en/docs/tutorial/static-files.md index 8fd65a0d7f..477ac5a849 100644 --- a/docs/en/docs/tutorial/static-files.md +++ b/docs/en/docs/tutorial/static-files.md @@ -23,7 +23,7 @@ You could also use `from starlette.staticfiles import StaticFiles`. This is different from using an `APIRouter` as a mounted application is completely independent. The OpenAPI and docs from your main application won't include anything from the mounted application, etc. -You can read more about this in the [Advanced User Guide](../advanced/index.md){.internal-link target=_blank}. +You can read more about this in the [Advanced User Guide](../advanced/index.md){target=_blank}. ## Details { #details } @@ -37,4 +37,4 @@ All these parameters can be different than "`static`", adjust them with the need ## More info { #more-info } -For more details and options check Starlette's docs about Static Files. +For more details and options check [Starlette's docs about Static Files](https://www.starlette.dev/staticfiles/){target=_blank}. diff --git a/docs/en/docs/tutorial/stream-json-lines.md b/docs/en/docs/tutorial/stream-json-lines.md index 2ee3aacc6c..0f3b63d98d 100644 --- a/docs/en/docs/tutorial/stream-json-lines.md +++ b/docs/en/docs/tutorial/stream-json-lines.md @@ -102,10 +102,10 @@ As in this case the function is not async, the right return type would be `Itera ### No Return Type { #no-return-type } -You can also omit the return type. FastAPI will then use the [`jsonable_encoder`](./encoder.md){.internal-link target=_blank} to convert the data to something that can be serialized to JSON and then send it as JSON Lines. +You can also omit the return type. FastAPI will then use the [`jsonable_encoder`](./encoder.md){target=_blank} to convert the data to something that can be serialized to JSON and then send it as JSON Lines. {* ../../docs_src/stream_json_lines/tutorial001_py310.py ln[33:36] hl[34] *} ## Server-Sent Events (SSE) { #server-sent-events-sse } -FastAPI also has first-class support for Server-Sent Events (SSE), which are quite similar but with a couple of extra details. You can learn about them in the next chapter: [Server-Sent Events (SSE)](server-sent-events.md){.internal-link target=_blank}. π€ +FastAPI also has first-class support for Server-Sent Events (SSE), which are quite similar but with a couple of extra details. You can learn about them in the next chapter: [Server-Sent Events (SSE)](server-sent-events.md){target=_blank}. π€ diff --git a/docs/en/docs/tutorial/testing.md b/docs/en/docs/tutorial/testing.md index 14c1b35668..4b93b99774 100644 --- a/docs/en/docs/tutorial/testing.md +++ b/docs/en/docs/tutorial/testing.md @@ -1,18 +1,18 @@ # Testing { #testing } -Thanks to Starlette, testing **FastAPI** applications is easy and enjoyable. +Thanks to [Starlette](https://www.starlette.dev/testclient/){target=_blank}, testing **FastAPI** applications is easy and enjoyable. -It is based on HTTPX, which in turn is designed based on Requests, so it's very familiar and intuitive. +It is based on [HTTPX](https://www.python-httpx.org){target=_blank}, which in turn is designed based on Requests, so it's very familiar and intuitive. -With it, you can use pytest directly with **FastAPI**. +With it, you can use [pytest](https://docs.pytest.org/){target=_blank} directly with **FastAPI**. ## Using `TestClient` { #using-testclient } /// info -To use `TestClient`, first install `httpx`. +To use `TestClient`, first install [`httpx`](https://www.python-httpx.org){target=_blank}. -Make sure you create a [virtual environment](../virtual-environments.md){.internal-link target=_blank}, activate it, and then install it, for example: +Make sure you create a [virtual environment](../virtual-environments.md){target=_blank}, activate it, and then install it, for example: ```console $ pip install httpx @@ -52,7 +52,7 @@ You could also use `from starlette.testclient import TestClient`. /// tip -If you want to call `async` functions in your tests apart from sending requests to your FastAPI application (e.g. asynchronous database functions), have a look at the [Async Tests](../advanced/async-tests.md){.internal-link target=_blank} in the advanced tutorial. +If you want to call `async` functions in your tests apart from sending requests to your FastAPI application (e.g. asynchronous database functions), have a look at the [Async Tests](../advanced/async-tests.md){target=_blank} in the advanced tutorial. /// @@ -64,7 +64,7 @@ And your **FastAPI** application might also be composed of several files/modules ### **FastAPI** app file { #fastapi-app-file } -Let's say you have a file structure as described in [Bigger Applications](bigger-applications.md){.internal-link target=_blank}: +Let's say you have a file structure as described in [Bigger Applications](bigger-applications.md){target=_blank}: ``` . @@ -142,13 +142,13 @@ 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 `httpx` or the `TestClient`) check the HTTPX documentation. +For more information about how to pass data to the backend (using `httpx` or the `TestClient`) check the [HTTPX documentation](https://www.python-httpx.org){target=_blank}. /// info Note that the `TestClient` receives data that can be converted to JSON, not Pydantic models. -If you have a Pydantic model in your test and you want to send its data to the application during testing, you can use the `jsonable_encoder` described in [JSON Compatible Encoder](encoder.md){.internal-link target=_blank}. +If you have a Pydantic model in your test and you want to send its data to the application during testing, you can use the `jsonable_encoder` described in [JSON Compatible Encoder](encoder.md){target=_blank}. /// @@ -156,7 +156,7 @@ If you have a Pydantic model in your test and you want to send its data to the a After that, you just need to install `pytest`. -Make sure you create a [virtual environment](../virtual-environments.md){.internal-link target=_blank}, activate it, and then install it, for example: +Make sure you create a [virtual environment](../virtual-environments.md){target=_blank}, activate it, and then install it, for example:diff --git a/docs/en/docs/virtual-environments.md b/docs/en/docs/virtual-environments.md index 615d7949f9..1c6307151b 100644 --- a/docs/en/docs/virtual-environments.md +++ b/docs/en/docs/virtual-environments.md @@ -22,7 +22,7 @@ A **virtual environment** is a directory with some files in it. This page will teach you how to use **virtual environments** and how they work. -If you are ready to adopt a **tool that manages everything** for you (including installing Python), try uv. +If you are ready to adopt a **tool that manages everything** for you (including installing Python), try [uv](https://github.com/astral-sh/uv){target=_blank}. /// @@ -86,7 +86,7 @@ $ python -m venv .venv //// tab | `uv` -If you have `uv` installed, you can use it to create a virtual environment. +If you have [`uv`](https://github.com/astral-sh/uv){target=_blank} installed, you can use it to create a virtual environment.@@ -150,7 +150,7 @@ $ .venv\Scripts\Activate.ps1 //// tab | Windows Bash -Or if you use Bash for Windows (e.g. Git Bash): +Or if you use Bash for Windows (e.g. [Git Bash](https://gitforwindows.org/){target=_blank}):@@ -216,7 +216,7 @@ If it shows the `python` binary at `.venv\Scripts\python`, inside of your projec /// tip -If you use `uv` you would use it to install things instead of `pip`, so you don't need to upgrade `pip`. π +If you use [`uv`](https://github.com/astral-sh/uv){target=_blank} you would use it to install things instead of `pip`, so you don't need to upgrade `pip`. π /// @@ -268,7 +268,7 @@ If you are using **Git** (you should), add a `.gitignore` file to exclude everyt /// tip -If you used `uv` to create the virtual environment, it already did this for you, you can skip this step. π +If you used [`uv`](https://github.com/astral-sh/uv){target=_blank} to create the virtual environment, it already did this for you, you can skip this step. π /// @@ -340,7 +340,7 @@ $ pip install "fastapi[standard]" //// tab | `uv` -If you have `uv`: +If you have [`uv`](https://github.com/astral-sh/uv){target=_blank}:@@ -372,7 +372,7 @@ $ pip install -r requirements.txt //// tab | `uv` -If you have `uv`: +If you have [`uv`](https://github.com/astral-sh/uv){target=_blank}:@@ -416,8 +416,8 @@ You would probably use an editor, make sure you configure it to use the same vir For example: -* VS Code -* PyCharm +* [VS Code](https://code.visualstudio.com/docs/python/environments#_select-and-activate-an-environment){target=_blank} +* [PyCharm](https://www.jetbrains.com/help/pycharm/creating-virtual-environment.html){target=_blank} /// tip @@ -455,7 +455,7 @@ Continue reading. ππ€ ## Why Virtual Environments { #why-virtual-environments } -To work with FastAPI you need to install Python. +To work with FastAPI you need to install [Python](https://www.python.org/){target=_blank}. After that, you would need to **install** FastAPI and any other **packages** you want to use. @@ -564,7 +564,7 @@ $ pip install "fastapi[standard]"-That will download a compressed file with the FastAPI code, normally from PyPI. +That will download a compressed file with the FastAPI code, normally from [PyPI](https://pypi.org/project/fastapi/){target=_blank}. It will also **download** files for other packages that FastAPI depends on. @@ -627,7 +627,7 @@ $ .venv\Scripts\Activate.ps1 //// tab | Windows Bash -Or if you use Bash for Windows (e.g. Git Bash): +Or if you use Bash for Windows (e.g. [Git Bash](https://gitforwindows.org/){target=_blank}):@@ -639,13 +639,13 @@ $ source .venv/Scripts/activate //// -That command will create or modify some [environment variables](environment-variables.md){.internal-link target=_blank} that will be available for the next commands. +That command will create or modify some [environment variables](environment-variables.md){target=_blank} that will be available for the next commands. One of those variables is the `PATH` variable. /// tip -You can learn more about the `PATH` environment variable in the [Environment Variables](environment-variables.md#path-environment-variable){.internal-link target=_blank} section. +You can learn more about the `PATH` environment variable in the [Environment Variables](environment-variables.md#path-environment-variable){target=_blank} section. /// @@ -846,7 +846,7 @@ This is a simple guide to get you started and teach you how everything works **u There are many **alternatives** to managing virtual environments, package dependencies (requirements), projects. -Once you are ready and want to use a tool to **manage the entire project**, packages dependencies, virtual environments, etc. I would suggest you try uv. +Once you are ready and want to use a tool to **manage the entire project**, packages dependencies, virtual environments, etc. I would suggest you try [uv](https://github.com/astral-sh/uv){target=_blank}. `uv` can do a lot of things, it can: