FastAPI

Installation
pip install scalar-fastapi
Usage
FastAPI makes it super easy to enable scalar with their out of the box OpenAPI support
from fastapi import FastAPI
from scalar_fastapi import get_scalar_api_reference
app = FastAPI()
@app.get("/")
def read_root():
return {"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,
)
Configuration
Currently available configuration options are listed below.
layout(defaultLayout.MODERN)show_sidebar(defualttrue)hide_download_button(defaultfalse)hide_models(defaultfalse)dark_mode(defaulttrue)search_hot_key(defaultSearchHotKey.K)hidden_clients(default[])servers(default[])default_open_all_tags(defaultfalse)authentication(default{})hide_client_button(defaultfalse)
Example
Check out the playground for a working example.