{
  "openapi": "3.1.0",
  "info": {
    "title": "API electoral de Medellín",
    "description": "Resultados históricos MMV de 2019 y 2023: Alcaldía, Concejo, Gobernación y Asamblea. Solo votos registrados en Medellín (Registraduría: departamento 01, municipio 001); sin JAL. Fuentes y huellas SHA-256 en /api/v1/fuentes. Histórico MMV oficial. El archivo no especifica la etapa; no se certifica como escrutinio definitivo. Ausencia de registro no equivale a cero votos.",
    "version": "1.0.0"
  },
  "paths": {
    "/health": {
      "get": {
        "tags": [
          "Estado"
        ],
        "summary": "Health",
        "operationId": "health_health_get",
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          }
        }
      }
    },
    "/api/v1/fuentes": {
      "get": {
        "tags": [
          "Metodología"
        ],
        "summary": "Sources",
        "operationId": "sources_api_v1_fuentes_get",
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          }
        }
      }
    },
    "/api/v1/elecciones": {
      "get": {
        "tags": [
          "Catálogos"
        ],
        "summary": "Elections",
        "operationId": "elections_api_v1_elecciones_get",
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          }
        }
      }
    },
    "/api/v1/resultados": {
      "get": {
        "tags": [
          "Resultados"
        ],
        "summary": "Results",
        "description": "Suma votos dentro del filtro. Partido suma candidatos + lista y excluye blanco/nulo/no marcado.\n\n`opcion` incluye candidatos, votos de lista y categorías especiales. `detalle` devuelve cada registro por mesa.\nLos catálogos incluyen únicamente entidades presentes en los archivos, no todos los candidatos inscritos.",
        "operationId": "results_api_v1_resultados_get",
        "parameters": [
          {
            "name": "agrupar_por",
            "in": "query",
            "required": false,
            "schema": {
              "enum": [
                "opcion",
                "partido",
                "puesto",
                "comuna",
                "mesa",
                "detalle"
              ],
              "type": "string",
              "default": "opcion",
              "title": "Agrupar Por"
            }
          },
          {
            "name": "limite",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "maximum": 1000,
              "minimum": 1,
              "default": 100,
              "title": "Limite"
            }
          },
          {
            "name": "desplazamiento",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 0,
              "default": 0,
              "title": "Desplazamiento"
            }
          },
          {
            "name": "anio",
            "in": "query",
            "required": true,
            "schema": {
              "$ref": "#/components/schemas/Year"
            }
          },
          {
            "name": "eleccion",
            "in": "query",
            "required": true,
            "schema": {
              "enum": [
                "alcaldia",
                "concejo",
                "gobernacion",
                "asamblea"
              ],
              "type": "string",
              "title": "Eleccion"
            }
          },
          {
            "name": "puesto_id",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "description": "ID del catálogo de puestos; incluye año, departamento, municipio, zona y puesto.",
              "title": "Puesto Id"
            },
            "description": "ID del catálogo de puestos; incluye año, departamento, municipio, zona y puesto."
          },
          {
            "name": "comuna_codigo",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "pattern": "^\\d{2}$"
                },
                {
                  "type": "null"
                }
              ],
              "description": "Código original MMV; 00 significa NACIONAL/sin asignación territorial específica.",
              "title": "Comuna Codigo"
            },
            "description": "Código original MMV; 00 significa NACIONAL/sin asignación territorial específica."
          },
          {
            "name": "zona",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "pattern": "^\\d{2}$"
                },
                {
                  "type": "null"
                }
              ],
              "title": "Zona"
            }
          },
          {
            "name": "mesa",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "integer",
                  "minimum": 1
                },
                {
                  "type": "null"
                }
              ],
              "title": "Mesa"
            }
          },
          {
            "name": "partido_id",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "Partido Id"
            }
          },
          {
            "name": "candidato_id",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "description": "ID devuelto por /candidatos. Es propio del año y elección.",
              "title": "Candidato Id"
            },
            "description": "ID devuelto por /candidatos. Es propio del año y elección."
          },
          {
            "name": "tipo_voto",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "enum": [
                    "candidato",
                    "lista",
                    "blanco",
                    "nulo",
                    "no_marcado"
                  ],
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "Tipo Voto"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/descargar": {
      "get": {
        "tags": [
          "Resultados"
        ],
        "summary": "Download",
        "description": "Descarga completa de una tabla agregada, con fuente y contexto de filtros.",
        "operationId": "download_api_v1_descargar_get",
        "parameters": [
          {
            "name": "agrupar_por",
            "in": "query",
            "required": false,
            "schema": {
              "enum": [
                "opcion",
                "partido",
                "puesto",
                "comuna"
              ],
              "type": "string",
              "default": "opcion",
              "title": "Agrupar Por"
            }
          },
          {
            "name": "anio",
            "in": "query",
            "required": true,
            "schema": {
              "$ref": "#/components/schemas/Year"
            }
          },
          {
            "name": "eleccion",
            "in": "query",
            "required": true,
            "schema": {
              "enum": [
                "alcaldia",
                "concejo",
                "gobernacion",
                "asamblea"
              ],
              "type": "string",
              "title": "Eleccion"
            }
          },
          {
            "name": "puesto_id",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "description": "ID del catálogo de puestos; incluye año, departamento, municipio, zona y puesto.",
              "title": "Puesto Id"
            },
            "description": "ID del catálogo de puestos; incluye año, departamento, municipio, zona y puesto."
          },
          {
            "name": "comuna_codigo",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "pattern": "^\\d{2}$"
                },
                {
                  "type": "null"
                }
              ],
              "description": "Código original MMV; 00 significa NACIONAL/sin asignación territorial específica.",
              "title": "Comuna Codigo"
            },
            "description": "Código original MMV; 00 significa NACIONAL/sin asignación territorial específica."
          },
          {
            "name": "zona",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "pattern": "^\\d{2}$"
                },
                {
                  "type": "null"
                }
              ],
              "title": "Zona"
            }
          },
          {
            "name": "mesa",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "integer",
                  "minimum": 1
                },
                {
                  "type": "null"
                }
              ],
              "title": "Mesa"
            }
          },
          {
            "name": "partido_id",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "Partido Id"
            }
          },
          {
            "name": "candidato_id",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "description": "ID devuelto por /candidatos. Es propio del año y elección.",
              "title": "Candidato Id"
            },
            "description": "ID devuelto por /candidatos. Es propio del año y elección."
          },
          {
            "name": "tipo_voto",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "enum": [
                    "candidato",
                    "lista",
                    "blanco",
                    "nulo",
                    "no_marcado"
                  ],
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "Tipo Voto"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/resumen": {
      "get": {
        "tags": [
          "Resultados"
        ],
        "summary": "Summary",
        "description": "Totales dentro del filtro, incluyendo categorías especiales. No calcula participación sin censo.\n\nVotos válidos = candidato + lista + blanco. No sumar resultados de distintas elecciones como personas únicas.",
        "operationId": "summary_api_v1_resumen_get",
        "parameters": [
          {
            "name": "anio",
            "in": "query",
            "required": true,
            "schema": {
              "$ref": "#/components/schemas/Year"
            }
          },
          {
            "name": "eleccion",
            "in": "query",
            "required": true,
            "schema": {
              "enum": [
                "alcaldia",
                "concejo",
                "gobernacion",
                "asamblea"
              ],
              "type": "string",
              "title": "Eleccion"
            }
          },
          {
            "name": "puesto_id",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "description": "ID del catálogo de puestos; incluye año, departamento, municipio, zona y puesto.",
              "title": "Puesto Id"
            },
            "description": "ID del catálogo de puestos; incluye año, departamento, municipio, zona y puesto."
          },
          {
            "name": "comuna_codigo",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "pattern": "^\\d{2}$"
                },
                {
                  "type": "null"
                }
              ],
              "description": "Código original MMV; 00 significa NACIONAL/sin asignación territorial específica.",
              "title": "Comuna Codigo"
            },
            "description": "Código original MMV; 00 significa NACIONAL/sin asignación territorial específica."
          },
          {
            "name": "zona",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "pattern": "^\\d{2}$"
                },
                {
                  "type": "null"
                }
              ],
              "title": "Zona"
            }
          },
          {
            "name": "mesa",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "integer",
                  "minimum": 1
                },
                {
                  "type": "null"
                }
              ],
              "title": "Mesa"
            }
          },
          {
            "name": "partido_id",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "Partido Id"
            }
          },
          {
            "name": "candidato_id",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "description": "ID devuelto por /candidatos. Es propio del año y elección.",
              "title": "Candidato Id"
            },
            "description": "ID devuelto por /candidatos. Es propio del año y elección."
          },
          {
            "name": "tipo_voto",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "enum": [
                    "candidato",
                    "lista",
                    "blanco",
                    "nulo",
                    "no_marcado"
                  ],
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "Tipo Voto"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/candidatos": {
      "get": {
        "tags": [
          "Catálogos"
        ],
        "summary": "Candidates",
        "operationId": "candidates_api_v1_candidatos_get",
        "parameters": [
          {
            "name": "anio",
            "in": "query",
            "required": true,
            "schema": {
              "$ref": "#/components/schemas/Year"
            }
          },
          {
            "name": "eleccion",
            "in": "query",
            "required": true,
            "schema": {
              "enum": [
                "alcaldia",
                "concejo",
                "gobernacion",
                "asamblea"
              ],
              "type": "string",
              "title": "Eleccion"
            }
          },
          {
            "name": "q",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "maxLength": 200
                },
                {
                  "type": "null"
                }
              ],
              "title": "Q"
            }
          },
          {
            "name": "partido_id",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "title": "Partido Id"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/partidos": {
      "get": {
        "tags": [
          "Catálogos"
        ],
        "summary": "Parties",
        "operationId": "parties_api_v1_partidos_get",
        "parameters": [
          {
            "name": "anio",
            "in": "query",
            "required": true,
            "schema": {
              "$ref": "#/components/schemas/Year"
            }
          },
          {
            "name": "eleccion",
            "in": "query",
            "required": true,
            "schema": {
              "enum": [
                "alcaldia",
                "concejo",
                "gobernacion",
                "asamblea"
              ],
              "type": "string",
              "title": "Eleccion"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/puestos": {
      "get": {
        "tags": [
          "Catálogos"
        ],
        "summary": "Stations",
        "operationId": "stations_api_v1_puestos_get",
        "parameters": [
          {
            "name": "anio",
            "in": "query",
            "required": true,
            "schema": {
              "$ref": "#/components/schemas/Year"
            }
          },
          {
            "name": "comuna_codigo",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "pattern": "^\\d{2}$"
                },
                {
                  "type": "null"
                }
              ],
              "title": "Comuna Codigo"
            }
          },
          {
            "name": "q",
            "in": "query",
            "required": false,
            "schema": {
              "anyOf": [
                {
                  "type": "string",
                  "maxLength": 200
                },
                {
                  "type": "null"
                }
              ],
              "title": "Q"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/comunas": {
      "get": {
        "tags": [
          "Catálogos"
        ],
        "summary": "Communes",
        "operationId": "communes_api_v1_comunas_get",
        "parameters": [
          {
            "name": "anio",
            "in": "query",
            "required": true,
            "schema": {
              "$ref": "#/components/schemas/Year"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/mesas": {
      "get": {
        "tags": [
          "Catálogos"
        ],
        "summary": "Tables",
        "operationId": "tables_api_v1_mesas_get",
        "parameters": [
          {
            "name": "anio",
            "in": "query",
            "required": true,
            "schema": {
              "$ref": "#/components/schemas/Year"
            }
          },
          {
            "name": "eleccion",
            "in": "query",
            "required": true,
            "schema": {
              "enum": [
                "alcaldia",
                "concejo",
                "gobernacion",
                "asamblea"
              ],
              "type": "string",
              "title": "Eleccion"
            }
          },
          {
            "name": "puesto_id",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "title": "Puesto Id"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "HTTPValidationError": {
        "properties": {
          "detail": {
            "items": {
              "$ref": "#/components/schemas/ValidationError"
            },
            "type": "array",
            "title": "Detail"
          }
        },
        "type": "object",
        "title": "HTTPValidationError"
      },
      "ValidationError": {
        "properties": {
          "loc": {
            "items": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "integer"
                }
              ]
            },
            "type": "array",
            "title": "Location"
          },
          "msg": {
            "type": "string",
            "title": "Message"
          },
          "type": {
            "type": "string",
            "title": "Error Type"
          },
          "input": {
            "title": "Input"
          },
          "ctx": {
            "type": "object",
            "title": "Context"
          }
        },
        "type": "object",
        "required": [
          "loc",
          "msg",
          "type"
        ],
        "title": "ValidationError"
      },
      "Year": {
        "type": "integer",
        "enum": [
          2019,
          2023
        ],
        "title": "Year"
      }
    }
  }
}