Metadata and Docs URLs
Part of: FastAPI Basics
Learn to customize API metadata, documentation, and OpenAPI configuration for professional API presentation.
What You'll Learn
- Configure API metadata including title, description, version, and contact information
- Add license information and terms of service to your API
- Customize OpenAPI and documentation URLs
- Organize endpoints with tags and descriptions
Theory and Concepts
Metadata and Docs URLs
🎯 What You'll Learn
- Configure API metadata for professional documentation
- Set title, description, version, and contact information
- Add license information and terms of service
- Customize OpenAPI and documentation URLs
- Organize endpoints with tags and descriptions
📚 Theory
When building APIs, professional documentation is essential. FastAPI automatically generates interactive documentation, but you can customize the metadata to make your API documentation more informative and professional.
API Metadata
You can configure several metadata fields when creating your FastAPI application. These fields appear in the automatic API documentation:
[Code Example]
Available Metadata Fields
- title: The name of your API (appears prominently in documentation)
- summary: A short one-liner about your API
- description: Detailed description supporting Markdown formatting
- version: Your API version (e.g., "1.0.0", "2.3.1")
- terms_of_service: URL to your terms of service
- contact: Dictionary with name, url, and email
- license_info: Dictionary with name and url (or identifier)
Markdown Support
The description field supports full Markdown syntax:
[Code Example]
Tags Metadata
Organize your endpoints with tags and add descriptions for each tag:
[Code Example]
Customizing Documentation URLs
FastAPI serves documentation at default URLs, but you can customize them:
[Code Example]
You can also disable documentation completely:
[Code Example]
🔧 Key Concepts
- OpenAPI Schema: JSON file describing your entire API structure
- Swagger UI: Interactive documentation at /docs by default
- ReDoc: Alternative documentation UI at /redoc by default
- Tags: Organize endpoints into logical groups in documentation
- Metadata: Information about your API shown in documentation
💡 Best Practices
- Write clear descriptions: Use Markdown to format documentation
- Version your API: Use semantic versioning (major.minor.patch)
- Provide contact information: Help users reach you for support
- Add license information: Clarify usage terms for your API
- Organize with tags: Group related endpoints together
- Keep it updated: Update metadata when your API changes
- Use meaningful titles: Make your API easily identifiable
🔗 Additional Resources
- FastAPI Metadata and Docs URLs
- OpenAPI Specification
- Semantic Versioning
- SPDX License List
Helpful Hint
Set metadata parameters when creating the FastAPI() instance to configure your API documentation