{
  "openapi": "3.0.3",
  "info": {
    "title": "Preprints.ai API",
    "description": "AI-powered quality assessment API for academic preprints. Submit any DOI, arXiv ID, bioRxiv URL, or medRxiv URL to receive a machine-generated quality grade. All assessments are indicators requiring human expert review.",
    "version": "1.1.0",
    "contact": {
      "name": "Infinite Researchers",
      "url": "https://infiniteresearchers.com"
    }
  },
  "servers": [
    { "url": "https://preprints.ai", "description": "Production" }
  ],
  "paths": {
    "/v1/assess": {
      "post": {
        "summary": "Submit a paper for assessment",
        "description": "Queue a preprint for AI quality assessment. Returns an assessment_id to poll for results.",
        "operationId": "submitAssessment",
        "tags": ["Assessment"],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["identifier"],
                "properties": {
                  "identifier": {
                    "type": "string",
                    "description": "DOI, arXiv ID, bioRxiv URL, or medRxiv URL",
                    "examples": [
                      "10.1101/2025.01.15.633214",
                      "2501.12345",
                      "https://www.biorxiv.org/content/10.1101/2025.01.15.633214"
                    ]
                  }
                }
              }
            }
          }
        },
        "responses": {
          "202": {
            "description": "Assessment queued",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "assessment_id": { "type": "string" },
                    "status": { "type": "string", "enum": ["queued", "processing"] }
                  }
                }
              }
            }
          },
          "400": { "description": "Invalid or unresolvable identifier" },
          "429": { "description": "Rate limit exceeded" }
        }
      }
    },
    "/v1/assess/{assessment_id}": {
      "get": {
        "summary": "Retrieve an assessment result",
        "description": "Fetch the result of a previously submitted assessment by its ID.",
        "operationId": "getAssessment",
        "tags": ["Assessment"],
        "parameters": [
          {
            "name": "assessment_id",
            "in": "path",
            "required": true,
            "schema": { "type": "string" }
          }
        ],
        "responses": {
          "200": {
            "description": "Assessment result",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/AssessmentResult" }
              }
            }
          },
          "202": { "description": "Assessment still processing" },
          "404": { "description": "Assessment not found" }
        }
      }
    },
    "/v1/assess/{previous_assessment_id}/reassess": {
      "post": {
        "summary": "Re-assess an updated preprint version",
        "operationId": "reassessment",
        "tags": ["Assessment"],
        "parameters": [
          {
            "name": "previous_assessment_id",
            "in": "path",
            "required": true,
            "schema": { "type": "string" }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["identifier"],
                "properties": {
                  "identifier": { "type": "string" }
                }
              }
            }
          }
        },
        "responses": {
          "202": { "description": "Re-assessment queued" }
        }
      }
    },
    "/v1/score/{identifier}": {
      "get": {
        "summary": "Look up a cached assessment by DOI or arXiv ID",
        "description": "Returns a cached assessment if previously assessed. Does not trigger a new assessment.",
        "operationId": "lookupScore",
        "tags": ["Assessment"],
        "parameters": [
          {
            "name": "identifier",
            "in": "path",
            "required": true,
            "schema": { "type": "string" },
            "description": "DOI or arXiv ID"
          }
        ],
        "responses": {
          "200": {
            "description": "Cached assessment",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/AssessmentResult" }
              }
            }
          },
          "404": { "description": "Not yet assessed — use POST /v1/assess to submit" }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "CriterionStatus": {
        "type": "string",
        "enum": ["reported", "not_reported", "not_applicable", "unknown"],
        "description": "Whether a rigor criterion was found in the paper text."
      },
      "RigorCriterion": {
        "type": "object",
        "description": "Result for a single ScreenIT rigor criterion (Eckmann et al. 2026, PLoS ONE 21(2):e0342225).",
        "properties": {
          "status": { "$ref": "#/components/schemas/CriterionStatus" },
          "evidence": {
            "type": "string",
            "nullable": true,
            "description": "Text excerpt that triggered the detection."
          },
          "section": {
            "type": "string",
            "nullable": true,
            "description": "Paper section where the evidence was found (methods, abstract, other)."
          },
          "recommendation": {
            "type": "string",
            "nullable": true,
            "description": "Actionable guidance if criterion is not_reported."
          },
          "confidence": {
            "type": "number",
            "format": "float",
            "minimum": 0,
            "maximum": 1,
            "description": "Detection confidence (0–1). Reflects published F1 benchmarks from Eckmann et al. 2026."
          },
          "tool_source": {
            "type": "string",
            "description": "Detection methodology (e.g. regex_sciScore_aligned, regex_preRob_SciScore_ensemble)."
          }
        }
      },
      "RigorCriteriaFlags": {
        "type": "object",
        "description": "Per-criterion rigor reporting flags from Layer 1 automated detection. Exposed separately from integrity_score so API consumers can apply their own sensitivity/specificity tradeoffs. Reference: Eckmann et al. (2026) PLoS ONE 21(2):e0342225.",
        "properties": {
          "blinding": {
            "allOf": [{ "$ref": "#/components/schemas/RigorCriterion" }],
            "description": "Blinding procedure reporting. Text-pattern F1≈0.89 (SciScore-aligned)."
          },
          "randomisation": {
            "allOf": [{ "$ref": "#/components/schemas/RigorCriterion" }],
            "description": "Randomisation method reporting. Text-pattern F1≈0.76 (pre-rob + SciScore ensemble)."
          },
          "power_calculation": {
            "allOf": [{ "$ref": "#/components/schemas/RigorCriterion" }],
            "description": "Power/sample size calculation reporting. Text-pattern F1≈0.79 (SciScore-aligned)."
          },
          "inclusion_exclusion": {
            "allOf": [{ "$ref": "#/components/schemas/RigorCriterion" }],
            "description": "Inclusion/exclusion criteria. Text component F1≈0.70–0.88. Flowchart-described criteria require separate image analysis."
          }
        }
      },
      "SoftwareCitationFlags": {
        "type": "object",
        "description": "Software citation quality flags. Full-paper SoftCite-aligned detection (F1≈0.87). Reference: Du et al. 2021; benchmark Eckmann et al. 2026.",
        "properties": {
          "unique_tools": {
            "type": "array",
            "items": { "type": "string" },
            "description": "Software tools detected in the paper."
          },
          "has_unversioned": {
            "type": "boolean",
            "description": "True if any tool is mentioned without a version number."
          },
          "has_uncited": {
            "type": "boolean",
            "description": "True if any tool lacks a citation, URL, or RRID."
          },
          "has_rrid": {
            "type": "boolean",
            "description": "True if any tool has an RRID (Research Resource Identifier)."
          },
          "recommendations": {
            "type": "array",
            "items": { "type": "string" },
            "description": "Actionable recommendations for improving software citation."
          }
        }
      },
      "AssessmentResult": {
        "type": "object",
        "properties": {
          "assessment_id": { "type": "string" },
          "doi": { "type": "string" },
          "grade": {
            "type": "string",
            "description": "Two-character grade: letter (A–E) + number (1–5). E.g. B4.",
            "pattern": "^[A-E][1-5]$"
          },
          "evidence_strength": {
            "type": "string",
            "enum": ["Compelling", "Convincing", "Solid", "Incomplete", "Inadequate"]
          },
          "significance": {
            "type": "string",
            "enum": ["Landmark", "Fundamental", "Important", "Valuable", "Useful"]
          },
          "integrity_score": {
            "type": "number",
            "format": "float",
            "minimum": 0,
            "maximum": 1,
            "description": "Normalised strength-of-evidence score (aggregate)"
          },
          "novelty_score": {
            "type": "number",
            "format": "float",
            "minimum": 0,
            "maximum": 1,
            "description": "Normalised significance-of-findings score (aggregate)"
          },
          "flags": {
            "type": "array",
            "items": { "type": "string" },
            "description": "Integrity flags raised by Layer 1 deterministic checks"
          },
          "rigor_criteria": {
            "allOf": [{ "$ref": "#/components/schemas/RigorCriteriaFlags" }],
            "nullable": true,
            "description": "Per-criterion rigor reporting status (ScreenIT, Eckmann et al. 2026). Null if Layer 1 was not run or study type is fully computational."
          },
          "software_citation": {
            "allOf": [{ "$ref": "#/components/schemas/SoftwareCitationFlags" }],
            "nullable": true,
            "description": "Software citation quality (SoftCite-aligned). Null if no software detected."
          },
          "confidence": {
            "type": "number",
            "format": "float",
            "minimum": 0,
            "maximum": 1
          },
          "num_reviewers": {
            "type": "integer",
            "description": "Number of AI reviewer agents that contributed"
          },
          "status": {
            "type": "string",
            "enum": ["queued", "processing", "complete", "failed", "deferred"]
          },
          "assessed_at": { "type": "string", "format": "date-time" }
        }
      }
    }
  }
}
