🔵🔵🔵 grai Soil Analysis API - v2.0

API for soil particle size distribution analysis from images with usage tracking

Developed by Enrico Soranzo

📊 Usage Tracking Enabled

This API now includes comprehensive usage tracking:

Available Endpoints

GET / - This page (public)
POST /analyze - Analyze soil image (multipart/form-data) [requires x-api-key]
POST /analyze_base64 - Analyze base64 encoded image [requires x-api-key]
GET /health - Health check (public)
GET /usage-stats?api_key=YOUR_KEY - Get usage statistics for your API key
GET /owner-stats?owner=username - Get usage statistics for an owner
GET /admin/stats - Admin endpoint to get overall statistics (requires special key)
Authentication: Protected endpoints require the header x-api-key: YOUR_KEY. Add API keys to the database or set environment variable API_KEYS_SEED on startup: API_KEYS_SEED="alice:KEY1,bob:KEY2".

📈 New Usage Statistics Features

Monitor your API usage with these new endpoints:

All statistics include request counts, success rates, response times, and endpoint breakdowns.

Quick Start

Upload an image using cURL:

curl -X POST -H "x-api-key: API_KEY" -F "file=@soil_image.jpeg" https://soranz84-graiAPI.hf.space/analyze

Get your usage statistics:

curl -H "x-api-key: API_KEY" https://soranz84-graiAPI.hf.space/usage-stats?api_key=API_KEY

Recommended Devices

HUAWEI_p9_Lite_20177, iPad Pro, iPhone 13 mini, iPhone 14, iPhone 14 Pro, iPhone 15 Pro, iPhone 16, iPhone 16 Pro, Motorola Edge, Motorola Edge 60 fusion, Motorola G7+, Motorola G30, Samsung Galaxy A17, Samsung Galaxy A32, Samsung A52, Samsung Galaxy S23, Samsung Galaxy S24, Vivo X60, Xiaomi 15, Xiaomi A2

Other Devices

grai is device-agnostic. An angle of view of 70° is assumed for uncalibrated devices. You can write to enrico@deepsoil.at to update the list of calibrated devices.