Soilitical's API provides an endpoint for interacting with our machine learning model, designed to predict the most suitable crop to grow based on various input parameters. This API is built using Django and offers a single endpoint for receiving the prediction.
git clone https://github.com/your-repository/soilitical-api.git
cd soilitical-api
pip install -r requirements.txt
python manage.py migrate
Create a .env file in the root directory with the following variables:
# SECURITY_KEY must be a random string
SECURITY_KEY=your-secret-key-here
# DEBUG mode (set to False for production)
DEBUG=True
- Endpoint:
/predict
- Method:
POST
- Description: Takes input data to make a prediction using the machine learning model. Returns the predicted class label.
Request Format:
Headers:
Content-Type: application/json
{
"soil_type": "clayey soil - loamy soil",
"ec_value": 0.97,
"temperature": 23.0,
"n_value": 23.85,
"p_value": 15.61,
"k_value": 20.49
}
curl -X POST https://api_example.com/predict \
-H "Content-Type: application/json" \
-d '{"soil_type":"clayey soil - loamy soil","ec_value":0.97,"temperature":23.0,"n_value":23.85,"p_value":15.61,"k_value":20.49}'
{
"prediction": "Mangoes"
}
- 400 Bad Request: Invalid input format or missing required fields
- 500 Internal Server Error: Model prediction failed
Prediction Example On Website: (Live at: Soilitical)
We welcome contributions to improve the API. Please follow these guidelines:
- Fork the repository and create a new branch.
- Ensure your code follows best practices and is well-documented.
- Open a pull request with a detailed description of your changes.