{
  "openapi": "3.1.0",
  "info": {
    "title": "doi2bbt API",
    "version": "1.0.0",
    "description": "Resolve DOI, PMID, PMCID, and modern arXiv identifiers to BibTeX with a frozen Better BibTeX-style base key.",
    "license": {
      "name": "MIT",
      "identifier": "MIT"
    }
  },
  "servers": [
    {
      "url": "https://doi2bbt.org"
    }
  ],
  "paths": {
    "/api/v1/resolve": {
      "get": {
        "summary": "Resolve an identifier to structured citation data",
        "operationId": "resolveCitation",
        "parameters": [
          {
            "name": "id",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "maxLength": 512
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Resolved citation",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ResolvedCitation"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Problem"
          },
          "404": {
            "$ref": "#/components/responses/Problem"
          },
          "422": {
            "$ref": "#/components/responses/Problem"
          },
          "429": {
            "$ref": "#/components/responses/Problem"
          },
          "502": {
            "$ref": "#/components/responses/Problem"
          },
          "504": {
            "$ref": "#/components/responses/Problem"
          }
        }
      }
    },
    "/api/v1/bibtex": {
      "get": {
        "summary": "Resolve an identifier to raw BibTeX",
        "operationId": "resolveBibtex",
        "parameters": [
          {
            "name": "id",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "maxLength": 512
            }
          }
        ],
        "responses": {
          "200": {
            "description": "BibTeX with a Better BibTeX-style key",
            "content": {
              "application/x-bibtex": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Problem"
          },
          "404": {
            "$ref": "#/components/responses/Problem"
          },
          "422": {
            "$ref": "#/components/responses/Problem"
          },
          "429": {
            "$ref": "#/components/responses/Problem"
          },
          "502": {
            "$ref": "#/components/responses/Problem"
          },
          "504": {
            "$ref": "#/components/responses/Problem"
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "ResolvedCitation": {
        "type": "object",
        "required": [
          "input",
          "input_type",
          "normalized_id",
          "doi",
          "citation_key",
          "bibtex",
          "source_url",
          "key_algorithm"
        ],
        "properties": {
          "input": {
            "type": "string"
          },
          "input_type": {
            "enum": [
              "doi",
              "pmid",
              "pmcid",
              "arxiv"
            ]
          },
          "normalized_id": {
            "type": "string"
          },
          "doi": {
            "type": "string"
          },
          "citation_key": {
            "type": "string"
          },
          "bibtex": {
            "type": "string"
          },
          "source_url": {
            "type": "string",
            "format": "uri"
          },
          "key_algorithm": {
            "type": "object",
            "properties": {
              "id": {
                "const": "bbt-default-v1"
              },
              "formula": {
                "const": "auth.lower + shorttitle(3,3) + year"
              },
              "collision_suffixes": {
                "const": false
              }
            }
          }
        }
      },
      "Problem": {
        "type": "object",
        "required": [
          "type",
          "title",
          "status",
          "detail"
        ],
        "properties": {
          "type": {
            "type": "string",
            "format": "uri"
          },
          "title": {
            "type": "string"
          },
          "status": {
            "type": "integer"
          },
          "detail": {
            "type": "string"
          },
          "instance": {
            "type": "string"
          }
        }
      }
    },
    "responses": {
      "Problem": {
        "description": "Problem details",
        "content": {
          "application/problem+json": {
            "schema": {
              "$ref": "#/components/schemas/Problem"
            }
          }
        }
      }
    }
  }
}