r/FastAPI • u/earonesty • Apr 24 '25
Tutorial π£ [Tool] fastapi-sitemap: Auto-generate sitemap.xml from your FastAPI routes
fastapi-sitemap: https://pypi.org/project/fastapi-sitemap/
Dynamically generates a sitemap.xml from your FastAPI routes.
- Automatically includes all
GETroutes without path parameters. - Excludes routes with path parameters or marked as private.
- Serves
sitemap.xmlat the root path. - Servess gzipped response with correct MIME type.
Usage:
=
=
# now GET /sitemap.xml is live
You can also add custom URLs using the @sitemap.source decorator.
You can also use it as a cli tool to generate a sitemap, if you prefer.
Source: https://github.com/earonesty/fastapi-sitemap
Disclaimer, I wrote this for myself. Feedback and contributions are welcome.
15
Upvotes
1
u/Adventurous-Finger70 Apr 24 '25
Whatβs the point of having sitemap for an api ? I would do it in the frontend instead
1
u/ZorroGuardaPavos Apr 24 '25
I will try it! Thanks for sharing