{
  "openapi": "3.1.0",
  "info": {
    "title": "Swapifie API",
    "version": "1.0.0",
    "description": "Embedded multi-chain swap infrastructure for bots, agents, wallets, and apps. Authenticate with an API key, request a quote, and assemble a transaction payload for execution in your own product."
  },
  "servers": [
    {
      "url": "https://www.swapifie.com",
      "description": "Production"
    }
  ],
  "security": [
    {
      "ApiKeyAuth": []
    }
  ],
  "components": {
    "securitySchemes": {
      "ApiKeyAuth": {
        "type": "apiKey",
        "in": "header",
        "name": "x-api-key",
        "description": "Partner API key. Bearer auth is also supported."
      },
      "BearerAuth": {
        "type": "http",
        "scheme": "bearer"
      }
    },
    "schemas": {
      "TokenAmount": {
        "type": "object",
        "required": [
          "tokenAddress",
          "amount"
        ],
        "properties": {
          "tokenAddress": {
            "type": "string",
            "description": "ERC-20 token contract address or the all-zero address for the native asset."
          },
          "amount": {
            "type": "string",
            "description": "Raw token amount as an integer string."
          }
        }
      },
      "OutputToken": {
        "type": "object",
        "required": [
          "tokenAddress",
          "proportion"
        ],
        "properties": {
          "tokenAddress": {
            "type": "string"
          },
          "proportion": {
            "type": "number",
            "description": "Relative output allocation. Use 1 for a single-token output."
          }
        }
      },
      "QuoteRequest": {
        "type": "object",
        "required": [
          "chainId",
          "inputTokens",
          "outputTokens",
          "userAddr",
          "slippageLimitPercent"
        ],
        "properties": {
          "chainId": {
            "type": "integer",
            "description": "EVM chain ID."
          },
          "inputTokens": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/TokenAmount"
            }
          },
          "outputTokens": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/OutputToken"
            }
          },
          "userAddr": {
            "type": "string",
            "description": "Wallet address that will execute the swap."
          },
          "slippageLimitPercent": {
            "type": "number"
          },
          "disableRFQs": {
            "type": "boolean"
          },
          "compact": {
            "type": "boolean"
          },
          "pathViz": {
            "type": "boolean"
          }
        },
        "example": {
          "chainId": 8453,
          "userAddr": "0xYourUserWallet",
          "slippageLimitPercent": 0.5,
          "inputTokens": [
            {
              "tokenAddress": "0x0000000000000000000000000000000000000000",
              "amount": "10000000000000000"
            }
          ],
          "outputTokens": [
            {
              "tokenAddress": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
              "proportion": 1
            }
          ]
        }
      },
      "QuoteResponse": {
        "type": "object",
        "properties": {
          "request": {
            "type": "object",
            "properties": {
              "requestId": {
                "type": "string"
              },
              "receivedAt": {
                "type": "string",
                "format": "date-time"
              }
            }
          },
          "account": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string"
              },
              "name": {
                "type": "string"
              }
            }
          },
          "monetization": {
            "type": "object",
            "properties": {
              "feeBps": {
                "type": "number"
              },
              "feeEstimateUsd": {
                "type": "number"
              },
              "revShareBps": {
                "type": "number"
              },
              "partnerRevenueShareUsd": {
                "type": "number"
              },
              "swapifieNetRevenueUsd": {
                "type": "number"
              }
            }
          },
          "quote": {
            "type": "object",
            "properties": {
              "inTokens": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "outTokens": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "inAmounts": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "outAmounts": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "gasEstimate": {
                "type": "number"
              },
              "dataGasEstimate": {
                "type": "number"
              },
              "gweiPerGas": {
                "type": "number"
              },
              "gasEstimateValue": {
                "type": "number"
              },
              "inValues": {
                "type": "array",
                "items": {
                  "type": "number"
                }
              },
              "outValues": {
                "type": "array",
                "items": {
                  "type": "number"
                }
              },
              "netOutValue": {
                "type": "number"
              },
              "percentDiff": {
                "type": "number"
              },
              "partnerFeePercent": {
                "type": "number"
              },
              "pathId": {
                "type": "string"
              },
              "pathViz": {},
              "blockNumber": {
                "type": "integer"
              }
            }
          }
        }
      },
      "AssembleRequest": {
        "type": "object",
        "required": [
          "userAddr",
          "pathId"
        ],
        "properties": {
          "userAddr": {
            "type": "string"
          },
          "pathId": {
            "type": "string"
          },
          "simulate": {
            "type": "boolean",
            "default": false
          }
        },
        "example": {
          "userAddr": "0xYourUserWallet",
          "pathId": "quote_path_id_here",
          "simulate": false
        }
      },
      "AssembleResponse": {
        "type": "object",
        "properties": {
          "request": {
            "type": "object",
            "properties": {
              "requestId": {
                "type": "string"
              },
              "receivedAt": {
                "type": "string",
                "format": "date-time"
              }
            }
          },
          "account": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string"
              },
              "name": {
                "type": "string"
              }
            }
          },
          "assemble": {
            "type": "object",
            "properties": {
              "deprecated": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "blockNumber": {
                "type": "integer"
              },
              "gasEstimate": {
                "type": "number"
              },
              "gasEstimateValue": {
                "type": "number"
              },
              "inputTokens": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/TokenAmount"
                }
              },
              "outputTokens": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/TokenAmount"
                }
              },
              "netOutValue": {
                "type": "number"
              },
              "outValues": {
                "type": "array",
                "items": {
                  "type": "number"
                }
              },
              "transaction": {
                "type": "object",
                "properties": {
                  "gas": {
                    "type": "integer"
                  },
                  "gasPrice": {
                    "type": "integer"
                  },
                  "value": {
                    "type": "string"
                  },
                  "to": {
                    "type": "string"
                  },
                  "from": {
                    "type": "string"
                  },
                  "data": {
                    "type": "string"
                  },
                  "nonce": {
                    "type": "integer"
                  },
                  "chainId": {
                    "type": "integer"
                  }
                }
              },
              "simulation": {}
            }
          }
        }
      },
      "HealthResponse": {
        "type": "object",
        "properties": {
          "ok": {
            "type": "boolean"
          },
          "service": {
            "type": "string"
          },
          "version": {
            "type": "string"
          },
          "timestamp": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "AccountResponse": {
        "type": "object",
        "properties": {
          "request": {
            "type": "object",
            "properties": {
              "requestId": {
                "type": "string"
              },
              "receivedAt": {
                "type": "string",
                "format": "date-time"
              }
            }
          },
          "account": {
            "type": "object",
            "description": "Authenticated partner account configuration."
          },
          "environments": {
            "type": "object"
          },
          "organization": {
            "type": "object"
          },
          "launchReadiness": {
            "type": [
              "object",
              "null"
            ]
          },
          "integrationModes": {
            "type": "array",
            "items": {
              "type": "object"
            }
          }
        }
      },
      "ErrorResponse": {
        "type": "object",
        "required": [
          "error",
          "message"
        ],
        "properties": {
          "error": {
            "type": "string"
          },
          "message": {
            "type": "string"
          }
        }
      }
    }
  },
  "paths": {
    "/api/v1/health": {
      "get": {
        "summary": "Health check",
        "security": [],
        "responses": {
          "200": {
            "description": "Service health and version",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HealthResponse"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/account": {
      "get": {
        "summary": "Get authenticated partner account details",
        "responses": {
          "200": {
            "description": "Partner account and launch readiness",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AccountResponse"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limited",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/quote": {
      "post": {
        "summary": "Create a partner-aware quote",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/QuoteRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Quote created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/QuoteResponse"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request or unsupported chain",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden origin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limited",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "502": {
            "description": "Quote provider failure",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/assemble": {
      "post": {
        "summary": "Assemble a transaction payload from a path ID",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AssembleRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Transaction assembled",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AssembleResponse"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limited",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "502": {
            "description": "Assembly provider failure",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    }
  }
}
