{
    "openapi": "3.1.0",
    "info": {
        "title": "MyPolitics Civic API",
        "version": "1.1.0",
        "description": "Arizona-first public candidate research. No scores, rankings, verified position assertions, or complete personalized ballots. Public beta; no uptime or freshness SLA."
    },
    "servers": [
        {
            "url": "https://mypolitics.vote"
        }
    ],
    "paths": {
        "/api/v1/": {
            "get": {
                "operationId": "queryCivicData",
                "summary": "Read Arizona candidate research and evidence",
                "description": "Start with coverage. Use candidates/races/topics to discover IDs. candidate, evidence and research require id. research returns paginated reviewed candidate-source records and a profile object (ReviewedProfile) or null. Research schema 1.1.0 adds cited biography and issue summaries, separate from quiz records; each claim carries source dates and context regardless of source pagination. Historical research versions remain supported. compare requires ids; changes accepts since. String filters are exact except q (case-insensitive substring). No authentication or personal data is accepted.",
                "parameters": [
                    {
                        "name": "resource",
                        "in": "query",
                        "required": false,
                        "schema": {
                            "type": "string",
                            "enum": [
                                "coverage",
                                "candidates",
                                "candidate",
                                "topics",
                                "races",
                                "evidence",
                                "research",
                                "compare",
                                "changes"
                            ],
                            "default": "coverage"
                        }
                    },
                    {
                        "name": "state",
                        "in": "query",
                        "required": false,
                        "schema": {
                            "type": "string",
                            "enum": [
                                "AZ"
                            ],
                            "default": "AZ"
                        }
                    },
                    {
                        "name": "election",
                        "in": "query",
                        "required": false,
                        "schema": {
                            "type": "string",
                            "enum": [
                                "2026-general"
                            ],
                            "default": "2026-general"
                        }
                    },
                    {
                        "name": "q",
                        "in": "query",
                        "required": false,
                        "schema": {
                            "type": "string",
                            "maxLength": 250
                        }
                    },
                    {
                        "name": "office",
                        "in": "query",
                        "required": false,
                        "schema": {
                            "type": "string",
                            "maxLength": 250
                        }
                    },
                    {
                        "name": "district",
                        "in": "query",
                        "required": false,
                        "schema": {
                            "type": "string",
                            "maxLength": 250
                        }
                    },
                    {
                        "name": "id",
                        "in": "query",
                        "required": false,
                        "schema": {
                            "type": "string",
                            "maxLength": 250
                        }
                    },
                    {
                        "name": "ids",
                        "in": "query",
                        "required": false,
                        "schema": {
                            "type": "string",
                            "description": "2 to 4 distinct comma-separated candidate IDs, all from one race."
                        }
                    },
                    {
                        "name": "topic",
                        "in": "query",
                        "required": false,
                        "schema": {
                            "type": "string",
                            "maxLength": 250
                        }
                    },
                    {
                        "name": "since",
                        "in": "query",
                        "required": false,
                        "schema": {
                            "type": "string",
                            "pattern": "^[0-9]+$",
                            "default": "0"
                        }
                    },
                    {
                        "name": "version",
                        "in": "query",
                        "required": false,
                        "schema": {
                            "type": "string",
                            "pattern": "^[a-f0-9]{24}$",
                            "description": "Optional immutable snapshot version."
                        }
                    },
                    {
                        "name": "limit",
                        "in": "query",
                        "required": false,
                        "schema": {
                            "type": "integer",
                            "minimum": 1,
                            "maximum": 100,
                            "default": 20
                        }
                    },
                    {
                        "name": "offset",
                        "in": "query",
                        "required": false,
                        "schema": {
                            "type": "integer",
                            "minimum": 0,
                            "maximum": 100000,
                            "default": 0
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Public data and explicit coverage metadata. resource=candidate includes evidence; candidates lists summaries; compare returns equal-topic source references; changes returns observation cursors.",
                        "headers": {
                            "ETag": {
                                "schema": {
                                    "type": "string"
                                }
                            },
                            "RateLimit-Limit": {
                                "schema": {
                                    "type": "integer"
                                }
                            },
                            "RateLimit-Remaining": {
                                "schema": {
                                    "type": "integer"
                                }
                            },
                            "RateLimit-Reset": {
                                "schema": {
                                    "type": "integer"
                                }
                            }
                        },
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Envelope"
                                }
                            }
                        }
                    },
                    "304": {
                        "description": "Unchanged representation"
                    },
                    "400": {
                        "description": "Invalid request",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    },
                    "404": {
                        "description": "Record not found",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    },
                    "405": {
                        "description": "Read-only endpoint",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    },
                    "422": {
                        "description": "Unsupported coverage or incompatible comparison",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    },
                    "429": {
                        "description": "Request quota exceeded; Retry-After gives seconds",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    },
                    "503": {
                        "description": "Dataset unavailable",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Error"
                                }
                            }
                        }
                    }
                }
            }
        }
    },
    "components": {
        "schemas": {
            "Evidence": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                    "id",
                    "candidate_id",
                    "topic_id",
                    "source_url",
                    "source_kind",
                    "status",
                    "published_at",
                    "reviewed_at",
                    "excerpt",
                    "note",
                    "url"
                ],
                "properties": {
                    "id": {
                        "type": "string",
                        "maxLength": 250
                    },
                    "candidate_id": {
                        "type": "string",
                        "maxLength": 250
                    },
                    "topic_id": {
                        "type": "string",
                        "maxLength": 250
                    },
                    "source_url": {
                        "type": "string",
                        "format": "uri"
                    },
                    "source_kind": {
                        "type": "string",
                        "enum": [
                            "candidate_research",
                            "party_baseline"
                        ]
                    },
                    "status": {
                        "const": "source_link_only"
                    },
                    "published_at": {
                        "type": [
                            "string",
                            "null"
                        ]
                    },
                    "reviewed_at": {
                        "type": [
                            "string",
                            "null"
                        ]
                    },
                    "excerpt": {
                        "type": [
                            "string",
                            "null"
                        ]
                    },
                    "note": {
                        "type": "string"
                    },
                    "url": {
                        "type": "string",
                        "format": "uri"
                    }
                }
            },
            "ResearchSource": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                    "id",
                    "url",
                    "kind",
                    "review_status",
                    "publication_date",
                    "reviewed_at",
                    "election_context",
                    "summary",
                    "topics",
                    "limitations",
                    "content_status"
                ],
                "properties": {
                    "id": {
                        "type": "string",
                        "maxLength": 250
                    },
                    "url": {
                        "type": "string",
                        "format": "uri"
                    },
                    "kind": {
                        "type": "string",
                        "maxLength": 250
                    },
                    "review_status": {
                        "type": "string",
                        "maxLength": 250
                    },
                    "publication_date": {
                        "type": [
                            "string",
                            "null"
                        ],
                        "format": "date"
                    },
                    "reviewed_at": {
                        "type": [
                            "string",
                            "null"
                        ],
                        "format": "date"
                    },
                    "election_context": {
                        "type": [
                            "string",
                            "null"
                        ]
                    },
                    "summary": {
                        "type": [
                            "string",
                            "null"
                        ]
                    },
                    "topics": {
                        "type": "array",
                        "items": {
                            "type": "string",
                            "maxLength": 250
                        }
                    },
                    "limitations": {
                        "type": "string",
                        "maxLength": 250
                    },
                    "content_status": {
                        "type": "string",
                        "enum": [
                            "reviewed_source",
                            "historical_source",
                            "provisional_source",
                            "nonresponse"
                        ]
                    }
                }
            },
            "ReviewedProfile": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                    "biography",
                    "positions",
                    "limitations"
                ],
                "properties": {
                    "biography": {
                        "type": "array",
                        "items": {
                            "$ref": "#/components/schemas/ProfileClaim"
                        }
                    },
                    "positions": {
                        "type": "array",
                        "items": {
                            "$ref": "#/components/schemas/ProfileClaim"
                        }
                    },
                    "limitations": {
                        "type": "string"
                    }
                }
            },
            "ProfileClaim": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                    "id",
                    "title",
                    "summary",
                    "context",
                    "reviewed_at",
                    "sources"
                ],
                "properties": {
                    "id": {
                        "type": "string",
                        "maxLength": 250
                    },
                    "title": {
                        "type": "string",
                        "maxLength": 250
                    },
                    "summary": {
                        "type": "string"
                    },
                    "context": {
                        "type": "string",
                        "enum": [
                            "current",
                            "historical",
                            "background"
                        ]
                    },
                    "reviewed_at": {
                        "type": "string",
                        "format": "date"
                    },
                    "sources": {
                        "type": "array",
                        "minItems": 1,
                        "items": {
                            "$ref": "#/components/schemas/ProfileCitation"
                        }
                    }
                }
            },
            "ProfileCitation": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                    "id",
                    "url",
                    "publication_date",
                    "reviewed_at",
                    "election_context"
                ],
                "properties": {
                    "id": {
                        "type": "string",
                        "maxLength": 250
                    },
                    "url": {
                        "type": "string",
                        "format": "uri"
                    },
                    "publication_date": {
                        "type": [
                            "string",
                            "null"
                        ],
                        "format": "date"
                    },
                    "reviewed_at": {
                        "type": [
                            "string",
                            "null"
                        ],
                        "format": "date"
                    },
                    "election_context": {
                        "type": [
                            "string",
                            "null"
                        ]
                    }
                }
            },
            "Candidate": {
                "type": "object",
                "required": [
                    "id",
                    "name",
                    "state",
                    "election",
                    "office",
                    "district",
                    "race_id",
                    "url"
                ],
                "properties": {
                    "id": {
                        "type": "string",
                        "maxLength": 250
                    },
                    "name": {
                        "type": "string",
                        "maxLength": 250
                    },
                    "state": {
                        "const": "AZ"
                    },
                    "election": {
                        "const": "2026-general"
                    },
                    "office": {
                        "type": "string",
                        "maxLength": 250
                    },
                    "district": {
                        "type": [
                            "string",
                            "null"
                        ]
                    },
                    "party": {
                        "type": [
                            "string",
                            "null"
                        ]
                    },
                    "website": {
                        "type": [
                            "string",
                            "null"
                        ],
                        "format": "uri"
                    },
                    "photo_url": {
                        "type": [
                            "string",
                            "null"
                        ],
                        "format": "uri",
                        "description": "Public portrait URL from the candidate directory. Null when unknown. URL presence is not a rights or freshness guarantee. Added in 1.1.0."
                    },
                    "official_source_url": {
                        "type": [
                            "string",
                            "null"
                        ],
                        "format": "uri"
                    },
                    "roster_status": {
                        "const": "active_in_project_directory"
                    },
                    "roster_reviewed_at": {
                        "type": [
                            "string",
                            "null"
                        ]
                    },
                    "race_id": {
                        "type": "string",
                        "maxLength": 250
                    },
                    "url": {
                        "type": "string",
                        "format": "uri"
                    },
                    "evidence": {
                        "type": "array",
                        "items": {
                            "$ref": "#/components/schemas/Evidence"
                        }
                    }
                }
            },
            "Envelope": {
                "type": "object",
                "required": [
                    "schema_version",
                    "dataset_version",
                    "snapshot_at",
                    "coverage",
                    "data"
                ],
                "properties": {
                    "schema_version": {
                        "type": "string"
                    },
                    "dataset_version": {
                        "type": "string"
                    },
                    "snapshot_at": {
                        "type": "string"
                    },
                    "coverage": {
                        "type": "object"
                    },
                    "data": {
                        "type": "object"
                    },
                    "attribution": {
                        "type": "string"
                    }
                }
            },
            "Error": {
                "type": "object",
                "required": [
                    "error"
                ],
                "properties": {
                    "error": {
                        "type": "object",
                        "required": [
                            "code",
                            "message"
                        ],
                        "properties": {
                            "code": {
                                "type": "string"
                            },
                            "message": {
                                "type": "string"
                            }
                        }
                    }
                }
            }
        }
    }
}
