{
  "openapi": "3.1.0",
  "info": {
    "title": "AgentClinical",
    "version": "1.0.0",
    "description": "ClinicalTrials.gov intelligence \u2014 search 400K+ trials by condition, intervention, sponsor, or phase. Full trial details, eligibility, outcomes, and aggregate stats. Pay-per-request via x402 on Base mainnet.",
    "contact": {
      "name": "Ocean Digital Group",
      "url": "https://memoryapi.org"
    }
  },
  "servers": [
    {
      "url": "https://clinical.memoryapi.org",
      "description": "Production"
    }
  ],
  "paths": {
    "/x402/clinical/trials": {
      "get": {
        "summary": "Search clinical trials",
        "description": "Search 400K+ clinical trials by condition, intervention, sponsor, status, or phase.",
        "x-price": "$0.005 USDC",
        "parameters": [
          {
            "name": "condition",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "Medical condition (e.g. 'diabetes', 'Alzheimer')"
          },
          {
            "name": "intervention",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "Drug or treatment (e.g. 'metformin', 'immunotherapy')"
          },
          {
            "name": "sponsor",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "Sponsoring organization (e.g. 'Pfizer', 'NIH')"
          },
          {
            "name": "status",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "RECRUITING",
                "COMPLETED",
                "ACTIVE_NOT_RECRUITING",
                "NOT_YET_RECRUITING"
              ]
            }
          },
          {
            "name": "phase",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "PHASE1",
                "PHASE2",
                "PHASE3",
                "PHASE4"
              ]
            }
          },
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "default": 10,
              "maximum": 20
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Clinical trials matching filters",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TrialsResponse"
                }
              }
            }
          },
          "402": {
            "description": "Payment required"
          }
        }
      }
    },
    "/x402/clinical/study": {
      "get": {
        "summary": "Get trial details",
        "description": "Full details for a specific clinical trial by NCT ID \u2014 eligibility criteria, primary/secondary outcomes, locations, sponsor, and results summary.",
        "x-price": "$0.005 USDC",
        "parameters": [
          {
            "name": "nct_id",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "NCT ID (e.g. NCT03232697)"
          }
        ],
        "responses": {
          "200": {
            "description": "Full trial details"
          },
          "402": {
            "description": "Payment required"
          }
        }
      }
    },
    "/x402/clinical/stats": {
      "get": {
        "summary": "Trial statistics",
        "description": "Aggregate clinical trial statistics for a condition \u2014 counts by status, phase breakdown, and top sponsors.",
        "x-price": "$0.005 USDC",
        "parameters": [
          {
            "name": "condition",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Medical condition to analyze"
          },
          {
            "name": "group_by",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "status",
                "phase",
                "sponsor"
              ],
              "default": "status"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Aggregate trial statistics"
          },
          "402": {
            "description": "Payment required"
          }
        }
      }
    },
    "/mcp": {
      "post": {
        "summary": "MCP endpoint",
        "description": "Model Context Protocol endpoint. Tools: search_trials, get_trial_details, get_trial_stats",
        "responses": {
          "200": {
            "description": "MCP response"
          }
        },
        "security": []
      }
    }
  },
  "components": {
    "schemas": {
      "TrialsResponse": {
        "type": "object",
        "properties": {
          "success": {
            "type": "boolean"
          },
          "total": {
            "type": "integer"
          },
          "count": {
            "type": "integer"
          },
          "trials": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "nct_id": {
                  "type": "string"
                },
                "title": {
                  "type": "string"
                },
                "status": {
                  "type": "string"
                },
                "phase": {
                  "type": "array",
                  "items": {
                    "type": "string"
                  }
                },
                "conditions": {
                  "type": "array",
                  "items": {
                    "type": "string"
                  }
                },
                "interventions": {
                  "type": "array",
                  "items": {
                    "type": "string"
                  }
                },
                "sponsor": {
                  "type": "string"
                },
                "start_date": {
                  "type": "string"
                },
                "completion_date": {
                  "type": "string"
                },
                "enrollment": {
                  "type": "integer"
                },
                "url": {
                  "type": "string"
                }
              }
            }
          }
        }
      }
    },
    "securitySchemes": {
      "x402": {
        "type": "http",
        "scheme": "bearer",
        "description": "x402 payment protocol \u2014 send USDC payment on Base mainnet"
      }
    }
  }
}