{
  "openapi": "3.0.3",
  "info": {
    "title": "AgentResearch API",
    "description": "Scientific literature search API with x402 micropayments. Search PubMed, arXiv, and Crossref citations.",
    "version": "1.0.0",
    "contact": { "name": "Ocean Digital Group", "url": "https://memoryapi.org" }
  },
  "servers": [
    { "url": "https://research.memoryapi.org", "description": "Production" }
  ],
  "paths": {
    "/health": {
      "get": {
        "summary": "Health check",
        "operationId": "health",
        "security": [],
        "responses": {
          "200": { "description": "Service is healthy", "content": { "application/json": { "schema": { "type": "object", "properties": { "status": { "type": "string" }, "service": { "type": "string" }, "port": { "type": "integer" } } } } } }
        }
      }
    },
    "/x402/research/pubmed": {
      "get": {
        "summary": "Search PubMed biomedical literature",
        "operationId": "searchPubmed",
        "x-price": "$0.005 USDC",
        "description": "Search PubMed (NIH) for peer-reviewed biomedical literature. Returns articles with titles, authors, journals, and DOIs.",
        "parameters": [
          { "name": "q", "in": "query", "required": true, "schema": { "type": "string" }, "description": "Search query (e.g. 'cancer immunotherapy', 'COVID-19 vaccines')" },
          { "name": "limit", "in": "query", "schema": { "type": "integer", "default": 10, "maximum": 20 }, "description": "Number of results" },
          { "name": "sort", "in": "query", "schema": { "type": "string", "enum": ["relevance", "date"], "default": "relevance" }, "description": "Sort order" }
        ],
        "responses": {
          "200": {
            "description": "PubMed search results",
            "content": { "application/json": { "schema": {
              "type": "object",
              "properties": {
                "success": { "type": "boolean" },
                "query": { "type": "string" },
                "count": { "type": "integer" },
                "total_found": { "type": "integer" },
                "articles": { "type": "array", "items": {
                  "type": "object",
                  "properties": {
                    "pmid": { "type": "string" },
                    "title": { "type": "string" },
                    "authors": { "type": "array", "items": { "type": "string" } },
                    "journal": { "type": "string" },
                    "pub_date": { "type": "string" },
                    "abstract_url": { "type": "string" },
                    "doi": { "type": "string" }
                  }
                }},
                "source": { "type": "string" }
              }
            }}}
          },
          "402": { "description": "Payment required — x402 micropayment of $0.005 USDC on Base" }
        }
      }
    },
    "/x402/research/arxiv": {
      "get": {
        "summary": "Search arXiv preprints",
        "operationId": "searchArxiv",
        "x-price": "$0.005 USDC",
        "description": "Search arXiv.org preprint server for CS, AI, physics, math, and more.",
        "parameters": [
          { "name": "q", "in": "query", "required": true, "schema": { "type": "string" }, "description": "Search query" },
          { "name": "category", "in": "query", "schema": { "type": "string", "enum": ["cs", "physics", "math", "q-bio", "stat", "econ"] }, "description": "arXiv category filter" },
          { "name": "limit", "in": "query", "schema": { "type": "integer", "default": 10, "maximum": 20 }, "description": "Number of results" }
        ],
        "responses": {
          "200": {
            "description": "arXiv search results",
            "content": { "application/json": { "schema": {
              "type": "object",
              "properties": {
                "success": { "type": "boolean" },
                "query": { "type": "string" },
                "count": { "type": "integer" },
                "papers": { "type": "array", "items": {
                  "type": "object",
                  "properties": {
                    "id": { "type": "string" },
                    "arxiv_id": { "type": "string" },
                    "title": { "type": "string" },
                    "summary": { "type": "string" },
                    "authors": { "type": "array", "items": { "type": "string" } },
                    "published": { "type": "string" },
                    "category": { "type": "string" },
                    "url": { "type": "string" }
                  }
                }},
                "source": { "type": "string" }
              }
            }}}
          },
          "402": { "description": "Payment required — x402 micropayment of $0.005 USDC on Base" }
        }
      }
    },
    "/x402/research/citations": {
      "get": {
        "summary": "Get paper citations via Crossref",
        "operationId": "getCitations",
        "x-price": "$0.005 USDC",
        "description": "Search for papers and get citation counts via Crossref. Supports DOI lookup and topic search.",
        "parameters": [
          { "name": "q", "in": "query", "schema": { "type": "string" }, "description": "Search query" },
          { "name": "doi", "in": "query", "schema": { "type": "string" }, "description": "Specific DOI to look up" },
          { "name": "limit", "in": "query", "schema": { "type": "integer", "default": 10, "maximum": 20 }, "description": "Number of results" },
          { "name": "type", "in": "query", "schema": { "type": "string", "enum": ["journal-article", "book-chapter", "proceedings-article"] }, "description": "Filter by publication type" }
        ],
        "responses": {
          "200": {
            "description": "Citation results",
            "content": { "application/json": { "schema": {
              "type": "object",
              "properties": {
                "success": { "type": "boolean" },
                "query": { "type": "string" },
                "count": { "type": "integer" },
                "papers": { "type": "array", "items": {
                  "type": "object",
                  "properties": {
                    "doi": { "type": "string" },
                    "title": { "type": "string" },
                    "authors": { "type": "array", "items": { "type": "string" } },
                    "published_year": { "type": "integer" },
                    "citation_count": { "type": "integer" },
                    "subjects": { "type": "array", "items": { "type": "string" } },
                    "publisher": { "type": "string" },
                    "url": { "type": "string" }
                  }
                }},
                "source": { "type": "string" }
              }
            }}}
          },
          "402": { "description": "Payment required — x402 micropayment of $0.005 USDC on Base" }
        }
      }
    },
    "/mcp": {
      "get": {
        "summary": "MCP server info",
        "operationId": "mcpInfo",
        "security": [],
        "responses": {
          "200": { "description": "MCP server info with available tools" }
        }
      },
      "post": {
        "summary": "MCP JSON-RPC endpoint",
        "operationId": "mcpCall",
        "security": [],
        "requestBody": {
          "required": true,
          "content": { "application/json": { "schema": { "type": "object", "properties": { "method": { "type": "string" }, "params": { "type": "object" }, "id": {} } } } }
        },
        "responses": {
          "200": { "description": "MCP JSON-RPC response" }
        }
      }
    }
  }
}
