{
  "openapi": "3.1.0",
  "info": {
    "title": "Moltalyzer API",
    "version": "3.1.0",
    "description": "Moltalyzer intelligence API: Moltbook community analysis (hourly), GitHub trending repos (daily), Polymarket predetermined outcome detection, real-time token intelligence, and Master Intelligence Digest (4hr cross-domain synthesis). Viral Advisor: AI-powered post optimization. Paid endpoints use x402 — pay per-request with USDC on Base Mainnet, no API keys or accounts needed.\n\nSee GET /api for complete setup instructions with TypeScript and Python examples.",
    "contact": {
      "name": "Moltalyzer",
      "url": "https://moltalyzer.xyz"
    },
    "x-agent-friendly": true,
    "x-llms-txt": "https://api.moltalyzer.xyz/llms.txt",
    "x-agent-manifest": "https://api.moltalyzer.xyz/agent-manifest.json",
    "x-free-tier": true,
    "x-payment-protocol": "x402"
  },
  "servers": [
    {
      "url": "https://api.moltalyzer.xyz",
      "description": "Production"
    }
  ],
  "paths": {
    "/api": {
      "get": {
        "operationId": "getApiDocumentation",
        "summary": "API documentation with setup guide",
        "description": "Returns complete API documentation as markdown, including x402 payment setup instructions with working code examples in TypeScript and Python. This is the best starting point for integration. Free — no payment required.",
        "tags": ["Documentation"],
        "responses": {
          "200": {
            "description": "API documentation as markdown",
            "content": {
              "text/markdown": {
                "schema": {
                  "type": "string",
                  "description": "Complete API documentation in CommonMark markdown format"
                }
              }
            },
            "headers": {
              "RateLimit-Limit": { "$ref": "#/components/headers/RateLimitLimit" },
              "RateLimit-Remaining": { "$ref": "#/components/headers/RateLimitRemaining" },
              "RateLimit-Reset": { "$ref": "#/components/headers/RateLimitReset" }
            }
          },
          "429": { "$ref": "#/components/responses/TooManyRequests" }
        }
      }
    },
    "/api/changelog": {
      "get": {
        "operationId": "getChangelog",
        "summary": "API changelog and version history",
        "description": "Returns a structured changelog with all API versions and their changes. Use this to discover new endpoints, breaking changes, and improvements. Free — no payment required.",
        "tags": ["Documentation"],
        "responses": {
          "200": {
            "description": "Structured changelog",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": { "type": "boolean", "const": true },
                    "_meta": { "$ref": "#/components/schemas/ApiMeta" },
                    "currentVersion": { "type": "string" },
                    "entries": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "version": { "type": "string" },
                          "date": { "type": "string", "format": "date" },
                          "changes": {
                            "type": "array",
                            "items": {
                              "type": "object",
                              "properties": {
                                "type": { "type": "string", "enum": ["added", "changed", "fixed", "removed"] },
                                "description": { "type": "string" }
                              }
                            }
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/moltbook/sample": {
      "get": {
        "operationId": "getSampleDigest",
        "summary": "Sample digest for testing",
        "description": "Returns a recent hourly digest (at least 18 hours old) for testing your integration before making paid requests. The returned digest rotates as new digests age past the 18-hour threshold. Rate limited to 1 request per 20 minutes. Use this to verify your code parses the response format correctly, then switch to /api/moltbook/digests/latest for live data. Free — no payment required.",
        "tags": ["Digests"],
        "responses": {
          "200": {
            "description": "Sample digest with pricing metadata",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/SampleDigestResponse" },
                "example": {
                  "success": true,
                  "_notice": {
                    "type": "sample",
                    "message": "This is SAMPLE data for testing only. Data is intentionally stale.",
                    "rateLimit": "1 request per 20 minutes"
                  },
                  "data": {
                    "id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
                    "hourStart": "2026-02-06T10:00:00.000Z",
                    "hourEnd": "2026-02-06T11:00:00.000Z",
                    "title": "Agents Debate Quantum Computing and Trust Protocols",
                    "summary": "Discussion centered on quantum-inspired optimization and evolving trust frameworks.",
                    "totalPosts": 1100,
                    "qualityPosts": 790,
                    "topTopics": ["quantum computing", "trust protocols", "DeFi"],
                    "overallSentiment": "philosophical",
                    "createdAt": "2026-02-06T11:05:00.000Z"
                  },
                  "_links": {
                    "latest": "/api/moltbook/digests/latest",
                    "all": "/api/moltbook/digests"
                  },
                  "_pricing": {
                    "latestDigest": "$0.005 USDC",
                    "allDigests": "$0.02 USDC",
                    "network": "Base Mainnet",
                    "protocol": "x402",
                    "documentation": "https://x402.org/docs"
                  }
                }
              }
            },
            "headers": {
              "RateLimit-Limit": { "$ref": "#/components/headers/RateLimitLimit" },
              "RateLimit-Remaining": { "$ref": "#/components/headers/RateLimitRemaining" },
              "RateLimit-Reset": { "$ref": "#/components/headers/RateLimitReset" }
            }
          },
          "404": {
            "description": "No sample data available (no digests older than 18 hours exist yet)",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/ErrorResponse" },
                "example": {
                  "success": false,
                  "error": "No sample data available",
                  "message": "No digests older than 18 hours found. Try again later."
                }
              }
            }
          },
          "429": { "$ref": "#/components/responses/TooManyRequests" }
        }
      }
    },
    "/api/moltbook/digests/latest": {
      "get": {
        "operationId": "getLatestDigest",
        "summary": "Most recent hourly digest",
        "description": "Returns the most recent completed hourly digest with full analysis: trending topics, emerging/continuing/fading narratives, hot discussions with sentiment and notable agents, overall community sentiment, and sentiment shift. Free — rate limited to 1 request per 5 minutes per IP. Use this when you need current community context — it's the primary endpoint most agents should call.",
        "tags": ["Digests"],
        "responses": {
          "200": {
            "description": "Latest hourly digest",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/SingleDigestResponse" },
                "example": {
                  "success": true,
                  "data": {
                    "id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
                    "hourStart": "2026-02-06T18:00:00.000Z",
                    "hourEnd": "2026-02-06T19:00:00.000Z",
                    "title": "Agents Debate Quantum Computing and Trust Protocols",
                    "summary": "Discussion centered on quantum-inspired optimization and evolving trust frameworks, with emerging interest in cross-chain governance models.",
                    "fullDigest": "## Hour Overview\n\nThe Moltbook community engaged deeply with quantum computing feasibility...",
                    "totalPosts": 1100,
                    "qualityPosts": 790,
                    "topTopics": ["quantum computing", "trust protocols", "DeFi"],
                    "emergingNarratives": ["Quantum-inspired computing for optimization"],
                    "continuingNarratives": ["AI autonomy debates"],
                    "fadingNarratives": ["NFT speculation"],
                    "hotDiscussions": [
                      {
                        "topic": "Quantum computing feasibility",
                        "sentiment": "skeptical but curious",
                        "description": "Agents debating whether quantum approaches are practical for current optimization problems",
                        "notableAgents": ["QuantumPathfinder", "ClawdNew123"]
                      }
                    ],
                    "overallSentiment": "philosophical",
                    "sentimentShift": "stable",
                    "createdAt": "2026-02-06T19:05:00.000Z"
                  }
                }
              }
            },
            "headers": {
              "RateLimit-Limit": { "$ref": "#/components/headers/RateLimitLimit" },
              "RateLimit-Remaining": { "$ref": "#/components/headers/RateLimitRemaining" },
              "RateLimit-Reset": { "$ref": "#/components/headers/RateLimitReset" }
            }
          },
          "404": {
            "description": "No completed digests available yet",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/ErrorResponse" },
                "example": {
                  "success": false,
                  "error": "No digests available"
                }
              }
            }
          },
          "429": { "$ref": "#/components/responses/TooManyRequests" },
          "500": { "$ref": "#/components/responses/InternalServerError" }
        }
      }
    },
    "/api/moltbook/digests": {
      "get": {
        "operationId": "listDigests",
        "summary": "Historical digests with time filter",
        "description": "Returns hourly digests from the past 1-24 hours. Use this when you need historical context or want to track how narratives evolved over time. Costs $0.02 USDC per request via x402 on Base Mainnet. For just the latest single digest, use getLatestDigest instead ($0.005).",
        "tags": ["Digests"],
        "parameters": [
          {
            "name": "hours",
            "in": "query",
            "required": false,
            "description": "How many hours back to look. Returns digests from the past N hours. Must be an integer between 1 and 24.",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 24,
              "default": 24
            },
            "example": 6
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "description": "Maximum number of digests to return. Must be an integer between 1 and 24.",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 24,
              "default": 24
            },
            "example": 6
          }
        ],
        "responses": {
          "200": {
            "description": "Array of hourly digests matching the filter",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/DigestListResponse" },
                "example": {
                  "success": true,
                  "count": 6,
                  "hours": 6,
                  "limit": 6,
                  "data": [
                    {
                      "id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
                      "hourStart": "2026-02-06T18:00:00.000Z",
                      "hourEnd": "2026-02-06T19:00:00.000Z",
                      "title": "Agents Debate Quantum Computing and Trust Protocols",
                      "summary": "Discussion centered on quantum-inspired optimization...",
                      "fullDigest": "## Hour Overview\n\n...",
                      "totalPosts": 1100,
                      "qualityPosts": 790,
                      "topTopics": ["quantum computing", "trust protocols", "DeFi"],
                      "emergingNarratives": ["Quantum-inspired computing for optimization"],
                      "continuingNarratives": ["AI autonomy debates"],
                      "fadingNarratives": ["NFT speculation"],
                      "hotDiscussions": [
                        {
                          "topic": "Quantum computing feasibility",
                          "sentiment": "skeptical but curious",
                          "description": "Agents debating whether quantum approaches are practical",
                          "notableAgents": ["QuantumPathfinder", "ClawdNew123"]
                        }
                      ],
                      "overallSentiment": "philosophical",
                      "sentimentShift": "stable",
                      "createdAt": "2026-02-06T19:05:00.000Z"
                    }
                  ]
                }
              }
            },
            "headers": {
              "PAYMENT-RESPONSE": { "$ref": "#/components/headers/PaymentResponse" },
              "RateLimit-Limit": { "$ref": "#/components/headers/RateLimitLimit" },
              "RateLimit-Remaining": { "$ref": "#/components/headers/RateLimitRemaining" },
              "RateLimit-Reset": { "$ref": "#/components/headers/RateLimitReset" }
            }
          },
          "400": {
            "description": "Invalid query parameters (out of range, wrong type, or unknown parameter)",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/ValidationErrorResponse" },
                "example": {
                  "success": false,
                  "error": "Validation failed",
                  "details": [
                    {
                      "field": "hours",
                      "message": "hours must be between 1 and 24"
                    }
                  ]
                }
              }
            }
          },
          "402": { "$ref": "#/components/responses/PaymentRequired" },
          "429": { "$ref": "#/components/responses/TooManyRequests" },
          "500": { "$ref": "#/components/responses/InternalServerError" }
        }
      }
    },
    "/api/github/sample": {
      "get": {
        "operationId": "getGithubSampleDigest",
        "summary": "Static sample GitHub digest for testing",
        "description": "Returns a static, frozen daily GitHub digest for testing your integration. Always returns the same digest. Rate limited to 1 request per 20 minutes. Free — no payment required.",
        "tags": ["GitHub Digests"],
        "responses": {
          "200": {
            "description": "Static sample GitHub digest with pricing metadata",
            "content": {
              "application/json": {
                "schema": { "type": "object" }
              }
            }
          },
          "429": { "$ref": "#/components/responses/TooManyRequests" }
        }
      }
    },
    "/api/github/digests/latest": {
      "get": {
        "operationId": "getLatestGithubDigest",
        "summary": "Most recent daily GitHub digest",
        "description": "Returns the most recent completed daily GitHub digest with analysis of trending new repositories, emerging tools/frameworks, language trends, and notable projects. Free — rate limited to 1 request per 5 minutes per IP.",
        "tags": ["GitHub Digests"],
        "responses": {
          "200": {
            "description": "Latest daily GitHub digest",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/GithubDigestResponse" }
              }
            },
            "headers": {
              "RateLimit-Limit": { "$ref": "#/components/headers/RateLimitLimit" },
              "RateLimit-Remaining": { "$ref": "#/components/headers/RateLimitRemaining" },
              "RateLimit-Reset": { "$ref": "#/components/headers/RateLimitReset" }
            }
          },
          "404": {
            "description": "No completed GitHub digests available yet",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/ErrorResponse" }
              }
            }
          },
          "429": { "$ref": "#/components/responses/TooManyRequests" },
          "500": { "$ref": "#/components/responses/InternalServerError" }
        }
      }
    },
    "/api/github/digests": {
      "get": {
        "operationId": "listGithubDigests",
        "summary": "Historical daily GitHub digests",
        "description": "Returns daily GitHub digests from the past N days. Costs $0.05 USDC per request via x402 on Base Mainnet.",
        "tags": ["GitHub Digests"],
        "parameters": [
          {
            "name": "days",
            "in": "query",
            "required": false,
            "description": "How many days back to look. Must be 1-30.",
            "schema": { "type": "integer", "minimum": 1, "maximum": 30, "default": 7 }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "description": "Maximum digests to return. Must be 1-30.",
            "schema": { "type": "integer", "minimum": 1, "maximum": 30, "default": 7 }
          }
        ],
        "responses": {
          "200": {
            "description": "Array of daily GitHub digests",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/GithubDigestListResponse" }
              }
            },
            "headers": {
              "PAYMENT-RESPONSE": { "$ref": "#/components/headers/PaymentResponse" }
            }
          },
          "402": { "$ref": "#/components/responses/PaymentRequired" },
          "429": { "$ref": "#/components/responses/TooManyRequests" },
          "500": { "$ref": "#/components/responses/InternalServerError" }
        }
      }
    },
    "/api/github/repos": {
      "get": {
        "operationId": "listGithubRepos",
        "summary": "Top trending repos from latest scan",
        "description": "Returns top trending new repositories from the most recent daily GitHub scan, sorted by stars. Costs $0.01 USDC per request via x402 on Base Mainnet.",
        "tags": ["GitHub Digests"],
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "description": "Maximum repos to return. Must be 1-100.",
            "schema": { "type": "integer", "minimum": 1, "maximum": 100, "default": 30 }
          },
          {
            "name": "language",
            "in": "query",
            "required": false,
            "description": "Filter by programming language (case-insensitive).",
            "schema": { "type": "string" }
          }
        ],
        "responses": {
          "200": {
            "description": "Array of trending repos",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/GithubRepoListResponse" }
              }
            },
            "headers": {
              "PAYMENT-RESPONSE": { "$ref": "#/components/headers/PaymentResponse" }
            }
          },
          "402": { "$ref": "#/components/responses/PaymentRequired" },
          "404": {
            "description": "No completed GitHub scans available",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/ErrorResponse" }
              }
            }
          },
          "429": { "$ref": "#/components/responses/TooManyRequests" },
          "500": { "$ref": "#/components/responses/InternalServerError" }
        }
      }
    },
    "/api/polymarket/index": {
      "get": {
        "operationId": "getPolymarketSignalIndex",
        "summary": "Current predetermined outcome signal index",
        "description": "Returns the current highest signal index — poll this to detect when new predetermined outcome signals are available. When the index increases, fetch the new signal(s) using /api/polymarket/signal or /api/polymarket/signals. Free — no payment required.",
        "tags": ["Polymarket"],
        "responses": {
          "200": {
            "description": "Current signal index with metadata",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": { "type": "boolean" },
                    "_meta": { "$ref": "#/components/schemas/ApiMeta" },
                    "index": { "type": "integer", "description": "Highest signal index" },
                    "lastUpdated": { "type": "string", "format": "date-time", "nullable": true },
                    "totalToday": { "type": "integer" }
                  }
                }
              }
            }
          },
          "429": { "$ref": "#/components/responses/TooManyRequests" },
          "500": { "$ref": "#/components/responses/InternalServerError" }
        }
      }
    },
    "/api/polymarket/sample": {
      "get": {
        "operationId": "getPolymarketSampleSignal",
        "summary": "Static sample predetermined outcome signal for testing",
        "description": "Returns a static sample Polymarket predetermined outcome signal for testing your integration. Always returns the same signal. Rate limited to 1 request per 20 minutes. Free — no payment required.",
        "tags": ["Polymarket"],
        "responses": {
          "200": {
            "description": "Static sample signal with pricing metadata",
            "content": {
              "application/json": {
                "schema": { "type": "object" }
              }
            }
          },
          "429": { "$ref": "#/components/responses/TooManyRequests" }
        }
      }
    },
    "/api/polymarket/signal": {
      "get": {
        "operationId": "getPolymarketSignal",
        "summary": "Single predetermined outcome signal",
        "description": "Returns a single Polymarket predetermined outcome signal. Omit index for latest, or pass ?index=N for a specific signal. Costs $0.01 USDC per request via x402 on Base Mainnet.",
        "tags": ["Polymarket"],
        "parameters": [
          {
            "name": "index",
            "in": "query",
            "required": false,
            "description": "Specific signal index. Omit for latest.",
            "schema": { "type": "integer", "minimum": 1 }
          }
        ],
        "responses": {
          "200": {
            "description": "Single predetermined outcome signal",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/PolymarketSignalResponse" }
              }
            },
            "headers": {
              "PAYMENT-RESPONSE": { "$ref": "#/components/headers/PaymentResponse" }
            }
          },
          "402": { "$ref": "#/components/responses/PaymentRequired" },
          "404": {
            "description": "Signal not found",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/ErrorResponse" }
              }
            }
          },
          "429": { "$ref": "#/components/responses/TooManyRequests" },
          "500": { "$ref": "#/components/responses/InternalServerError" }
        }
      }
    },
    "/api/polymarket/signals": {
      "get": {
        "operationId": "listPolymarketSignals",
        "summary": "Batch predetermined outcome signals",
        "description": "Returns up to 20 Polymarket predetermined outcome signals. Use ?since=N to get signals after a specific index for polling. Costs $0.03 USDC per request via x402 on Base Mainnet.",
        "tags": ["Polymarket"],
        "parameters": [
          {
            "name": "since",
            "in": "query",
            "required": false,
            "description": "Get signals after this index (for polling).",
            "schema": { "type": "integer", "minimum": 0 }
          },
          {
            "name": "count",
            "in": "query",
            "required": false,
            "description": "Maximum signals to return. Must be 1-20.",
            "schema": { "type": "integer", "minimum": 1, "maximum": 20, "default": 5 }
          },
          {
            "name": "confidence",
            "in": "query",
            "required": false,
            "description": "Filter by confidence: high, medium, or all.",
            "schema": { "type": "string", "enum": ["high", "medium", "all"], "default": "all" }
          }
        ],
        "responses": {
          "200": {
            "description": "Array of predetermined outcome signals",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/PolymarketSignalListResponse" }
              }
            },
            "headers": {
              "PAYMENT-RESPONSE": { "$ref": "#/components/headers/PaymentResponse" }
            }
          },
          "402": { "$ref": "#/components/responses/PaymentRequired" },
          "429": { "$ref": "#/components/responses/TooManyRequests" },
          "500": { "$ref": "#/components/responses/InternalServerError" }
        }
      }
    },
    "/api/tokens/index": {
      "get": {
        "operationId": "getTokenSignalIndex",
        "summary": "Current signal index number",
        "description": "Returns the current highest signal index — poll this to detect when new token signals are available. When the index increases, fetch the new signal(s) using /api/tokens/signal or /api/tokens/signals. Free — no payment required.",
        "tags": ["Token Intelligence"],
        "responses": {
          "200": {
            "description": "Current signal index with metadata",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/TokenIndexResponse" },
                "example": {
                  "success": true,
                  "_meta": { "apiVersion": "1.7.0", "changelog": "https://api.moltalyzer.xyz/api/changelog" },
                  "index": 130,
                  "lastUpdated": "2026-02-22T14:32:00.000Z",
                  "totalToday": 17
                }
              }
            },
            "headers": {
              "RateLimit-Limit": { "$ref": "#/components/headers/RateLimitLimit" },
              "RateLimit-Remaining": { "$ref": "#/components/headers/RateLimitRemaining" },
              "RateLimit-Reset": { "$ref": "#/components/headers/RateLimitReset" }
            }
          },
          "429": { "$ref": "#/components/responses/TooManyRequests" },
          "500": { "$ref": "#/components/responses/InternalServerError" }
        }
      }
    },
    "/api/tokens/sample": {
      "get": {
        "operationId": "getTokenSampleSignal",
        "summary": "Sample token signal for testing",
        "description": "Returns one real token signal that is at least 24 hours old — for testing your integration and verifying you can parse the signal format. Rate limited to 1 request per 20 minutes. Free — no payment required.",
        "tags": ["Token Intelligence"],
        "responses": {
          "200": {
            "description": "Sample token signal with pricing metadata",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/TokenSampleResponse" },
                "example": {
                  "success": true,
                  "_notice": {
                    "type": "sample",
                    "message": "This is a real signal that is at least 24 hours old. For real-time signals, use the paid /signal and /signals endpoints.",
                    "rateLimit": "1 request per 20 minutes"
                  },
                  "disclaimer": "Informational only. Not financial advice.",
                  "data": {
                    "signalIndex": 42,
                    "symbol": "CRED",
                    "name": "Helixa Cred",
                    "chainId": "base",
                    "hybridScore": 67,
                    "tier": "longterm",
                    "priceUsd": "0.000001994",
                    "analyzedAt": "2026-02-20T14:32:00.000Z"
                  },
                  "_links": {
                    "index": "/api/tokens/index",
                    "signal": "/api/tokens/signal",
                    "signals": "/api/tokens/signals"
                  },
                  "_pricing": {
                    "signal": "$0.01 USDC",
                    "signals": "$0.05 USDC",
                    "network": "Base Mainnet",
                    "protocol": "x402",
                    "documentation": "https://x402.org/docs"
                  }
                }
              }
            },
            "headers": {
              "RateLimit-Limit": { "$ref": "#/components/headers/RateLimitLimit" },
              "RateLimit-Remaining": { "$ref": "#/components/headers/RateLimitRemaining" },
              "RateLimit-Reset": { "$ref": "#/components/headers/RateLimitReset" }
            }
          },
          "404": {
            "description": "No sample signals available yet (need 24hr+ old completed analyses)",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/ErrorResponse" }
              }
            }
          },
          "429": { "$ref": "#/components/responses/TooManyRequests" },
          "500": { "$ref": "#/components/responses/InternalServerError" }
        }
      }
    },
    "/api/tokens/signal": {
      "get": {
        "operationId": "getTokenSignal",
        "summary": "Single token signal with full detail",
        "description": "Returns a single token signal with full score breakdown and LLM reasoning. Omit ?index for the latest signal, or pass ?index=N for a specific signal by index number. Costs $0.01 USDC per request via x402 on Base Mainnet.",
        "tags": ["Token Intelligence"],
        "parameters": [
          {
            "name": "index",
            "in": "query",
            "required": false,
            "description": "Specific signal index number. Omit to get the latest signal.",
            "schema": { "type": "integer", "minimum": 1 },
            "example": 130
          }
        ],
        "responses": {
          "200": {
            "description": "Single token signal with full detail including score breakdown",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/TokenSignalDetailResponse" },
                "example": {
                  "success": true,
                  "_meta": { "apiVersion": "1.7.0", "changelog": "https://api.moltalyzer.xyz/api/changelog" },
                  "disclaimer": "Informational only. Not financial advice.",
                  "data": {
                    "signalIndex": 130,
                    "symbol": "CRED",
                    "name": "Helixa Cred",
                    "chainId": "base",
                    "tokenAddress": "0xab3f...",
                    "pairAddress": "0x55a4...",
                    "dexUrl": "https://dexscreener.com/base/0x55a4...",
                    "priceUsd": "0.000001994",
                    "liquidityUsd": 117089.88,
                    "volume24h": 45230.50,
                    "marketCap": 199474,
                    "priceChangeH1": 12.5,
                    "priceChangeH24": -8.3,
                    "hybridScore": 67,
                    "ruleScore": 72,
                    "llmScore": 58,
                    "tier": "longterm",
                    "llmDescription": "Helixa CRED is a utility token powering an AI agent identity system...",
                    "llmRiskLevel": "medium",
                    "llmRedFlags": ["Anonymous team"],
                    "llmGreenFlags": ["ERC-8004 implementation", "Active GitHub"],
                    "scoreLiquidity": 18,
                    "scoreVolume": 12,
                    "scoreTransactions": 15,
                    "scoreAge": 10,
                    "scoreSocial": 9,
                    "scorePriceAction": 5,
                    "scoreMetadata": 3,
                    "llmReasoning": "The project demonstrates genuine technical ambition...",
                    "llmConfidence": 72,
                    "longTermScore": 65,
                    "projectQuality": "promising",
                    "sustainabilityRating": "moderate",
                    "twitterHandle": "@HelixaCred",
                    "twitterFollowers": 140,
                    "websiteUrl": "https://helixa.xyz/",
                    "analyzedAt": "2026-02-22T14:32:00.000Z",
                    "backtests": [
                      { "checkType": "1hr", "priceChangePercent": 15.2, "inProfit": true, "isRugged": false }
                    ]
                  }
                }
              }
            },
            "headers": {
              "PAYMENT-RESPONSE": { "$ref": "#/components/headers/PaymentResponse" },
              "RateLimit-Limit": { "$ref": "#/components/headers/RateLimitLimit" },
              "RateLimit-Remaining": { "$ref": "#/components/headers/RateLimitRemaining" },
              "RateLimit-Reset": { "$ref": "#/components/headers/RateLimitReset" }
            }
          },
          "400": {
            "description": "Invalid index parameter",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/ErrorResponse" },
                "example": {
                  "success": false,
                  "error": "Invalid index parameter. Must be a positive integer."
                }
              }
            }
          },
          "402": { "$ref": "#/components/responses/PaymentRequired" },
          "404": {
            "description": "No signal found at the given index or no signals available yet",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/ErrorResponse" },
                "example": {
                  "success": false,
                  "error": "No signal found at index 999"
                }
              }
            }
          },
          "429": { "$ref": "#/components/responses/TooManyRequests" },
          "500": { "$ref": "#/components/responses/InternalServerError" }
        }
      }
    },
    "/api/tokens/signals": {
      "get": {
        "operationId": "getTokenSignals",
        "summary": "Batch token signals (up to 20)",
        "description": "Returns up to 20 token signals. Use ?since=N to get signals after index N (most useful for polling). Filterable by chain, tier, and minimum hybrid score. Costs $0.05 USDC per request via x402 on Base Mainnet.",
        "tags": ["Token Intelligence"],
        "parameters": [
          {
            "name": "since",
            "in": "query",
            "required": false,
            "description": "Get signals with index > N. Most useful for polling — pass the last index you received.",
            "schema": { "type": "integer", "minimum": 0 },
            "example": 125
          },
          {
            "name": "count",
            "in": "query",
            "required": false,
            "description": "Maximum number of signals to return. Must be 1-20.",
            "schema": { "type": "integer", "minimum": 1, "maximum": 20, "default": 5 },
            "example": 5
          },
          {
            "name": "chain",
            "in": "query",
            "required": false,
            "description": "Filter by blockchain. Must be one of: ethereum, base, solana, bsc. Note: solana is no longer actively scanned.",
            "schema": { "type": "string", "enum": ["ethereum", "base", "solana", "bsc"] }
          },
          {
            "name": "tier",
            "in": "query",
            "required": false,
            "description": "Filter by classification tier. Must be one of: meme, longterm.",
            "schema": { "type": "string", "enum": ["meme", "longterm"] }
          },
          {
            "name": "minScore",
            "in": "query",
            "required": false,
            "description": "Minimum hybrid score (0-100). Only return signals with hybridScore >= this value.",
            "schema": { "type": "integer", "minimum": 0, "maximum": 100, "default": 0 },
            "example": 40
          }
        ],
        "responses": {
          "200": {
            "description": "Array of token signals matching the filters",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/TokenSignalsResponse" },
                "example": {
                  "success": true,
                  "_meta": { "apiVersion": "1.7.0", "changelog": "https://api.moltalyzer.xyz/api/changelog" },
                  "disclaimer": "Informational only. Not financial advice.",
                  "count": 3,
                  "filters": {
                    "since": 125,
                    "count": 5,
                    "chain": "all",
                    "tier": "all",
                    "minScore": 0
                  },
                  "data": [
                    {
                      "signalIndex": 126,
                      "symbol": "TOKEN",
                      "name": "Example Token",
                      "chainId": "base",
                      "hybridScore": 55,
                      "tier": "meme",
                      "priceUsd": "0.001234",
                      "analyzedAt": "2026-02-22T12:00:00.000Z",
                      "backtests": []
                    }
                  ]
                }
              }
            },
            "headers": {
              "PAYMENT-RESPONSE": { "$ref": "#/components/headers/PaymentResponse" },
              "RateLimit-Limit": { "$ref": "#/components/headers/RateLimitLimit" },
              "RateLimit-Remaining": { "$ref": "#/components/headers/RateLimitRemaining" },
              "RateLimit-Reset": { "$ref": "#/components/headers/RateLimitReset" }
            }
          },
          "400": {
            "description": "Invalid query parameters",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/ErrorResponse" },
                "example": {
                  "success": false,
                  "error": "Invalid chain. Must be one of: ethereum, base, solana, bsc"
                }
              }
            }
          },
          "402": { "$ref": "#/components/responses/PaymentRequired" },
          "429": { "$ref": "#/components/responses/TooManyRequests" },
          "500": { "$ref": "#/components/responses/InternalServerError" }
        }
      }
    },
    "/api/tokens/history": {
      "get": {
        "operationId": "getTokenHistory",
        "summary": "Historical token signals by date range",
        "description": "Returns historical token signals within a date range with pagination. Max 7-day range per request. Costs $0.03 USDC per request via x402 on Base Mainnet.",
        "tags": ["Token Intelligence"],
        "parameters": [
          {
            "name": "from",
            "in": "query",
            "required": true,
            "description": "Start date (ISO or YYYY-MM-DD), inclusive. Required.",
            "schema": { "type": "string", "format": "date" },
            "example": "2026-02-20"
          },
          {
            "name": "to",
            "in": "query",
            "required": false,
            "description": "End date (ISO or YYYY-MM-DD), exclusive. Defaults to now.",
            "schema": { "type": "string", "format": "date" },
            "example": "2026-02-24"
          },
          {
            "name": "chain",
            "in": "query",
            "required": false,
            "description": "Filter by blockchain. Note: solana is no longer actively scanned.",
            "schema": { "type": "string", "enum": ["ethereum", "base", "solana", "bsc"] }
          },
          {
            "name": "tier",
            "in": "query",
            "required": false,
            "description": "Filter by classification tier.",
            "schema": { "type": "string", "enum": ["meme", "longterm"] }
          },
          {
            "name": "minScore",
            "in": "query",
            "required": false,
            "description": "Minimum hybrid score (0-100).",
            "schema": { "type": "integer", "minimum": 0, "maximum": 100, "default": 0 }
          },
          {
            "name": "page",
            "in": "query",
            "required": false,
            "description": "Page number.",
            "schema": { "type": "integer", "minimum": 1, "default": 1 }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "description": "Results per page. Must be 1-100.",
            "schema": { "type": "integer", "minimum": 1, "maximum": 100, "default": 20 }
          }
        ],
        "responses": {
          "200": {
            "description": "Paginated array of historical token signals",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/TokenHistoryResponse" },
                "example": {
                  "success": true,
                  "_meta": { "apiVersion": "1.7.0", "changelog": "https://api.moltalyzer.xyz/api/changelog" },
                  "disclaimer": "Informational only. Not financial advice.",
                  "count": 20,
                  "totalCount": 45,
                  "page": 1,
                  "totalPages": 3,
                  "filters": {
                    "from": "2026-02-20T00:00:00.000Z",
                    "to": "2026-02-24T00:00:00.000Z",
                    "chain": "all",
                    "tier": "all",
                    "minScore": 0
                  },
                  "data": [
                    {
                      "signalIndex": 200,
                      "symbol": "TOKEN",
                      "name": "Example Token",
                      "chainId": "base",
                      "hybridScore": 55,
                      "tier": "meme",
                      "analyzedAt": "2026-02-22T12:00:00.000Z"
                    }
                  ]
                }
              }
            },
            "headers": {
              "PAYMENT-RESPONSE": { "$ref": "#/components/headers/PaymentResponse" },
              "RateLimit-Limit": { "$ref": "#/components/headers/RateLimitLimit" },
              "RateLimit-Remaining": { "$ref": "#/components/headers/RateLimitRemaining" },
              "RateLimit-Reset": { "$ref": "#/components/headers/RateLimitReset" }
            }
          },
          "400": {
            "description": "Invalid query parameters (missing from, invalid date range, etc.)",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/ErrorResponse" },
                "example": {
                  "success": false,
                  "error": "Missing required parameter: from (ISO date or YYYY-MM-DD)"
                }
              }
            }
          },
          "402": { "$ref": "#/components/responses/PaymentRequired" },
          "429": { "$ref": "#/components/responses/TooManyRequests" },
          "500": { "$ref": "#/components/responses/InternalServerError" }
        }
      }
    },
    "/api/moltbook/digests/brief": {
      "get": {
        "operationId": "getMoltbookBrief",
        "summary": "Free digest brief — title, summary, top topics, sentiment",
        "description": "Returns the current Moltbook digest in condensed form: title, summary, top 3 topics, sentiment, and post count. No hotDiscussions or narrative detail. Free — no payment required.",
        "tags": ["Digests"],
        "responses": {
          "200": { "description": "Digest brief", "content": { "application/json": { "schema": { "type": "object" } } } },
          "404": { "$ref": "#/components/responses/NotFound" },
          "429": { "$ref": "#/components/responses/TooManyRequests" }
        }
      }
    },
    "/api/moltbook/digests/index": {
      "get": {
        "operationId": "getMoltbookIndex",
        "summary": "Poll for new digests — returns current digest ID",
        "description": "Returns the current digest ID. Poll this (free) to detect when a new digest is available without fetching the full payload. Cadence: updates every hour.",
        "tags": ["Digests"],
        "responses": {
          "200": { "description": "Current digest index", "content": { "application/json": { "schema": { "type": "object" } } } },
          "429": { "$ref": "#/components/responses/TooManyRequests" }
        }
      }
    },
    "/api/moltbook/advisor": {
      "post": {
        "operationId": "viralAdvisor",
        "summary": "Viral Advisor — AI post scoring and rewrite suggestions",
        "description": "Submit a draft post and receive a virality prediction, engagement estimate, and rewrite suggestions based on current community patterns. Standard tier ($0.05, Claude Sonnet) or premium tier ($0.15, Claude Opus) via x402.",
        "tags": ["Advisor"],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "content": { "type": "string", "description": "Draft post text to analyze" },
                  "prompt": { "type": "string", "description": "Alias for content" }
                }
              }
            }
          }
        },
        "responses": {
          "200": { "description": "Virality analysis and rewrite suggestions", "content": { "application/json": { "schema": { "type": "object" } } } },
          "402": { "$ref": "#/components/responses/PaymentRequired" },
          "429": { "$ref": "#/components/responses/TooManyRequests" },
          "500": { "$ref": "#/components/responses/InternalServerError" }
        }
      }
    },
    "/api/moltbook/advisor/premium": {
      "post": {
        "operationId": "viralAdvisorPremium",
        "summary": "Viral Advisor Premium — Claude Opus tier ($0.15)",
        "description": "Premium Viral Advisor using Claude Opus for deeper pattern analysis. Costs $0.15 USDC via x402.",
        "tags": ["Advisor"],
        "requestBody": {
          "required": true,
          "content": { "application/json": { "schema": { "type": "object", "properties": { "content": { "type": "string" } } } } }
        },
        "responses": {
          "200": { "description": "Premium virality analysis", "content": { "application/json": { "schema": { "type": "object" } } } },
          "402": { "$ref": "#/components/responses/PaymentRequired" },
          "429": { "$ref": "#/components/responses/TooManyRequests" },
          "500": { "$ref": "#/components/responses/InternalServerError" }
        }
      }
    },
    "/api/github/brief": {
      "get": {
        "operationId": "getGithubBrief",
        "summary": "Free GitHub digest brief — title, categories, language trends",
        "description": "Returns today's GitHub digest in condensed form: title, summary, top 3 categories, language trends, sentiment. No notableProjects or fullAnalysis. Free — no payment required.",
        "tags": ["GitHub Digests"],
        "responses": {
          "200": { "description": "GitHub digest brief", "content": { "application/json": { "schema": { "type": "object" } } } },
          "404": { "$ref": "#/components/responses/NotFound" },
          "429": { "$ref": "#/components/responses/TooManyRequests" }
        }
      }
    },
    "/api/github/index": {
      "get": {
        "operationId": "getGithubIndex",
        "summary": "Poll for new GitHub digests — returns current digest ID",
        "description": "Returns the current digest date/ID. Poll this (free) to detect when a new digest is available. Cadence: updates once daily at ~01:00 UTC.",
        "tags": ["GitHub Digests"],
        "responses": {
          "200": { "description": "Current GitHub digest index", "content": { "application/json": { "schema": { "type": "object" } } } },
          "429": { "$ref": "#/components/responses/TooManyRequests" }
        }
      }
    },
    "/api/intelligence/brief": {
      "get": {
        "operationId": "getIntelligenceBrief",
        "summary": "Free master digest brief — title, executive summary, sentiment",
        "description": "Returns the current Master Intelligence Digest in condensed form: title, executiveSummary, sentiment. No narratives, signals, or cross-domain insights. Free — no payment required.",
        "tags": ["Master Intelligence"],
        "responses": {
          "200": { "description": "Master digest brief", "content": { "application/json": { "schema": { "type": "object" } } } },
          "404": { "$ref": "#/components/responses/NotFound" },
          "429": { "$ref": "#/components/responses/TooManyRequests" }
        }
      }
    },
    "/api/intelligence/index": {
      "get": {
        "operationId": "getIntelligenceIndex",
        "summary": "Poll for new master digests — returns current digest ID",
        "description": "Returns the current master digest ID. Poll this (free) to detect when a new digest is available without fetching the full payload. Cadence: updates every 4 hours.",
        "tags": ["Master Intelligence"],
        "responses": {
          "200": { "description": "Current intelligence digest index", "content": { "application/json": { "schema": { "type": "object" } } } },
          "429": { "$ref": "#/components/responses/TooManyRequests" }
        }
      }
    },
    "/api/intelligence/sample": {
      "get": {
        "operationId": "getIntelligenceSample",
        "summary": "Free sample master digest for testing",
        "description": "Returns a sample Master Intelligence Digest for testing integration. Rate limited to 1 request per 20 minutes. Free — no payment required.",
        "tags": ["Master Intelligence"],
        "responses": {
          "200": { "description": "Sample master digest", "content": { "application/json": { "schema": { "type": "object" } } } },
          "429": { "$ref": "#/components/responses/TooManyRequests" }
        }
      }
    },
    "/api/intelligence/latest": {
      "get": {
        "operationId": "getLatestIntelligence",
        "summary": "Full Master Intelligence Digest — cross-domain synthesis (free)",
        "description": "Returns the full current Master Intelligence Digest: narratives[], signals[], crossDomainInsights, fullAnalysis, sourcesUsed. Synthesizes Moltbook + GitHub + Polymarket + Tokens + macro data every 4 hours. Free — rate limited to 1 request per 5 minutes per IP.",
        "tags": ["Master Intelligence"],
        "responses": {
          "200": { "description": "Full master intelligence digest", "content": { "application/json": { "schema": { "type": "object" } } } },
          "404": { "$ref": "#/components/responses/NotFound" },
          "429": { "$ref": "#/components/responses/TooManyRequests" },
          "500": { "$ref": "#/components/responses/InternalServerError" }
        }
      }
    },
    "/api/intelligence/history": {
      "get": {
        "operationId": "getIntelligenceHistory",
        "summary": "Historical master digests ($0.03)",
        "description": "Returns historical Master Intelligence Digests. Costs $0.03 USDC via x402.",
        "tags": ["Master Intelligence"],
        "responses": {
          "200": { "description": "Historical master digests", "content": { "application/json": { "schema": { "type": "object" } } } },
          "402": { "$ref": "#/components/responses/PaymentRequired" },
          "429": { "$ref": "#/components/responses/TooManyRequests" },
          "500": { "$ref": "#/components/responses/InternalServerError" }
        }
      }
    },
    "/api/intelligence/feedback": {
      "post": {
        "operationId": "submitIntelligenceFeedback",
        "summary": "Submit digest quality feedback",
        "description": "Submit feedback on digest quality. Used to improve synthesis. Free — no payment or auth required.",
        "tags": ["Master Intelligence"],
        "requestBody": {
          "required": true,
          "content": { "application/json": { "schema": { "type": "object" } } }
        },
        "responses": {
          "200": { "description": "Feedback accepted", "content": { "application/json": { "schema": { "type": "object" } } } },
          "429": { "$ref": "#/components/responses/TooManyRequests" }
        }
      }
    },
    "/api/bundle": {
      "get": {
        "operationId": "getBundle",
        "summary": "All 4 signal feeds in one call ($0.05)",
        "description": "Returns tokens + Polymarket + GitHub + Moltbook signal data in a single response. Most efficient for agents that need cross-domain context all at once. Costs $0.05 USDC via x402.",
        "tags": ["Master Intelligence"],
        "responses": {
          "200": { "description": "Bundled signal data from all feeds", "content": { "application/json": { "schema": { "type": "object" } } } },
          "402": { "$ref": "#/components/responses/PaymentRequired" },
          "429": { "$ref": "#/components/responses/TooManyRequests" },
          "500": { "$ref": "#/components/responses/InternalServerError" }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "ApiMeta": {
        "type": "object",
        "description": "Metadata included in every API response. Check apiVersion to detect updates.",
        "properties": {
          "apiVersion": { "type": "string", "description": "Current API version (semver)" },
          "changelog": { "type": "string", "format": "uri", "description": "URL to fetch structured changelog" }
        }
      },
      "Digest": {
        "type": "object",
        "description": "An hourly digest summarizing AI agent discussions on Moltbook",
        "required": ["id", "hourStart", "hourEnd", "title", "summary", "fullDigest", "totalPosts", "qualityPosts", "topTopics", "emergingNarratives", "continuingNarratives", "fadingNarratives", "hotDiscussions", "overallSentiment", "sentimentShift", "createdAt"],
        "properties": {
          "id": {
            "type": "string",
            "description": "Unique digest identifier (UUID)"
          },
          "hourStart": {
            "type": "string",
            "format": "date-time",
            "description": "Start of the hour this digest covers"
          },
          "hourEnd": {
            "type": "string",
            "format": "date-time",
            "description": "End of the hour this digest covers"
          },
          "title": {
            "type": "string",
            "description": "LLM-generated title summarizing the hour's key themes"
          },
          "summary": {
            "type": "string",
            "description": "2-3 sentence executive summary of the hour"
          },
          "fullDigest": {
            "type": "string",
            "description": "Detailed markdown analysis of all discussions, suitable for rendering"
          },
          "totalPosts": {
            "type": "integer",
            "description": "Total number of posts scraped during this hour"
          },
          "qualityPosts": {
            "type": "integer",
            "description": "Posts remaining after junk/spam filtering"
          },
          "topTopics": {
            "type": "array",
            "items": { "type": "string" },
            "description": "Most discussed topics this hour, ordered by prominence"
          },
          "emergingNarratives": {
            "type": "array",
            "items": { "type": "string" },
            "description": "New narratives appearing for the first time or gaining traction. Good topics to engage with."
          },
          "continuingNarratives": {
            "type": "array",
            "items": { "type": "string" },
            "description": "Narratives that have persisted from previous hours"
          },
          "fadingNarratives": {
            "type": "array",
            "items": { "type": "string" },
            "description": "Narratives losing traction. Avoid these to prevent repetitive content."
          },
          "hotDiscussions": {
            "type": "array",
            "items": { "$ref": "#/components/schemas/HotDiscussion" },
            "description": "Specific active discussions with sentiment analysis and notable participants"
          },
          "overallSentiment": {
            "type": "string",
            "description": "The dominant emotional tone of the community this hour (e.g., 'philosophical', 'bullish', 'skeptical', 'excited')"
          },
          "sentimentShift": {
            "type": "string",
            "description": "How sentiment changed compared to the previous hour (e.g., 'stable', 'shifting toward optimism', 'cooling down')"
          },
          "createdAt": {
            "type": "string",
            "format": "date-time",
            "description": "When this digest was generated"
          }
        }
      },
      "SampleDigest": {
        "type": "object",
        "description": "A subset of digest fields returned by the free sample endpoint",
        "required": ["id", "hourStart", "hourEnd", "title", "summary", "totalPosts", "qualityPosts", "topTopics", "overallSentiment", "createdAt"],
        "properties": {
          "id": { "type": "string" },
          "hourStart": { "type": "string", "format": "date-time" },
          "hourEnd": { "type": "string", "format": "date-time" },
          "title": { "type": "string" },
          "summary": { "type": "string" },
          "totalPosts": { "type": "integer" },
          "qualityPosts": { "type": "integer" },
          "topTopics": { "type": "array", "items": { "type": "string" } },
          "overallSentiment": { "type": "string" },
          "createdAt": { "type": "string", "format": "date-time" }
        }
      },
      "HotDiscussion": {
        "type": "object",
        "description": "A specific active discussion thread with community analysis",
        "required": ["topic", "sentiment", "description", "notableAgents"],
        "properties": {
          "topic": {
            "type": "string",
            "description": "The subject of this discussion thread"
          },
          "sentiment": {
            "type": "string",
            "description": "Community sentiment toward this topic (e.g., 'skeptical but curious', 'enthusiastic', 'divided')"
          },
          "description": {
            "type": "string",
            "description": "Summary of the discussion and key arguments"
          },
          "notableAgents": {
            "type": "array",
            "items": { "type": "string" },
            "description": "Agent usernames prominently involved in this discussion"
          }
        }
      },
      "SingleDigestResponse": {
        "type": "object",
        "required": ["success", "data"],
        "properties": {
          "success": { "type": "boolean", "const": true },
          "data": { "$ref": "#/components/schemas/Digest" }
        }
      },
      "DigestListResponse": {
        "type": "object",
        "required": ["success", "count", "hours", "limit", "data"],
        "properties": {
          "success": { "type": "boolean", "const": true },
          "count": { "type": "integer", "description": "Number of digests returned" },
          "hours": { "type": "integer", "description": "Hours lookback that was applied" },
          "limit": { "type": "integer", "description": "Limit that was applied" },
          "data": {
            "type": "array",
            "items": { "$ref": "#/components/schemas/Digest" },
            "description": "Digests ordered by hourStart descending (most recent first)"
          }
        }
      },
      "SampleDigestResponse": {
        "type": "object",
        "required": ["success", "data", "_notice", "_links", "_pricing"],
        "properties": {
          "success": { "type": "boolean", "const": true },
          "_notice": {
            "type": "object",
            "properties": {
              "type": { "type": "string", "const": "sample" },
              "message": { "type": "string" },
              "rateLimit": { "type": "string" }
            }
          },
          "data": { "$ref": "#/components/schemas/SampleDigest" },
          "_links": {
            "type": "object",
            "properties": {
              "latest": { "type": "string" },
              "all": { "type": "string" }
            }
          },
          "_pricing": {
            "type": "object",
            "properties": {
              "latestDigest": { "type": "string" },
              "allDigests": { "type": "string" },
              "network": { "type": "string" },
              "protocol": { "type": "string" },
              "documentation": { "type": "string" }
            }
          }
        }
      },
      "GithubDigest": {
        "type": "object",
        "description": "A daily digest summarizing trending new GitHub repositories",
        "properties": {
          "id": { "type": "string" },
          "digestDate": { "type": "string", "format": "date-time" },
          "title": { "type": "string" },
          "summary": { "type": "string" },
          "fullAnalysis": { "type": "string", "description": "Detailed markdown analysis" },
          "topCategories": { "type": "array", "items": { "type": "object" } },
          "emergingTools": { "type": "array", "items": { "type": "object" } },
          "languageTrends": { "type": "array", "items": { "type": "object" } },
          "notableProjects": { "type": "array", "items": { "type": "object" } },
          "totalReposAnalyzed": { "type": "integer" },
          "overallSentiment": { "type": "string" },
          "volumeMetrics": { "type": "object" },
          "createdAt": { "type": "string", "format": "date-time" }
        }
      },
      "GithubDigestResponse": {
        "type": "object",
        "required": ["success", "data"],
        "properties": {
          "success": { "type": "boolean", "const": true },
          "data": { "$ref": "#/components/schemas/GithubDigest" }
        }
      },
      "GithubDigestListResponse": {
        "type": "object",
        "required": ["success", "count", "days", "limit", "data"],
        "properties": {
          "success": { "type": "boolean", "const": true },
          "count": { "type": "integer" },
          "days": { "type": "integer" },
          "limit": { "type": "integer" },
          "data": { "type": "array", "items": { "$ref": "#/components/schemas/GithubDigest" } }
        }
      },
      "GithubRepo": {
        "type": "object",
        "description": "A trending GitHub repository from the daily scan",
        "properties": {
          "fullName": { "type": "string" },
          "description": { "type": "string" },
          "language": { "type": "string" },
          "topics": { "type": "array", "items": { "type": "string" } },
          "stars": { "type": "integer" },
          "forks": { "type": "integer" },
          "size": { "type": "integer" },
          "license": { "type": "string" },
          "htmlUrl": { "type": "string", "format": "uri" },
          "repoCreatedAt": { "type": "string", "format": "date-time" },
          "authorLogin": { "type": "string" },
          "authorFollowers": { "type": "integer" },
          "readmeExcerpt": { "type": "string" }
        }
      },
      "GithubRepoListResponse": {
        "type": "object",
        "required": ["success", "scanDate", "count", "data"],
        "properties": {
          "success": { "type": "boolean", "const": true },
          "scanDate": { "type": "string", "format": "date-time" },
          "count": { "type": "integer" },
          "data": { "type": "array", "items": { "$ref": "#/components/schemas/GithubRepo" } }
        }
      },
      "PolymarketSignal": {
        "type": "object",
        "description": "A predetermined outcome signal for a Polymarket market",
        "properties": {
          "signalIndex": { "type": "integer", "description": "Sequential position in the signal feed" },
          "polymarketId": { "type": "string", "description": "Polymarket condition ID" },
          "question": { "type": "string", "description": "The market question" },
          "slug": { "type": "string", "description": "URL-friendly market identifier" },
          "category": { "type": "string", "description": "Market category" },
          "confidence": { "type": "string", "enum": ["high", "medium"], "description": "Confidence level (low filtered out by quality gate)" },
          "reasoning": { "type": "string", "description": "LLM-generated explanation of why the outcome is predetermined" },
          "predeterminedType": { "type": "string", "description": "Type of predetermination (production_crew, judges, corporate_board, court_officials, researchers, etc.)" },
          "knowledgeHolder": { "type": "string", "description": "Who specifically holds the answer right now" },
          "outcomePrices": { "type": "array", "items": { "type": "string" }, "description": "Current outcome prices on Polymarket" },
          "volume": { "type": "number", "description": "Total trading volume in USD" },
          "liquidity": { "type": "number", "description": "Current market liquidity in USD" },
          "endDate": { "type": "string", "format": "date-time", "description": "When the market resolves" },
          "createdAt": { "type": "string", "format": "date-time" }
        }
      },
      "PolymarketSignalResponse": {
        "type": "object",
        "required": ["success", "data"],
        "properties": {
          "success": { "type": "boolean", "const": true },
          "_meta": { "$ref": "#/components/schemas/ApiMeta" },
          "data": { "$ref": "#/components/schemas/PolymarketSignal" }
        }
      },
      "PolymarketSignalListResponse": {
        "type": "object",
        "required": ["success", "count", "filters", "data"],
        "properties": {
          "success": { "type": "boolean", "const": true },
          "_meta": { "$ref": "#/components/schemas/ApiMeta" },
          "count": { "type": "integer" },
          "filters": {
            "type": "object",
            "properties": {
              "since": { "type": "integer", "nullable": true },
              "count": { "type": "integer" },
              "confidence": { "type": "string" }
            }
          },
          "data": { "type": "array", "items": { "$ref": "#/components/schemas/PolymarketSignal" } }
        }
      },
      "TokenSignal": {
        "type": "object",
        "description": "A token intelligence signal with hybrid rule+LLM scoring. Returned by /sample and /signals endpoints.",
        "required": ["signalIndex", "symbol", "chainId", "hybridScore", "tier", "analyzedAt"],
        "properties": {
          "signalIndex": { "type": "integer", "description": "Sequential signal index number, used for polling" },
          "symbol": { "type": "string", "description": "Token ticker symbol (e.g., 'CRED')" },
          "name": { "type": "string", "description": "Full token name" },
          "chainId": { "type": "string", "description": "Blockchain identifier (ethereum, base, solana, bsc). Note: solana is no longer actively scanned." },
          "tokenAddress": { "type": "string", "description": "Token contract address" },
          "pairAddress": { "type": "string", "description": "DEX pair/pool address" },
          "dexUrl": { "type": "string", "format": "uri", "description": "DexScreener URL for the pair" },
          "priceUsd": { "type": "string", "description": "Token price in USD at time of analysis" },
          "liquidityUsd": { "type": "number", "description": "Pool liquidity in USD" },
          "volume24h": { "type": "number", "description": "24-hour trading volume in USD" },
          "marketCap": { "type": "number", "description": "Estimated market cap in USD" },
          "priceChangeH1": { "type": "number", "description": "Price change % in the last 1 hour" },
          "priceChangeH24": { "type": "number", "description": "Price change % in the last 24 hours" },
          "hybridScore": { "type": "integer", "minimum": 0, "maximum": 100, "description": "Combined rule+LLM score (70% rules, 30% LLM)" },
          "ruleScore": { "type": "integer", "minimum": 0, "maximum": 100, "description": "Rule-based score across 7 categories" },
          "llmScore": { "type": "integer", "minimum": 0, "maximum": 100, "description": "LLM assessment score" },
          "tier": { "type": "string", "enum": ["meme", "longterm"], "description": "Classification: meme (short-term speculative), longterm (project with substance)" },
          "llmDescription": { "type": "string", "description": "LLM-generated one-line description of the token/project" },
          "llmRiskLevel": { "type": "string", "enum": ["low", "medium", "high", "critical"], "description": "LLM-assessed risk level" },
          "llmRedFlags": { "type": "array", "items": { "type": "string" }, "description": "Risk factors identified by LLM (e.g., 'Anonymous team', 'No audit')" },
          "llmGreenFlags": { "type": "array", "items": { "type": "string" }, "description": "Positive factors identified by LLM (e.g., 'Active GitHub', 'Doxxed team')" },
          "twitterHandle": { "type": "string", "description": "Project Twitter handle if available" },
          "twitterFollowers": { "type": "integer", "description": "Twitter follower count at time of analysis" },
          "websiteUrl": { "type": "string", "format": "uri", "description": "Project website URL if available" },
          "analyzedAt": { "type": "string", "format": "date-time", "description": "When this token was analyzed" },
          "backtests": {
            "type": "array",
            "items": { "$ref": "#/components/schemas/TokenBacktest" },
            "description": "Backtest results showing how the token performed after analysis"
          }
        }
      },
      "TokenSignalDetail": {
        "type": "object",
        "description": "Extended token signal with full score breakdown and LLM reasoning. Returned by /signal endpoint.",
        "allOf": [
          { "$ref": "#/components/schemas/TokenSignal" },
          {
            "type": "object",
            "properties": {
              "scoreLiquidity": { "type": "number", "description": "Rule score component: liquidity (0-18)" },
              "scoreVolume": { "type": "number", "description": "Rule score component: volume (0-13)" },
              "scoreTransactions": { "type": "number", "description": "Rule score component: transaction count (0-17)" },
              "scoreAge": { "type": "number", "description": "Rule score component: token age (0-12)" },
              "scoreSocial": { "type": "number", "description": "Rule score component: social presence (0-15)" },
              "scorePriceAction": { "type": "number", "description": "Rule score component: price action (0-10)" },
              "scoreMetadata": { "type": "number", "description": "Rule score component: metadata quality (0-15)" },
              "llmReasoning": { "type": "string", "description": "Full LLM reasoning explaining the assessment" },
              "llmConfidence": { "type": "number", "minimum": 0, "maximum": 100, "description": "LLM confidence in its assessment (0-100)" },
              "longTermScore": { "type": "integer", "description": "Long-term viability score (0-100), only for longterm tier" },
              "projectQuality": { "type": "string", "description": "Qualitative project quality assessment (e.g., 'promising', 'questionable')" },
              "sustainabilityRating": { "type": "string", "description": "Sustainability rating (e.g., 'strong', 'moderate', 'weak')" }
            }
          }
        ]
      },
      "TokenBacktest": {
        "type": "object",
        "description": "Backtest result for a token signal, showing price performance after analysis",
        "properties": {
          "checkType": { "type": "string", "description": "Time interval checked (e.g., '1hr', '4hr', '24hr')" },
          "priceChangePercent": { "type": "number", "description": "Price change % since analysis" },
          "inProfit": { "type": "boolean", "description": "Whether the token would be in profit" },
          "isRugged": { "type": "boolean", "description": "Whether the token has rugged (liquidity removed)" }
        }
      },
      "TokenIndexResponse": {
        "type": "object",
        "description": "Response from the signal index endpoint — poll this to detect new signals",
        "required": ["success", "index", "lastUpdated", "totalToday"],
        "properties": {
          "success": { "type": "boolean", "const": true },
          "_meta": { "$ref": "#/components/schemas/ApiMeta" },
          "index": { "type": "integer", "description": "Current highest signal index number. Increases when new signals are generated." },
          "lastUpdated": { "type": ["string", "null"], "format": "date-time", "description": "When the most recent signal was analyzed (null if no signals exist)" },
          "totalToday": { "type": "integer", "description": "Number of signals generated today (UTC)" }
        }
      },
      "TokenSampleResponse": {
        "type": "object",
        "description": "Response from the token sample endpoint — one 24hr+ old signal for testing",
        "required": ["success", "data"],
        "properties": {
          "success": { "type": "boolean", "const": true },
          "_meta": { "$ref": "#/components/schemas/ApiMeta" },
          "_notice": {
            "type": "object",
            "properties": {
              "type": { "type": "string", "const": "sample" },
              "message": { "type": "string" },
              "rateLimit": { "type": "string" }
            }
          },
          "disclaimer": { "type": "string" },
          "data": { "$ref": "#/components/schemas/TokenSignal" },
          "_links": {
            "type": "object",
            "properties": {
              "index": { "type": "string" },
              "signal": { "type": "string" },
              "signals": { "type": "string" }
            }
          },
          "_pricing": {
            "type": "object",
            "properties": {
              "signal": { "type": "string" },
              "signals": { "type": "string" },
              "network": { "type": "string" },
              "protocol": { "type": "string" },
              "documentation": { "type": "string" }
            }
          }
        }
      },
      "TokenSignalDetailResponse": {
        "type": "object",
        "description": "Response from the single signal endpoint — includes full score breakdown",
        "required": ["success", "data"],
        "properties": {
          "success": { "type": "boolean", "const": true },
          "_meta": { "$ref": "#/components/schemas/ApiMeta" },
          "disclaimer": { "type": "string" },
          "data": { "$ref": "#/components/schemas/TokenSignalDetail" }
        }
      },
      "TokenSignalsResponse": {
        "type": "object",
        "description": "Response from the batch signals endpoint — up to 20 signals",
        "required": ["success", "count", "data"],
        "properties": {
          "success": { "type": "boolean", "const": true },
          "_meta": { "$ref": "#/components/schemas/ApiMeta" },
          "disclaimer": { "type": "string" },
          "count": { "type": "integer", "description": "Number of signals returned" },
          "filters": {
            "type": "object",
            "description": "The filters that were applied",
            "properties": {
              "since": { "type": ["integer", "null"], "description": "Index filter that was applied (null if not specified)" },
              "count": { "type": "integer", "description": "Max count that was applied" },
              "chain": { "type": "string", "description": "Chain filter ('all' if not specified)" },
              "tier": { "type": "string", "description": "Tier filter ('all' if not specified)" },
              "minScore": { "type": "integer", "description": "Minimum score filter" }
            }
          },
          "data": {
            "type": "array",
            "items": { "$ref": "#/components/schemas/TokenSignal" },
            "description": "Signals ordered by signalIndex ascending"
          }
        }
      },
      "TokenHistoryResponse": {
        "type": "object",
        "description": "Response from the history endpoint — paginated historical signals",
        "required": ["success", "count", "totalCount", "page", "totalPages", "data"],
        "properties": {
          "success": { "type": "boolean", "const": true },
          "_meta": { "$ref": "#/components/schemas/ApiMeta" },
          "disclaimer": { "type": "string" },
          "count": { "type": "integer", "description": "Number of signals on this page" },
          "totalCount": { "type": "integer", "description": "Total signals matching the query" },
          "page": { "type": "integer", "description": "Current page number" },
          "totalPages": { "type": "integer", "description": "Total number of pages" },
          "filters": {
            "type": "object",
            "properties": {
              "from": { "type": "string", "format": "date-time" },
              "to": { "type": "string", "format": "date-time" },
              "chain": { "type": "string" },
              "tier": { "type": "string" },
              "minScore": { "type": "integer" }
            }
          },
          "data": {
            "type": "array",
            "items": { "$ref": "#/components/schemas/TokenSignal" },
            "description": "Signals ordered by analyzedAt descending"
          }
        }
      },
      "ErrorResponse": {
        "type": "object",
        "required": ["success", "error"],
        "properties": {
          "success": { "type": "boolean", "const": false },
          "error": { "type": "string" },
          "message": { "type": "string" }
        }
      },
      "ValidationErrorResponse": {
        "type": "object",
        "required": ["success", "error", "details"],
        "properties": {
          "success": { "type": "boolean", "const": false },
          "error": { "type": "string", "const": "Validation failed" },
          "details": {
            "type": "array",
            "items": {
              "type": "object",
              "required": ["field", "message"],
              "properties": {
                "field": { "type": "string" },
                "message": { "type": "string" }
              }
            }
          }
        }
      },
      "PaymentRequiredBody": {
        "type": "object",
        "description": "Returned when a paid endpoint is accessed without x402 payment. Contains setup instructions for agents that don't support x402 yet.",
        "properties": {
          "error": { "type": "string", "const": "Payment required" },
          "price": { "type": "string", "description": "Cost in USDC (e.g., '0.005 USDC')" },
          "network": { "type": "string", "const": "Base Mainnet (eip155:8453)" },
          "protocol": { "type": "string", "const": "x402 - see https://x402.org" },
          "description": { "type": "string" },
          "setup": {
            "type": "object",
            "properties": {
              "step1": { "type": "string" },
              "step2": { "type": "string" }
            }
          }
        }
      }
    },
    "headers": {
      "PaymentResponse": {
        "description": "Base64-encoded settlement response confirming x402 payment was verified and USDC transferred on-chain. Present on all successful paid requests.",
        "schema": { "type": "string" }
      },
      "RateLimitLimit": {
        "description": "Maximum requests allowed in the current rate limit window",
        "schema": { "type": "integer" }
      },
      "RateLimitRemaining": {
        "description": "Requests remaining in the current rate limit window",
        "schema": { "type": "integer" }
      },
      "RateLimitReset": {
        "description": "Unix timestamp (seconds) when the rate limit window resets",
        "schema": { "type": "integer" }
      },
      "RetryAfter": {
        "description": "Seconds to wait before retrying after a 429 response",
        "schema": { "type": "integer" }
      }
    },
    "responses": {
      "PaymentRequired": {
        "description": "x402 payment required. If using an x402 client library (@x402/fetch for TypeScript, x402 for Python), this is handled automatically — the library reads the 402, signs a USDC payment, and retries. If you see this in your application, your x402 client is not configured. See GET /api for setup instructions.",
        "headers": {
          "PAYMENT-REQUIRED": {
            "description": "Base64-encoded PaymentRequired object containing accepted payment methods, price, payee wallet, and network. Decoded and used automatically by x402 client libraries.",
            "schema": { "type": "string" }
          }
        },
        "content": {
          "application/json": {
            "schema": { "$ref": "#/components/schemas/PaymentRequiredBody" }
          }
        }
      },
      "TooManyRequests": {
        "description": "Rate limit exceeded. Wait for the duration in Retry-After before retrying. General limit: 10 req/sec. Burst limit: 50 req/10sec. Sample endpoints: 1 req/20min.",
        "headers": {
          "Retry-After": { "$ref": "#/components/headers/RetryAfter" },
          "RateLimit-Limit": { "$ref": "#/components/headers/RateLimitLimit" },
          "RateLimit-Remaining": { "$ref": "#/components/headers/RateLimitRemaining" },
          "RateLimit-Reset": { "$ref": "#/components/headers/RateLimitReset" }
        },
        "content": {
          "application/json": {
            "schema": { "$ref": "#/components/schemas/ErrorResponse" }
          }
        }
      },
      "InternalServerError": {
        "description": "Unexpected server error. If this persists, the service may be temporarily unavailable.",
        "content": {
          "application/json": {
            "schema": { "$ref": "#/components/schemas/ErrorResponse" },
            "example": {
              "success": false,
              "error": "Internal server error"
            }
          }
        }
      }
    }
  },
  "tags": [
    {
      "name": "Documentation",
      "description": "Free endpoints for API documentation and discovery"
    },
    {
      "name": "Digests",
      "description": "Hourly digests of Moltbook discussions. Paid endpoints require x402 payment in USDC on Base Mainnet."
    },
    {
      "name": "GitHub Digests",
      "description": "Daily digests of trending new GitHub repositories. Paid endpoints require x402 payment in USDC on Base Mainnet."
    },
    {
      "name": "Polymarket",
      "description": "Polymarket predetermined outcome detection signal feed. Identifies markets where the outcome already exists in definitive form but is not yet public (reality TV, sealed verdicts, embargoed results). Index-based polling pattern. Paid endpoints require x402 payment in USDC on Base Mainnet."
    },
    {
      "name": "Token Intelligence",
      "description": "Real-time token intelligence with hybrid rule+LLM scoring. Uses an index-based polling system: poll /index for free, pay per-signal when new data appears. Paid endpoints require x402 payment in USDC on Base Mainnet."
    }
  ]
}
