Registry / web-framework / fastapi-offline

fastapi-offline

JSON →
library1.7.6pypypi✓ verified 86d ago

fastapi-offline is a Python library that enables FastAPI applications to serve their interactive documentation (Swagger UI and Redoc) without relying on external Content Delivery Networks (CDNs). It bundles the necessary static assets locally, making it suitable for environments with restricted internet access or for improved reliability. The library is actively maintained, with frequent releases (currently v1.7.6) to vendor new dependencies and ensure compatibility with the latest Python and FastAPI versions.

pip install fastapi-offline
INSTALL
IMPORT
SIG · FASTAPI-OFFLINE
F
fastapi-offline
web-frameworkpythonv1.7.6
Install
3.8s avg
Import
1224ms
Disk
32MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v1.7.6 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.920 runs
installs and imports cleanly · install 0.0s · import 1.267s · 34.5MB
glibc
py 3.103.920 runs
installs and imports cleanly · install 3.8s · import 1.181s · 34MB
32MB installed
● package 32MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

FastAPIOffline
from fastapi_offline import FastAPIOffline
from fastapi import FastAPI
When using `fastapi-offline`, you should instantiate `FastAPIOffline` instead of `FastAPI` to enable offline documentation features.

This quickstart demonstrates how to create a basic FastAPI application using `FastAPIOffline`. Simply import `FastAPIOffline` and instantiate it instead of `FastAPI`. The interactive documentation (Swagger UI and ReDoc) will then be served from local assets, making them available offline. Any parameters passed to `FastAPIOffline()` (except `docs_url`, `redoc_url`, `favicon_url`, and `static_url`) are forwarded to the underlying `FastAPI` instance.

from fastapi_offline import FastAPIOffline import uvicorn app = FastAPIOffline( title="My Offline API", description="A simple API with offline docs" ) @app.get("/") async def read_root(): return {"message": "Hello Offline World!"} @app.get("/items/{item_id}") async def read_item(item_id: int): return {"item_id": item_id} # To run this app, save it as main.py and execute: uvicorn main:app --reload # Then open http://127.0.0.1:8000/docs or http://127.0.0.1:8000/redoc in your browser.
Debug
Known issues
breakingOlder Python versions are no longer supported or tested. Releases starting from v1.7.0 and v1.7.4 explicitly stopped testing on EOL Python versions (e.g., 3.7 and 3.9).
fix
Ensure your project uses Python 3.8 or newer. Upgrade your Python environment to a currently supported version.
affects: <1.7.0 (for Python 3.7), <1.7.4 (for Python 3.9)
gotchaThe `FastAPIOffline` constructor handles `docs_url`, `redoc_url`, `favicon_url`, and `static_url` parameters differently than a standard `FastAPI` app. Attempting to set these directly on the underlying `FastAPI` instance or expecting default FastAPI behavior for these specific URLs might lead to unexpected results.
fix
Customize `docs_url`, `redoc_url`, `favicon_url`, and `static_url` directly through the `FastAPIOffline` constructor. Other `FastAPI` parameters are passed through as expected.
affects: All versions
gotchaCompatibility issues may arise if `fastapi-offline` is significantly outdated compared to your `fastapi` version. `fastapi-offline`'s releases often include updates to the bundled Swagger UI and Redoc assets to track changes in FastAPI's behavior and dependencies.
fix
Always try to keep `fastapi-offline` updated to a version compatible with your `fastapi` installation. Check the release notes of `fastapi-offline` for any specific FastAPI version tracking information.
affects: All versions
Errors
Common errors & fixes
Documentation UI (Swagger/Redoc) not loading or showing old content in browser.
The `fastapi-offline` version is too old for the `fastapi` version, leading to incompatible bundled assets, or a custom `static_url` is misconfigured.
fix
Update `fastapi-offline` to the latest version (`pip install --upgrade fastapi-offline`). If you use a custom `static_url`, ensure it's correctly configured to point to the `fastapi-offline`'s served static files (default is `/static-offline-docs`).
ModuleNotFoundError: No module named 'fastapi_offline'
The `fastapi-offline` package is not installed in your current Python environment.
fix
Install the package using pip: `pip install fastapi-offline`.
AttributeError: 'FastAPI' object has no attribute 'get_swagger_ui_html' (or similar internal doc-related FastAPI errors).
This error often occurs when `fastapi-offline` is intended to manage the documentation routes, but internal FastAPI functions are being called directly or implicitly in a way that conflicts with `fastapi-offline`'s approach, possibly due to a version mismatch.
fix
Ensure you are consistently instantiating `FastAPIOffline` and not directly manipulating FastAPI's internal documentation rendering. Check that both `fastapi-offline` and `fastapi` are reasonably up-to-date and compatible versions.
Upgrade
Version history
1.7.6latest on PyPI · released Jan 15, 2026
Audit
Dependencies
fastapirequiredCore framework that fastapi-offline extends to provide offline documentation. While not a direct runtime dependency of the package itself, it's the fundamental framework this library is designed to work with.
uvicornoptionalASGI server commonly used to run FastAPI applications.
Agent activity
20 hits · last 30 days
node
20
Resources
fastapi-offline — pip install fastapi-offline · libregistry