Skip to content

Quick Start

Get your first diagnosis in under 5 minutes.


Step 1 — Make Your First Request

The simplest request needs only an image. No parameters required.

curl -X POST "https://api.tajirifarm.com/diagnoses/" \
  -F "image=@leaf_sample.jpg"
import requests

response = requests.post(
    "https://api.tajirifarm.com/diagnoses/",
    files={"image": open("leaf_sample.jpg", "rb")}
)

print(response.json())
const formData = new FormData();
formData.append('image', imageFile);

const response = await fetch('https://api.tajirifarm.com/diagnoses/', {
    method: 'POST',
    body: formData
});

const result = await response.json();
console.log(result);

The API returns a JSON response:

{
  "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 causing dark concentric rings on leaves.",
      "affected_parts": ["leaves"],
      "reference_images": ["https://gd.eppo.int/..."]
    }
  ],
  "treatment": {
    "immediate_actions": ["Remove affected leaves", "Improve air circulation"],
    "recommended_products": ["Copper-based fungicide"],
    "natural_alternatives": ["Neem oil spray"],
    "prevention": ["Crop rotation", "Resistant varieties"]
  },
  "detections": null,
  "additional_notes": null,
  "error": null
}

That's it!

You just diagnosed a plant disease. The API detected the crop automatically, identified the disease with its scientific name, and provided a treatment plan.


Step 2 — Add Context for Better Results

Adding crop type and region significantly improves accuracy. The AI uses this context to narrow down region-specific diseases.

curl -X POST "https://api.tajirifarm.com/diagnoses/" \
  -F "image=@maize_leaf.jpg" \
  -F "crop_type=maize" \
  -F "region=Kenya" \
  -F "growth_stage=flowering"
response = requests.post(
    "https://api.tajirifarm.com/diagnoses/",
    files={"image": open("maize_leaf.jpg", "rb")},
    data={
        "crop_type": "maize",
        "region": "Kenya",
        "growth_stage": "flowering"
    }
)

Why context matters

Without context, the AI considers all possible diseases worldwide. With crop_type=maize and region=Kenya, it prioritizes diseases common in East African maize — giving more accurate results.


Step 3 — Choose Your Language

Responses are available in 6 languages. Set the language parameter:

Code Language
en English
fr French
sw Swahili
es Spanish
pt Portuguese
it Italian
curl -X POST "https://api.tajirifarm.com/diagnoses/" \
  -F "image=@cassava_leaf.jpg" \
  -F "crop_type=cassava" \
  -F "region=Tanzania" \
  -F "language=sw"
curl -X POST "https://api.tajirifarm.com/diagnoses/" \
  -F "image=@cassava_leaf.jpg" \
  -F "crop_type=cassava" \
  -F "region=RDC" \
  -F "language=fr"

Note

Enum keys and field names in the JSON response always remain in English. Only the descriptive text (diagnosis names, descriptions, treatment advice) is translated.

See the full Supported Languages Guide for details.


Step 4 — Adjust Detail Level

Three detail levels adapt the response to your audience:

Level Audience Description
simple Farmers Clear, jargon-free language with practical advice
standard Technicians Balanced — technical terms with explanations
expert Agronomists Full scientific detail, pathogen taxonomy
curl -X POST "https://api.tajirifarm.com/diagnoses/" \
  -F "image=@tomato_leaf.jpg" \
  -F "crop_type=tomato" \
  -F "region=Ethiopia" \
  -F "detail_level=simple" \
  -F "language=en"

Step 5 — Enable Bounding Boxes

For visual applications that need to highlight affected areas on the image:

curl -X POST "https://api.tajirifarm.com/diagnoses/" \
  -F "image=@pepper_leaf.jpg" \
  -F "crop_type=pepper" \
  -F "include_bbox=true"

Response includes normalized coordinates [x, y, width, height]:

{
  "detections": [
    {
      "name": "bacterial_spot",
      "bbox": [0.15, 0.30, 0.25, 0.20],
      "confidence": 0.82
    }
  ]
}

Coordinate format

All values are normalized between 0 and 1. To convert to pixels: pixel_x = bbox_x * image_width.


Putting It All Together

A complete request using all parameters:

import requests
import json

response = requests.post(
    "https://api.tajirifarm.com/diagnoses/",
    files={
        "image": ("maize.jpg", open("maize.jpg", "rb"), "image/jpeg")
    },
    data={
        "crop_type": "maize",
        "region": "Kenya",
        "growth_stage": "flowering",
        "description": "Yellow streaks on upper leaves",
        "language": "en",
        "detail_level": "standard",
        "include_bbox": True,
        "user_data": json.dumps({
            "phone": "+254712345678",
            "device": "android"
        })
    }
)

result = response.json()

if result["image_analysis"]["is_plant"] and result["crop_health"] == "unhealthy":
    for diagnosis in result["diagnoses"]:
        print(f"Disease: {diagnosis['name']}")
        print(f"Scientific: {diagnosis['scientific_name']}")
        print(f"Confidence: {diagnosis['confidence']:.0%}")
        print(f"Urgency: {diagnosis['urgency']}")
curl -X POST "https://api.tajirifarm.com/diagnoses/" \
  -F "image=@maize.jpg" \
  -F "crop_type=maize" \
  -F "region=Kenya" \
  -F "growth_stage=flowering" \
  -F "description=Yellow streaks on upper leaves" \
  -F "language=en" \
  -F "detail_level=standard" \
  -F "include_bbox=true" \
  -F 'user_data={"phone": "+254712345678", "device": "android"}'

What's Next?

  • API Reference


    Full parameter documentation and response schemas.

    API Reference

  • Integration Guides


    Production clients, framework integrations, and visualizations.

    Integration

  • Image Requirements


    How to get the best results from your images.

    Image Guide

  • Error Handling


    Handle errors and rate limits properly.

    Errors