{
  "openapi": "3.1.0",
  "info": {
    "title": "ClinicalIntelPulse API",
    "description": "Pharmaceutical pipeline and clinical trial intelligence API. Synthesizes 400,000+ registered trials from ClinicalTrials.gov with FDA OpenFDA, PubMed, and real-time news. All endpoints require x402 payment (USDC on Base mainnet) via the PAYMENT-SIGNATURE header.",
    "version": "1.0.0",
    "contact": { "url": "https://clinicalintelpulse.vercel.app" }
  },
  "servers": [{ "url": "https://clinicalintelpulse.vercel.app" }],
  "components": {
    "securitySchemes": {
      "x402": {
        "type": "apiKey",
        "in": "header",
        "name": "PAYMENT-SIGNATURE",
        "description": "x402 payment signature. Send a GET request without this header to receive a 402 with payment requirements. Sign the payment and retry.",
        "required": true
      }
    },
    "parameters": {
      "condition": { "name": "condition", "in": "query", "required": false, "schema": { "type": "string" }, "description": "Disease or condition — e.g. 'Non-Small Cell Lung Cancer' | 'Alzheimer Disease' | 'Type 2 Diabetes'" },
      "lang": { "name": "lang", "in": "query", "required": false, "schema": { "type": "string", "enum": ["en","es","fr","de","ja","zh","ko","pt","ar","hi"], "default": "en" }, "description": "Response language" }
    }
  },
  "security": [{ "x402": [] }],
  "paths": {
    "/api/clinical/pipeline-scan": {
      "get": {
        "summary": "Phase 2/3 pipeline scan",
        "description": "All active Phase 2/3 trials for any disease globally — trial counts, sponsor landscape, geographic distribution, mechanism breakdown, pipeline density assessment. Data: ClinicalTrials.gov v2 (no API key required).",
        "operationId": "pipelineScan",
        "parameters": [
          { "$ref": "#/components/parameters/condition" },
          { "name": "phase", "in": "query", "required": false, "schema": { "type": "string", "enum": ["phase2","phase3","both"], "default": "both" } },
          { "name": "status", "in": "query", "required": false, "schema": { "type": "string", "enum": ["active","all"], "default": "active" } },
          { "$ref": "#/components/parameters/lang" }
        ],
        "responses": { "200": { "description": "Pipeline scan" }, "402": { "description": "Payment required" } },
        "x-price-usd": 0.15, "x-agent-use-case": "on-demand"
      }
    },
    "/api/clinical/approval-outlook": {
      "get": {
        "summary": "FDA/EMA approval probability",
        "description": "Approval probability for drugs in a disease area — PDUFA calendar, completed trial data, regulatory designations, historical success rates. Data: ClinicalTrials.gov + FDA OpenFDA + PDUFA synthesis.",
        "operationId": "approvalOutlook",
        "parameters": [
          { "$ref": "#/components/parameters/condition" },
          { "name": "horizon", "in": "query", "required": false, "schema": { "type": "string", "enum": ["12m","18m","24m"], "default": "18m" } },
          { "name": "agency", "in": "query", "required": false, "schema": { "type": "string", "enum": ["FDA","EMA","both"], "default": "both" } },
          { "$ref": "#/components/parameters/lang" }
        ],
        "responses": { "200": { "description": "Approval outlook" }, "402": { "description": "Payment required" } },
        "x-price-usd": 0.25, "x-agent-use-case": "on-demand"
      }
    },
    "/api/clinical/sponsor-intel": {
      "get": {
        "summary": "Pharma/biotech pipeline intelligence",
        "description": "Pipeline by phase, FDA approval history, Phase 3 assets with peak sales estimates, partnerships, investment signals for any company. Data: ClinicalTrials.gov + FDA OpenFDA + news synthesis.",
        "operationId": "sponsorIntel",
        "parameters": [
          { "name": "sponsor", "in": "query", "required": false, "schema": { "type": "string" }, "description": "Company name — e.g. 'Moderna' | 'Alnylam' | 'Vertex Pharmaceuticals'" },
          { "name": "focus", "in": "query", "required": false, "schema": { "type": "string", "enum": ["pipeline","approvals","deals","all"], "default": "all" } },
          { "$ref": "#/components/parameters/lang" }
        ],
        "responses": { "200": { "description": "Sponsor intelligence" }, "402": { "description": "Payment required" } },
        "x-price-usd": 0.20, "x-agent-use-case": "on-demand"
      }
    },
    "/api/clinical/disease-landscape": {
      "get": {
        "summary": "Full disease landscape report",
        "description": "Comprehensive disease brief — approved drugs, mechanism landscape (crowded/gaps), Phase 2-3 pipeline, PDUFA calendar, M&A deal activity, opportunity score (0-100), investment thesis. Replaces Evaluate Pharma/Citeline.",
        "operationId": "diseaseLandscape",
        "parameters": [
          { "$ref": "#/components/parameters/condition" },
          { "name": "depth", "in": "query", "required": false, "schema": { "type": "string", "enum": ["standard","deep"], "default": "standard" } },
          { "$ref": "#/components/parameters/lang" }
        ],
        "responses": { "200": { "description": "Disease landscape" }, "402": { "description": "Payment required" } },
        "x-price-usd": 0.35, "x-agent-use-case": "on-demand"
      }
    },
    "/api/clinical/trial-brief": {
      "get": {
        "summary": "Clinical trial deep dive by NCT ID",
        "description": "Full trial design, endpoints, eligibility, enrollment, geographic footprint, outcome summary for any trial by NCT ID. Data: ClinicalTrials.gov v2 + PubMed.",
        "operationId": "trialBrief",
        "parameters": [
          { "name": "nct_id", "in": "query", "required": true, "schema": { "type": "string" }, "description": "NCT identifier — e.g. NCT04368728" },
          { "$ref": "#/components/parameters/lang" }
        ],
        "responses": { "200": { "description": "Trial brief" }, "400": { "description": "Invalid NCT ID" }, "402": { "description": "Payment required" }, "404": { "description": "Trial not found" } },
        "x-price-usd": 0.10, "x-agent-use-case": "on-demand"
      }
    },
    "/api/clinical/mechanism-map": {
      "get": {
        "summary": "Drug target and MOA landscape",
        "description": "Approved mechanisms, pipeline targets by phase, first-in-class opportunities, white spaces (validated biology, no agent), modality breakdown, combination landscape. Data: ClinicalTrials.gov + PubMed + synthesis.",
        "operationId": "mechanismMap",
        "parameters": [
          { "$ref": "#/components/parameters/condition" },
          { "name": "mechanism", "in": "query", "required": false, "schema": { "type": "string" }, "description": "Optional focus — e.g. 'BTK inhibitor' | 'CAR-T' | 'IL-17'" },
          { "$ref": "#/components/parameters/lang" }
        ],
        "responses": { "200": { "description": "Mechanism map" }, "402": { "description": "Payment required" } },
        "x-price-usd": 0.20, "x-agent-use-case": "on-demand"
      }
    },
    "/api/clinical/global-trials": {
      "get": {
        "summary": "Global clinical trial landscape",
        "description": "International distribution across WHO ICTRP registries — ChiCTR/China, CTRI/India, UMIN/Japan, REBEC/Brazil, ANZCTR/Australia, KCT/Korea, and 10+ more. Regional regulatory landscape, unmet needs, development finance context.",
        "operationId": "globalTrials",
        "parameters": [
          { "$ref": "#/components/parameters/condition" },
          { "name": "region", "in": "query", "required": false, "schema": { "type": "string", "enum": ["global","africa","asia","europe","latin-america","middle-east","north-america"], "default": "global" } },
          { "$ref": "#/components/parameters/lang" }
        ],
        "responses": { "200": { "description": "Global trial landscape" }, "402": { "description": "Payment required" } },
        "x-price-usd": 0.15, "x-agent-use-case": "on-demand"
      }
    },
    "/api/clinical/failure-analysis": {
      "get": {
        "summary": "Clinical trial failure analysis",
        "description": "Phase 2→3 and Phase 3→approval success rates, failure taxonomy (wrong hypothesis/patient/endpoint/dose/safety), named failed trials, lessons learned, successful design principles, biomarker strategy.",
        "operationId": "failureAnalysis",
        "parameters": [
          { "$ref": "#/components/parameters/condition" },
          { "$ref": "#/components/parameters/lang" }
        ],
        "responses": { "200": { "description": "Failure analysis" }, "402": { "description": "Payment required" } },
        "x-price-usd": 0.20, "x-agent-use-case": "on-demand"
      }
    },
    "/api/clinical/patient-finder": {
      "get": {
        "summary": "Recruiting trial finder (plain language)",
        "description": "Patient-friendly finder — recruiting trials with plain-language summaries, accessible eligibility, step-by-step application guide, patient advocacy resources. Global coverage. Data: ClinicalTrials.gov v2.",
        "operationId": "patientFinder",
        "parameters": [
          { "$ref": "#/components/parameters/condition" },
          { "name": "country", "in": "query", "required": false, "schema": { "type": "string" }, "description": "Optional country filter — e.g. 'United States' | 'Germany' | 'Australia'" },
          { "name": "phase", "in": "query", "required": false, "schema": { "type": "string", "enum": ["phase2","phase3","any"], "default": "any" } },
          { "$ref": "#/components/parameters/lang" }
        ],
        "responses": { "200": { "description": "Patient finder results" }, "402": { "description": "Payment required" } },
        "x-price-usd": 0.10, "x-agent-use-case": "on-demand"
      }
    },
    "/api/clinical/deal-signal": {
      "get": {
        "summary": "Biotech M&A and licensing deal signals",
        "description": "Acquisition targets with estimated deal values, recent deal comps (named transactions + dollar values), most likely acquirers, deal timing signals, valuation framework, red flags.",
        "operationId": "dealSignal",
        "parameters": [
          { "$ref": "#/components/parameters/condition" },
          { "name": "deal_type", "in": "query", "required": false, "schema": { "type": "string", "enum": ["acquisition","licensing","both"], "default": "both" } },
          { "name": "stage", "in": "query", "required": false, "schema": { "type": "string", "enum": ["phase2","phase3","both"], "default": "both" } },
          { "$ref": "#/components/parameters/lang" }
        ],
        "responses": { "200": { "description": "Deal signal report" }, "402": { "description": "Payment required" } },
        "x-price-usd": 0.35, "x-agent-use-case": "on-demand"
      }
    }
  }
}
