{
  "openapi": "3.1.0",
  "info": {
    "title": "QualeAI API",
    "version": "1.0.0",
    "description": "API pubblica read-only del catalogo QualeAI: ricerca, schede, confronti e raccomandazioni di tool AI. Dati editoriali in italiano, con giudizi e classifiche non influenzati da annunci o commissioni affiliate.",
    "contact": {
      "name": "QualeAI",
      "url": "https://www.qualeai.it",
      "email": "info@qualeai.it"
    },
    "license": {
      "name": "All rights reserved",
      "url": "https://www.qualeai.it/privacy"
    }
  },
  "servers": [
    {
      "url": "https://www.qualeai.it",
      "description": "Production"
    }
  ],
  "externalDocs": {
    "description": "Documentazione per agenti AI (llms.txt)",
    "url": "https://www.qualeai.it/llms.txt"
  },
  "tags": [
    {
      "name": "tools",
      "description": "Catalogo tool AI"
    },
    {
      "name": "compare",
      "description": "Confronti editoriali tra tool"
    },
    {
      "name": "recommend",
      "description": "Raccomandazioni in base al caso d'uso"
    }
  ],
  "paths": {
    "/api/tools": {
      "get": {
        "tags": [
          "tools"
        ],
        "summary": "Cerca tool nel catalogo",
        "description": "Ricerca con filtri esatti (categoria, pricing, difficulty) e full-text query opzionale. Risultati ordinati per rilevanza se q presente, altrimenti per nome.",
        "parameters": [
          {
            "name": "q",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "Full-text query su nome, tagline, descrizione, useCases, strengths."
          },
          {
            "name": "category",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "Categoria singola o lista comma-separated.",
            "examples": {
              "single": {
                "value": "coding"
              },
              "multiple": {
                "value": "writing,research"
              }
            }
          },
          {
            "name": "pricing",
            "in": "query",
            "schema": {
              "$ref": "#/components/schemas/Pricing"
            }
          },
          {
            "name": "difficulty",
            "in": "query",
            "schema": {
              "$ref": "#/components/schemas/Difficulty"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 20
            }
          },
          {
            "name": "offset",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 0,
              "default": 0
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Risultati ricerca",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ToolSearchResponse"
                }
              }
            }
          },
          "400": {
            "description": "Parametri non validi",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/api/tools/{id}": {
      "get": {
        "tags": [
          "tools"
        ],
        "summary": "Scheda completa di un tool",
        "description": "Restituisce tutti i dati strutturati del tool richiesto.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Identificatore stabile del tool (es. \"chatgpt\", \"claude\")."
          }
        ],
        "responses": {
          "200": {
            "description": "Tool trovato",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ToolDetail"
                }
              }
            },
            "headers": {
              "Link": {
                "description": "Rappresentazioni alternative (Markdown e HTML).",
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "404": {
            "description": "Tool non trovato",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/api/compare/{slug}": {
      "get": {
        "tags": [
          "compare"
        ],
        "summary": "Confronto editoriale tra due tool",
        "description": "Lo slug deve essere in ordine alfabetico canonico (es. chatgpt-vs-claude, non claude-vs-chatgpt).",
        "parameters": [
          {
            "name": "slug",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^[a-z0-9-]+-vs-[a-z0-9-]+$"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Confronto trovato",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Comparison"
                }
              }
            }
          },
          "404": {
            "description": "Slug invalido o confronto editoriale non disponibile",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/api/recommend": {
      "post": {
        "tags": [
          "recommend"
        ],
        "summary": "Raccomandazione tool basata su goal",
        "description": "Match tra goal in linguaggio naturale e use-case curate. Filtri opzionali su budget e difficulty.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/RecommendRequest"
              },
              "examples": {
                "emailWriting": {
                  "value": {
                    "goal": "scrivere email professionali",
                    "budget": "freemium",
                    "difficulty": "facile"
                  }
                },
                "videoEditing": {
                  "value": {
                    "goal": "creare video con avatar AI",
                    "budget": "any"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Raccomandazione generata",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RecommendResponse"
                }
              }
            }
          },
          "400": {
            "description": "Body non valido",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Nessun tool corrisponde al goal e ai filtri",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "Pricing": {
        "type": "string",
        "enum": [
          "free",
          "freemium",
          "paid"
        ]
      },
      "Difficulty": {
        "type": "string",
        "enum": [
          "facile",
          "medio",
          "avanzato"
        ]
      },
      "Category": {
        "type": "string",
        "enum": [
          "coding",
          "writing",
          "images",
          "video",
          "research",
          "chat",
          "audio",
          "data",
          "productivity"
        ]
      },
      "ToolSummary": {
        "type": "object",
        "required": [
          "id",
          "name",
          "tagline",
          "categories",
          "pricing",
          "difficulty",
          "url",
          "qualeAiUrl",
          "markdownUrl",
          "apiUrl"
        ],
        "properties": {
          "id": {
            "type": "string",
            "description": "Identificatore stabile (es. \"chatgpt\")."
          },
          "name": {
            "type": "string"
          },
          "tagline": {
            "type": "string"
          },
          "categories": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Category"
            }
          },
          "pricing": {
            "$ref": "#/components/schemas/Pricing"
          },
          "difficulty": {
            "$ref": "#/components/schemas/Difficulty"
          },
          "url": {
            "type": "string",
            "format": "uri",
            "description": "URL ufficiale del tool."
          },
          "qualeAiUrl": {
            "type": "string",
            "format": "uri",
            "description": "Pagina HTML su QualeAI."
          },
          "markdownUrl": {
            "type": "string",
            "format": "uri",
            "description": "Versione Markdown della scheda."
          },
          "apiUrl": {
            "type": "string",
            "format": "uri",
            "description": "Endpoint JSON di questa scheda."
          }
        }
      },
      "ToolDetail": {
        "allOf": [
          {
            "$ref": "#/components/schemas/ToolSummary"
          },
          {
            "type": "object",
            "required": [
              "description",
              "longDescription",
              "strengths",
              "bestFor",
              "pros",
              "cons",
              "useCases",
              "pricingDetails"
            ],
            "properties": {
              "description": {
                "type": "string"
              },
              "longDescription": {
                "type": "string"
              },
              "strengths": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "bestFor": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "pros": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "cons": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "useCases": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "pricingDetails": {
                "type": "object",
                "required": [
                  "pro"
                ],
                "properties": {
                  "free": {
                    "type": "string"
                  },
                  "pro": {
                    "type": "string"
                  }
                }
              },
              "pricingUrl": {
                "type": "string",
                "format": "uri"
              },
              "pricingCheckedAt": {
                "type": "string",
                "format": "date"
              },
              "privacy": {
                "type": "object",
                "properties": {
                  "dataProcessing": {
                    "type": "string",
                    "enum": [
                      "EU",
                      "USA",
                      "Cina",
                      "globale"
                    ]
                  },
                  "gdprCompliant": {
                    "type": "boolean"
                  },
                  "canOptOutTraining": {
                    "type": "boolean"
                  }
                }
              },
              "benchmarks": {
                "type": "object",
                "properties": {
                  "arena": {
                    "type": "object",
                    "properties": {
                      "rank": {
                        "type": "integer"
                      },
                      "totalModels": {
                        "type": "integer"
                      },
                      "date": {
                        "type": "string"
                      }
                    }
                  },
                  "sweBench": {
                    "type": "object",
                    "properties": {
                      "score": {
                        "type": "number"
                      },
                      "date": {
                        "type": "string"
                      }
                    }
                  }
                }
              }
            }
          }
        ]
      },
      "ToolSearchResponse": {
        "type": "object",
        "required": [
          "total",
          "limit",
          "offset",
          "filters",
          "results"
        ],
        "properties": {
          "total": {
            "type": "integer"
          },
          "limit": {
            "type": "integer"
          },
          "offset": {
            "type": "integer"
          },
          "filters": {
            "type": "object",
            "properties": {
              "q": {
                "type": "string",
                "nullable": true
              },
              "categories": {
                "type": "array",
                "nullable": true,
                "items": {
                  "$ref": "#/components/schemas/Category"
                }
              },
              "pricing": {
                "allOf": [
                  {
                    "$ref": "#/components/schemas/Pricing"
                  }
                ],
                "nullable": true
              },
              "difficulty": {
                "allOf": [
                  {
                    "$ref": "#/components/schemas/Difficulty"
                  }
                ],
                "nullable": true
              }
            }
          },
          "results": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ToolSummary"
            }
          }
        }
      },
      "Comparison": {
        "type": "object",
        "required": [
          "slug",
          "tool1",
          "tool2",
          "tool1WinsFor",
          "tool2WinsFor",
          "qualeAiUrl",
          "markdownUrl"
        ],
        "properties": {
          "slug": {
            "type": "string"
          },
          "tool1": {
            "$ref": "#/components/schemas/ToolSummary"
          },
          "tool2": {
            "$ref": "#/components/schemas/ToolSummary"
          },
          "intro": {
            "type": "string"
          },
          "tool1WinsFor": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "tool2WinsFor": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "qualeAiUrl": {
            "type": "string",
            "format": "uri"
          },
          "markdownUrl": {
            "type": "string",
            "format": "uri"
          }
        }
      },
      "RecommendRequest": {
        "type": "object",
        "required": [
          "goal"
        ],
        "properties": {
          "goal": {
            "type": "string",
            "maxLength": 500,
            "description": "Cosa vuoi fare, in linguaggio naturale italiano."
          },
          "budget": {
            "type": "string",
            "enum": [
              "free",
              "freemium",
              "any"
            ],
            "default": "any"
          },
          "difficulty": {
            "type": "string",
            "enum": [
              "facile",
              "medio",
              "avanzato",
              "any"
            ],
            "default": "any"
          }
        }
      },
      "RecommendResponse": {
        "type": "object",
        "required": [
          "recommended",
          "alternatives",
          "matchedUseCase",
          "reasoning"
        ],
        "properties": {
          "recommended": {
            "$ref": "#/components/schemas/ToolDetail"
          },
          "alternatives": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ToolDetail"
            }
          },
          "matchedUseCase": {
            "type": "object",
            "nullable": true,
            "properties": {
              "slug": {
                "type": "string"
              },
              "name": {
                "type": "string"
              }
            }
          },
          "reasoning": {
            "type": "string"
          }
        }
      },
      "ErrorResponse": {
        "type": "object",
        "required": [
          "error"
        ],
        "properties": {
          "error": {
            "type": "object",
            "required": [
              "code",
              "message"
            ],
            "properties": {
              "code": {
                "type": "string"
              },
              "message": {
                "type": "string"
              },
              "details": {}
            }
          }
        }
      }
    }
  }
}