{
    "openapi": "3.1.0",
    "info": {
        "title": "Teoriprov Körkort · Offentlig information",
        "version": "1.4.0",
        "termsOfService": "https://teoriprov-korkort.se/data/#reutilisation",
        "description": "Endast läsning, utan nyckel eller kakor. Offentlig CORS-åtkomst för GET-anrop. API och MCP delar en gräns på 120 anrop per minut och IP-adress. Vid svarskod 429 ska Retry-After följas. Ett ändringsdatum innebär inte att fakta har granskats.",
        "contact": {
            "email": "contact@teoriprov-korkort.se"
        }
    },
    "security": [],
    "servers": [
        {
            "url": "https://teoriprov-korkort.se/api/v1"
        }
    ],
    "paths": {
        "/": {
            "get": {
                "operationId": "getCatalogue",
                "summary": "API-beskrivning och länkar",
                "parameters": [],
                "responses": {
                    "200": {
                        "description": "Offentligt resultat",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object"
                                }
                            }
                        }
                    },
                    "307": {
                        "description": "Följ omdirigeringen till den uppdaterade versionen på samma domän.",
                        "headers": {
                            "Location": {
                                "schema": {
                                    "type": "string",
                                    "format": "uri"
                                }
                            }
                        }
                    },
                    "400": {
                        "description": "Ogiltig begäran, okänd informationspost, nådd gräns eller otillgänglig tjänst.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "error": {
                                            "type": "object",
                                            "properties": {
                                                "code": {
                                                    "type": "string"
                                                },
                                                "message": {
                                                    "type": "string"
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    },
                    "404": {
                        "description": "Ogiltig begäran, okänd informationspost, nådd gräns eller otillgänglig tjänst.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "error": {
                                            "type": "object",
                                            "properties": {
                                                "code": {
                                                    "type": "string"
                                                },
                                                "message": {
                                                    "type": "string"
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    },
                    "405": {
                        "description": "Ogiltig begäran, okänd informationspost, nådd gräns eller otillgänglig tjänst.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "error": {
                                            "type": "object",
                                            "properties": {
                                                "code": {
                                                    "type": "string"
                                                },
                                                "message": {
                                                    "type": "string"
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    },
                    "429": {
                        "description": "Ogiltig begäran, okänd informationspost, nådd gräns eller otillgänglig tjänst.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "error": {
                                            "type": "object",
                                            "properties": {
                                                "code": {
                                                    "type": "string"
                                                },
                                                "message": {
                                                    "type": "string"
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        },
                        "headers": {
                            "Retry-After": {
                                "description": "Antal sekunder att vänta före ett nytt försök.",
                                "schema": {
                                    "type": "integer",
                                    "minimum": 1,
                                    "maximum": 60
                                }
                            }
                        }
                    },
                    "503": {
                        "description": "Ogiltig begäran, okänd informationspost, nådd gräns eller otillgänglig tjänst.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "error": {
                                            "type": "object",
                                            "properties": {
                                                "code": {
                                                    "type": "string"
                                                },
                                                "message": {
                                                    "type": "string"
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        },
        "/facts": {
            "get": {
                "operationId": "searchFacts",
                "summary": "Sök bland offentliga informationsposter",
                "parameters": [
                    {
                        "name": "q",
                        "in": "query",
                        "description": "Ord att söka efter i titeln, innehållet eller referenserna. Diakritiska tecken ignoreras. Alla betydelsebärande ord måste finnas med.",
                        "schema": {
                            "type": "string",
                            "maxLength": 300
                        }
                    },
                    {
                        "name": "region",
                        "in": "query",
                        "description": "Området som anges i informationsposten. Officiella regler och lektioner är märkta med ”Sverige”.",
                        "schema": {
                            "type": "string",
                            "enum": [
                                "sverige"
                            ]
                        }
                    },
                    {
                        "name": "kind",
                        "in": "query",
                        "schema": {
                            "type": "string",
                            "enum": [
                                "fact",
                                "expertise",
                                "organization",
                                "offer",
                                "person",
                                "article",
                                "lesson",
                                "page",
                                "tool"
                            ]
                        }
                    },
                    {
                        "name": "limit",
                        "in": "query",
                        "schema": {
                            "type": "integer",
                            "minimum": 1,
                            "maximum": 50,
                            "default": 10
                        }
                    },
                    {
                        "name": "offset",
                        "in": "query",
                        "schema": {
                            "type": "integer",
                            "minimum": 0,
                            "maximum": 10000,
                            "default": 0
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Offentligt resultat",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "required": [
                                        "results",
                                        "total",
                                        "limit",
                                        "offset"
                                    ],
                                    "properties": {
                                        "results": {
                                            "type": "array",
                                            "items": {
                                                "$ref": "#/components/schemas/Fact"
                                            }
                                        },
                                        "total": {
                                            "type": "integer"
                                        },
                                        "limit": {
                                            "type": "integer"
                                        },
                                        "offset": {
                                            "type": "integer"
                                        }
                                    }
                                }
                            }
                        }
                    },
                    "307": {
                        "description": "Följ omdirigeringen till den uppdaterade versionen på samma domän.",
                        "headers": {
                            "Location": {
                                "schema": {
                                    "type": "string",
                                    "format": "uri"
                                }
                            }
                        }
                    },
                    "400": {
                        "description": "Ogiltig begäran, okänd informationspost, nådd gräns eller otillgänglig tjänst.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "error": {
                                            "type": "object",
                                            "properties": {
                                                "code": {
                                                    "type": "string"
                                                },
                                                "message": {
                                                    "type": "string"
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    },
                    "404": {
                        "description": "Ogiltig begäran, okänd informationspost, nådd gräns eller otillgänglig tjänst.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "error": {
                                            "type": "object",
                                            "properties": {
                                                "code": {
                                                    "type": "string"
                                                },
                                                "message": {
                                                    "type": "string"
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    },
                    "405": {
                        "description": "Ogiltig begäran, okänd informationspost, nådd gräns eller otillgänglig tjänst.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "error": {
                                            "type": "object",
                                            "properties": {
                                                "code": {
                                                    "type": "string"
                                                },
                                                "message": {
                                                    "type": "string"
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    },
                    "429": {
                        "description": "Ogiltig begäran, okänd informationspost, nådd gräns eller otillgänglig tjänst.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "error": {
                                            "type": "object",
                                            "properties": {
                                                "code": {
                                                    "type": "string"
                                                },
                                                "message": {
                                                    "type": "string"
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        },
                        "headers": {
                            "Retry-After": {
                                "description": "Antal sekunder att vänta före ett nytt försök.",
                                "schema": {
                                    "type": "integer",
                                    "minimum": 1,
                                    "maximum": 60
                                }
                            }
                        }
                    },
                    "503": {
                        "description": "Ogiltig begäran, okänd informationspost, nådd gräns eller otillgänglig tjänst.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "error": {
                                            "type": "object",
                                            "properties": {
                                                "code": {
                                                    "type": "string"
                                                },
                                                "message": {
                                                    "type": "string"
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        },
        "/facts/{id}": {
            "get": {
                "operationId": "getFact",
                "summary": "Läs en informationspost med dess ursprung",
                "parameters": [
                    {
                        "name": "id",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "string",
                            "pattern": "^(?:(?:expertise-)?fait|page|brand|offer|person)-[a-f0-9]{16}$"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Offentligt resultat",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Fact"
                                }
                            }
                        }
                    },
                    "307": {
                        "description": "Följ omdirigeringen till den uppdaterade versionen på samma domän.",
                        "headers": {
                            "Location": {
                                "schema": {
                                    "type": "string",
                                    "format": "uri"
                                }
                            }
                        }
                    },
                    "400": {
                        "description": "Ogiltig begäran, okänd informationspost, nådd gräns eller otillgänglig tjänst.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "error": {
                                            "type": "object",
                                            "properties": {
                                                "code": {
                                                    "type": "string"
                                                },
                                                "message": {
                                                    "type": "string"
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    },
                    "404": {
                        "description": "Ogiltig begäran, okänd informationspost, nådd gräns eller otillgänglig tjänst.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "error": {
                                            "type": "object",
                                            "properties": {
                                                "code": {
                                                    "type": "string"
                                                },
                                                "message": {
                                                    "type": "string"
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    },
                    "405": {
                        "description": "Ogiltig begäran, okänd informationspost, nådd gräns eller otillgänglig tjänst.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "error": {
                                            "type": "object",
                                            "properties": {
                                                "code": {
                                                    "type": "string"
                                                },
                                                "message": {
                                                    "type": "string"
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    },
                    "429": {
                        "description": "Ogiltig begäran, okänd informationspost, nådd gräns eller otillgänglig tjänst.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "error": {
                                            "type": "object",
                                            "properties": {
                                                "code": {
                                                    "type": "string"
                                                },
                                                "message": {
                                                    "type": "string"
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        },
                        "headers": {
                            "Retry-After": {
                                "description": "Antal sekunder att vänta före ett nytt försök.",
                                "schema": {
                                    "type": "integer",
                                    "minimum": 1,
                                    "maximum": 60
                                }
                            }
                        }
                    },
                    "503": {
                        "description": "Ogiltig begäran, okänd informationspost, nådd gräns eller otillgänglig tjänst.",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "error": {
                                            "type": "object",
                                            "properties": {
                                                "code": {
                                                    "type": "string"
                                                },
                                                "message": {
                                                    "type": "string"
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    },
    "components": {
        "schemas": {
            "Fact": {
                "type": "object",
                "required": [
                    "id",
                    "kind",
                    "title",
                    "text",
                    "url",
                    "regions",
                    "sources"
                ],
                "properties": {
                    "id": {
                        "type": "string",
                        "pattern": "^(?:(?:expertise-)?fait|page|brand|offer|person)-[a-f0-9]{16}$"
                    },
                    "kind": {
                        "type": "string",
                        "enum": [
                            "fact",
                            "expertise",
                            "organization",
                            "offer",
                            "person",
                            "article",
                            "lesson",
                            "page",
                            "tool"
                        ]
                    },
                    "title": {
                        "type": "string"
                    },
                    "text": {
                        "type": "string"
                    },
                    "description": {
                        "type": "string"
                    },
                    "url": {
                        "type": "string",
                        "format": "uri"
                    },
                    "regions": {
                        "type": "array",
                        "items": {
                            "type": "string"
                        }
                    },
                    "verified_at": {
                        "type": "string",
                        "format": "date"
                    },
                    "effective_from": {
                        "type": "string",
                        "format": "date"
                    },
                    "modified_at": {
                        "type": "string"
                    },
                    "evidence_kind": {
                        "type": "string",
                        "enum": [
                            "product",
                            "method",
                            "declaration",
                            "analysis"
                        ]
                    },
                    "verification_scope": {
                        "type": "string"
                    },
                    "bibliography": {
                        "type": "array",
                        "description": "Källhänvisningar i lektionstexten.",
                        "items": {
                            "type": "string"
                        }
                    },
                    "chapter": {
                        "type": "object",
                        "description": "Kapitlet som lektionen tillhör.",
                        "properties": {
                            "number": {
                                "type": "integer"
                            },
                            "title": {
                                "type": "string"
                            }
                        }
                    },
                    "image": {
                        "type": "string",
                        "format": "uri",
                        "description": "Lektionens bild: videons miniatyrbild eller, om den saknas, den första bilden i innehållet."
                    },
                    "video": {
                        "type": "object",
                        "description": "YouTube-video som visas i lektionen, med värden från dess strukturerade data. Utan transkription.",
                        "properties": {
                            "youtube_id": {
                                "type": "string"
                            },
                            "title": {
                                "type": "string"
                            },
                            "description": {
                                "type": "string"
                            },
                            "url": {
                                "type": "string",
                                "format": "uri"
                            },
                            "embed_url": {
                                "type": "string",
                                "format": "uri"
                            },
                            "thumbnail_url": {
                                "type": "string",
                                "format": "uri"
                            },
                            "duration": {
                                "type": "string"
                            },
                            "duration_seconds": {
                                "type": "integer"
                            },
                            "upload_date": {
                                "type": "string"
                            },
                            "chapters": {
                                "type": "array",
                                "items": {
                                    "type": "object",
                                    "properties": {
                                        "start_seconds": {
                                            "type": "integer"
                                        },
                                        "title": {
                                            "type": "string"
                                        },
                                        "url": {
                                            "type": "string",
                                            "format": "uri"
                                        }
                                    }
                                }
                            }
                        }
                    },
                    "organization_data": {
                        "type": "object"
                    },
                    "person_data": {
                        "type": "object"
                    },
                    "offer_data": {
                        "type": "object"
                    },
                    "sources": {
                        "type": "array",
                        "items": {
                            "type": "object",
                            "required": [
                                "url",
                                "label",
                                "type"
                            ],
                            "properties": {
                                "url": {
                                    "type": "string",
                                    "format": "uri"
                                },
                                "label": {
                                    "type": "string"
                                },
                                "type": {
                                    "type": "string",
                                    "enum": [
                                        "official",
                                        "operator",
                                        "brand",
                                        "source"
                                    ]
                                }
                            }
                        }
                    }
                }
            }
        }
    },
    "externalDocs": {
        "url": "https://teoriprov-korkort.se/data/api/"
    }
}