Registry / web-framework / scalar-fastapi

scalar-fastapi

JSON →
library1.9.0pypypi✓ verified 30d ago

Scalar FastAPI is a Python plugin that enhances the default FastAPI documentation experience by rendering a beautiful, interactive API reference based on the OpenAPI/Swagger specification. It provides a modern, responsive UI and a developer-first experience, offering extensive customization options for branding and layout. The library is actively maintained, with frequent updates to its underlying JavaScript components reflected in new Python wrapper releases.

pip install scalar-fastapi uvicorn
INSTALL
IMPORT
SIG · SCALAR-FASTAPI
S
scalar-fastapi
web-frameworkpythonv1.9.0
Install
4.1s avg
Import
1314ms
Disk
32MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.9–3.13
musl
3.9–3.13
Install & Compatibility
Where this runs
tested against v1.9.0 · 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.10–3.95 runs
installs and imports cleanly · install 0.0s · import 1.362s · 33.9MB
glibc
py 3.10–3.95 runs
installs and imports cleanly · install 4.1s · import 1.266s · 33MB
32MB installed
● package 32MB
Code
Verified usage

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

get_scalar_api_reference
✓ from scalar_fastapi import get_scalar_api_reference
OpenAPISource
✓ from scalar_fastapi import get_scalar_api_reference, OpenAPISource
Used for providing multiple OpenAPI sources to the documentation.
Layout
✓ from scalar_fastapi import Layout
Provides options for customizing the documentation layout.
Theme
✓ from scalar_fastapi import Theme
Provides options for customizing the documentation theme.

This example sets up a basic FastAPI application and integrates Scalar documentation at the `/scalar` endpoint. It uses `app.openapi_url` to automatically load the API's schema. Run with `uvicorn main:app --reload` and navigate to `/scalar`.

from fastapi import FastAPI from scalar_fastapi import get_scalar_api_reference import uvicorn app = FastAPI( title="My Awesome API", description="A simple FastAPI application to demonstrate Scalar docs.", version="1.0.0", ) @app.get("/") async def read_root(): return {"message": "Hello, World!"} @app.get("/scalar", include_in_schema=False) async def scalar_html(): return get_scalar_api_reference( openapi_url=app.openapi_url, title=app.title, # Optional: Avoid CORS issues with a proxy # scalar_proxy_url="https://proxy.scalar.com", # Optional: Disable telemetry # telemetry=False ) # To run: uvicorn main:app --reload # Then open http://127.0.0.1:8000/scalar in your browser
Debug
Known issues
gotchaTelemetry is enabled by default. To disable usage telemetry for privacy or compliance, explicitly set `telemetry=False` in the `get_scalar_api_reference` call.
fix
Pass `telemetry=False` to `get_scalar_api_reference()`.
affects: All versions
gotchaThe AI Chat 'Agent' feature is enabled by default on localhost with limited free messages. For production environments, an Agent key is required for full functionality. Failing to provide a key will limit or disable the AI features.
fix
For production, configure `agent=AgentScalarConfig(key="your-agent-scalar-key")` in `get_scalar_api_reference` or per `OpenAPISource`.
affects: All versions with Agent feature
deprecatedThe `hide_download_button` parameter in `get_scalar_api_reference` is deprecated. Use `document_download_type` instead to control the visibility and type of the OpenAPI document download button.
fix
Replace `hide_download_button=True` with `document_download_type=DocumentDownloadType.NONE` (or `JSON`, `YAML`, `BOTH` as needed).
affects: 1.5.0+
gotchaWhen serving the OpenAPI document from a different origin than Scalar (e.g., local development vs. hosted Scalar), CORS issues might occur. The documentation recommends using `scalar_proxy_url` to mitigate these problems.
fix
Pass `scalar_proxy_url="https://proxy.scalar.com"` (or your own proxy URL) to `get_scalar_api_reference()`.
affects: All versions
gotchaThe `scalar-fastapi` Python package wraps a core JavaScript frontend library. While the underlying JS components (e.g., `@scalar/api-client`, `@scalar/api-reference`) receive very frequent updates and potentially major changes, the Python wrapper's release cycle is less frequent. Python users might experience a slight delay in new frontend features or minor breaking changes being reflected in the `scalar-fastapi` version.
fix
Check the `scalar-fastapi` changelog (`integrations/fastapi/CHANGELOG.md` in the main Scalar GitHub repo) for Python-specific updates and breaking changes rather than solely relying on the overall Scalar project's release notes.
affects: All versions
Upgrade
Version history
1.9.0latest on PyPI · released Aug 28, 2026
Audit
Dependencies
fastapirequiredCore web framework required to generate OpenAPI schema.
uvicornoptionalASGI server to run FastAPI applications, necessary for quickstart examples.
Agent activity
22 hits · last 30 days
node
20
Resources
scalar-fastapi — pip install scalar-fastapi · libregistry