{"id":4245,"library":"scalar-fastapi","title":"Scalar FastAPI","description":"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.","status":"active","version":"1.8.2","language":"en","source_language":"en","source_url":"https://github.com/scalar/scalar","tags":["fastapi","openapi","swagger","api-documentation","docs","ui"],"install":[{"cmd":"pip install scalar-fastapi uvicorn","lang":"bash","label":"Install library and Uvicorn"}],"dependencies":[{"reason":"Core web framework required to generate OpenAPI schema.","package":"fastapi"},{"reason":"ASGI server to run FastAPI applications, necessary for quickstart examples.","package":"uvicorn","optional":true}],"imports":[{"symbol":"get_scalar_api_reference","correct":"from scalar_fastapi import get_scalar_api_reference"},{"note":"Used for providing multiple OpenAPI sources to the documentation.","symbol":"OpenAPISource","correct":"from scalar_fastapi import get_scalar_api_reference, OpenAPISource"},{"note":"Provides options for customizing the documentation layout.","symbol":"Layout","correct":"from scalar_fastapi import Layout"},{"note":"Provides options for customizing the documentation theme.","symbol":"Theme","correct":"from scalar_fastapi import Theme"}],"quickstart":{"code":"from fastapi import FastAPI\nfrom scalar_fastapi import get_scalar_api_reference\nimport uvicorn\n\napp = FastAPI(\n    title=\"My Awesome API\",\n    description=\"A simple FastAPI application to demonstrate Scalar docs.\",\n    version=\"1.0.0\",\n)\n\n@app.get(\"/\")\nasync def read_root():\n    return {\"message\": \"Hello, World!\"}\n\n@app.get(\"/scalar\", include_in_schema=False)\nasync def scalar_html():\n    return get_scalar_api_reference(\n        openapi_url=app.openapi_url,\n        title=app.title,\n        # Optional: Avoid CORS issues with a proxy\n        # scalar_proxy_url=\"https://proxy.scalar.com\",\n        # Optional: Disable telemetry\n        # telemetry=False\n    )\n\n# To run: uvicorn main:app --reload\n# Then open http://127.0.0.1:8000/scalar in your browser\n","lang":"python","description":"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`."},"warnings":[{"fix":"Pass `telemetry=False` to `get_scalar_api_reference()`.","message":"Telemetry is enabled by default. To disable usage telemetry for privacy or compliance, explicitly set `telemetry=False` in the `get_scalar_api_reference` call.","severity":"gotcha","affected_versions":"All versions"},{"fix":"For production, configure `agent=AgentScalarConfig(key=\"your-agent-scalar-key\")` in `get_scalar_api_reference` or per `OpenAPISource`.","message":"The 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.","severity":"gotcha","affected_versions":"All versions with Agent feature"},{"fix":"Replace `hide_download_button=True` with `document_download_type=DocumentDownloadType.NONE` (or `JSON`, `YAML`, `BOTH` as needed).","message":"The `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.","severity":"deprecated","affected_versions":"1.5.0+"},{"fix":"Pass `scalar_proxy_url=\"https://proxy.scalar.com\"` (or your own proxy URL) to `get_scalar_api_reference()`.","message":"When 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.","severity":"gotcha","affected_versions":"All versions"},{"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.","message":"The `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.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-11T00:00:00.000Z","next_check":"2026-07-10T00:00:00.000Z"}