Method: GET
Endpoint: /api/bmi/{weight}/{height}
Framework Used: Flask (Python)
Request URL: https://bmicalculatorapi.vercel.app/api/bmi/87.9/1.75
| Parameter | Type | Required | Description |
|---|---|---|---|
weight |
float | Yes | Body weight in kilograms |
height |
float | Yes | Height in meters |
{
"Category": "Overweight",
"bmi": 28.702,
"height": 1.75,
"weight": 87.9
}
Fields:
{
"Error": "Height parameter cannot be Zero"
}
{
"error": "Invalid parameters. Please provide numeric values for weight and height."
}
| BMI Range | Category |
|---|---|
| < 18.5 | Underweight |
| 18.5 – 24.9 | Normal weight |
| 25 – 29.9 | Overweight |
| 30 and above | Obese |
import requests
# User input
weight = 87.9
height = 1.75
# URL of the API
url = f"https://bmicalculatorapi.vercel.app/api/bmi/{weight}/{height}"
# Make the GET request
response = requests.get(url)
# Check if the request was successful
if response.status_code == 200:
data = response.json()
print("API Response:", data)
else:
print("Error:", response.status_code)