{
  "openapi": "3.1.0",
  "info": {
    "title": "Avioverse EASA library API",
    "version": "1.0.0",
    "description": "Read-only access to the Avioverse public library: the EASA regulations with the official reference on every rule, its AMC and GM, EASA definitions, and citation-verified implementation guides. Every answer carries the page URL to cite. No key is needed. Reproduced from the EASA Easy Access Rules for convenience. Not the official publication — verify against the Official Journal of the European Union and the EASA publications before operational use. Informational only: decisions, approvals and sign-off stay with accountable people.",
    "termsOfService": "https://avioverse.aero/legal/terms",
    "contact": {
      "name": "Avioverse",
      "url": "https://avioverse.aero/contact"
    }
  },
  "servers": [
    {
      "url": "https://avioverse.aero"
    }
  ],
  "externalDocs": {
    "description": "Map of the site for assistants",
    "url": "https://avioverse.aero/llms.txt"
  },
  "paths": {
    "/api/v1/regulations": {
      "get": {
        "operationId": "listRegulations",
        "summary": "List the regulations",
        "description": "List the EASA regulations in the library with their official reference, the EAR revision date the text reproduces, and the `regulation` value to pass to `get_rule`.",
        "responses": {
          "200": {
            "description": "The regulations",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "regulations": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Regulation"
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/search": {
      "get": {
        "operationId": "searchLibrary",
        "summary": "Search the library",
        "description": "Search EASA rules, EASA definitions, implementation guides, articles and the Metis manual by reference or by words. Returns matching pages with their URLs. A rule reference such as 145.A.30 ranks exact matches first.",
        "parameters": [
          {
            "name": "q",
            "in": "query",
            "required": true,
            "description": "Words or a rule reference",
            "schema": {
              "type": "string",
              "minLength": 2,
              "maxLength": 200
            }
          },
          {
            "name": "type",
            "in": "query",
            "description": "Comma-separated result types to include",
            "schema": {
              "type": "string",
              "example": "rule,guide"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 50,
              "default": 10
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Matching pages, best first",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "query": {
                      "type": "string"
                    },
                    "results": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/SearchResult"
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "A parameter is missing or out of range",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/rules/{reference}": {
      "get": {
        "operationId": "getRule",
        "summary": "Get an EASA rule by reference",
        "description": "Return an EASA rule by its reference (for example 145.A.30(e), CAMO.A.305, ORO.GEN.200, FCL.010) with its text, AMC and GM, the regulation, the EAR revision date and the page URL. A rule published point by point lists its points to request next. If several regulations use the reference (such as Article 2), the matches are listed: pass `regulation` to choose one.",
        "parameters": [
          {
            "name": "reference",
            "in": "path",
            "required": true,
            "description": "URL-encoded rule reference",
            "schema": {
              "type": "string"
            },
            "example": "145.A.30(e)"
          },
          {
            "name": "regulation",
            "in": "query",
            "description": "Regulation slug, when several regulations use the reference",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The rule",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Rule"
                }
              }
            }
          },
          "300": {
            "description": "Several regulations use this reference",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "$ref": "#/components/schemas/ErrorDetail"
                    },
                    "matches": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/RuleSummary"
                      }
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "No rule has this reference",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/glossary/{term}": {
      "get": {
        "operationId": "lookupTerm",
        "summary": "Look up a definition",
        "description": "Return how EASA defines a term, quoted verbatim with the regulation and article it comes from, plus the entry from the general aviation glossary when there is one.",
        "parameters": [
          {
            "name": "term",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "example": "error management"
          }
        ],
        "responses": {
          "200": {
            "description": "The definitions",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Term"
                }
              }
            }
          },
          "404": {
            "description": "No definition for this term",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "Regulation": {
        "type": "object",
        "required": [
          "slug",
          "title",
          "officialRef",
          "earRevision",
          "url"
        ],
        "properties": {
          "slug": {
            "type": "string",
            "description": "Value for the `regulation` parameter"
          },
          "title": {
            "type": "string"
          },
          "officialRef": {
            "type": "string",
            "description": "For example: Regulation (EU) No 1321/2014"
          },
          "earRevision": {
            "type": "string",
            "description": "Date of the EASA Easy Access Rules revision the text reproduces (YYYY-MM-DD)"
          },
          "domain": {
            "type": "string"
          },
          "url": {
            "type": "string"
          }
        }
      },
      "RuleSummary": {
        "type": "object",
        "required": [
          "title",
          "role",
          "regulation",
          "url",
          "markdownUrl"
        ],
        "properties": {
          "reference": {
            "type": [
              "string",
              "null"
            ],
            "description": "For example: 145.A.30(e)"
          },
          "title": {
            "type": "string"
          },
          "role": {
            "type": "string",
            "enum": [
              "IR",
              "AMC",
              "GM",
              "APPENDIX"
            ]
          },
          "regulation": {
            "$ref": "#/components/schemas/Regulation"
          },
          "url": {
            "type": "string",
            "description": "The page to cite"
          },
          "markdownUrl": {
            "type": "string",
            "description": "The same page as Markdown"
          }
        }
      },
      "Rule": {
        "allOf": [
          {
            "$ref": "#/components/schemas/RuleSummary"
          },
          {
            "type": "object",
            "required": [
              "text",
              "subPoints",
              "notice"
            ],
            "properties": {
              "text": {
                "type": "string",
                "description": "The rule with its AMC and GM, as Markdown"
              },
              "subPoints": {
                "type": "array",
                "description": "Points of this rule that have their own page",
                "items": {
                  "type": "object",
                  "properties": {
                    "reference": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "title": {
                      "type": "string"
                    },
                    "url": {
                      "type": "string"
                    }
                  }
                }
              },
              "notice": {
                "type": "string"
              }
            }
          }
        ]
      },
      "SearchResult": {
        "type": "object",
        "required": [
          "type",
          "path",
          "title",
          "context",
          "url",
          "markdownUrl"
        ],
        "properties": {
          "type": {
            "type": "string",
            "enum": [
              "rule",
              "term",
              "guide",
              "article",
              "doc"
            ]
          },
          "path": {
            "type": "string"
          },
          "title": {
            "type": "string"
          },
          "context": {
            "type": "string"
          },
          "reference": {
            "type": "string"
          },
          "url": {
            "type": "string",
            "description": "The page to cite"
          },
          "markdownUrl": {
            "type": "string",
            "description": "The same page as Markdown"
          }
        }
      },
      "Term": {
        "type": "object",
        "required": [
          "term",
          "definitions",
          "glossary"
        ],
        "properties": {
          "term": {
            "type": "string"
          },
          "url": {
            "type": [
              "string",
              "null"
            ]
          },
          "definitions": {
            "type": "array",
            "description": "EASA definitions, verbatim",
            "items": {
              "type": "object",
              "properties": {
                "text": {
                  "type": "string"
                },
                "source": {
                  "type": "string",
                  "description": "Article or rule"
                },
                "regulation": {
                  "type": "string"
                },
                "officialRef": {
                  "type": "string"
                },
                "earRevision": {
                  "type": "string"
                },
                "url": {
                  "type": "string"
                }
              }
            }
          },
          "glossary": {
            "type": "array",
            "description": "General aviation glossary entries",
            "items": {
              "type": "object",
              "properties": {
                "definition": {
                  "type": "string"
                },
                "source": {
                  "type": "string"
                },
                "sourceUrl": {
                  "type": "string"
                }
              }
            }
          }
        }
      },
      "ErrorDetail": {
        "type": "object",
        "required": [
          "code",
          "message"
        ],
        "properties": {
          "code": {
            "type": "string"
          },
          "message": {
            "type": "string"
          }
        }
      },
      "Error": {
        "type": "object",
        "required": [
          "error"
        ],
        "properties": {
          "error": {
            "$ref": "#/components/schemas/ErrorDetail"
          }
        }
      }
    }
  }
}
