{
 "openapi": "3.1.0",
 "info": {
  "title": "API abierta de eleccionesEspaña.com",
  "version": "1.0.0",
  "description": "Datos electorales de España en JSON, de solo lectura, sin autenticación: encuestas de elecciones generales, autonómicas y municipales, calendario, noticias y fuentes. Se actualizan dos veces al día (encuestas) y cada dos horas (noticias). Cita la fuente original de cada encuesta (campo src).",
  "contact": {
   "name": "SECRA SOLUTIONS SL",
   "url": "https://xn--eleccionesespaa-crb.com/legal/aviso-legal"
  }
 },
 "servers": [
  {
   "url": "https://xn--eleccionesespaa-crb.com"
  }
 ],
 "externalDocs": {
  "url": "https://xn--eleccionesespaa-crb.com/docs/api"
 },
 "components": {
  "schemas": {
   "Poll": {
    "type": "object",
    "properties": {
     "id": {
      "type": "string"
     },
     "firm": {
      "type": "string",
      "description": "Encuestadora"
     },
     "media": {
      "type": [
       "string",
       "null"
      ],
      "description": "Medio o cliente que la encarga"
     },
     "start": {
      "type": "string",
      "format": "date"
     },
     "end": {
      "type": "string",
      "format": "date",
      "description": "Fin del trabajo de campo"
     },
     "sample": {
      "type": [
       "integer",
       "null"
      ]
     },
     "turnout": {
      "type": [
       "number",
       "null"
      ]
     },
     "lead": {
      "type": [
       "number",
       "null"
      ]
     },
     "type": {
      "type": "string",
      "enum": [
       "election"
      ],
      "description": "Solo en filas de resultados electorales de referencia"
     },
     "src": {
      "type": "string",
      "format": "uri",
      "description": "Publicación original"
     },
     "r": {
      "type": "object",
      "description": "Resultado por partido: v = % voto, s = escaños (número o [mín, máx])",
      "additionalProperties": {
       "type": "object",
       "properties": {
        "v": {
         "type": [
          "number",
          "null"
         ]
        },
        "s": {
         "oneOf": [
          {
           "type": "integer"
          },
          {
           "type": "array",
           "items": {
            "type": "integer"
           },
           "minItems": 2,
           "maxItems": 2
          }
         ]
        }
       }
      }
     }
    }
   },
   "Party": {
    "type": "object",
    "properties": {
     "id": {
      "type": "string"
     },
     "color": {
      "type": [
       "string",
       "null"
      ]
     },
     "avg": {
      "type": [
       "number",
       "null"
      ]
     }
    }
   }
  }
 },
 "paths": {
  "/data/general.json": {
   "get": {
    "summary": "Elecciones generales: fecha, partidos y todas las encuestas",
    "description": "",
    "operationId": "data_general",
    "responses": {
     "200": {
      "description": "OK",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "properties": {
          "election": {
           "type": "object"
          },
          "parties": {
           "type": "array",
           "items": {
            "$ref": "#/components/schemas/Party"
           }
          },
          "polls": {
           "type": "array",
           "items": {
            "$ref": "#/components/schemas/Poll"
           }
          },
          "updated": {
           "type": "string",
           "format": "date-time"
          }
         }
        }
       }
      }
     }
    }
   }
  },
  "/data/subnational.json": {
   "get": {
    "summary": "Encuestas de las generales por comunidad autónoma y provincia",
    "description": "",
    "operationId": "data_subnational",
    "responses": {
     "200": {
      "description": "OK",
      "content": {
       "application/json": {
        "schema": {
         "type": "object"
        }
       }
      }
     }
    }
   }
  },
  "/data/regional/index.json": {
   "get": {
    "summary": "Calendario de elecciones autonómicas con la última encuesta de cada comunidad",
    "description": "",
    "operationId": "data_regional_index",
    "responses": {
     "200": {
      "description": "OK",
      "content": {
       "application/json": {
        "schema": {
         "type": "object"
        }
       }
      }
     }
    }
   }
  },
  "/data/regional/{id}.json": {
   "get": {
    "summary": "Encuestas de las próximas elecciones de una comunidad",
    "description": "",
    "operationId": "regional_detail",
    "responses": {
     "200": {
      "description": "OK",
      "content": {
       "application/json": {
        "schema": {
         "type": "object"
        }
       }
      }
     }
    },
    "parameters": [
     {
      "name": "id",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string"
      },
      "description": "Identificador de la comunidad (p. ej. madrid, cataluna, comunidad-valenciana)"
     }
    ]
   }
  },
  "/data/municipal/index.json": {
   "get": {
    "summary": "Municipios con encuestas para las elecciones municipales",
    "description": "",
    "operationId": "data_municipal_index",
    "responses": {
     "200": {
      "description": "OK",
      "content": {
       "application/json": {
        "schema": {
         "type": "object"
        }
       }
      }
     }
    }
   }
  },
  "/data/municipal/{id}.json": {
   "get": {
    "summary": "Encuestas de un municipio",
    "description": "",
    "operationId": "municipal_detail",
    "responses": {
     "200": {
      "description": "OK",
      "content": {
       "application/json": {
        "schema": {
         "type": "object"
        }
       }
      }
     }
    },
    "parameters": [
     {
      "name": "id",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string"
      }
     }
    ]
   }
  },
  "/data/news.json": {
   "get": {
    "summary": "Noticias electorales de los últimos 14 días (titular, extracto, enlace, medio, etiquetas)",
    "description": "",
    "operationId": "data_news",
    "responses": {
     "200": {
      "description": "OK",
      "content": {
       "application/json": {
        "schema": {
         "type": "object"
        }
       }
      }
     }
    }
   }
  },
  "/data/sources.json": {
   "get": {
    "summary": "Encuestadoras, medios y periódicos utilizados",
    "description": "",
    "operationId": "data_sources",
    "responses": {
     "200": {
      "description": "OK",
      "content": {
       "application/json": {
        "schema": {
         "type": "object"
        }
       }
      }
     }
    }
   }
  },
  "/data/meta.json": {
   "get": {
    "summary": "Fecha de la última actualización y recuentos",
    "description": "",
    "operationId": "data_meta",
    "responses": {
     "200": {
      "description": "OK",
      "content": {
       "application/json": {
        "schema": {
         "type": "object"
        }
       }
      }
     }
    }
   }
  },
  "/healthz": {
   "get": {
    "summary": "Estado del servicio",
    "operationId": "health",
    "responses": {
     "200": {
      "description": "ok",
      "content": {
       "text/plain": {
        "schema": {
         "type": "string"
        }
       }
      }
     }
    }
   }
  }
 }
}