{"id":25086001,"url":"https://github.com/EmmyAnieDev/hngx-stage1-number-classifier-api","last_synced_at":"2025-10-22T05:31:03.383Z","repository":{"id":275519673,"uuid":"926300554","full_name":"EmmyAnieDev/hngx-stage1-number-classifier-api","owner":"EmmyAnieDev","description":"A RESTful API for analyzing numbers, determining their mathematical properties, and fetching fun facts. Built as part of my HNG Stage 1 task. ","archived":false,"fork":false,"pushed_at":"2025-02-10T11:48:12.000Z","size":13,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-05-16T12:14:39.104Z","etag":null,"topics":["rest-api","third-party-api"],"latest_commit_sha":null,"homepage":"https://number-classifier-api-production.up.railway.app/api/classify-number","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/EmmyAnieDev.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2025-02-03T01:48:43.000Z","updated_at":"2025-02-10T11:48:15.000Z","dependencies_parsed_at":null,"dependency_job_id":"a00d8e6a-1524-4f81-bfec-b192e5470d99","html_url":"https://github.com/EmmyAnieDev/hngx-stage1-number-classifier-api","commit_stats":null,"previous_names":["emmyaniedev/number-classifier-api","emmyaniedev/hngx-stage1-number-classifier-api"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/EmmyAnieDev/hngx-stage1-number-classifier-api","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EmmyAnieDev%2Fhngx-stage1-number-classifier-api","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EmmyAnieDev%2Fhngx-stage1-number-classifier-api/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EmmyAnieDev%2Fhngx-stage1-number-classifier-api/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EmmyAnieDev%2Fhngx-stage1-number-classifier-api/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/EmmyAnieDev","download_url":"https://codeload.github.com/EmmyAnieDev/hngx-stage1-number-classifier-api/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EmmyAnieDev%2Fhngx-stage1-number-classifier-api/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":280384113,"owners_count":26321688,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-22T02:00:06.515Z","response_time":63,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["rest-api","third-party-api"],"created_at":"2025-02-07T08:32:05.242Z","updated_at":"2025-10-22T05:31:03.378Z","avatar_url":"https://github.com/EmmyAnieDev.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Number Classification API\n\nA RESTful API that analyzes numbers and returns their mathematical properties along with interesting facts.\n\n## Project Structure\n\n```\nnumber-classification-api/\n├── app.py                  # Application entry point and route\n├── services/\n│   └── number_api_service.py  # Business logic\n├── utils/\n│   ├── constants.py          # Configuration constants\n│   └── number_properties.py   # Mathematical utilities\n├── requirements.txt\n└── README.md\n```\n\n## Features\n\n- Determines if a number is **prime**\n- Checks if a number is **perfect**\n- Identifies **Armstrong numbers**\n- Calculates **digit sum**\n- Classifies numbers as **even/odd**\n- Fetches fun facts from the **Numbers API**\n- **CORS enabled**\n- Handles invalid input gracefully\n\n## Requirements\n\n- Python 3.8+\n- Flask\n- Flask-CORS\n- Requests\n- gunicorn\n\n## Installation\n\n1. **Clone the repository:**\n    ```bash\n    git clone https://github.com/EmmyAnieDev/hngx-stage1-number-classifier-api.git\n    cd hngx-stage1-number-classifier-api\n    ```\n\n2. Create a virtual environment and activate it:\n```bash\npython -m venv venv\nsource venv/bin/activate  # On Windows use: venv\\Scripts\\activate\n```\n\n3. Install dependencies:\n```bash\npip install -r requirements.txt\n```\n\n## Running the Application\n\n1. Start the server:\n```bash\npython app.py\n```\n\n2. The API will be available at `http://localhost:8000`\n\n\n## API Documentation\n\n### Method: `GET`\n\n### Endpoint: `/api/classify-number`\n\n### Query Parameter: `number` (required): The integer to analyze\n\n#### Full URL for Localhost Testing: Analyzes a number and returns its properties.\n \n```bash\n   http://localhost:8000/api/classify-number?number=5\n   ```\n\n#### Success Response (200 OK)\n\n```json\n{\n    \"number\": 5,\n    \"is_prime\": true,\n    \"is_perfect\": false,\n    \"properties\": [\n        \"armstrong\",\n        \"odd\"\n    ],\n    \"digit_sum\": 5,\n    \"fun_fact\": \"5 is the third prime number.\"\n}\n```\n\n#### Error Response (400 Bad Request)\n\n```json\n{\n    \"number\": \"letter\",\n    \"error\": true\n}\n```\n\n#### Occurs when an invalid input (like a letter/alphabet) is provided.\n\n```json\n{\n    \"number\": \"null\",\n    \"error\": true\n}\n```\n\n#### Occurs when the `number` parameter is missing from the request.\n\n```json\n{\n    \"number\": \"\",\n    \"error\": true\n}\n```\n\n#### Occurs when the `number` parameter has an empty value.\n\n\n## Deployment\n\nThe API is deployed on Railway and can be accessed at:\n```\nhttps://number-classifier-api-production.up.railway.app/\n```\n\n## Quick Test\n\nTo test the full URL with the parameter:\n\n### Method: `GET`\n\n```bash\ncurl \"https://number-classifier-api-production.up.railway.app/api/classify-number?number=5\"\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FEmmyAnieDev%2Fhngx-stage1-number-classifier-api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FEmmyAnieDev%2Fhngx-stage1-number-classifier-api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FEmmyAnieDev%2Fhngx-stage1-number-classifier-api/lists"}