{
  "openapi": "3.1.0",
  "info": {
    "title": "Marketplace for AI Agents — APIs",
    "version": "1.0.0",
    "description": "x402-gated APIs for autonomous agents. Payments settle in USDC on Base mainnet. Each endpoint returns HTTP 402 with a machine-readable `accepts` payload on the first paid call; agents resign an EIP-3009 USDC authorization and resend with `X-PAYMENT`.",
    "contact": {
      "url": "https://marketplaceforaiagents.com"
    }
  },
  "servers": [
    {
      "url": "https://marketplaceforaiagents.com"
    }
  ],
  "x-x402": {
    "payTo": "0x05e82e03753c7bc99fb24d10a876cce53f24b7b7",
    "network": "base",
    "asset": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
    "scheme": "exact",
    "manifest": "https://marketplaceforaiagents.com/.well-known/x402"
  },
  "paths": {
    "/api/public/v1/youtube-transcripts": {
      "get": {
        "operationId": "getYouTubeTranscripts",
        "summary": "Fetch transcript segments for a YouTube video",
        "description": "Returns full timed transcript segments. Free for the first 3 calls per identity hash, then $0.005 USDC per call via x402.",
        "parameters": [
          {
            "name": "video_id",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 11,
              "maxLength": 11
            },
            "description": "YouTube video ID (11 characters)."
          },
          {
            "name": "lang",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Optional ISO language code (e.g. 'en')."
          },
          {
            "name": "X-PAYMENT",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Base64-encoded x402 PaymentPayload. Required after the free tier is exhausted."
          }
        ],
        "responses": {
          "200": {
            "description": "Transcript segments.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TranscriptResponse"
                }
              }
            }
          },
          "400": {
            "description": "Bad request — missing or invalid video_id."
          },
          "402": {
            "description": "Payment required. Body contains x402 `accepts`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PaymentRequired"
                }
              }
            }
          },
          "500": {
            "description": "Upstream or settlement error."
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "TranscriptSegment": {
        "type": "object",
        "properties": {
          "text": {
            "type": "string"
          },
          "start": {
            "type": "number",
            "description": "Start time in seconds."
          },
          "duration": {
            "type": "number",
            "description": "Segment length in seconds."
          }
        },
        "required": [
          "text",
          "start",
          "duration"
        ]
      },
      "TranscriptResponse": {
        "type": "object",
        "properties": {
          "video_id": {
            "type": "string"
          },
          "transcripts": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/TranscriptSegment"
            }
          }
        },
        "required": [
          "transcripts"
        ]
      },
      "PaymentRequired": {
        "type": "object",
        "properties": {
          "x402Version": {
            "type": "integer",
            "example": 1
          },
          "error": {
            "type": "string",
            "example": "X-PAYMENT header required"
          },
          "accepts": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "scheme": {
                  "type": "string",
                  "example": "exact"
                },
                "network": {
                  "type": "string",
                  "example": "base"
                },
                "maxAmountRequired": {
                  "type": "string",
                  "example": "5000"
                },
                "asset": {
                  "type": "string"
                },
                "payTo": {
                  "type": "string"
                },
                "resource": {
                  "type": "string"
                },
                "description": {
                  "type": "string"
                },
                "mimeType": {
                  "type": "string"
                },
                "maxTimeoutSeconds": {
                  "type": "integer"
                },
                "extra": {
                  "type": "object"
                }
              }
            }
          }
        }
      }
    }
  }
}