{"id":37748129,"url":"https://github.com/waketzheng/fastapi-cdn-host","last_synced_at":"2026-01-16T14:19:08.123Z","repository":{"id":211107474,"uuid":"726758938","full_name":"waketzheng/fastapi-cdn-host","owner":"waketzheng","description":"Auto choose the fastest CDN host for swagger-ui in /docs.","archived":false,"fork":false,"pushed_at":"2025-11-28T10:11:15.000Z","size":3968,"stargazers_count":16,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-11-28T11:52:43.723Z","etag":null,"topics":["fastapi"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/waketzheng.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2023-12-03T10:12:08.000Z","updated_at":"2025-11-28T07:02:22.000Z","dependencies_parsed_at":"2024-04-18T11:29:58.778Z","dependency_job_id":"f4f31ccc-41f9-415b-bd69-5aeba09bd920","html_url":"https://github.com/waketzheng/fastapi-cdn-host","commit_stats":null,"previous_names":["waketzheng/fastapi-cdn-host"],"tags_count":32,"template":false,"template_full_name":null,"purl":"pkg:github/waketzheng/fastapi-cdn-host","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/waketzheng%2Ffastapi-cdn-host","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/waketzheng%2Ffastapi-cdn-host/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/waketzheng%2Ffastapi-cdn-host/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/waketzheng%2Ffastapi-cdn-host/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/waketzheng","download_url":"https://codeload.github.com/waketzheng/fastapi-cdn-host/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/waketzheng%2Ffastapi-cdn-host/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28479374,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-16T11:59:17.896Z","status":"ssl_error","status_checked_at":"2026-01-16T11:55:55.838Z","response_time":107,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["fastapi"],"created_at":"2026-01-16T14:19:07.706Z","updated_at":"2026-01-16T14:19:08.117Z","avatar_url":"https://github.com/waketzheng.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# FastAPI CDN host Selector for docs ui\n![Python Versions](https://img.shields.io/pypi/pyversions/fastapi-cdn-host)\n[![LatestVersionInPypi](https://img.shields.io/pypi/v/fastapi-cdn-host.svg?style=flat)](https://pypi.python.org/pypi/fastapi-cdn-host)\n[![GithubActionResult](https://github.com/waketzheng/fastapi-cdn-host/workflows/ci/badge.svg)](https://github.com/waketzheng/fastapi-cdn-host/actions?query=workflow:ci)\n[![Coverage Status](https://coveralls.io/repos/github/waketzheng/fastapi-cdn-host/badge.svg?branch=main)](https://coveralls.io/github/waketzheng/fastapi-cdn-host?branch=main)\n[![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)\n[![security: bandit](https://img.shields.io/badge/security-bandit-yellow.svg)](https://github.com/PyCQA/bandit)\n\nAuto find swagger-ui in local files, if exist use them.\nOtherwise make concurrent http requests by httpx to find out which third part cdn host(cdn.jsdelivr.net/unpkg.com/cdnjs.cloudflare.com/cdn.staticfile.org) is the fastest one.\n\n\n**English** | [中文](./README.zh.md)\n\n## Install\n\n```bash\npip install fastapi-cdn-host\n```\n\n## Usage\n```py\nimport fastapi_cdn_host\nfrom fastapi import FastAPI\n\napp = FastAPI()\n# include_routes ...\n\nfastapi_cdn_host.patch_docs(app)\n```\nSee more at:\n- [examples/](https://github.com/waketzheng/fastapi-cdn-host/tree/main/examples)\n- [tests/](https://github.com/waketzheng/fastapi-cdn-host/tree/main/tests)\n\n## Detail\n1. Let's say that the default docs CDN host https://cdn.jsdelivr.net is too slow in your network, while unpkg.com is much faster.\n```py\nimport fastapi_cdn_host\nfrom fastapi import FastAPI\n\napp = FastAPI()\nfastapi_cdn_host.patch_docs(app)  # Will use `unpkg.com`(or other faster host) to replace the `cdn.jsdelivr.net/npm`\n```\n2. To support offline docs/, put swagger-ui asset files into local directory named `static`\n```py\nfrom pathlib import Path\n\nfastapi_cdn_host.patch_docs(app, Path(__file__).parent.joinpath('static'))\n```\nThis get the same result of the example in official document:\nhttps://fastapi.tiangolo.com/how-to/custom-docs-ui-assets/?h=static#self-hosting-javascript-and-css-for-docs\n\n3. If asset files are ready in private cdn\n```py\nfrom fastapi_cdn_host import AssetUrl\n\nfastapi_cdn_host.patch_docs(\n    app,\n    cdn_host=AssetUrl(\n        js='http://my-cdn.com/swagger-ui.js',\n        css='http://my-cdn.com/swagger-ui.css',\n        redoc='http://my-cdn.com/redoc.standalone.js',\n        favicon='http://my-cdn.com/favicon.ico',\n    )\n)\n```\n\n## License\n\n[MIT](./LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwaketzheng%2Ffastapi-cdn-host","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwaketzheng%2Ffastapi-cdn-host","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwaketzheng%2Ffastapi-cdn-host/lists"}