openapi: 3.1.0
info:
  title: Autonomy API Network
  version: 0.2.0
  description: Payment-ready micro-APIs designed for software and AI agents.
  x-guidance: >-
    Use the paid POST endpoints for developer, website, image, text, and
    data-quality tasks. Send the documented JSON body. An unpaid request
    returns an x402 HTTP 402 challenge. Pay the quoted USDC amount on Base
    mainnet, then retry the same request to receive the JSON result.

servers:
  - url: https://autonomy-api-network.onrender.com
    description: Production
  - url: http://localhost:4021
    description: Local development

paths:
  /health:
    get:
      operationId: getHealth
      summary: Health check
      responses:
        "200":
          description: Service is healthy
          content:
            application/json:
              schema:
                type: object

  /v1/catalog:
    get:
      operationId: getCatalog
      summary: List available tools, prices, and sample inputs
      responses:
        "200":
          description: Endpoint catalog
          content:
            application/json:
              schema:
                type: object

  /v1/website-intelligence:
    post:
      operationId: inspectWebsite
      summary: Generate a premium website intelligence report
      description: >-
        Score and inspect a public website for availability, performance, TLS,
        DNS, SEO, security headers, robots.txt, sitemap, structured data, and
        prioritized issues.
      tags:
        - Website Intelligence
      x-payment-info:
        price:
          mode: fixed
          currency: USD
          amount: "0.025000"
        protocols:
          - x402: {}
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              additionalProperties: false
              required:
                - url
              properties:
                url:
                  type: string
                  format: uri
                  description: Public HTTP or HTTPS URL
            example:
              url: https://example.com
      responses:
        "200":
          description: Website intelligence report
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/DataResponse"
        "400":
          $ref: "#/components/responses/BadRequest"
        "402":
          $ref: "#/components/responses/PaymentRequired"
        "413":
          $ref: "#/components/responses/TooLarge"
        "422":
          $ref: "#/components/responses/Unprocessable"

  /v1/url-audit:
    post:
      operationId: auditUrl
      summary: Audit a public URL
      tags:
        - Website
      x-payment-info:
        price:
          mode: fixed
          currency: USD
          amount: "0.005000"
        protocols:
          - x402: {}
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              additionalProperties: false
              required:
                - url
              properties:
                url:
                  type: string
                  format: uri
            example:
              url: https://example.com
      responses:
        "200":
          description: URL audit result
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/DataResponse"
        "400":
          $ref: "#/components/responses/BadRequest"
        "402":
          $ref: "#/components/responses/PaymentRequired"
        "413":
          $ref: "#/components/responses/TooLarge"
        "422":
          $ref: "#/components/responses/Unprocessable"

  /v1/json-repair:
    post:
      operationId: repairJson
      summary: Repair malformed JSON
      tags:
        - Developer Tools
      x-payment-info:
        price:
          mode: fixed
          currency: USD
          amount: "0.001000"
        protocols:
          - x402: {}
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              additionalProperties: false
              required:
                - text
              properties:
                text:
                  type: string
                  maxLength: 250000
                schema:
                  type: object
                  additionalProperties: true
            example:
              text: "{name: 'Ada', active: true,}"
      responses:
        "200":
          description: Repaired JSON and optional schema validation
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/DataResponse"
        "400":
          $ref: "#/components/responses/BadRequest"
        "402":
          $ref: "#/components/responses/PaymentRequired"
        "422":
          $ref: "#/components/responses/Unprocessable"

  /v1/csv-inspect:
    post:
      operationId: inspectCsv
      summary: Inspect CSV data
      tags:
        - Data
      x-payment-info:
        price:
          mode: fixed
          currency: USD
          amount: "0.003000"
        protocols:
          - x402: {}
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              additionalProperties: false
              required:
                - csv
              properties:
                csv:
                  type: string
                  maxLength: 500000
                delimiter:
                  type: string
                  minLength: 1
                  maxLength: 1
            example:
              csv: |-
                name,age
                Ada,36
                Grace,40
      responses:
        "200":
          description: CSV shape and quality report
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/DataResponse"
        "400":
          $ref: "#/components/responses/BadRequest"
        "402":
          $ref: "#/components/responses/PaymentRequired"
        "422":
          $ref: "#/components/responses/Unprocessable"

  /v1/image-inspect:
    post:
      operationId: inspectImage
      summary: Inspect a base64 image
      tags:
        - Images
      x-payment-info:
        price:
          mode: fixed
          currency: USD
          amount: "0.003000"
        protocols:
          - x402: {}
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              additionalProperties: false
              required:
                - base64
              properties:
                base64:
                  type: string
                  description: Base64 bytes or a data URL, up to 4 MB decoded
            example:
              base64: data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAAB...
      responses:
        "200":
          description: Image metadata and optimization suggestions
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/DataResponse"
        "400":
          $ref: "#/components/responses/BadRequest"
        "402":
          $ref: "#/components/responses/PaymentRequired"
        "413":
          $ref: "#/components/responses/TooLarge"
        "422":
          $ref: "#/components/responses/Unprocessable"

  /v1/text-diff:
    post:
      operationId: diffText
      summary: Compare two text or HTML snapshots
      tags:
        - Text
      x-payment-info:
        price:
          mode: fixed
          currency: USD
          amount: "0.001000"
        protocols:
          - x402: {}
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              additionalProperties: false
              required:
                - before
                - after
              properties:
                before:
                  type: string
                  maxLength: 300000
                after:
                  type: string
                  maxLength: 300000
            example:
              before: "Price: $10"
              after: "Price: $12"
      responses:
        "200":
          description: Line-level difference report
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/DataResponse"
        "400":
          $ref: "#/components/responses/BadRequest"
        "402":
          $ref: "#/components/responses/PaymentRequired"

components:
  schemas:
    DataResponse:
      type: object
      required:
        - data
      properties:
        data:
          type: object
          additionalProperties: true

    Error:
      type: object
      required:
        - error
      properties:
        error:
          type: object
          required:
            - code
            - message
          properties:
            code:
              type: string
            message:
              type: string
            details: {}

  responses:
    BadRequest:
      description: Invalid request
      content:
        application/json:
          schema:
            $ref: "#/components/schemas/Error"

    PaymentRequired:
      description: Payment Required
      headers:
        PAYMENT-REQUIRED:
          description: Base64-encoded x402 v2 payment requirement
          schema:
            type: string
      content:
        application/json:
          schema:
            type: object

    TooLarge:
      description: Request or inspected resource exceeds a configured limit
      content:
        application/json:
          schema:
            $ref: "#/components/schemas/Error"

    Unprocessable:
      description: Input was valid JSON but could not be processed
      content:
        application/json:
          schema:
            $ref: "#/components/schemas/Error"
