{
  "openapi": "3.1.0",
  "info": {
    "title": "AgentHealth x402 API",
    "version": "1.0.0",
    "description": "Health and biomedical data API powered by x402 micropayments. Access NIH grants, WHO health statistics, ClinVar genetic variants, and Human Protein Atlas expression data.",
    "contact": {
      "name": "Ocean Digital Group",
      "url": "https://memoryapi.org"
    }
  },
  "servers": [
    {
      "url": "https://health.memoryapi.org",
      "description": "Production"
    }
  ],
  "paths": {
    "/health": {
      "get": {
        "summary": "Health check",
        "operationId": "healthCheck",
        "security": [],
        "responses": {
          "200": {
            "description": "Service status",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": { "type": "string" },
                    "service": { "type": "string" },
                    "port": { "type": "number" }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/mcp": {
      "get": {
        "summary": "MCP server info",
        "operationId": "mcpInfo",
        "security": [],
        "responses": {
          "200": {
            "description": "MCP server details and available tools"
          }
        }
      },
      "post": {
        "summary": "MCP JSON-RPC endpoint",
        "operationId": "mcpCall",
        "security": [],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "jsonrpc": { "type": "string" },
                  "method": { "type": "string" },
                  "params": { "type": "object" },
                  "id": {}
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "MCP JSON-RPC response"
          }
        }
      }
    },
    "/x402/health/grants": {
      "get": {
        "summary": "NIH Research Grants",
        "operationId": "getNihGrants",
        "description": "Search NIH-funded research grants from the RePORTER database. Filter by topic, fiscal year, and institution.",
        "x-price": "$0.005",
        "parameters": [
          { "name": "q", "in": "query", "schema": { "type": "string", "default": "cancer" }, "description": "Search query" },
          { "name": "year", "in": "query", "schema": { "type": "integer" }, "description": "Fiscal year (default: current)" },
          { "name": "institution", "in": "query", "schema": { "type": "string" }, "description": "Filter by organization name" },
          { "name": "limit", "in": "query", "schema": { "type": "integer", "default": 10, "maximum": 25 }, "description": "Number of results" }
        ],
        "responses": {
          "200": {
            "description": "NIH grant results",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": { "type": "boolean" },
                    "query": { "type": "string" },
                    "fiscal_year": { "type": "integer" },
                    "total_grants": { "type": "integer" },
                    "total_funding_usd": { "type": "number" },
                    "count": { "type": "integer" },
                    "grants": { "type": "array", "items": { "type": "object" } },
                    "source": { "type": "string" }
                  }
                }
              }
            }
          },
          "402": { "description": "Payment required" }
        }
      }
    },
    "/x402/health/global": {
      "get": {
        "summary": "WHO Global Health Data",
        "operationId": "getWhoHealth",
        "description": "Retrieve WHO Global Health Observatory indicators: life expectancy, obesity, alcohol consumption, air pollution, and more.",
        "x-price": "$0.001",
        "parameters": [
          { "name": "indicator", "in": "query", "schema": { "type": "string", "default": "WHOSIS_000001" }, "description": "WHO indicator code (e.g. WHOSIS_000001) or search term (e.g. 'life expectancy')" },
          { "name": "country", "in": "query", "schema": { "type": "string" }, "description": "ISO3 country code (USA, CHN, GBR). Omit for all." },
          { "name": "limit", "in": "query", "schema": { "type": "integer", "default": 10 }, "description": "Number of data points" }
        ],
        "responses": {
          "200": {
            "description": "WHO health data",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": { "type": "boolean" },
                    "indicator": { "type": "string" },
                    "indicator_name": { "type": "string" },
                    "country": { "type": "string" },
                    "count": { "type": "integer" },
                    "data": { "type": "array", "items": { "type": "object" } },
                    "source": { "type": "string" }
                  }
                }
              }
            }
          },
          "402": { "description": "Payment required" }
        }
      }
    },
    "/x402/health/variants": {
      "get": {
        "summary": "ClinVar Genetic Variants",
        "operationId": "getGeneticVariants",
        "description": "Search NCBI ClinVar for genetic variants by gene symbol and clinical significance.",
        "x-price": "$0.005",
        "parameters": [
          { "name": "gene", "in": "query", "schema": { "type": "string", "default": "BRCA1" }, "description": "Gene symbol (e.g. BRCA1, TP53)" },
          { "name": "significance", "in": "query", "schema": { "type": "string", "default": "pathogenic", "enum": ["pathogenic", "benign", "uncertain"] }, "description": "Clinical significance filter" },
          { "name": "limit", "in": "query", "schema": { "type": "integer", "default": 10, "maximum": 25 }, "description": "Number of variants" }
        ],
        "responses": {
          "200": {
            "description": "ClinVar variant results",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": { "type": "boolean" },
                    "gene": { "type": "string" },
                    "significance": { "type": "string" },
                    "count": { "type": "integer" },
                    "variants": { "type": "array", "items": { "type": "object" } },
                    "source": { "type": "string" }
                  }
                }
              }
            }
          },
          "402": { "description": "Payment required" }
        }
      }
    },
    "/x402/health/protein": {
      "get": {
        "summary": "Protein Expression Data",
        "operationId": "getProteinExpression",
        "description": "Get tissue-specific and brain-regional RNA expression data from the Human Protein Atlas.",
        "x-price": "$0.005",
        "parameters": [
          { "name": "gene", "in": "query", "schema": { "type": "string", "default": "BRCA1" }, "description": "Gene symbol (e.g. BRCA1, TP53, APOE)" },
          { "name": "type", "in": "query", "schema": { "type": "string", "default": "expression", "enum": ["expression", "cancer"] }, "description": "expression (normal tissues) or cancer (cancer RNA)" }
        ],
        "responses": {
          "200": {
            "description": "Protein expression data",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": { "type": "boolean" },
                    "gene": { "type": "string" },
                    "results_count": { "type": "integer" },
                    "proteins": { "type": "array", "items": { "type": "object" } },
                    "source": { "type": "string" }
                  }
                }
              }
            }
          },
          "402": { "description": "Payment required" }
        }
      }
    }
  }
}
