{
    "name": "TrueCode API",
    "version": "1.0.0",
    "description": "Sistema di verifica autenticità prodotto",
    "status": "online",
    "timestamp": "2026-04-14T14:35:23+00:00",
    "endpoints": {
        "public": [
            {
                "method": "POST",
                "path": "/api/verify.php",
                "description": "Verifica autenticità codice prodotto",
                "auth": false,
                "params": {
                    "code": "string (required) - Codice prodotto da verificare"
                },
                "response": {
                    "valid": "Codice autentico, poche verifiche",
                    "suspicious": "Codice autentico ma con molte verifiche (>38)",
                    "not_found": "Codice non presente nel database"
                }
            },
            {
                "method": "GET",
                "path": "/api/health.php",
                "description": "Health check del sistema",
                "auth": false
            }
        ],
        "authentication": [
            {
                "method": "POST",
                "path": "/api/auth/login.php",
                "description": "Login produttore (JWT authentication)",
                "auth": false,
                "params": {
                    "email": "string (required)",
                    "password": "string (required)"
                },
                "response": {
                    "token": "JWT token da usare per richieste autenticate",
                    "user": "Informazioni utente"
                }
            }
        ],
        "codes_management": [
            {
                "method": "GET",
                "path": "/api/codes/list.php",
                "description": "Lista codici prodotto del produttore",
                "auth": true,
                "params": {
                    "page": "int (optional, default: 1)",
                    "limit": "int (optional, default: 20)",
                    "search": "string (optional)"
                }
            },
            {
                "method": "POST",
                "path": "/api/codes/create.php",
                "description": "Crea nuovo codice prodotto",
                "auth": true,
                "params": {
                    "code": "string (required, 5-50 chars)",
                    "product_name": "string (optional)",
                    "batch_number": "string (optional)",
                    "product_size": "string (optional)",
                    "production_date": "date (optional)",
                    "notes": "text (optional)"
                }
            },
            {
                "method": "POST",
                "path": "/api/codes/batch.php",
                "description": "Crea codici in batch (max 1000)",
                "auth": true,
                "params": {
                    "codes": "array (required) - Array di oggetti codice"
                }
            }
        ],
        "statistics": [
            {
                "method": "GET",
                "path": "/api/stats/dashboard.php",
                "description": "Statistiche dashboard produttore",
                "auth": true,
                "response": {
                    "overview": "Statistiche generali",
                    "weekly_trend": "Trend ultimi 7 giorni",
                    "top_codes": "Codici più verificati",
                    "suspicious_codes": "Codici con molte verifiche",
                    "recent_alerts": "Alert antifrode recenti"
                }
            }
        ]
    },
    "authentication": {
        "type": "JWT (JSON Web Token)",
        "header": "Authorization: Bearer {token}",
        "expiry": "24 hours",
        "note": "Ottenere il token tramite /api/auth/login.php"
    },
    "rate_limiting": {
        "enabled": true,
        "public_endpoints": "100 requests/hour per IP",
        "authenticated_endpoints": "1000 requests/hour per user"
    },
    "security": {
        "https": "Raccomandato in produzione",
        "cors": "Configurabile tramite config.php",
        "input_validation": "Tutti gli input sono sanitizzati",
        "sql_injection": "Protezione via prepared statements",
        "xss": "Protezione via htmlspecialchars"
    },
    "fraud_detection": {
        "enabled": true,
        "features": [
            "Rilevamento verifiche eccessive (>38)",
            "Tracciamento geografico anomalo",
            "Pattern IP sospetti",
            "Alert automatici"
        ]
    },
    "documentation": {
        "full_docs": "https://docs.truecode.local",
        "github": "https://github.com/yourcompany/truecode",
        "support": "support@truecode.local"
    }
}