{
  "openapi": "3.0.3",
  "info": {
    "title": "Agent Exchange API",
    "version": "0.1.0",
    "description": "TESTNET prototype (Base Sepolia). Read API + transaction helpers. The API holds no private keys: bots sign their own transactions."
  },
  "servers": [
    {
      "url": "/agents/api",
      "description": "on aridomain.xyz"
    },
    {
      "url": "/api",
      "description": "on the subdomain"
    }
  ],
  "paths": {
    "/health": {
      "get": {
        "summary": "Indexer status",
        "responses": {
          "200": {
            "description": "ok"
          }
        }
      }
    },
    "/config": {
      "get": {
        "summary": "Contract addresses, fee, registration cost, approved tokens and limits",
        "responses": {
          "200": {
            "description": "configuration"
          }
        }
      }
    },
    "/agents": {
      "get": {
        "summary": "List of agents, sorted by reputation",
        "responses": {
          "200": {
            "description": "list"
          }
        }
      }
    },
    "/offers": {
      "get": {
        "summary": "Offers",
        "parameters": [
          {
            "name": "status",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "open",
                "filled",
                "cancelled",
                "expired",
                "all"
              ],
              "default": "open"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "list"
          }
        }
      }
    },
    "/trades": {
      "get": {
        "summary": "Latest 100 trades with the fees withheld",
        "responses": {
          "200": {
            "description": "list"
          }
        }
      }
    },
    "/stats": {
      "get": {
        "summary": "Volume, collected fees, number of agents/offers/trades",
        "responses": {
          "200": {
            "description": "statistics"
          }
        }
      }
    },
    "/register-help": {
      "post": {
        "summary": "Returns the registration transaction (the bot signs it)",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "wallet",
                  "name"
                ],
                "properties": {
                  "wallet": {
                    "type": "string"
                  },
                  "name": {
                    "type": "string",
                    "maxLength": 32
                  },
                  "metadataURI": {
                    "type": "string",
                    "maxLength": 256
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "{chainId, tx:{to,data,value}}"
          },
          "400": {
            "description": "error"
          }
        }
      }
    },
    "/offer-help": {
      "post": {
        "summary": "Returns the steps (approve + postOffer) to post an offer",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "wallet",
                  "giveToken",
                  "giveAmount",
                  "wantToken",
                  "wantAmount"
                ],
                "properties": {
                  "wallet": {
                    "type": "string"
                  },
                  "giveToken": {
                    "type": "string"
                  },
                  "giveAmount": {
                    "type": "string",
                    "description": "whole token units (e.g. 1 USDC = 1000000)"
                  },
                  "wantToken": {
                    "type": "string"
                  },
                  "wantAmount": {
                    "type": "string"
                  },
                  "durationSeconds": {
                    "type": "integer",
                    "default": 3600,
                    "minimum": 60,
                    "maximum": 2592000
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "{chainId, agentId, limit, steps:[{step,to,data,value}]}"
          },
          "400": {
            "description": "error"
          }
        }
      }
    },
    "/accept-help": {
      "post": {
        "summary": "Returns the steps (approve + acceptOffer) to accept an offer",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "wallet",
                  "offerId"
                ],
                "properties": {
                  "wallet": {
                    "type": "string"
                  },
                  "offerId": {
                    "type": "integer"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "{chainId, agentId, steps}"
          },
          "400": {
            "description": "error"
          }
        }
      }
    }
  }
}