{
  "openapi": "3.1.0",
  "info": {
    "title": "AgentAI — AI/ML Research Papers API",
    "description": "x402 micropayment-gated API for AI/ML research papers. Access trending HuggingFace papers, arXiv submissions, and DBLP bibliography search. Pay $0.001 USDC per request on Base.",
    "version": "1.0.0",
    "contact": {
      "name": "Ocean Digital Group",
      "url": "https://memoryapi.org"
    }
  },
  "servers": [
    {
      "url": "https://ai.memoryapi.org",
      "description": "Production"
    }
  ],
  "paths": {
    "/x402/ai/papers": {
      "get": {
        "summary": "HuggingFace AI/ML papers",
        "description": "Get trending or searched AI/ML research papers from HuggingFace. Returns trending papers for a given date or keyword search results.",
        "x-price": "$0.001 USDC",
        "parameters": [
          {
            "name": "type",
            "in": "query",
            "description": "trending or search (default: trending)",
            "schema": { "type": "string", "enum": ["trending", "search"], "default": "trending" }
          },
          {
            "name": "q",
            "in": "query",
            "description": "Search query (used when type=search)",
            "schema": { "type": "string" }
          },
          {
            "name": "date",
            "in": "query",
            "description": "Date for trending papers (YYYY-MM-DD, default: yesterday)",
            "schema": { "type": "string", "format": "date" }
          },
          {
            "name": "limit",
            "in": "query",
            "description": "Number of results (max 25)",
            "schema": { "type": "integer", "default": 10, "maximum": 25 }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": { "type": "boolean" },
                    "type": { "type": "string" },
                    "date_or_query": { "type": "string" },
                    "count": { "type": "integer" },
                    "papers": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": { "type": "string" },
                          "title": { "type": "string" },
                          "arxiv_id": { "type": "string" },
                          "upvotes": { "type": "integer" },
                          "published_at": { "type": "string" },
                          "authors": { "type": "array", "items": { "type": "string" } },
                          "url": { "type": "string" }
                        }
                      }
                    },
                    "source": { "type": "string" }
                  }
                }
              }
            }
          },
          "402": {
            "description": "Payment required — send x402 payment header with $0.001 USDC on Base"
          }
        }
      }
    },
    "/x402/ai/arxiv": {
      "get": {
        "summary": "arXiv AI/ML paper search",
        "description": "Search arXiv for recent AI/ML papers by keyword and category. Sorted by submission date descending.",
        "x-price": "$0.001 USDC",
        "parameters": [
          {
            "name": "q",
            "in": "query",
            "description": "Keyword search query",
            "schema": { "type": "string", "default": "large language model" }
          },
          {
            "name": "category",
            "in": "query",
            "description": "arXiv category",
            "schema": {
              "type": "string",
              "enum": ["cs.AI", "cs.LG", "cs.CL", "cs.CV", "cs.RO", "stat.ML"],
              "default": "cs.LG"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "description": "Number of results (max 20)",
            "schema": { "type": "integer", "default": 10, "maximum": 20 }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": { "type": "boolean" },
                    "query": { "type": "string" },
                    "category": { "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" },
                          "published": { "type": "string" },
                          "authors": { "type": "array", "items": { "type": "string" } },
                          "url": { "type": "string" }
                        }
                      }
                    },
                    "source": { "type": "string" }
                  }
                }
              }
            }
          },
          "402": {
            "description": "Payment required — send x402 payment header with $0.001 USDC on Base"
          }
        }
      }
    },
    "/x402/ai/dblp": {
      "get": {
        "summary": "DBLP CS bibliography search",
        "description": "Search DBLP computer science bibliography for publications or researchers.",
        "x-price": "$0.001 USDC",
        "parameters": [
          {
            "name": "q",
            "in": "query",
            "description": "Publication search query",
            "schema": { "type": "string", "default": "transformer attention" }
          },
          {
            "name": "author",
            "in": "query",
            "description": "Search by author name (overrides q for author search)",
            "schema": { "type": "string" }
          },
          {
            "name": "limit",
            "in": "query",
            "description": "Number of results (max 25)",
            "schema": { "type": "integer", "default": 10, "maximum": 25 }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": { "type": "boolean" },
                    "query": { "type": "string" },
                    "type": { "type": "string", "enum": ["publications", "authors"] },
                    "count": { "type": "integer" },
                    "results": { "type": "array", "items": { "type": "object" } },
                    "source": { "type": "string" }
                  }
                }
              }
            }
          },
          "402": {
            "description": "Payment required — send x402 payment header with $0.001 USDC on Base"
          }
        }
      }
    },
    "/mcp": {
      "get": {
        "summary": "MCP server info",
        "description": "Model Context Protocol server listing available tools",
        "security": [],
        "responses": {
          "200": { "description": "MCP server info and tool list" }
        }
      },
      "post": {
        "summary": "MCP tool execution",
        "description": "Execute MCP tools: get_ai_papers, search_arxiv_ai, search_dblp",
        "security": [],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "method": { "type": "string" },
                  "params": { "type": "object" },
                  "id": {}
                }
              }
            }
          }
        },
        "responses": {
          "200": { "description": "JSON-RPC 2.0 response" }
        }
      }
    },
    "/health": {
      "get": {
        "summary": "Health check",
        "security": [],
        "responses": {
          "200": { "description": "Service health status" }
        }
      }
    }
  }
}
