This project is a simple Number Classification API built with Node.js, and Express.js. It accepts an integer as input and returns various properties about the number, such as:
- Whether the number is prime, perfect, odd, or even.
- Whether the number is an Armstrong number.
- The sum of its digits.
- A fun fact retrieved dynamically from NumbersAPI.
- Accepts GET requests with a
number
parameter. - Input validation using Simple Validator.
- Proper HTTP status codes for valid and invalid inputs.
- Fetches fun facts dynamically from NumbersAPI.
- Error handling for incorrect inputs.
- Node.js - JavaScript runtime environment
- Express.js - Web framework
- NumbersAPI - External API for fun facts
git clone https://github.com/Dan-Gaya/STAGE_ONE--Render.git
cd STAGE_ONE
npm install
npm start
The API will be available locally at: http://localhost:5000
GET /api/classify-number?number=371
{
"number": 371,
"is_prime": false,
"is_perfect": false,
"properties": ["armstrong", "odd"],
"digit_sum": 11,
"fun_fact": "371 is the sum of three consecutive primes: 113 + 127 + 131."
}
📥 Request:
GET /api/classify-number?number=abc
📤 Response:
{
"number": "abc",
"error": true
}
If something goes wrong on the server, the response will be:
{
"error": true,
"message": "Internal Server Error"
}
the API was deployed on the Url : (https://stage-one-render.onrender.com/api/classify-number)
Feel free to fork this repo and submit pull requests with any improvements! 🚀
This project is open-source and available under the MIT License.
💡 Author: Abdulaziz Nura Kani