A powerful REST API system that allows any AI model, chatbot, or web app to perform complex mathematical operations, including solving expressions, plotting graphs, calculus, and more.
- High Performance: Built with FastAPI and asynchronous from the ground up.
- Secure: Protected by API Key authentication.
- Comprehensive: Covers a wide range of math operations from basic arithmetic to calculus.
- Visual: Generates high-quality plots and LaTeX images on the fly.
- Self-Documenting: Interactive API documentation available at the
/docsendpoint. - Deploy-Ready: Includes configuration for one-click deployment to Render.
- Language: Python 3.11
- Framework: FastAPI
- Core Libraries: SymPy (symbolic math), NumPy, Matplotlib
- Server: Uvicorn (development), Gunicorn (production)
- Deployment: Render
This project is configured for easy deployment on Render's free tier.
- Fork and Clone: Fork this repository to your own GitHub account and then clone it to your local machine.
- Create a New Web Service on Render:
- Go to the Render Dashboard and click "New" -> "Web Service".
- Connect the GitHub repository you just created.
- Render will automatically detect the
render.yamlfile. Give your service a name (e.g.,mathwiz-api) and approve the plan.
- Deployment: Render will build and deploy your application. The
render.yamlfile handles everything:- It installs dependencies from
requirements.txt. - It runs the
gunicornproduction server. - It automatically generates a secure
API_KEYfor you.
- It installs dependencies from
- Find Your API Key: Once deployed, go to the "Environment" tab for your service on Render to find your auto-generated
API_KEY. You will need this key to make requests.
- Clone the repository:
git clone https://github.com/YOUR_USERNAME/mathwiz-api.git cd mathwiz-api - Create a virtual environment:
python -m venv venv source venv/bin/activate # On Windows, use `venv\Scripts\activate`
- Install dependencies:
pip install -r requirements.txt
- Run the development server:
The API will be available at
uvicorn app:app --reload
http://127.0.0.1:8000.
All endpoints require an X-API-KEY header for authentication.
Header: X-API-KEY: your-render-api-key
curl -X POST "https://your-app-name.onrender.com/evaluate" \
-H "Content-Type: application/json" \
-H "X-API-KEY: your-render-api-key" \
-d '{
"expression": "sqrt(16) + 2**5"
}'
# Response:
# { "result": 36.0 }curl -X POST "https://your-app-name.onrender.com/solve-equation" \
-H "Content-Type: application/json" \
-H "X-API-KEY: your-render-api-key" \
-d '{
"equation": "x**2 + 5*x + 6 = 0"
}'
# Response:
# {
# "solutions": ["-2.00000000000000", "-3.00000000000000"],
# "steps": [
# "Given equation: Eq(x**2 + 5*x + 6, 0)",
# "Rearranging to solve for the variable.",
# "The solutions are: -2.00000000000000, -3.00000000000000"
# ]
# }Explore all endpoints and their inputs interactively by visiting the /docs route on your deployed API URL.