API Reference¶
- app.main.echo(message: str = Query(None))¶
Echo endpoint.
- Parameters:
message (str) – The message to echo back.
- Returns:
A JSON object containing the echoed message.
- Return type:
dict
Example JSON response:
{ "echo": "Hello, World!" }
- app.main.get_random_fact()¶
Get a random fact.
- Returns:
A JSON object containing a random fact.
- Return type:
dict
Example JSON response:
{ "fact": "Did you know that honey never spoils?" }
- app.main.health_check()¶
Health check endpoint.
- Returns:
A simple JSON status message.
- Return type:
dict
Example JSON response:
{ "status": "ok" }
- app.main.read_info()¶
Information endpoint with project details.
- Returns:
- A JSON object containing:
project name
version
description
author
- Return type:
dict
Example JSON response:
{ "project": "FastAPI Docs Starter", "version": "1.0.0", "description": "This is a small API for documentation practice", "author": "Dom Caracappa" }
- app.main.read_math_fact(number: int = Query(PydanticUndefined))¶
Math Fact endpoint.
- Parameters:
number (int) – A positive integer to learn fun math facts about.
- Returns:
A JSON object containing the number and a list of interesting facts.
- Return type:
dict
- Example usage:
In browser: http://127.0.0.1:8000/math-fact?number=12
Using curl: curl “http://127.0.0.1:8000/math-fact?number=12”
- Example JSON response:
- {
“number”: 12, “facts”: [
“12 is an even number.”, “12 is not prime (divisible by 2).”, “The square of 12 is 144.”, “The cube of 12 is 1728.”
]
}
- app.main.read_root()¶
Root endpoint of the API.
- Returns:
A JSON greeting message.
- Return type:
dict
Example JSON response:
{ "message": "Hello, FastAPI!" }