{
  "openapi": "3.1.0",
  "info": {
    "title": "Takar Second Opinion",
    "version": "1.0.0",
    "description": "A second opinion for any Telegraph intent, in one call. Takar asks two different Telegraph miners, chosen by an open on-chain record of who was right (EAS on Ethereum Sepolia), and tells you whether they agree. It never averages: a disagreement comes back with both answers and the fields that differ. Free to call; Takar pays the asks in test USDC. Testnet only. Built for Telegraph Hackathon Season II, which pays cash prizes."
  },
  "servers": [
    {
      "url": "https://takar-telegraph.vercel.app"
    }
  ],
  "paths": {
    "/api/second-opinion": {
      "post": {
        "operationId": "secondOpinion",
        "summary": "Ask two independent Telegraph miners the same question and compare their answers",
        "description": "Use this before acting on intelligence from Telegraph: prices, weather, sanctions, event outcomes, on-chain facts, any intent. If verdict is 'agree', act on 'answer'. If 'disagree', do not act on either answer alone: report both and the differing fields. If 'insufficient', fewer than two usable answers were available.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "intent",
                  "params"
                ],
                "properties": {
                  "intent": {
                    "type": "string",
                    "description": "Exact Telegraph intent name, from https://devnode.telegraphprotocol.com/engine/v1/intents",
                    "example": "EVENT_OUTCOME_RESOLUTION_GENERAL"
                  },
                  "params": {
                    "type": "object",
                    "description": "The intent's request params, as its schema defines them",
                    "example": {
                      "event": "Did Argentina win the 2022 FIFA World Cup?"
                    }
                  },
                  "client": {
                    "type": "string",
                    "maxLength": 40,
                    "description": "Optional name for your app. Every call is recorded on EAS; named clients are counted by name in /api/feed.",
                    "example": "my-mind"
                  },
                  "fields": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    },
                    "maxItems": 5,
                    "description": "Optional: the fields that decide the verdict (both miners must fill them); other differences are reported as other_differences",
                    "example": [
                      "matched"
                    ]
                  },
                  "escalate": {
                    "type": "boolean",
                    "description": "Optional: when the two answers disagree, buy one more independent opinion and report which side it matches (escalation.sides_with). The verdict stays 'disagree'. Agreement buys nothing extra."
                  },
                  "maxUsd": {
                    "type": "number",
                    "description": "Optional: a lower cost cap for this call in USD (the server's cap is 0.03)."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The comparison",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "verdict": {
                      "type": "string",
                      "enum": [
                        "agree",
                        "disagree",
                        "insufficient"
                      ]
                    },
                    "answer": {
                      "type": "object",
                      "description": "The agreed answer (only when verdict is agree)"
                    },
                    "differ": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      },
                      "description": "Fields on which the miners disagree"
                    },
                    "compared": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "answers": {
                      "type": "array",
                      "description": "Each miner's answer, its id and its Telegraph signal hash",
                      "items": {
                        "type": "object"
                      }
                    },
                    "signals": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      },
                      "description": "Public Telegraph records of each ask"
                    },
                    "costUsd": {
                      "type": "number"
                    },
                    "spread": {
                      "type": "object",
                      "description": "For numeric fields, how far apart the two answers were (even when they agree within tolerance)"
                    },
                    "record": {
                      "type": "string",
                      "description": "The EAS attestation transaction for this call"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad intent or params"
          },
          "429": {
            "description": "Rate limited"
          }
        }
      }
    },
    "/api/reputation": {
      "get": {
        "operationId": "minerReputation",
        "summary": "Which Telegraph miner to trust for an intent, from the open on-chain record",
        "parameters": [
          {
            "name": "intent",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "example": "EVENT_OUTCOME_RESOLUTION_GENERAL"
          },
          {
            "name": "attester",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Only count evidence from this attester address"
          }
        ],
        "responses": {
          "200": {
            "description": "Miners ranked by the Wilson lower bound of accuracy, with right / wrong / unusable / abstained counts"
          }
        }
      }
    },
    "/api/resolve": {
      "post": {
        "operationId": "resolveEvent",
        "summary": "Resolve a real-world event (Takar Outcome, Telegraph miner 20261117)",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "event"
                ],
                "properties": {
                  "event": {
                    "type": "string",
                    "example": "Did Argentina win the 2022 FIFA World Cup?"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "outcome yes / no / unresolved, with the source it rests on"
          }
        }
      }
    },
    "/api/feed": {
      "get": {
        "operationId": "secondOpinionFeed",
        "summary": "Every second opinion given, counted from EAS: calls, verdicts, intents, clients, latest disagreements with both signals",
        "responses": {
          "200": {
            "description": "Feed summary"
          }
        }
      }
    },
    "/api/miner": {
      "get": {
        "operationId": "minerReport",
        "summary": "Why a Telegraph miner scored what it scored: per-epoch scores, spot checks, status, paid record, and flags such as a 0 with no failure reason",
        "parameters": [
          {
            "name": "id",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            },
            "example": "takar-outcome"
          },
          {
            "name": "format",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "svg"
              ]
            },
            "description": "svg returns a README badge"
          }
        ],
        "responses": {
          "200": {
            "description": "Report per intent"
          }
        }
      }
    },
    "/api/network": {
      "get": {
        "operationId": "networkCheck",
        "summary": "Who runs the miners (fee addresses, independent operators per intent), how often miners from different operators disagree (from the EAS feed), or one signal traced to the node, Takar's ledger and its EAS anchor",
        "parameters": [
          {
            "name": "view",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "operators",
                "disagreement",
                "signal"
              ],
              "default": "operators"
            }
          },
          {
            "name": "hash",
            "in": "query",
            "required": false,
            "description": "Signal hash (0x + 64 hex), for view=signal",
            "schema": {
              "type": "string",
              "pattern": "^0x[0-9a-fA-F]{64}$"
            },
            "example": "0xe3e293c9262f0c8f053eeb11ffc02356c006578f4f2099cc7bbacb5920d969b4"
          }
        ],
        "responses": {
          "200": {
            "description": "The view"
          },
          "400": {
            "description": "Unknown view or malformed hash"
          },
          "503": {
            "description": "Registry or feed unreachable"
          }
        }
      }
    }
  }
}
