{
  "openapi": "3.1.0",
  "info": {
    "title": "Election Index API",
    "version": "2026-09-24.29d6dd3f",
    "description": "Neutral, sourced national election calendar with count stage windows and classified sources. Every response has meta.dataset_version.",
    "license": {
      "name": "CC BY 4.0",
      "url": "https://creativecommons.org/licenses/by/4.0/"
    }
  },
  "servers": [
    {
      "url": "https://electionindex.org"
    }
  ],
  "paths": {
    "/v1/elections": {
      "get": {
        "operationId": "listElections",
        "summary": "Elections in a date range",
        "parameters": [
          {
            "name": "country",
            "in": "query",
            "required": false,
            "description": "ISO 3166-1 alpha-2",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "from",
            "in": "query",
            "required": false,
            "description": "YYYY-MM-DD",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "to",
            "in": "query",
            "required": false,
            "description": "YYYY-MM-DD",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "status",
            "in": "query",
            "required": false,
            "description": "scheduled | counting | finalising | final-expected",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "full",
            "in": "query",
            "required": false,
            "description": "1 to include full races",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Elections",
            "content": {
              "application/json": {}
            }
          }
        }
      }
    },
    "/v1/elections/{id}": {
      "get": {
        "operationId": "getElection",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "One election",
            "content": {
              "application/json": {}
            }
          }
        }
      }
    },
    "/v1/elections/{id}/races/{race}": {
      "get": {
        "operationId": "getRace",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "race",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "One race",
            "content": {
              "application/json": {}
            }
          }
        }
      }
    },
    "/v1/elections/{id}/races/{race}/when": {
      "get": {
        "operationId": "stageWindow",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "race",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "stage",
            "in": "query",
            "required": false,
            "description": "Stage id",
            "schema": {
              "type": "string",
              "enum": [
                "exit-poll",
                "election-night",
                "media-call",
                "intermediate-count",
                "final-result",
                "court-validation",
                "government"
              ],
              "default": "final-result"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Stage window",
            "content": {
              "application/json": {}
            }
          }
        }
      }
    },
    "/v1/elections/{id}/races/{race}/sources": {
      "get": {
        "operationId": "raceSources",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "race",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "resolvable",
            "in": "query",
            "required": false,
            "description": "1 for race_results and feeds only",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Classified sources",
            "content": {
              "application/json": {}
            }
          }
        }
      }
    },
    "/v1/check": {
      "get": {
        "operationId": "checkQuestion",
        "summary": "Is a question about a stage answerable at a time?",
        "parameters": [
          {
            "name": "election",
            "in": "query",
            "required": true,
            "description": "Election id",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "race",
            "in": "query",
            "required": false,
            "description": "Race id (optional if one race)",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "stage",
            "in": "query",
            "required": false,
            "description": "Stage id",
            "schema": {
              "type": "string",
              "enum": [
                "exit-poll",
                "election-night",
                "media-call",
                "intermediate-count",
                "final-result",
                "court-validation",
                "government"
              ],
              "default": "final-result"
            }
          },
          {
            "name": "ask_at",
            "in": "query",
            "required": false,
            "description": "ISO date-time; default now",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Verdict",
            "content": {
              "application/json": {}
            }
          }
        }
      }
    },
    "/v1/authorities": {
      "get": {
        "operationId": "listAuthorities",
        "responses": {
          "200": {
            "description": "Authorities",
            "content": {
              "application/json": {}
            }
          }
        }
      }
    },
    "/v1/countries": {
      "get": {
        "operationId": "listCountries",
        "responses": {
          "200": {
            "description": "Countries",
            "content": {
              "application/json": {}
            }
          }
        }
      }
    },
    "/v1/discovered": {
      "get": {
        "operationId": "listDiscovered",
        "summary": "Found by the Scout, not verified",
        "responses": {
          "200": {
            "description": "Discovered elections",
            "content": {
              "application/json": {}
            }
          }
        }
      }
    },
    "/v1/health": {
      "get": {
        "operationId": "health",
        "responses": {
          "200": {
            "description": "Dataset health",
            "content": {
              "application/json": {}
            }
          }
        }
      }
    },
    "/v1/corrections": {
      "get": {
        "operationId": "listCorrections",
        "parameters": [
          {
            "name": "status",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "open",
                "accepted",
                "rejected",
                "duplicate"
              ]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Public log of correction reports and their outcomes",
            "content": {
              "application/json": {}
            }
          }
        }
      },
      "post": {
        "operationId": "submitCorrection",
        "description": "Report a mistake with a URL that proves it. Public; checked like any other claim; never changes the data by itself. At most 5 per hour per client.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "claim",
                  "evidence"
                ],
                "properties": {
                  "claim": {
                    "type": "string",
                    "minLength": 10,
                    "maxLength": 2000
                  },
                  "evidence": {
                    "type": "string",
                    "format": "uri"
                  },
                  "election": {
                    "type": "string"
                  },
                  "race": {
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Filed"
          },
          "400": {
            "description": "Invalid"
          },
          "429": {
            "description": "Rate limited"
          }
        }
      }
    }
  }
}