This is the Public API of CropHawk, designed to enable developers to seamlessly integrate and utilize our machine learning models.
https://crophawk-api.onrender.com/
- Fertilizer Recommendation: Suggests optimal fertilizers based on the soil conditions.
- Crop Recommendation: Recommends the best crops based on the agricultural parameters.
POST /fertilizer_recommendation
Request Body:
{
"temperature": 28,
"humidity": 65,
"moisture": 30,
"soil_type": 1,
"crop_type": 2,
"nitrogen": 40,
"potassium": 35,
"phosphorous": 50
}
Response:
{
"status": "success",
"recommendation": "Superphosphate"
}
POST /crop_recommendation
Request Body:
{
"nitrogen": 40,
"potassium": 35,
"phosphorous": 50,
"temperature": 28,
"humidity": 64.6,
"rainfall": 214.4,
"pH": 6.8
}
Response:
{
"status": "success",
"recommendation": "mango"
}
To use the API in a JavaScript applications, follow the example below:
const fetchFertilizerRecommendation = async () => {
try {
const response = await fetch('https://crophawk-api.onrender.com/fertilizer_recommendation', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({
"temperature": 28,
"humidity": 65,
"moisture": 30,
"soil_type": 1,
"crop_type": 2,
"nitrogen": 40,
"potassium": 35,
"phosphorous": 50,
})
});
const data = await response.json();
console.log(data);
} catch (error) {
console.error('Error fetching data:', error);
}
};