Diagnosis Endpoint¶
Analyze plant images and receive AI-powered disease diagnosis.
Endpoint¶
Request Parameters¶
Form Data (multipart/form-data)¶
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
image |
file | Yes | - | Plant image (JPEG, PNG, WebP, HEIC) |
crop_type |
enum | No | - | Type of crop. See Supported Crops. |
region |
string | No | - | Geographic region (e.g., "Kenya", "Tanzania") |
growth_stage |
string | No | - | Plant growth stage (e.g., "seedling", "flowering") |
description |
string | No | - | User's description of observed symptoms |
language |
enum | No | fr |
Response language: en, fr, sw, es, pt, it |
detail_level |
enum | No | standard |
Detail level: simple, standard, expert |
include_bbox |
boolean | No | false |
Include bounding boxes for affected areas |
user_data |
string (JSON) | No | - | Client metadata as JSON string (see below) |
About user_data
user_data is sent as a JSON string in the form data, not as an object. The API parses it server-side. Invalid JSON is silently ignored.
Recommended fields:
| Field | Type | Description |
|---|---|---|
phone |
string | User's phone number. Used to track usage per farmer and enable follow-up support. Automatically hashed (SHA-256) server-side before logging — the raw number is never stored in logs. |
country_code |
string | Country dialing code (e.g., "+269", "+254") |
device |
string | Client device type (e.g., "android", "ios", "web") |
Example: '{"phone": "+269321234567", "country_code": "+269", "device": "android"}'
Request Examples¶
Minimal Request¶
Full Request with All Parameters¶
import requests
response = requests.post(
"https://api.tajirifarm.com/diagnoses/",
files={
"image": ("plant.jpg", open("plant.jpg", "rb"), "image/jpeg")
},
data={
"crop_type": "tomato",
"region": "Kenya",
"growth_stage": "flowering",
"description": "Yellow spots appearing on lower leaves",
"language": "en",
"detail_level": "expert",
"include_bbox": True,
"user_data": '{"phone": "+254712345678", "country_code": "+254", "device": "android"}'
}
)
curl -X POST "https://api.tajirifarm.com/diagnoses/" \
-F "image=@plant.jpg" \
-F "crop_type=tomato" \
-F "region=Kenya" \
-F "growth_stage=flowering" \
-F "description=Yellow spots appearing on lower leaves" \
-F "language=en" \
-F "detail_level=expert" \
-F "include_bbox=true" \
-F 'user_data={"country_code": "+254", "device": "android"}'
Response¶
Success Response (200 OK)¶
{
"request_id": "550e8400-e29b-41d4-a716-446655440000",
"image_analysis": {
"is_plant": true,
"quality_issue": null
},
"crop_health": "unhealthy",
"diagnoses": [
{
"scientific_name": "Alternaria solani",
"eppo_code": "ALTESO",
"name": "Early Blight",
"category": "fungal",
"confidence": 0.87,
"urgency": "moderate",
"description": "Fungal disease characterized by dark, concentric rings forming a 'target' pattern on leaves. Common in warm, humid conditions.",
"affected_parts": ["leaves", "lower foliage"],
"reference_images": ["https://gd.eppo.int/media/data/photos/ALTESO/ALTESO_001.jpg"]
},
{
"scientific_name": null,
"eppo_code": null,
"name": "Nutrient Deficiency - Nitrogen",
"category": "nutrient_deficiency",
"confidence": 0.45,
"urgency": "low",
"description": "Yellowing of older leaves, potentially indicating nitrogen deficiency.",
"affected_parts": ["lower leaves"],
"reference_images": null
}
],
"treatment": {
"immediate_actions": [
"Remove and destroy affected leaves",
"Improve air circulation between plants",
"Avoid overhead irrigation"
],
"recommended_products": [
"Chlorothalonil-based fungicide",
"Copper hydroxide",
"Mancozeb"
],
"natural_alternatives": [
"Neem oil spray (1-2%)",
"Baking soda solution (1 tbsp per gallon)",
"Compost tea foliar spray"
],
"prevention": [
"Practice 2-3 year crop rotation",
"Use disease-resistant varieties",
"Maintain proper plant spacing",
"Mulch to prevent soil splash"
]
},
"detections": [
{
"name": "early_blight",
"bbox": [0.15, 0.30, 0.25, 0.20],
"confidence": 0.87
}
],
"additional_notes": "The disease appears to be in early stages. Prompt treatment should prevent significant yield loss."
}
Response with Image Quality Issue¶
{
"request_id": "550e8400-e29b-41d4-a716-446655440001",
"image_analysis": {
"is_plant": true,
"quality_issue": "Image is too blurry for accurate diagnosis. Please provide a clearer photo."
},
"crop_health": "unknown",
"diagnoses": [],
"treatment": null,
"detections": null,
"additional_notes": null
}
Non-Plant Image Response¶
{
"request_id": "550e8400-e29b-41d4-a716-446655440002",
"image_analysis": {
"is_plant": false,
"quality_issue": null
},
"crop_health": "unknown",
"diagnoses": [],
"treatment": null,
"detections": null,
"additional_notes": "The image does not appear to contain a plant. Please submit a photo of the crop you want diagnosed."
}
Response Headers¶
| Header | Description |
|---|---|
X-Request-ID |
Unique request identifier |
X-RateLimit-Limit |
Rate limit ceiling |
X-RateLimit-Remaining |
Remaining requests in window |
X-RateLimit-Reset |
Time when rate limit resets |
Error Responses¶
See the full Error Handling guide for all error codes, examples, and retry logic.
See Also¶
- Response Schema — Detailed field descriptions and enums
- Image Requirements — How to get the best results
- Supported Crops — Valid
crop_typevalues - Supported Languages — Valid
languagevalues