{
  "openapi": "3.1.0",
  "info": {
    "title": "x402 Agent Tools: GEO audit + trading metrics",
    "version": "1.1.0",
    "description": "x402 pay-per-call API. Prices in USDC; networks: solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp, eip155:8453",
    "contact": {
      "email": "electro.nest10@gmail.com"
    }
  },
  "servers": [
    {
      "url": "https://geo-audit-x402.vojtech-digital.workers.dev"
    }
  ],
  "paths": {
    "/": {
      "get": {
        "summary": "Service info, endpoints, prices, networks",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        }
      }
    },
    "/health": {
      "get": {
        "summary": "Health check",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/.well-known/x402": {
      "get": {
        "summary": "x402 discovery resource list",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        }
      }
    },
    "/llms.txt": {
      "get": {
        "summary": "Agent-readable documentation",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "text/plain": {
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        }
      }
    },
    "/openapi.json": {
      "get": {
        "summary": "This OpenAPI document",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        }
      }
    },
    "/v1/preview": {
      "get": {
        "summary": "Free GEO audit preview",
        "parameters": [
          {
            "name": "url",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uri",
              "description": "Public http(s) URL of the page to audit"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Preview",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "url": {
                      "type": "string"
                    },
                    "score": {
                      "type": "integer"
                    },
                    "grade": {
                      "type": "string"
                    },
                    "issues_found": {
                      "type": "integer"
                    },
                    "top_issue_titles": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "upgrade": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid input (not charged)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "502": {
            "description": "Target unreachable"
          }
        }
      }
    },
    "/v1/audit": {
      "get": {
        "summary": "Full GEO / AI visibility audit (0.05 USDC)",
        "description": "AI search visibility (GEO) audit of a public web page. Fetches the page plus robots.txt, llms.txt and sitemap and checks: access for 12 AI crawlers (GPTBot, OAI-SearchBot, ChatGPT-User, ClaudeBot, Claude-SearchBot, Claude-User, PerplexityBot, Perplexity-User, Google-Extended, Applebot-Extended, CCBot, Bingbot), llms.txt, sitemap, JSON-LD schema types, title/meta/canonical/Open Graph, headings and content structure, JS-only rendering, response time. Returns a 0-100 score, A-F grade, every check with pass/warn/fail, and top priority fixes with copy-paste snippets. Deterministic, no LLM. Input: ?url=<public http(s) URL>. Not charged on invalid URL (400) or unreachable target (502).",
        "x-x402": {
          "price": "0.05",
          "currency": "USDC",
          "networks": [
            "solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp",
            "eip155:8453"
          ],
          "x402Versions": [
            1,
            2
          ],
          "facilitator": "https://facilitator.payai.network"
        },
        "parameters": [
          {
            "name": "url",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uri",
              "description": "Public http(s) URL of the page to audit"
            }
          },
          {
            "name": "X-PAYMENT",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "x402 v1 payment payload (base64 JSON)"
          },
          {
            "name": "PAYMENT-SIGNATURE",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "x402 v2 payment payload (base64 JSON)"
          }
        ],
        "responses": {
          "200": {
            "description": "Audit report",
            "headers": {
              "X-PAYMENT-RESPONSE": {
                "schema": {
                  "type": "string"
                }
              },
              "PAYMENT-RESPONSE": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "audited_url": {
                      "type": "string"
                    },
                    "final_url": {
                      "type": "string"
                    },
                    "score": {
                      "type": "integer",
                      "minimum": 0,
                      "maximum": 100
                    },
                    "grade": {
                      "enum": [
                        "A",
                        "B",
                        "C",
                        "D",
                        "F"
                      ]
                    },
                    "issues_found": {
                      "type": "integer"
                    },
                    "priority_fixes": {
                      "type": "array",
                      "items": {
                        "type": "object"
                      }
                    },
                    "ai_crawlers": {
                      "type": "object",
                      "additionalProperties": {
                        "enum": [
                          "allowed",
                          "blocked"
                        ]
                      }
                    },
                    "json_ld_types": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "word_count": {
                      "type": "integer"
                    },
                    "checks": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "title": {
                            "type": "string"
                          },
                          "status": {
                            "enum": [
                              "pass",
                              "warn",
                              "fail"
                            ]
                          },
                          "weight": {
                            "type": "number"
                          },
                          "detail": {
                            "type": "string"
                          },
                          "fix": {
                            "type": "string"
                          }
                        }
                      }
                    },
                    "generated_at": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "score",
                    "grade",
                    "checks"
                  ]
                },
                "example": {
                  "audited_url": "https://example.com/",
                  "final_url": "https://example.com/",
                  "score": 62,
                  "grade": "D",
                  "issues_found": 17,
                  "priority_fixes": [
                    {
                      "id": "llms_txt",
                      "title": "/llms.txt present",
                      "status": "fail",
                      "weight": 7,
                      "detail": "...",
                      "fix": "Create /llms.txt ..."
                    }
                  ],
                  "ai_crawlers": {
                    "GPTBot": "allowed",
                    "ClaudeBot": "allowed",
                    "PerplexityBot": "allowed"
                  },
                  "json_ld_types": [],
                  "word_count": 30,
                  "checks": [
                    {
                      "id": "https",
                      "title": "HTTPS",
                      "status": "pass",
                      "weight": 5,
                      "detail": "...",
                      "fix": ""
                    }
                  ],
                  "generated_at": "2026-11-28T00:00:00.000Z"
                }
              }
            }
          },
          "400": {
            "description": "Invalid input (not charged)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "402": {
            "description": "Payment required. Body: x402 v1 challenge; header PAYMENT-REQUIRED: base64 x402 v2 challenge.",
            "headers": {
              "PAYMENT-REQUIRED": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "502": {
            "description": "Target unreachable (not charged)"
          }
        }
      }
    },
    "/v1/trading-metrics": {
      "post": {
        "summary": "Trading strategy statistics + edge verdict (0.01 USDC)",
        "description": "Statistical edge check for a trading strategy. POST JSON with per-trade PnL (trades), periodic fractional returns (returns) and/or an equity curve (equity). Returns winRate, avgWin, avgLoss, payoffRatio, expectancy, profitFactor, totalPnl, maxDrawdown (abs and pct), maxConsecutiveLosses, Sharpe, Sortino, Kelly fraction, one-sample t-statistic and one-sided p-value for mean > 0, a seeded 1000-sample bootstrap 95% CI of expectancy, and a verdict: 'supported', 'not supported' or 'insufficient sample' (n < 30), with an honest caveat. Deterministic, no LLM, no data stored. Not charged on invalid input (400).",
        "x-x402": {
          "price": "0.01",
          "currency": "USDC",
          "networks": [
            "solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp",
            "eip155:8453"
          ],
          "x402Versions": [
            1,
            2
          ],
          "facilitator": "https://facilitator.payai.network"
        },
        "parameters": [
          {
            "name": "X-PAYMENT",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "x402 v1 payment payload (base64 JSON)"
          },
          {
            "name": "PAYMENT-SIGNATURE",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "x402 v2 payment payload (base64 JSON)"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false,
                "description": "Provide at least one of trades, returns, equity.",
                "properties": {
                  "trades": {
                    "type": "array",
                    "items": {
                      "type": "number"
                    },
                    "minItems": 2,
                    "maxItems": 100000,
                    "description": "Per-trade profit/loss in account currency, e.g. [12.5, -8, 30]. Used for win/loss stats, expectancy and t-test."
                  },
                  "returns": {
                    "type": "array",
                    "items": {
                      "type": "number"
                    },
                    "minItems": 2,
                    "maxItems": 100000,
                    "description": "Per-period fractional returns, e.g. 0.01 = +1%. Each must be > -1. Used for Sharpe/Sortino (and win/loss stats if trades absent)."
                  },
                  "equity": {
                    "type": "array",
                    "items": {
                      "type": "number"
                    },
                    "minItems": 3,
                    "maxItems": 100000,
                    "description": "Equity curve (account value per period, all > 0, min 3 points). Used for drawdown; returns derived from it if returns absent."
                  },
                  "periodsPerYear": {
                    "type": "number",
                    "exclusiveMinimum": 0,
                    "maximum": 1000000,
                    "description": "Annualization factor for Sharpe/Sortino. Default 252 for returns/equity; per-trade (1) when only trades are given."
                  },
                  "riskFreeRate": {
                    "type": "number",
                    "exclusiveMinimum": -1,
                    "exclusiveMaximum": 1,
                    "description": "Annual risk-free rate as a fraction (e.g. 0.04). Applied to returns only. Default 0."
                  },
                  "startingEquity": {
                    "type": "number",
                    "exclusiveMinimum": 0,
                    "description": "Optional account size, so trade-based maxDrawdown.pct is a % of account."
                  },
                  "seed": {
                    "type": "integer",
                    "minimum": 0,
                    "maximum": 4294967295,
                    "description": "Bootstrap PRNG seed. Default 42."
                  }
                }
              },
              "example": {
                "trades": [
                  12.5,
                  -8,
                  30,
                  -4.2,
                  18,
                  -11,
                  7.5,
                  22,
                  -9,
                  15
                ],
                "startingEquity": 1000
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Metrics",
            "headers": {
              "X-PAYMENT-RESPONSE": {
                "schema": {
                  "type": "string"
                }
              },
              "PAYMENT-RESPONSE": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "n": {
                      "type": "integer"
                    },
                    "basis": {
                      "enum": [
                        "trades",
                        "returns"
                      ]
                    },
                    "winRate": {
                      "type": [
                        "number",
                        "null"
                      ],
                      "description": "wins / (wins + losses); zero outcomes excluded"
                    },
                    "avgWin": {
                      "type": [
                        "number",
                        "null"
                      ]
                    },
                    "avgLoss": {
                      "type": [
                        "number",
                        "null"
                      ],
                      "description": "mean losing outcome (negative)"
                    },
                    "payoffRatio": {
                      "type": [
                        "number",
                        "null"
                      ]
                    },
                    "expectancy": {
                      "type": [
                        "number",
                        "null"
                      ],
                      "description": "mean outcome per trade/period"
                    },
                    "profitFactor": {
                      "type": [
                        "number",
                        "null"
                      ]
                    },
                    "totalPnl": {
                      "type": [
                        "number",
                        "null"
                      ]
                    },
                    "maxDrawdown": {
                      "type": "object",
                      "properties": {
                        "abs": {
                          "type": [
                            "number",
                            "null"
                          ]
                        },
                        "pct": {
                          "type": [
                            "number",
                            "null"
                          ]
                        },
                        "basis": {
                          "type": "string"
                        }
                      }
                    },
                    "maxConsecutiveLosses": {
                      "type": "integer"
                    },
                    "sharpe": {
                      "type": [
                        "number",
                        "null"
                      ]
                    },
                    "sortino": {
                      "type": [
                        "number",
                        "null"
                      ]
                    },
                    "ratioBasis": {
                      "type": "string"
                    },
                    "periodsPerYear": {
                      "type": "number"
                    },
                    "kellyFraction": {
                      "type": [
                        "number",
                        "null"
                      ]
                    },
                    "tStatMean": {
                      "type": [
                        "number",
                        "null"
                      ]
                    },
                    "pValueMeanGt0": {
                      "type": [
                        "number",
                        "null"
                      ]
                    },
                    "bootstrap": {
                      "type": "object",
                      "properties": {
                        "expectancyCI95": {
                          "type": "array",
                          "items": {
                            "type": [
                              "number",
                              "null"
                            ]
                          }
                        },
                        "samples": {
                          "type": "integer"
                        },
                        "seed": {
                          "type": "integer"
                        },
                        "method": {
                          "type": "string"
                        }
                      }
                    },
                    "verdict": {
                      "enum": [
                        "supported",
                        "not supported",
                        "insufficient sample"
                      ]
                    },
                    "verdictReason": {
                      "type": "string"
                    },
                    "caveat": {
                      "type": "string"
                    },
                    "notes": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    }
                  },
                  "required": [
                    "n",
                    "verdict",
                    "expectancy",
                    "caveat"
                  ]
                },
                "example": {
                  "n": 10,
                  "basis": "trades",
                  "winRate": 0.6,
                  "avgWin": 17.5,
                  "avgLoss": -8.05,
                  "payoffRatio": 2.173913043,
                  "expectancy": 7.28,
                  "profitFactor": 3.260869565,
                  "totalPnl": 72.8,
                  "maxDrawdown": {
                    "abs": 11,
                    "pct": 0.01049317943,
                    "basis": "cumulative trades + startingEquity"
                  },
                  "maxConsecutiveLosses": 1,
                  "sharpe": 0.5011552844,
                  "sortino": 1.366934299,
                  "ratioBasis": "trades",
                  "periodsPerYear": 1,
                  "kellyFraction": 0.416,
                  "tStatMean": 1.58479216,
                  "pValueMeanGt0": 0.07373721587,
                  "bootstrap": {
                    "expectancyCI95": [
                      -0.64025,
                      15.805
                    ],
                    "samples": 1000,
                    "seed": 42,
                    "method": "percentile, iid resampling"
                  },
                  "verdict": "insufficient sample",
                  "verdictReason": "Only 10 observations; at least 30 are needed before any conclusion about expectancy.",
                  "caveat": "Statistical check of past results only, not financial advice or a forecast. Assumes observations are independent and identically distributed; autocorrelation, regime changes, unmodeled fees/slippage, survivorship and look-ahead bias, and testing many strategy variants (multiple comparisons / overfitting) can all make a 'supported' edge disappear out of sample. Kelly assumes the win rate and payoff are known exactly; most practitioners bet a fraction of it.",
                  "notes": [
                    "sharpe/sortino are per-trade (not annualized); pass periodsPerYear (trades per year) to annualize."
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Invalid input (not charged)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "402": {
            "description": "Payment required. Body: x402 v1 challenge; header PAYMENT-REQUIRED: base64 x402 v2 challenge.",
            "headers": {
              "PAYMENT-REQUIRED": {
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "Error": {
        "type": "object",
        "properties": {
          "error": {
            "type": "string"
          }
        },
        "required": [
          "error"
        ]
      }
    }
  }
}