{
  "openapi": "3.1.0",
  "info": {
    "title": "QuéVidrio API",
    "version": "1.0.0",
    "summary": "Qué celulares comparten el mismo vidrio templado (API pública de solo lectura).",
    "description": "API pública, gratuita y de solo lectura, sin autenticación. Las respuestas están en español. Las equivalencias verificadas (`matches`) tienen nivel de confianza y fuente; los `dimension_candidates` NO están verificados (`verified: false`) y no deben presentarse como compatibles. Uso: búsqueda y respuestas con enlace a quevidrio.com. El conjunto de datos no se licencia para entrenar modelos (robots.txt: Content-Signal ai-train=no).",
    "contact": {
      "url": "https://www.quevidrio.com/metodologia"
    }
  },
  "servers": [
    {
      "url": "https://www.quevidrio.com"
    }
  ],
  "externalDocs": {
    "url": "https://www.quevidrio.com/metodologia#api",
    "description": "Metodología y documentación"
  },
  "paths": {
    "/api/buscar.json": {
      "get": {
        "operationId": "buscarCelular",
        "summary": "Buscar celulares por nombre",
        "parameters": [
          {
            "name": "q",
            "in": "query",
            "required": true,
            "description": "Modelo a buscar (tolera abreviaturas: \"a15\", \"redmi note 13\").",
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 80
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 20,
              "default": 10
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Resultados, mejor coincidencia primero",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "query",
                    "results"
                  ],
                  "properties": {
                    "query": {
                      "type": "string"
                    },
                    "results": {
                      "type": "array",
                      "items": {
                        "allOf": [
                          {
                            "$ref": "#/components/schemas/PhoneRef"
                          },
                          {
                            "type": "object",
                            "properties": {
                              "uuid": {
                                "type": "string",
                                "format": "uuid",
                                "description": "Identificador estable del celular (el mismo de la API de la comunidad)"
                              },
                              "glass_count": {
                                "type": "integer",
                                "description": "Modelos verificados que comparten su vidrio"
                              },
                              "url": {
                                "type": "string",
                                "format": "uri"
                              },
                              "api_url": {
                                "type": "string",
                                "format": "uri"
                              }
                            }
                          }
                        ]
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "status": {
                          "type": "integer"
                        },
                        "message": {
                          "type": "string"
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/vidrio/{canonical_id}.json": {
      "get": {
        "operationId": "vidrioCompatible",
        "summary": "Modelos que comparten el vidrio templado de un celular",
        "parameters": [
          {
            "name": "canonical_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^[a-z0-9][a-z0-9-]*$"
            },
            "examples": {
              "a15": {
                "value": "samsung-galaxy-a15"
              }
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Equivalencias verificadas y candidatos sin verificar",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GlassPayload"
                }
              }
            }
          },
          "404": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "status": {
                          "type": "integer"
                        },
                        "message": {
                          "type": "string"
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/estado.json": {
      "get": {
        "operationId": "estado",
        "summary": "Estado del servicio y fecha de los datos",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "string",
                      "enum": [
                        "ok"
                      ]
                    },
                    "generated_at": {
                      "type": "string",
                      "format": "date-time"
                    },
                    "phones": {
                      "type": "integer"
                    },
                    "glass_pairs": {
                      "type": "integer"
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "PhoneRef": {
        "type": "object",
        "required": [
          "canonical_id",
          "name",
          "brand",
          "brand_name"
        ],
        "properties": {
          "canonical_id": {
            "type": "string",
            "examples": [
              "samsung-galaxy-a15"
            ]
          },
          "name": {
            "type": "string",
            "examples": [
              "Samsung Galaxy A15"
            ]
          },
          "brand": {
            "type": "string",
            "examples": [
              "samsung"
            ]
          },
          "brand_name": {
            "type": "string",
            "examples": [
              "Samsung"
            ]
          }
        }
      },
      "Match": {
        "allOf": [
          {
            "$ref": "#/components/schemas/PhoneRef"
          },
          {
            "type": "object",
            "required": [
              "verified",
              "confidence",
              "sources",
              "url"
            ],
            "properties": {
              "verified": {
                "const": true
              },
              "confidence": {
                "type": "string",
                "enum": [
                  "confirmado",
                  "probable",
                  "reportado"
                ]
              },
              "confidence_label": {
                "type": "string",
                "enum": [
                  "Confirmado",
                  "Probable",
                  "Reportado"
                ]
              },
              "rating": {
                "type": [
                  "number",
                  "null"
                ],
                "description": "Valoración media de la comunidad (1–5)"
              },
              "votes": {
                "type": [
                  "integer",
                  "null"
                ]
              },
              "sources": {
                "type": "object",
                "properties": {
                  "manufacturers": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    },
                    "examples": [
                      [
                        "mietubl"
                      ]
                    ]
                  },
                  "community": {
                    "type": "boolean"
                  },
                  "text": {
                    "type": "string"
                  }
                }
              },
              "delta": {
                "type": "object",
                "description": "Diferencia (otro − este) del cuerpo en mm y de la pantalla en pulgadas",
                "properties": {
                  "height_mm": {
                    "type": [
                      "number",
                      "null"
                    ]
                  },
                  "width_mm": {
                    "type": [
                      "number",
                      "null"
                    ]
                  },
                  "screen_in": {
                    "type": [
                      "number",
                      "null"
                    ]
                  }
                }
              },
              "url": {
                "type": "string",
                "format": "uri"
              },
              "comparison_url": {
                "type": "string",
                "format": "uri"
              },
              "api_url": {
                "type": "string",
                "format": "uri"
              }
            }
          }
        ]
      },
      "DimensionCandidate": {
        "allOf": [
          {
            "$ref": "#/components/schemas/PhoneRef"
          },
          {
            "type": "object",
            "required": [
              "verified",
              "status"
            ],
            "description": "Mide casi lo mismo. NO verificado: no es una compatibilidad.",
            "properties": {
              "verified": {
                "const": false
              },
              "status": {
                "const": "sin_verificar"
              },
              "delta": {
                "type": "object",
                "properties": {
                  "height_mm": {
                    "type": "number"
                  },
                  "width_mm": {
                    "type": "number"
                  },
                  "screen_in": {
                    "type": "number"
                  }
                }
              },
              "url": {
                "type": "string",
                "format": "uri"
              },
              "api_url": {
                "type": "string",
                "format": "uri"
              }
            }
          }
        ]
      },
      "GlassPayload": {
        "type": "object",
        "required": [
          "phone",
          "matches",
          "dimension_candidates",
          "meta"
        ],
        "properties": {
          "phone": {
            "allOf": [
              {
                "$ref": "#/components/schemas/PhoneRef"
              },
              {
                "type": "object",
                "properties": {
                  "dimensions": {
                    "type": "object",
                    "properties": {
                      "height_mm": {
                        "type": [
                          "number",
                          "null"
                        ]
                      },
                      "width_mm": {
                        "type": [
                          "number",
                          "null"
                        ]
                      },
                      "depth_mm": {
                        "type": [
                          "number",
                          "null"
                        ]
                      },
                      "screen_in": {
                        "type": [
                          "number",
                          "null"
                        ]
                      }
                    }
                  },
                  "urls": {
                    "type": "object",
                    "properties": {
                      "glass_page": {
                        "type": "string",
                        "format": "uri"
                      },
                      "specs_page": {
                        "type": "string",
                        "format": "uri"
                      },
                      "api": {
                        "type": "string",
                        "format": "uri"
                      }
                    }
                  }
                }
              }
            ]
          },
          "matches_count": {
            "type": "integer"
          },
          "matches": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Match"
            }
          },
          "dimension_candidates": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/DimensionCandidate"
            }
          },
          "notes": {
            "type": "object",
            "properties": {
              "caveat": {
                "type": "string"
              },
              "dimension_candidates": {
                "type": "string"
              }
            }
          },
          "meta": {
            "type": "object",
            "properties": {
              "api_version": {
                "type": "string"
              },
              "generated_at": {
                "type": "string",
                "format": "date-time"
              },
              "methodology_url": {
                "type": "string",
                "format": "uri"
              },
              "confidence_levels": {
                "type": "object",
                "additionalProperties": {
                  "type": "string"
                }
              },
              "language": {
                "const": "es"
              }
            }
          }
        }
      }
    }
  }
}