{
  "openapi": "3.1.0",
  "jsonSchemaDialect": "https://spec.openapis.org/oas/3.1/dialect/base",
  "info": {
    "title": "Akashic U.S. Elections Public API",
    "version": "1.7.0",
    "summary": "Read-only public REST endpoints and MCP server discovery for 2000–2026 U.S. election analytics.",
    "description": "Programmatic read-only API for Akashic (akashic.app). Serves 2000–2026 U.S. Presidential, House, Senate, Governor, and special election results computed strictly over total valid candidate votes, alongside Adjusted MAR candidate performance, CVAP Reach, 6,775 modeled SLDU/SLDL districts, 10,192 cities, Political Twins, spatial Albers equal-area projections, and printable OpenGraph PNG cards.",
    "contact": {
      "name": "Akashic Intelligence",
      "email": "hello@akashic.app",
      "url": "https://akashic.app/support"
    },
    "x-mcp-endpoint": "https://akashic.app/mcp",
    "x-mcp-server-card": "https://akashic.app/.well-known/mcp/server-card.json",
    "x-llms-txt": "https://akashic.app/llms.txt"
  },
  "servers": [
    {
      "url": "https://akashic.app",
      "description": "Akashic Production API"
    }
  ],
  "externalDocs": {
    "description": "Akashic API & MCP Developer Portal",
    "url": "https://akashic.app/developers"
  },
  "security": [],
  "tags": [
    {
      "name": "Datasets",
      "description": "Filtered CSV and JSON exports across 19 election and demographic tables."
    },
    {
      "name": "Lookup",
      "description": "ZIP, city, county, district, candidate, and place discovery."
    },
    {
      "name": "Comparisons",
      "description": "Cycle-to-cycle election swings, ecological WLS attribution, and timelines."
    },
    {
      "name": "Spatial",
      "description": "Albers equal-area polygon and site-radius election projections."
    },
    {
      "name": "Status & Media",
      "description": "Live canvass health, OpenGraph PNG cards, and Markdown representations."
    }
  ],
  "paths": {
    "/api/datasets/export": {
      "get": {
        "operationId": "exportDataset",
        "tags": [
          "Datasets"
        ],
        "summary": "Export filtered Akashic dataset rows in JSON or CSV",
        "description": "Queries any of 19 public Akashic election, candidate edge, CVAP reach, legislative baseline, metro/DMA/city, or state-context datasets. Preserves valid-candidate-votes shares and Observed vs. Modeled provenance.",
        "parameters": [
          {
            "name": "dataset",
            "in": "query",
            "required": true,
            "description": "Dataset identifier to export.",
            "schema": {
              "type": "string",
              "enum": [
                "metros-cbsa",
                "media-markets-dma",
                "csa-metros",
                "american-nations",
                "cities-index",
                "communities-cohorts",
                "sld-summary",
                "sld-districts",
                "sld-officeholders-summary",
                "ideology-119th",
                "watchlists-2027-2028",
                "precinct-swing-coverage-2026",
                "state-executives",
                "county-migration-reg",
                "primaries-2026-geo",
                "historical-state-office-atlas",
                "edge",
                "reach",
                "election"
              ]
            },
            "example": "edge"
          },
          {
            "name": "format",
            "in": "query",
            "required": false,
            "description": "Output serialization format.",
            "schema": {
              "type": "string",
              "enum": [
                "json",
                "csv"
              ],
              "default": "json"
            }
          },
          {
            "name": "state",
            "in": "query",
            "required": false,
            "description": "Two-letter U.S. state or DC postal abbreviation (required for sld-districts).",
            "schema": {
              "type": "string",
              "pattern": "^[A-Za-z]{2}$"
            },
            "example": "TX"
          },
          {
            "name": "year",
            "in": "query",
            "required": false,
            "description": "Election cycle year (2000–2026) when dataset is 'election'.",
            "schema": {
              "type": "integer",
              "minimum": 2000,
              "maximum": 2026
            },
            "example": 2026
          },
          {
            "name": "office",
            "in": "query",
            "required": false,
            "description": "Office filter when dataset is 'election', 'edge', or 'reach'.",
            "schema": {
              "type": "string",
              "enum": [
                "president",
                "house",
                "senate",
                "governor",
                "all"
              ]
            },
            "example": "house"
          },
          {
            "name": "chamber",
            "in": "query",
            "required": false,
            "description": "Legislative chamber filter for sld-districts.",
            "schema": {
              "type": "string",
              "enum": [
                "upper",
                "lower"
              ]
            }
          },
          {
            "name": "minPop",
            "in": "query",
            "required": false,
            "description": "Minimum Census population threshold for place datasets.",
            "schema": {
              "type": "integer",
              "minimum": 0
            }
          },
          {
            "name": "q",
            "in": "query",
            "required": false,
            "description": "Case-insensitive substring search across names, codes, or districts.",
            "schema": {
              "type": "string",
              "maxLength": 120
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "description": "Maximum rows to return (1–5000).",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 5000,
              "default": 250
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Filtered JSON bundle with provenance metadata or downloadable CSV file.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": true
                }
              },
              "text/csv": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "400": {
            "description": "Structured JSON error response with error code and documentation hint.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "404": {
            "description": "Structured JSON error response with error code and documentation hint.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "500": {
            "description": "Structured JSON error response with error code and documentation hint.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      }
    },
    "/api/profile/lookup": {
      "get": {
        "operationId": "lookupPoliticalProfile",
        "tags": [
          "Lookup"
        ],
        "summary": "Resolve a ZIP code, city, county, or congressional district to its political profile",
        "description": "Maps any 5-digit U.S. ZIP code, Census city, county, CD120 district, or state into overlapping 2026 U.S. House contests, 2024 Presidential baseline, CBSA/DMA/American Nation stack, and modeled Political Twins.",
        "parameters": [
          {
            "name": "q",
            "in": "query",
            "required": true,
            "description": "5-digit ZIP code, city/state, county, CD code (e.g. TX-34), or state name.",
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 120
            },
            "example": "78701"
          }
        ],
        "responses": {
          "200": {
            "description": "Resolved geographic profile, district results, community stack, and Political Twins.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "ok"
                  ],
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    },
                    "resolvedKind": {
                      "type": "string"
                    },
                    "title": {
                      "type": "string"
                    }
                  },
                  "additionalProperties": true
                }
              }
            }
          },
          "400": {
            "description": "Structured JSON error response with error code and documentation hint.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "404": {
            "description": "Structured JSON error response with error code and documentation hint.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      }
    },
    "/api/search/jump": {
      "get": {
        "operationId": "searchEntities",
        "tags": [
          "Lookup"
        ],
        "summary": "Autocomplete search across Akashic races, candidates, and places",
        "description": "Returns matching candidate dossiers, 2000–2026 contests, and geographic places for a query string.",
        "parameters": [
          {
            "name": "q",
            "in": "query",
            "required": true,
            "description": "Search prefix or keyword (at least 2 characters).",
            "schema": {
              "type": "string",
              "minLength": 2,
              "maxLength": 80
            },
            "example": "Austin"
          }
        ],
        "responses": {
          "200": {
            "description": "Matching candidates, races, and places arrays.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "query": {
                      "type": "string"
                    },
                    "candidates": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "additionalProperties": true
                      }
                    },
                    "races": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "additionalProperties": true
                      }
                    },
                    "places": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "additionalProperties": true
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/compare/elections": {
      "get": {
        "operationId": "compareElections",
        "tags": [
          "Comparisons"
        ],
        "summary": "Compare two U.S. elections across states, counties, or districts",
        "description": "Computes unit-by-unit valid-vote D–R swings, flips, turnout shifts, and ecological WLS demographic swing attribution between any two election cycles.",
        "parameters": [
          {
            "name": "yearA",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 2000,
              "maximum": 2026
            },
            "example": 2026
          },
          {
            "name": "officeA",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "example": "governor"
          },
          {
            "name": "yearB",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 2000,
              "maximum": 2026
            },
            "example": 2024
          },
          {
            "name": "officeB",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "example": "president"
          },
          {
            "name": "subGeoLevel",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "state",
                "county",
                "cd"
              ],
              "default": "state"
            }
          },
          {
            "name": "stateFilter",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "pattern": "^[A-Za-z]{2}$"
            }
          },
          {
            "name": "excludeRedistricted",
            "in": "query",
            "required": false,
            "schema": {
              "type": "boolean",
              "default": false
            }
          },
          {
            "name": "weightMode",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "valid_votes",
                "cvap"
              ],
              "default": "valid_votes"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Swing comparison summary, unit movers, and WLS attribution diagnostics.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": true
                }
              }
            }
          },
          "400": {
            "description": "Structured JSON error response with error code and documentation hint.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "404": {
            "description": "Structured JSON error response with error code and documentation hint.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      }
    },
    "/api/compare/place": {
      "get": {
        "operationId": "comparePlaceHistory",
        "tags": [
          "Comparisons"
        ],
        "summary": "Inspect 2000–2026 multi-cycle election history for a single geography",
        "description": "Returns 2000–2026 Presidential, House, Senate, Governor, and special election timelines plus migration and voter registration context for a state, county, or district.",
        "parameters": [
          {
            "name": "q",
            "in": "query",
            "required": true,
            "description": "State abbreviation, county name/FIPS, or congressional district code (e.g. TX-09).",
            "schema": {
              "type": "string",
              "minLength": 2,
              "maxLength": 120
            },
            "example": "TX-09"
          },
          {
            "name": "offices",
            "in": "query",
            "required": false,
            "description": "Comma-separated office list.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "includeSpecials",
            "in": "query",
            "required": false,
            "schema": {
              "type": "boolean",
              "default": true
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Geography election trajectory across covered cycles.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": true
                }
              }
            }
          },
          "400": {
            "description": "Structured JSON error response with error code and documentation hint.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "404": {
            "description": "Structured JSON error response with error code and documentation hint.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      }
    },
    "/api/live/status": {
      "get": {
        "operationId": "getLiveCanvassStatus",
        "tags": [
          "Status & Media"
        ],
        "summary": "Read live 2026 certification and uncalled-contest canvass health",
        "description": "Returns state certification counts (0–51), active live monitor status, uncalled contest count, and remaining-ballot hurdle previews.",
        "responses": {
          "200": {
            "description": "Live canvass certification and uncalled race summary.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "ok",
                    "certifiedStates",
                    "totalStates",
                    "uncalledCount"
                  ],
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    },
                    "status": {
                      "type": "string"
                    },
                    "certifiedStates": {
                      "type": "integer"
                    },
                    "totalStates": {
                      "type": "integer"
                    },
                    "uncalledCount": {
                      "type": "integer"
                    },
                    "snapshotDate": {
                      "type": "string"
                    }
                  },
                  "additionalProperties": true
                }
              }
            }
          },
          "500": {
            "description": "Structured JSON error response with error code and documentation hint.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      }
    },
    "/api/spatial/project": {
      "post": {
        "operationId": "projectSpatialFootprint",
        "tags": [
          "Spatial"
        ],
        "summary": "Project a GeoJSON polygon, site radius, or FIPS/CD list onto 2020–2026 baselines",
        "description": "Reaggregates 2020–2026 Presidential, Senate, Governor, and 2026 House valid-vote totals plus CVAP demographics using Albers equal-area spatial weights.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "label": {
                    "type": "string",
                    "maxLength": 120
                  },
                  "geojson": {
                    "type": "object",
                    "additionalProperties": true
                  },
                  "center": {
                    "type": "object",
                    "properties": {
                      "lat": {
                        "type": "number",
                        "minimum": 18,
                        "maximum": 72
                      },
                      "lon": {
                        "type": "number",
                        "minimum": -179,
                        "maximum": -65
                      },
                      "radiusKm": {
                        "type": "number",
                        "minimum": 1,
                        "maximum": 500
                      }
                    }
                  },
                  "unitIds": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    },
                    "maxItems": 250
                  },
                  "theme": {
                    "type": "string",
                    "enum": [
                      "dark",
                      "light"
                    ]
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Modeled valid-vote election projection and intersecting counties/CDs.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": true
                }
              }
            }
          },
          "400": {
            "description": "Structured JSON error response with error code and documentation hint.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "413": {
            "description": "Structured JSON error response with error code and documentation hint.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          },
          "429": {
            "description": "Structured JSON error response with error code and documentation hint.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      }
    },
    "/api/og": {
      "get": {
        "operationId": "renderOgCard",
        "tags": [
          "Status & Media"
        ],
        "summary": "Render a 1200x630 PNG OpenGraph summary card",
        "description": "Generates cached OpenGraph PNG graphics for Akashic hubs, states, races, candidates, legislatures, and places.",
        "parameters": [
          {
            "name": "kind",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "home",
                "edge",
                "reach",
                "race",
                "candidate",
                "state",
                "legislature",
                "place",
                "hub"
              ],
              "default": "home"
            }
          },
          {
            "name": "slug",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "year",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "office",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "placeKind",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "theme",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "dark",
                "light"
              ],
              "default": "dark"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "1200x630 PNG social card image.",
            "content": {
              "image/png": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              }
            }
          },
          "400": {
            "description": "Structured JSON error response with error code and documentation hint.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiError"
                }
              }
            }
          }
        }
      }
    },
    "/api/markdown": {
      "get": {
        "operationId": "renderPageMarkdown",
        "tags": [
          "Status & Media"
        ],
        "summary": "Fetch clean Markdown representation for an Akashic route",
        "description": "Backs HTTP Accept: text/markdown negotiation across all core pages, races, candidates, states, places, and blog posts.",
        "parameters": [
          {
            "name": "path",
            "in": "query",
            "required": false,
            "description": "Site path starting with '/' (defaults to '/').",
            "schema": {
              "type": "string",
              "default": "/"
            },
            "example": "/edge"
          }
        ],
        "responses": {
          "200": {
            "description": "Citation-ready Markdown body.",
            "content": {
              "text/markdown": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "404": {
            "description": "Agent-friendly Markdown 404 guide.",
            "content": {
              "text/markdown": {
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "ApiError": {
        "type": "object",
        "required": [
          "error"
        ],
        "properties": {
          "ok": {
            "type": "boolean",
            "enum": [
              false
            ]
          },
          "error": {
            "oneOf": [
              {
                "type": "string"
              },
              {
                "type": "object",
                "required": [
                  "code",
                  "message"
                ],
                "properties": {
                  "code": {
                    "type": "string"
                  },
                  "status": {
                    "type": "integer"
                  },
                  "message": {
                    "type": "string"
                  },
                  "hint": {
                    "type": "string"
                  },
                  "docsUrl": {
                    "type": "string",
                    "format": "uri"
                  },
                  "openApiUrl": {
                    "type": "string",
                    "format": "uri"
                  }
                }
              }
            ]
          }
        }
      }
    }
  }
}