FastAPI Standalone Docs
Host FastAPI Swagger UI and ReDoc without any third party CDNs. Handy if you want to be able to use the docs offline or want to avoid loading content from 3rd party CDNs due to privacy reasons.
This library was heavily inspired by fastapi-offline-swagger-ui, but we wanted a way to take it into use with less boilerplate code and also have it hosted on PyPI.
Installation
The package is available on PyPI:
pip install fastapi-standalone-docs
Usage
Import StandaloneDocs and pass in the FastAPI application to it:
from fastapi import FastAPI
from fastapi_standalone_docs import StandaloneDocs
app = FastAPI()
StandaloneDocs(app=app)
The static files will by default be served from subpaths of the docs_url and
redoc_url as you've specified in your FastAPI app. The library doesn't make any
assumption on any particular path being reserved for the library. And if you disable
either of the two UIs, the corresponding files won't either be served unnecessarily.
This example would move the Swagger UI and the static files needed for it to the path
/swagger and disable the ReDoc interface and the static files needed by it:
from fastapi import FastAPI
from fastapi_standalone_docs import StandaloneDocs
app = FastAPI(docs_url="/swagger", redoc_url=None)
StandaloneDocs(app=app)
By default, the library will use the FastAPI favicons, and they're served from
{docs_url}/fastapi/favicon.png and {redoc_url}/fastapi/favicon.png. You can use your
own favicons like this, which will also disable the FastAPI icons:
from fastapi import FastAPI
from fastapi_standalone_docs import StandaloneDocs
app = FastAPI()
StandaloneDocs(
app=app,
redoc_favicon_url="/favicon.png",
swagger_favicon_url="/favicon.png",
)
To make the docs truly stand alone the Google Fonts are by default disabled (they are
used in the ReDoc interface). If you want to enable them just set
with_google_fonts=True, like this:
from fastapi import FastAPI
from fastapi_standalone_docs import StandaloneDocs
app = FastAPI()
StandaloneDocs(
app=app,
with_google_fonts=True,
)
Disclaimer
Note! If you create multiple FastAPI apps in the same runtime (quite unlikely
use-case), for example by mounting one app inside another, using StandaloneDocs on one
of them will affect the other ones as well, as the library patches two of the shared
functions (get_swagger_ui_html and get_redoc_html). Thus, the library should not be
used in such a setup unless all the apps will use StandaloneDocs with the same settings
and the same docs_url, redoc_url and openapi_url on the FastAPI app itself. If any
of those differ, only the app that called StandaloneDocs last will serve its docs
correctly.
Development
PRs are welcome!
This project is using uv, so please ensure you've installed it. To set up the project run:
uv sync
uv run pre-commit install
Running tests locally (pre-commit hooks, mypy, pytest and a dependency audit):
uv run invoke test
Updating the static files from the CDNs:
uv run update-fastapi-standalone-docs
If you want to test using it locally in some other project, in that project run this (make sure to adjust the path to the local repo):
uv add --editable ../fastapi-standalone-docs
License
The code of this library itself is released under the MIT license. Please however note that this library also contains parts of ReDoc, which is licensed under the MIT license, Swagger UI, which is licensed under the Apache 2.0 License, as well as parts of FastAPI (the favicon), which is licensed under the MIT license.
Metadata
Release files for fastapi-standalone-docs 0.3.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| fastapi_standalone_docs-0.3.0.tar.gz | 814.5 kB | With provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| fastapi_standalone_docs-0.3.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 1.6 MB
Release files / fastapi_standalone_docs-0.3.0.tar.gz
| Download URL | fastapi_standalone_docs-0.3.0.tar.gz |
|---|---|
| Size | 814.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
01d331922cfe315cf6f0b8693299f451cc20da4b57a3e0658e3c706ad3b5ee8e
|
|
BLAKE2b-256 checksum How to use checksums |
2ffbc0cea3f1a0d9e67ad826bb39756c5dcb73193dce48e80107513cbf1438a5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 16, 2026.
Transparency logRelease files / fastapi_standalone_docs-0.3.0-py3-none-any.whl
| Download URL | fastapi_standalone_docs-0.3.0-py3-none-any.whl |
|---|---|
| Size | 814.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
2cd0462698c92105655fb70b242f95cb32afe7e20bb2f6b9cc2b65fa985ffe7f
|
|
BLAKE2b-256 checksum How to use checksums |
57d2b6a95d33dfb0ec61bb740c7b2b1590a90db5fb65a817c1d5671f76743aad
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 16, 2026.
Transparency logSecurity for fastapi-standalone-docs 0.3.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
All 2 files in this release have been uploaded with provenance metadata.
Attestation for fastapi_standalone_docs-0.3.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 16, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.