BMI Calculator API Documentation

API Endpoint

Method: GET

Endpoint: /api/bmi/{weight}/{height}

Framework Used: Flask (Python)

Example Request:

Request URL: https://bmicalculatorapi.vercel.app/api/bmi/87.9/1.75

Path Parameters

Parameter Type Required Description
weight float Yes Body weight in kilograms
height float Yes Height in meters

Response

Success (200 OK)

{
  "Category": "Overweight",
  "bmi": 28.702,
  "height": 1.75,
  "weight": 87.9
}
        

Fields:

Error Responses

1. Height is Zero (400 Bad Request)

{
  "Error": "Height parameter cannot be Zero"
}
        

2. Invalid Parameters (400 Bad Request)

{
  "error": "Invalid parameters. Please provide numeric values for weight and height."
}
        

BMI Categories Reference

BMI Range Category
< 18.5 Underweight
18.5 – 24.9 Normal weight
25 – 29.9 Overweight
30 and above Obese

Sample Code

Language: Python


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)