{
  "openapi": "3.1.0",
  "info": {
    "title": "Drug Landscape Public API",
    "version": "1.0.0",
    "description": "Open, machine-readable pharma intelligence. 156,000+ drugs, 915 companies, 61 disease areas, 480,000+ clinical trials. Use this API to power LLM agents, drug-discovery tools, and clinical research workflows.",
    "contact": { "name": "Drug Landscape", "url": "https://druglandscape.com", "email": "hello@druglandscape.com" },
    "license": { "name": "Public read; cite as 'Drug Landscape (druglandscape.com)'" }
  },
  "servers": [
    { "url": "https://druglandscape.com", "description": "Production" }
  ],
  "tags": [
    { "name": "drugs", "description": "Drug profiles" },
    { "name": "diseases", "description": "Disease landscapes" },
    { "name": "companies", "description": "Pharma company profiles" },
    { "name": "trials", "description": "Clinical trials" },
    { "name": "search", "description": "Search and discovery" }
  ],
  "paths": {
    "/api/drug/{slug}": {
      "get": {
        "tags": ["drugs"],
        "summary": "Get a drug profile (JSON)",
        "description": "Full drug profile including brand/generic names, mechanism, indications, safety, clinical trials, patents, pricing, and revenue. Slugs accept brand name, generic name, or development code (e.g. 'keytruda', 'pembrolizumab', 'mk-3475' all resolve to the same drug).",
        "parameters": [
          { "name": "slug", "in": "path", "required": true, "schema": { "type": "string" }, "example": "keytruda" }
        ],
        "responses": {
          "200": { "description": "Drug profile", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Drug" } } } },
          "404": { "description": "Drug not found" }
        }
      }
    },
    "/api/drug/{slug}.md": {
      "get": {
        "tags": ["drugs"],
        "summary": "Get a drug profile as plain markdown (best for LLM ingestion)",
        "parameters": [
          { "name": "slug", "in": "path", "required": true, "schema": { "type": "string" }, "example": "keytruda" }
        ],
        "responses": {
          "200": { "description": "Markdown profile", "content": { "text/markdown": { "schema": { "type": "string" } } } }
        }
      }
    },
    "/api/disease/{slug}": {
      "get": {
        "tags": ["diseases"],
        "summary": "Get a disease landscape (JSON)",
        "description": "Full disease landscape: name, subtypes, epidemiology, diagnostic tests, treatment lines, approved drugs, pipeline drugs, clinical guidelines.",
        "parameters": [
          { "name": "slug", "in": "path", "required": true, "schema": { "type": "string" }, "example": "breast-cancer" }
        ],
        "responses": {
          "200": { "description": "Disease landscape" }
        }
      }
    },
    "/api/disease/{slug}.md": {
      "get": {
        "tags": ["diseases"],
        "summary": "Disease landscape as markdown",
        "parameters": [
          { "name": "slug", "in": "path", "required": true, "schema": { "type": "string" } }
        ],
        "responses": { "200": { "description": "Markdown landscape" } }
      }
    },
    "/api/company/{slug}": {
      "get": {
        "tags": ["companies"],
        "summary": "Get a company profile",
        "parameters": [
          { "name": "slug", "in": "path", "required": true, "schema": { "type": "string" }, "example": "pfizer" }
        ],
        "responses": { "200": { "description": "Company profile" } }
      }
    },
    "/api/trial/{nctId}": {
      "get": {
        "tags": ["trials"],
        "summary": "Get a clinical trial",
        "parameters": [
          { "name": "nctId", "in": "path", "required": true, "schema": { "type": "string", "pattern": "^NCT[0-9]{8}$" }, "example": "NCT04368728" }
        ],
        "responses": { "200": { "description": "Trial detail" } }
      }
    },
    "/api/search": {
      "get": {
        "tags": ["search"],
        "summary": "Global search across drugs, companies, diseases, trials",
        "parameters": [
          { "name": "q", "in": "query", "required": true, "schema": { "type": "string" }, "example": "GLP-1 agonist obesity" },
          { "name": "type", "in": "query", "schema": { "type": "string", "enum": ["drug", "company", "disease", "trial", "all"] } },
          { "name": "limit", "in": "query", "schema": { "type": "integer", "default": 10, "maximum": 50 } }
        ],
        "responses": { "200": { "description": "Search results" } }
      }
    },
    "/api/browse": {
      "get": {
        "tags": ["search"],
        "summary": "Filtered browse of drugs",
        "parameters": [
          { "name": "type", "in": "query", "schema": { "type": "string", "enum": ["drug", "company", "disease", "trial"] } },
          { "name": "phase", "in": "query", "schema": { "type": "string", "enum": ["marketed", "phase_3", "phase_2", "phase_1"] } },
          { "name": "therapeutic_area", "in": "query", "schema": { "type": "string" } },
          { "name": "drug_class", "in": "query", "schema": { "type": "string" } },
          { "name": "limit", "in": "query", "schema": { "type": "integer", "default": 50 } }
        ],
        "responses": { "200": { "description": "Browse results" } }
      }
    },
    "/api/stats": {
      "get": {
        "tags": ["search"],
        "summary": "Aggregate database statistics",
        "responses": { "200": { "description": "Counts by entity type, phase, therapeutic area" } }
      }
    },
    "/api/top-drugs": {
      "get": {
        "tags": ["drugs"],
        "summary": "Best-selling and most-tracked drugs",
        "responses": { "200": { "description": "Top drugs by revenue + traffic" } }
      }
    },
    "/api/blockbusters": {
      "get": {
        "tags": ["drugs"],
        "summary": "Drugs with >$1B annual revenue",
        "responses": { "200": { "description": "Blockbuster drugs" } }
      }
    }
  },
  "components": {
    "schemas": {
      "Drug": {
        "type": "object",
        "properties": {
          "id": { "type": "string", "description": "Canonical slug" },
          "brandName": { "type": "string" },
          "genericName": { "type": "string" },
          "companyName": { "type": "string" },
          "phase": { "type": "string", "enum": ["marketed", "phase_3", "phase_2", "phase_1", "preclinical", "discontinued", "nda_filed", "bla_filed"] },
          "status": { "type": "string" },
          "modality": { "type": "string" },
          "drugClass": { "type": "string" },
          "molecularTarget": { "type": "string" },
          "therapeuticArea": { "type": "string" },
          "mechanism": {
            "type": "object",
            "properties": {
              "oneSentence": { "type": "string" },
              "explanation": { "type": "string" }
            }
          },
          "indications": {
            "type": "object",
            "properties": {
              "approved": { "type": "array", "items": { "type": "object" } },
              "pipeline": { "type": "array", "items": { "type": "object" } },
              "offLabel": { "type": "array", "items": { "type": "object" } }
            }
          },
          "safety": { "type": "object" },
          "trials": { "type": "array", "items": { "type": "object" } },
          "patents": { "type": "array", "items": { "type": "object" } },
          "commercial": { "type": "object" },
          "firstApprovalDate": { "type": "string", "format": "date" }
        }
      }
    }
  }
}
