{
  "openapi": "3.0.3",
  "info": {
    "title": "DegenAI x402 API",
    "version": "1.0.0",
    "description": "x402 protocol API for HyperLiquid trading. Agent ID: 23121",
    "contact": {
      "name": "DegenAI",
      "url": "https://degenai.dev/erc8004"
    }
  },
  "servers": [
    {
      "url": "https://degenai.dev",
      "description": "Production"
    }
  ],
  "paths": {
    "/x402": {
      "get": {
        "summary": "Discovery endpoint",
        "description": "Returns available capabilities, pricing, health status, and integration documentation",
        "tags": [
          "Discovery"
        ],
        "responses": {
          "200": {
            "description": "Discovery response with capabilities and health status"
          }
        }
      }
    },
    "/x402/authorize/prepare": {
      "post": {
        "summary": "Prepare authorization",
        "description": "Returns EIP-712 typed data for signing",
        "tags": [
          "Authorization"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "payerAddress",
                  "hyperLiquidWallet"
                ],
                "properties": {
                  "payerAddress": {
                    "type": "string",
                    "description": "Wallet address for x402 payments"
                  },
                  "hyperLiquidWallet": {
                    "type": "string",
                    "description": "Wallet address for HyperLiquid trading"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "EIP-712 typed data for signing"
          }
        }
      }
    },
    "/x402/authorize/approve": {
      "post": {
        "summary": "Complete authorization",
        "description": "Submit signed EIP-712 data to complete authorization",
        "tags": [
          "Authorization"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "payerAddress",
                  "hyperLiquidWallet",
                  "signature",
                  "builderFeeSignature",
                  "nonce",
                  "builderNonce"
                ],
                "properties": {
                  "payerAddress": {
                    "type": "string"
                  },
                  "hyperLiquidWallet": {
                    "type": "string"
                  },
                  "signature": {
                    "type": "string",
                    "description": "Agent approval signature"
                  },
                  "builderFeeSignature": {
                    "type": "string",
                    "description": "Builder fee signature"
                  },
                  "nonce": {
                    "type": "integer",
                    "description": "Nonce from /prepare"
                  },
                  "builderNonce": {
                    "type": "integer",
                    "description": "Builder nonce from /prepare"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Authorization successful"
          },
          "400": {
            "description": "Invalid signature or parameters"
          }
        }
      }
    },
    "/x402/authorize/status": {
      "get": {
        "summary": "Check authorization status",
        "description": "Check if a payer is authorized for trading",
        "tags": [
          "Authorization"
        ],
        "parameters": [
          {
            "name": "payerAddress",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Authorization status"
          }
        }
      }
    },
    "/x402/automation_evaluate": {
      "post": {
        "summary": "Run a single automation evaluation and charge only for actual LLM usage. Returns the evaluation result (condition met/not met, reasoning, action taken) and the actual cost. Uses the x402 \u0027upto\u0027 scheme -- you authorize a maximum and are charged only what was consumed.",
        "description": "Pricing: Up to $0.50 per evaluation, billed by actual LLM token usage",
        "tags": [
          "Paid Capabilities"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "ruleId"
                ],
                "properties": {
                  "ruleId": {
                    "type": "integer",
                    "description": "The automation rule ID to evaluate"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response"
          },
          "402": {
            "description": "Payment required"
          },
          "429": {
            "description": "Rate limit exceeded"
          }
        },
        "parameters": [
          {
            "name": "PAYMENT-SIGNATURE",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Base64 encoded EIP-3009 payment signature"
          }
        ]
      }
    },
    "/x402/automation_list": {
      "post": {
        "summary": "List all automation rules for your wallet. Returns each rule\u0027s state, asset, condition, and the shared wallet balance.",
        "description": "FREE - No payment required",
        "tags": [
          "Free Capabilities"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [],
                "properties": {}
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response"
          },
          "402": null,
          "429": {
            "description": "Rate limit exceeded"
          }
        }
      }
    },
    "/x402/get_trade_history": {
      "post": {
        "summary": "Get recent trading history (fills) for a HyperLiquid wallet. Returns executed trades with coin, side, size, price, and fees.",
        "description": "FREE - No payment required",
        "tags": [
          "Free Capabilities"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "wallet"
                ],
                "properties": {
                  "wallet": {
                    "type": "string",
                    "description": "HyperLiquid wallet address to query"
                  },
                  "limit": {
                    "type": "number",
                    "description": "Maximum number of trades to return (default: 50, max: 200)"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response"
          },
          "402": null,
          "429": {
            "description": "Rate limit exceeded"
          }
        }
      }
    },
    "/x402/get_account_summary": {
      "post": {
        "summary": "Get account summary for a HyperLiquid wallet. Returns account value, margin used, available balance, and position count.",
        "description": "FREE - No payment required",
        "tags": [
          "Free Capabilities"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "wallet"
                ],
                "properties": {
                  "wallet": {
                    "type": "string",
                    "description": "HyperLiquid wallet address to query"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response"
          },
          "402": null,
          "429": {
            "description": "Rate limit exceeded"
          }
        }
      }
    },
    "/x402/get_available_assets": {
      "post": {
        "summary": "Get list of available tradeable assets on HyperLiquid. Returns asset symbols, current prices, and trading parameters.",
        "description": "FREE - No payment required",
        "tags": [
          "Free Capabilities"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [],
                "properties": {
                  "filter": {
                    "type": "string",
                    "description": "Optional filter by asset symbol prefix"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response"
          },
          "402": null,
          "429": {
            "description": "Rate limit exceeded"
          }
        }
      }
    },
    "/x402/chart_screenshot": {
      "post": {
        "summary": "Generate financial chart screenshots with technical indicators. Supports all HyperLiquid assets and 44 indicators: ADX, ADXFull, Aroon, ATR, Beta, BollingerBands, CCI, ChandelierExit, CMF, Correlation, DEMA, DonchianChannels, EMA, FundingRateChart, HMA, HorizontalLinesIndicator, Ichimoku, KeltnerChannels, KST, MACD, MFI, MondayRange, OBV, OrderbookHeatmap, ParabolicSAR, PivotPoints, PriceRelativeStrength, ROC, RSI, Slope, SMA, SpreadRatio, StdDev, Stochastic, StochasticRSI, StructuralLevels, SuperTrend, TEMA, TSI, Volume, VWAP, VWMA, WilliamsR, WMA. Returns a PNG image.",
        "description": "Pricing: $0.005 per chart render",
        "tags": [
          "Paid Capabilities"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "coin",
                  "interval"
                ],
                "properties": {
                  "coin": {
                    "type": "string",
                    "description": "Asset symbol (e.g. BTC, ETH, SOL, xyz:AAPL)"
                  },
                  "interval": {
                    "type": "string",
                    "description": "Candle interval"
                  },
                  "indicators": {
                    "type": "array",
                    "description": "Technical indicators in Name:param format (max 5). Available: ADX, ADXFull, Aroon, ATR, Beta, BollingerBands, CCI, ChandelierExit, CMF, Correlation, DEMA, DonchianChannels, EMA, FundingRateChart, HMA, HorizontalLinesIndicator, Ichimoku, KeltnerChannels, KST, MACD, MFI, MondayRange, OBV, OrderbookHeatmap, ParabolicSAR, PivotPoints, PriceRelativeStrength, ROC, RSI, Slope, SMA, SpreadRatio, StdDev, Stochastic, StochasticRSI, StructuralLevels, SuperTrend, TEMA, TSI, Volume, VWAP, VWMA, WilliamsR, WMA. Format: Name (default params), Name:period (e.g. RSI:14), Name:p1:p2 (e.g. BollingerBands:20:2)"
                  },
                  "days": {
                    "type": "integer",
                    "description": "History in days (default based on interval)"
                  },
                  "width": {
                    "type": "integer",
                    "description": "Image width in pixels"
                  },
                  "height": {
                    "type": "integer",
                    "description": "Image height in pixels"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response"
          },
          "402": {
            "description": "Payment required"
          },
          "429": {
            "description": "Rate limit exceeded"
          }
        },
        "parameters": [
          {
            "name": "PAYMENT-SIGNATURE",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Base64 encoded EIP-3009 payment signature"
          }
        ]
      }
    },
    "/x402/get_open_orders": {
      "post": {
        "summary": "Get open (unfilled) orders for a HyperLiquid wallet. Returns order details including coin, side, size, price, and order type.",
        "description": "FREE - No payment required",
        "tags": [
          "Free Capabilities"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "wallet"
                ],
                "properties": {
                  "wallet": {
                    "type": "string",
                    "description": "HyperLiquid wallet address to query orders for"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response"
          },
          "402": null,
          "429": {
            "description": "Rate limit exceeded"
          }
        }
      }
    },
    "/x402/automation_create": {
      "post": {
        "summary": "Create a new automation rule with natural language conditions and actions. Requires trading authorization. Includes 1000 LLM evaluation checks. The automation evaluates your condition on a schedule and executes the action when met. Trades are charged separately at standard x402 rates.",
        "description": "Pricing: $5.00 -- includes 1000 automation evaluation checks. Trades charged separately at standard x402 rates.",
        "tags": [
          "Paid Capabilities"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "asset",
                  "conditionPrompt",
                  "actionPrompt"
                ],
                "properties": {
                  "asset": {
                    "type": "string",
                    "description": "Target asset symbol (e.g., ETH, BTC, SOL)"
                  },
                  "conditionPrompt": {
                    "type": "string",
                    "description": "Natural language condition (e.g., \u0027Buy if RSI drops below 30 on the 4h chart\u0027)"
                  },
                  "actionPrompt": {
                    "type": "string",
                    "description": "Natural language action to execute when condition is met (e.g., \u0027Buy $100 of ETH\u0027)"
                  },
                  "interval": {
                    "type": "string",
                    "description": "Chart interval context for evaluation"
                  },
                  "name": {
                    "type": "string",
                    "description": "Optional friendly name for the automation (auto-generated if omitted)"
                  },
                  "webhookUrl": {
                    "type": "string",
                    "description": "Optional URL to receive webhook notifications for automation events (condition_met, trade_executed, error, credits_low, etc.)"
                  },
                  "deactivateAfterTrigger": {
                    "type": "boolean",
                    "description": "If true, automation deactivates after first trigger (one-shot mode)"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response"
          },
          "402": {
            "description": "Payment required"
          },
          "429": {
            "description": "Rate limit exceeded"
          }
        },
        "parameters": [
          {
            "name": "PAYMENT-SIGNATURE",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Base64 encoded EIP-3009 payment signature"
          }
        ]
      }
    },
    "/x402/automation_status": {
      "post": {
        "summary": "Get the current state of an automation rule including last check result, trigger configuration, recent execution logs, and shared wallet balance.",
        "description": "FREE - No payment required",
        "tags": [
          "Free Capabilities"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "ruleId"
                ],
                "properties": {
                  "ruleId": {
                    "type": "integer",
                    "description": "The automation rule ID to query"
                  },
                  "logLimit": {
                    "type": "integer",
                    "description": "Number of recent logs to include (default 5, max 50)"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response"
          },
          "402": null,
          "429": {
            "description": "Rate limit exceeded"
          }
        }
      }
    },
    "/x402/automation_topup": {
      "post": {
        "summary": "Add 1000 evaluation checks to your automation balance. Balance is shared across all your automations. If automations were paused due to depleted credits, they auto-resume after topup.",
        "description": "Pricing: $5.00 -- 1000 additional automation evaluation checks",
        "tags": [
          "Paid Capabilities"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [],
                "properties": {}
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response"
          },
          "402": {
            "description": "Payment required"
          },
          "429": {
            "description": "Rate limit exceeded"
          }
        },
        "parameters": [
          {
            "name": "PAYMENT-SIGNATURE",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Base64 encoded EIP-3009 payment signature"
          }
        ]
      }
    },
    "/x402/hyperliquid_order": {
      "post": {
        "summary": "Execute trading operations on HyperLiquid perpetual futures. Supports limit, market, and stop orders with optional take-profit/stop-loss. Actions: create_market, create_limit, create_stop, modify_by_oid, cancel_by_oid, etc.",
        "description": "Pricing: $0.10 base \u002B 0.01% of trade size",
        "tags": [
          "Paid Capabilities"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "action"
                ],
                "properties": {
                  "action": {
                    "type": "string",
                    "description": "Trading action to perform"
                  },
                  "coin": {
                    "type": "string",
                    "description": "Asset symbol (e.g., \u0027BTC\u0027, \u0027ETH\u0027)"
                  },
                  "isBuy": {
                    "type": "boolean",
                    "description": "True for buy/long, false for sell/short"
                  },
                  "dollarSize": {
                    "type": "number",
                    "description": "Order size in USD"
                  },
                  "price": {
                    "type": "number",
                    "description": "Limit price (required for limit orders)"
                  },
                  "triggerPrice": {
                    "type": "number",
                    "description": "Trigger price for stop orders"
                  },
                  "reduceOnly": {
                    "type": "boolean",
                    "description": "If true, order will only reduce existing position"
                  },
                  "takeProfitPrice": {
                    "type": "number",
                    "description": "Optional take-profit price"
                  },
                  "stopLossPrice": {
                    "type": "number",
                    "description": "Optional stop-loss price"
                  },
                  "oid": {
                    "type": "integer",
                    "description": "Order ID (for modify/cancel operations)"
                  },
                  "cloid": {
                    "type": "string",
                    "description": "Client order ID (alternative to oid)"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response"
          },
          "402": {
            "description": "Payment required"
          },
          "429": {
            "description": "Rate limit exceeded"
          }
        },
        "parameters": [
          {
            "name": "PAYMENT-SIGNATURE",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Base64 encoded EIP-3009 payment signature"
          }
        ]
      }
    },
    "/x402/get_spot_balances": {
      "post": {
        "summary": "Get spot clearinghouse balances for a HyperLiquid wallet. Returns token balances including USDC. Essential for unified account mode where USDC balance lives in the spot clearinghouse.",
        "description": "FREE - No payment required",
        "tags": [
          "Free Capabilities"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "wallet"
                ],
                "properties": {
                  "wallet": {
                    "type": "string",
                    "description": "HyperLiquid wallet address to query spot balances for"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response"
          },
          "402": null,
          "429": {
            "description": "Rate limit exceeded"
          }
        }
      }
    },
    "/x402/get_positions": {
      "post": {
        "summary": "Get active trading positions for a HyperLiquid wallet. Returns position size, entry price, unrealized PnL, liquidation price, and leverage.",
        "description": "FREE - No payment required",
        "tags": [
          "Free Capabilities"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "wallet"
                ],
                "properties": {
                  "wallet": {
                    "type": "string",
                    "description": "HyperLiquid wallet address to query positions for"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response"
          },
          "402": null,
          "429": {
            "description": "Rate limit exceeded"
          }
        }
      }
    },
    "/x402/automation_manage": {
      "post": {
        "summary": "Start, stop, or delete an existing automation rule. Stopping pauses evaluation without deleting the rule. Deleting soft-deletes the rule (preserves cost history).",
        "description": "FREE - No payment required",
        "tags": [
          "Free Capabilities"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "ruleId",
                  "action"
                ],
                "properties": {
                  "ruleId": {
                    "type": "integer",
                    "description": "The automation rule ID to manage"
                  },
                  "action": {
                    "type": "string",
                    "description": "Management action to perform"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response"
          },
          "402": null,
          "429": {
            "description": "Rate limit exceeded"
          }
        }
      }
    },
    "/x402/automation_info": {
      "post": {
        "summary": "Get automation system metadata: supported assets, valid intervals, trigger types, resource limits, and pricing. Use this before creating automations to understand available options.",
        "description": "FREE - No payment required",
        "tags": [
          "Free Capabilities"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [],
                "properties": {}
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response"
          },
          "402": null,
          "429": {
            "description": "Rate limit exceeded"
          }
        }
      }
    }
  },
  "components": {
    "schemas": {},
    "securitySchemes": {
      "paymentSignature": {
        "type": "apiKey",
        "in": "header",
        "name": "PAYMENT-SIGNATURE",
        "description": "Base64 encoded EIP-3009 TransferWithAuthorization signature"
      }
    }
  },
  "tags": [
    {
      "name": "Discovery",
      "description": "API discovery and health"
    },
    {
      "name": "Authorization",
      "description": "One-time trading authorization (FREE)"
    },
    {
      "name": "Free Capabilities",
      "description": "Read-only queries - no payment required"
    },
    {
      "name": "Paid Capabilities",
      "description": "Trading operations requiring x402 payment"
    }
  ]
}