> For the complete documentation index, see [llms.txt](https://minara.ai/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://minara.ai/docs/minara-handbook/zh/jiao-yi/agent-api/api-reference-x402.md).

# API 参考（x402）

### 开发者 x402 API

使用按量付费模型的 Minara x402 端点技术规格。

**基础 URL**: `https://x402.minara.ai`

## Chat (Base Chain)

> Ask Minara AI - Intelligent crypto assistant

```json
{"openapi":"3.0.0","info":{"title":"Minara x402 API","version":"1.0"},"servers":[{"url":"https://x402.minara.ai"}],"security":[{"x402Payment":[]}],"components":{"securitySchemes":{"x402Payment":{"type":"apiKey","in":"header","name":"x-payment-response","description":"Payment proof token obtained from x402 payment challenge flow. Required after completing payment."}},"schemas":{"ChatRequest":{"type":"object","required":["userQuery"],"properties":{"userQuery":{"type":"string","description":"Required. User query content."}}},"ChatResponse":{"type":"object","properties":{"content":{"type":"string","description":"AI response content."}}},"BadRequestError":{"type":"object","properties":{"error":{"type":"string"},"message":{"type":"string"}}},"UnauthorizedError":{"type":"object","properties":{"error":{"type":"string"},"message":{"type":"string"}}},"PaymentRequiredError":{"type":"object","properties":{"error":{"type":"string"},"message":{"type":"string"},"paymentInstructions":{"type":"object","properties":{"amount":{"type":"string","description":"Payment amount required."},"currency":{"type":"string","description":"Payment currency (e.g., USDC)."},"recipient":{"type":"string","description":"Payment recipient address."},"chain":{"type":"string","description":"Blockchain for payment."}}}}}}},"paths":{"/x402/chat":{"post":{"summary":"Chat (Base Chain)","description":"Ask Minara AI - Intelligent crypto assistant","operationId":"x402Chat","tags":["AI"],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ChatRequest"}}}},"responses":{"201":{"description":"Successful response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ChatResponse"}}}},"400":{"description":"Bad Request - Invalid parameters","content":{"application/json":{"schema":{"$ref":"#/components/schemas/BadRequestError"}}}},"401":{"description":"Unauthorized - Invalid payment response token","content":{"application/json":{"schema":{"$ref":"#/components/schemas/UnauthorizedError"}}}},"402":{"description":"Payment Required","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PaymentRequiredError"}}}}}}}}}
```

## Chat Expert (Base Chain)

> Ask Minara AI - Intelligent crypto assistant

```json
{"openapi":"3.0.0","info":{"title":"Minara x402 API","version":"1.0"},"servers":[{"url":"https://x402.minara.ai"}],"security":[{"x402Payment":[]}],"components":{"securitySchemes":{"x402Payment":{"type":"apiKey","in":"header","name":"x-payment-response","description":"Payment proof token obtained from x402 payment challenge flow. Required after completing payment."}},"schemas":{"ChatRequest":{"type":"object","required":["userQuery"],"properties":{"userQuery":{"type":"string","description":"Required. User query content."}}},"ChatResponse":{"type":"object","properties":{"content":{"type":"string","description":"AI response content."}}},"PaymentRequiredError":{"type":"object","properties":{"error":{"type":"string"},"message":{"type":"string"},"paymentInstructions":{"type":"object","properties":{"amount":{"type":"string","description":"Payment amount required."},"currency":{"type":"string","description":"Payment currency (e.g., USDC)."},"recipient":{"type":"string","description":"Payment recipient address."},"chain":{"type":"string","description":"Blockchain for payment."}}}}}}},"paths":{"/x402/chat/expert":{"post":{"summary":"Chat Expert (Base Chain)","description":"Ask Minara AI - Intelligent crypto assistant","operationId":"x402ChatExpert","tags":["AI"],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ChatRequest"}}}},"responses":{"201":{"description":"Successful response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ChatResponse"}}}},"400":{"description":"Bad Request - Invalid parameters"},"401":{"description":"Unauthorized - Invalid payment response token"},"402":{"description":"Payment Required","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PaymentRequiredError"}}}}}}}}}
```

## Chat (Polygon Chain)

> Ask Minara AI - Intelligent crypto assistant

```json
{"openapi":"3.0.0","info":{"title":"Minara x402 API","version":"1.0"},"servers":[{"url":"https://x402.minara.ai"}],"security":[{"x402Payment":[]}],"components":{"securitySchemes":{"x402Payment":{"type":"apiKey","in":"header","name":"x-payment-response","description":"Payment proof token obtained from x402 payment challenge flow. Required after completing payment."}},"schemas":{"ChatRequest":{"type":"object","required":["userQuery"],"properties":{"userQuery":{"type":"string","description":"Required. User query content."}}},"ChatResponse":{"type":"object","properties":{"content":{"type":"string","description":"AI response content."}}},"BadRequestError":{"type":"object","properties":{"error":{"type":"string"},"message":{"type":"string"}}},"UnauthorizedError":{"type":"object","properties":{"error":{"type":"string"},"message":{"type":"string"}}},"PaymentRequiredError":{"type":"object","properties":{"error":{"type":"string"},"message":{"type":"string"},"paymentInstructions":{"type":"object","properties":{"amount":{"type":"string","description":"Payment amount required."},"currency":{"type":"string","description":"Payment currency (e.g., USDC)."},"recipient":{"type":"string","description":"Payment recipient address."},"chain":{"type":"string","description":"Blockchain for payment."}}}}}}},"paths":{"/x402/polygon/chat":{"post":{"summary":"Chat (Polygon Chain)","description":"Ask Minara AI - Intelligent crypto assistant","operationId":"x402PolygonChat","tags":["AI"],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ChatRequest"}}}},"responses":{"201":{"description":"Successful response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ChatResponse"}}}},"400":{"description":"Bad Request - Invalid parameters","content":{"application/json":{"schema":{"$ref":"#/components/schemas/BadRequestError"}}}},"401":{"description":"Unauthorized - Invalid payment response token","content":{"application/json":{"schema":{"$ref":"#/components/schemas/UnauthorizedError"}}}},"402":{"description":"Payment Required","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PaymentRequiredError"}}}}}}}}}
```

## Chat Expert (Polygon Chain)

> Ask Minara AI - Intelligent crypto assistant

```json
{"openapi":"3.0.0","info":{"title":"Minara x402 API","version":"1.0"},"servers":[{"url":"https://x402.minara.ai"}],"security":[{"x402Payment":[]}],"components":{"securitySchemes":{"x402Payment":{"type":"apiKey","in":"header","name":"x-payment-response","description":"Payment proof token obtained from x402 payment challenge flow. Required after completing payment."}},"schemas":{"ChatRequest":{"type":"object","required":["userQuery"],"properties":{"userQuery":{"type":"string","description":"Required. User query content."}}},"ChatResponse":{"type":"object","properties":{"content":{"type":"string","description":"AI response content."}}},"PaymentRequiredError":{"type":"object","properties":{"error":{"type":"string"},"message":{"type":"string"},"paymentInstructions":{"type":"object","properties":{"amount":{"type":"string","description":"Payment amount required."},"currency":{"type":"string","description":"Payment currency (e.g., USDC)."},"recipient":{"type":"string","description":"Payment recipient address."},"chain":{"type":"string","description":"Blockchain for payment."}}}}}}},"paths":{"/x402/polygon/chat/expert":{"post":{"summary":"Chat Expert (Polygon Chain)","description":"Ask Minara AI - Intelligent crypto assistant","operationId":"x402PolygonChatExpert","tags":["AI"],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ChatRequest"}}}},"responses":{"201":{"description":"Successful response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ChatResponse"}}}},"400":{"description":"Bad Request - Invalid parameters"},"401":{"description":"Unauthorized - Invalid payment response token"},"402":{"description":"Payment Required","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PaymentRequiredError"}}}}}}}}}
```

## Chat (Solana Chain)

> Ask Minara AI - Intelligent crypto assistant

```json
{"openapi":"3.0.0","info":{"title":"Minara x402 API","version":"1.0"},"servers":[{"url":"https://x402.minara.ai"}],"security":[{"x402Payment":[]}],"components":{"securitySchemes":{"x402Payment":{"type":"apiKey","in":"header","name":"x-payment-response","description":"Payment proof token obtained from x402 payment challenge flow. Required after completing payment."}},"schemas":{"ChatRequest":{"type":"object","required":["userQuery"],"properties":{"userQuery":{"type":"string","description":"Required. User query content."}}},"ChatResponse":{"type":"object","properties":{"content":{"type":"string","description":"AI response content."}}},"PaymentRequiredError":{"type":"object","properties":{"error":{"type":"string"},"message":{"type":"string"},"paymentInstructions":{"type":"object","properties":{"amount":{"type":"string","description":"Payment amount required."},"currency":{"type":"string","description":"Payment currency (e.g., USDC)."},"recipient":{"type":"string","description":"Payment recipient address."},"chain":{"type":"string","description":"Blockchain for payment."}}}}}}},"paths":{"/x402/solana/chat":{"post":{"summary":"Chat (Solana Chain)","description":"Ask Minara AI - Intelligent crypto assistant","operationId":"x402SolanaChat","tags":["AI"],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ChatRequest"}}}},"responses":{"201":{"description":"Successful response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ChatResponse"}}}},"400":{"description":"Bad Request - Invalid parameters"},"401":{"description":"Unauthorized - Invalid payment response token"},"402":{"description":"Payment Required","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PaymentRequiredError"}}}}}}}}}
```

## Chat Expert (Solana Chain)

> Ask Minara AI - Intelligent crypto assistant

```json
{"openapi":"3.0.0","info":{"title":"Minara x402 API","version":"1.0"},"servers":[{"url":"https://x402.minara.ai"}],"security":[{"x402Payment":[]}],"components":{"securitySchemes":{"x402Payment":{"type":"apiKey","in":"header","name":"x-payment-response","description":"Payment proof token obtained from x402 payment challenge flow. Required after completing payment."}},"schemas":{"ChatRequest":{"type":"object","required":["userQuery"],"properties":{"userQuery":{"type":"string","description":"Required. User query content."}}},"ChatResponse":{"type":"object","properties":{"content":{"type":"string","description":"AI response content."}}},"PaymentRequiredError":{"type":"object","properties":{"error":{"type":"string"},"message":{"type":"string"},"paymentInstructions":{"type":"object","properties":{"amount":{"type":"string","description":"Payment amount required."},"currency":{"type":"string","description":"Payment currency (e.g., USDC)."},"recipient":{"type":"string","description":"Payment recipient address."},"chain":{"type":"string","description":"Blockchain for payment."}}}}}}},"paths":{"/x402/solana/chat/expert":{"post":{"summary":"Chat Expert (Solana Chain)","description":"Ask Minara AI - Intelligent crypto assistant","operationId":"x402SolanaChatExpert","tags":["AI"],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ChatRequest"}}}},"responses":{"201":{"description":"Successful response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ChatResponse"}}}},"400":{"description":"Bad Request - Invalid parameters"},"401":{"description":"Unauthorized - Invalid payment response token"},"402":{"description":"Payment Required","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PaymentRequiredError"}}}}}}}}}
```

## Perpetual Trading Suggestion

> Get AI-powered perpetual trading suggestions with long/short recommendations, entry price, stop loss, take profit levels, and confidence score.

```json
{"openapi":"3.0.0","info":{"title":"Minara x402 API","version":"1.0"},"servers":[{"url":"https://x402.minara.ai"}],"security":[{"x402Payment":[]}],"components":{"securitySchemes":{"x402Payment":{"type":"apiKey","in":"header","name":"x-payment-response","description":"Payment proof token obtained from x402 payment challenge flow. Required after completing payment."}},"schemas":{"PerpTradingRequest":{"type":"object","required":["symbol"],"properties":{"symbol":{"type":"string","description":"Required. Trading symbol (e.g., 'BTC', 'ETH', 'SOL')."},"style":{"type":"string","enum":["scalping","day-trading","swing-trading"],"default":"scalping","description":"Optional. Trading style: 'scalping', 'day-trading', or 'swing-trading'. Default: 'scalping'."},"marginUSD":{"type":"number","default":1000,"description":"Optional. Margin in USD. Default: 1000."},"leverage":{"type":"number","default":10,"minimum":1,"maximum":40,"description":"Optional. Leverage multiplier (max: 40). Default: 10."},"strategy":{"type":"string","default":"max-profit","description":"Optional. Strategy type. Default: 'max-profit'. More strategies coming soon."}}},"PerpTradingResponse":{"type":"object","properties":{"entryPrice":{"type":"number","description":"Recommended entry price."},"side":{"type":"string","enum":["long","short"],"description":"Trading side recommendation."},"stopLossPrice":{"type":"number","description":"Recommended stop loss price."},"takeProfitPrice":{"type":"number","description":"Recommended take profit price."},"confidence":{"type":"number","minimum":0,"maximum":100,"description":"Confidence score (0-100)."},"reasons":{"type":"array","items":{"type":"string"},"description":"Analysis reasons based on technical indicators."},"risks":{"type":"array","items":{"type":"string"},"description":"Risk factors to consider."}}},"PaymentRequiredError":{"type":"object","properties":{"error":{"type":"string"},"message":{"type":"string"},"paymentInstructions":{"type":"object","properties":{"amount":{"type":"string","description":"Payment amount required."},"currency":{"type":"string","description":"Payment currency (e.g., USDC)."},"recipient":{"type":"string","description":"Payment recipient address."},"chain":{"type":"string","description":"Blockchain for payment."}}}}}}},"paths":{"/x402/perp-trading-suggestion":{"post":{"summary":"Perpetual Trading Suggestion","description":"Get AI-powered perpetual trading suggestions with long/short recommendations, entry price, stop loss, take profit levels, and confidence score.","operationId":"x402PerpTradingSuggestion","tags":["Trading"],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/PerpTradingRequest"}}}},"responses":{"201":{"description":"Successful response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PerpTradingResponse"}}}},"400":{"description":"Bad Request - Invalid parameters"},"401":{"description":"Unauthorized - Invalid payment response token"},"402":{"description":"Payment Required","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PaymentRequiredError"}}}}}}}}}
```

## Intent to Swap Transaction

> Convert natural language trading intent into an executable swap transaction payload. Compatible with OKX DEX by default.

```json
{"openapi":"3.0.0","info":{"title":"Minara x402 API","version":"1.0"},"servers":[{"url":"https://x402.minara.ai"}],"security":[{"x402Payment":[]}],"components":{"securitySchemes":{"x402Payment":{"type":"apiKey","in":"header","name":"x-payment-response","description":"Payment proof token obtained from x402 payment challenge flow. Required after completing payment."}},"schemas":{"IntentToSwapRequest":{"type":"object","required":["intent","walletAddress"],"properties":{"intent":{"type":"string","description":"Required. Natural language swap intent (e.g., 'swap 0.1 ETH to USDC')."},"walletAddress":{"type":"string","description":"Required. User wallet address (0x...)."},"chain":{"type":"string","description":"Optional. Chain name (e.g., 'base', 'ethereum', 'bsc', 'arbitrum', 'optimism')."}}},"SwapTransactionResponse":{"type":"object","properties":{"transaction":{"type":"object","description":"Swap transaction details","properties":{"chain":{"type":"string","description":"Chain name."},"inputTokenAddress":{"type":"string","description":"Input token contract address."},"inputTokenSymbol":{"type":"string","description":"Input token symbol."},"outputTokenAddress":{"type":"string","description":"Output token contract address."},"outputTokenSymbol":{"type":"string","description":"Output token symbol."},"amount":{"type":"string","description":"Transaction amount."},"amountPercentage":{"type":"number","description":"Amount percentage."},"slippagePercent":{"type":"string","description":"Slippage percentage."}}}}},"PaymentRequiredError":{"type":"object","properties":{"error":{"type":"string"},"message":{"type":"string"},"paymentInstructions":{"type":"object","properties":{"amount":{"type":"string","description":"Payment amount required."},"currency":{"type":"string","description":"Payment currency (e.g., USDC)."},"recipient":{"type":"string","description":"Payment recipient address."},"chain":{"type":"string","description":"Blockchain for payment."}}}}}}},"paths":{"/x402/intent-to-swap-tx":{"post":{"summary":"Intent to Swap Transaction","description":"Convert natural language trading intent into an executable swap transaction payload. Compatible with OKX DEX by default.","operationId":"x402IntentToSwap","tags":["Trading"],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/IntentToSwapRequest"}}}},"responses":{"201":{"description":"Successful response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SwapTransactionResponse"}}}},"400":{"description":"Bad Request - Invalid parameters"},"401":{"description":"Unauthorized - Invalid payment response token"},"402":{"description":"Payment Required","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PaymentRequiredError"}}}}}}}}}
```

## Prediction Market Analysis (Base Chain)

> AI-powered prediction market analysis. Analyze prediction market events and get probability estimates for each outcome with detailed reasoning.

```json
{"openapi":"3.0.0","info":{"title":"Minara x402 API","version":"1.0"},"servers":[{"url":"https://x402.minara.ai"}],"security":[{"x402Payment":[]}],"components":{"securitySchemes":{"x402Payment":{"type":"apiKey","in":"header","name":"x-payment-response","description":"Payment proof token obtained from x402 payment challenge flow. Required after completing payment."}},"schemas":{"PredictionMarketRequest":{"type":"object","required":["link","mode"],"properties":{"link":{"type":"string","description":"Required. Prediction market page link (e.g., Polymarket event URL)."},"mode":{"type":"string","enum":["fast","expert"],"description":"Required. Chat mode: 'fast' or 'expert'."},"only_result":{"type":"boolean","default":false,"description":"Optional. Only return prediction probabilities without reasoning. Default: false."},"customPrompt":{"type":"string","description":"Optional. Custom instructions to guide the analysis. Use this to specify focus areas, risk preferences, or analysis style."}}},"PredictionMarketResponse":{"type":"object","properties":{"predictions":{"type":"array","description":"Array of prediction outcomes. Each outcome represents an event option with its yes/no probabilities.","items":{"type":"object","properties":{"outcome":{"type":"string","description":"Outcome name (event option, e.g., candidate name, team name)."},"yesProb":{"type":"number","description":"Probability of YES for this outcome (0-1)."},"noProb":{"type":"number","description":"Probability of NO for this outcome (0-1)."}}}},"reasoning":{"type":"string","description":"AI reasoning and analysis (empty if only_result=true)."}}},"BadRequestError":{"type":"object","properties":{"error":{"type":"string"},"message":{"type":"string"}}},"UnauthorizedError":{"type":"object","properties":{"error":{"type":"string"},"message":{"type":"string"}}},"PaymentRequiredError":{"type":"object","properties":{"error":{"type":"string"},"message":{"type":"string"},"paymentInstructions":{"type":"object","properties":{"amount":{"type":"string","description":"Payment amount required."},"currency":{"type":"string","description":"Payment currency (e.g., USDC)."},"recipient":{"type":"string","description":"Payment recipient address."},"chain":{"type":"string","description":"Blockchain for payment."}}}}}}},"paths":{"/x402/prediction-market-ask":{"post":{"summary":"Prediction Market Analysis (Base Chain)","description":"AI-powered prediction market analysis. Analyze prediction market events and get probability estimates for each outcome with detailed reasoning.","operationId":"x402PredictionMarketAsk","tags":["Prediction"],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/PredictionMarketRequest"}}}},"responses":{"201":{"description":"Successful response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PredictionMarketResponse"}}}},"400":{"description":"Bad Request - Invalid parameters","content":{"application/json":{"schema":{"$ref":"#/components/schemas/BadRequestError"}}}},"401":{"description":"Unauthorized - Invalid payment response token","content":{"application/json":{"schema":{"$ref":"#/components/schemas/UnauthorizedError"}}}},"402":{"description":"Payment Required","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PaymentRequiredError"}}}}}}}}}
```

## 端点

### 聊天（Base 链）

**端点：** `POST /x402/chat`

#### 请求

**请求头：**

* `x-payment-response` （必需）- 来自 x402 协议的支付证明令牌
* `Content-Type: application/json`

**请求体参数：**

| 参数          | 类型  | 必需 | 描述     |
| ----------- | --- | -- | ------ |
| `userQuery` | 字符串 | 是  | 用户查询内容 |

#### 示例请求

```bash
curl -X POST https://x402.minara.ai/x402/chat \\
  -H "x-payment-response: <payment_proof_token>" \\
  -H "Content-Type: application/json" \\
  -d '{
    "userQuery": "BTC 当前价格是多少，以及关键支撑位在哪里？"
  }'
```

#### 响应

**状态：** 201 已创建

```json
{
  "content": "BTC 目前交易价格为 98,450 美元。关键支撑位在 96,500 美元和 94,200 美元。近期放量突破 97,000 美元表明可能延续看涨走势..."
}
```

***

### Base 链聊天专家

**端点：** `POST /x402/chat/expert`

询问 Minara AI - Base 链上的智能加密货币助手，专家模式

#### 请求

**请求头：**

* `x-payment-response` （必需）- 来自 x402 协议的支付证明令牌
* `Content-Type: application/json`

**请求体参数：**

| 参数          | 类型  | 必需 | 描述     |
| ----------- | --- | -- | ------ |
| `userQuery` | 字符串 | 是  | 用户查询内容 |

#### 示例请求

```bash
curl -X POST https://x402.minara.ai/x402/chat/expert \\
  -H "x-payment-response: <payment_proof_token>" \\
  -H "Content-Type: application/json" \\
  -d '{
    "userQuery": "请提供对 ETH 的全面分析，包括链上指标和交易策略"
  }'
```

#### 响应

**状态：** 201 已创建

```json
{
  "content": "ETH 全面分析：\n\n**价格走势**：ETH 交易价格为 3,420 美元，正在 3,400-3,500 美元区间附近盘整...\n\n**链上指标**：活跃地址环比增长 12%，表明网络活动正在增加...\n\n**交易策略**：可考虑在回调至 3,300 美元支撑位时分批建仓，目标位为 3,600 美元和 3,850 美元..."
}
```

***

### 聊天（Solana 链）

**端点：** `POST /x402/solana/chat`

#### 请求

**请求头：**

* `x-payment-response` （必需）- 来自 x402 协议的支付证明令牌
* `Content-Type: application/json`

**请求体参数：**

| 参数          | 类型  | 必需 | 描述     |
| ----------- | --- | -- | ------ |
| `userQuery` | 字符串 | 是  | 用户查询内容 |

#### 示例请求

```bash
curl -X POST https://x402.minara.ai/x402/solana/chat \\
  -H "x-payment-response: <payment_proof_token>" \\
  -H "Content-Type: application/json" \\
  -d '{
    "userQuery": "现在给我看看 Solana 上最热门的代币"
  }'
```

#### 响应

**状态：** 201 已创建

```json
{
  "content": "Solana 热门代币：\n1. WIF - 上涨 24%，24 小时成交量 4,500 万美元\n2. BONK - 上涨 18%，社区活跃度强劲\n3. JUP - 近期拉升后正在盘整，成交量达 3,800 万美元..."
}
```

### Solana 链聊天专家

**端点：** `POST /x402/solana/chat/expert`

询问 Minara AI - Solana 链上的智能加密货币助手，专家模式

#### 请求

**请求头：**

* `x-payment-response` （必需）- 来自 x402 协议的支付证明令牌
* `Content-Type: application/json`

**请求体参数：**

| 参数          | 类型  | 必需 | 描述     |
| ----------- | --- | -- | ------ |
| `userQuery` | 字符串 | 是  | 用户查询内容 |

#### 示例请求

```bash
curl -X POST https://x402.minara.ai/x402/solana/chat/expert \\
  -H "x-payment-response: <payment_proof_token>" \\
  -H "Content-Type: application/json" \\
  -d '{
    "userQuery": "分析 JUP 代币的流动性分布和鲸鱼动向"
  }'
```

#### 响应

**状态：** 201 已创建

```json
{
  "content": "**JUP 代币深度分析**\n\n**流动性分布**：主要 DEX 上的总流动性为 1.25 亿美元，其中 65% 集中在 0.85-0.92 美元区间...\n\n**鲸鱼活动**：前 10 名持有者控制着 34% 的供应量。检测到过去 24 小时内有 3 笔显著的鲸鱼交易，总计买入 420 万美元...\n\n**风险评估**：价格高于 1.00 美元关口时存在中等流动性风险。请在仓位控制中考虑这一点..."
}
```

***

### 聊天（Polygon 链）

**端点：** `POST /x402/polygon/chat`

询问 Minara AI - Polygon 链上的智能加密货币助手

#### 请求

**请求头：**

* `x-payment-response` （必需）- 来自 x402 协议的支付证明令牌
* `Content-Type: application/json`

**请求体参数：**

| 参数          | 类型  | 必需 | 描述     |
| ----------- | --- | -- | ------ |
| `userQuery` | 字符串 | 是  | 用户查询内容 |

#### 示例请求

```bash
curl -X POST https://x402.minara.ai/x402/polygon/chat \\
  -H "x-payment-response: <payment_proof_token>" \\
  -H "Content-Type: application/json" \\
  -d '{
    "userQuery": "BTC 当前价格是多少，以及关键支撑位在哪里？"
  }'
```

#### 响应

**状态：** 201 已创建

```json
{
  "content": "BTC 目前交易价格为 98,450 美元。关键支撑位在 96,500 美元和 94,200 美元。近期放量突破 97,000 美元表明可能延续看涨走势..."
}
```

***

### Polygon 链聊天专家

**端点：** `POST /x402/polygon/chat/expert`

询问 Minara AI - Polygon 链上的智能加密货币助手，专家模式

#### 请求

**请求头：**

* `x-payment-response` （必需）- 来自 x402 协议的支付证明令牌
* `Content-Type: application/json`

**请求体参数：**

| 参数          | 类型  | 必需 | 描述     |
| ----------- | --- | -- | ------ |
| `userQuery` | 字符串 | 是  | 用户查询内容 |

#### 示例请求

```bash
curl -X POST https://x402.minara.ai/x402/polygon/chat/expert \\
  -H "x-payment-response: <payment_proof_token>" \\
  -H "Content-Type: application/json" \\
  -d '{
    "userQuery": "请提供对 ETH 的全面分析，包括链上指标和交易策略"
  }'
```

#### 响应

**状态：** 201 已创建

```json
{
  "content": "**ETH 全面分析**\n\n**价格走势**：ETH 交易价格为 3,420 美元，正在 3,400-3,500 美元区间附近盘整...\n\n**链上指标**：活跃地址环比增长 12%，表明网络活动正在增加...\n\n**交易策略**：可考虑在回调至 3,300 美元支撑位时分批建仓，目标位为 3,600 美元和 3,850 美元..."
}
```

***

## 交易端点

### 交易意图转换为交易

**端点：** `POST /x402/intent-to-swap-tx`

将自然语言交易意图转换为可执行的兑换交易负载。默认兼容 OKX DEX。

#### 请求

**请求头：**

* `x-payment-response` （必需）- 来自 x402 协议的支付证明令牌
* `Content-Type: application/json`

**请求体参数：**

| 参数              | 类型  | 必需 | 描述                                                    |
| --------------- | --- | -- | ----------------------------------------------------- |
| `intent`        | 字符串 | 是  | 自然语言交换意图（例如，“将 0.1 ETH 兑换为 USDC”）                     |
| `walletAddress` | 字符串 | 是  | 用户钱包地址（0x...）                                         |
| `chain`         | 字符串 | 否  | 链名称（例如："base"、"ethereum"、"bsc"、"arbitrum"、"optimism"） |

#### 示例请求

```bash
curl -X POST https://x402.minara.ai/x402/intent-to-swap-tx \\
  -H "x-payment-response: <payment_proof_token>" \\
  -H "Content-Type: application/json" \\
  -d '{
    "intent": "将 0.1 ETH 兑换为 USDC",
    "walletAddress": "0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb1",
    "chain": "base"
  }'
```

#### 响应

**状态：** 201 已创建

```json
{
  "transaction": {
    "chain": "base",
    "inputTokenAddress": "0x4200000000000000000000000000000000000006",
    "inputTokenSymbol": "ETH",
    "outputTokenAddress": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
    "outputTokenSymbol": "USDC",
    "amount": "0.1",
    "amountPercentage": 100,
    "slippagePercent": "0.5"
  }
}
```

***

### 永续交易建议

**端点：** `POST /x402/perp-trading-suggestion`

通过 AI 提供永续合约交易建议，包括做多/做空推荐、入场价格、止损、止盈位，以及基于全面市场分析的置信度评分。

#### 请求

**请求头：**

* `x-payment-response` （必需）- 来自 x402 协议的支付证明令牌
* `Content-Type: application/json`

**请求体参数：**

| 参数          | 类型  | 必需 | 默认      | 描述                           |
| ----------- | --- | -- | ------- | ---------------------------- |
| `symbol`    | 字符串 | 是  | -       | 交易标的（例如，“BTC”、“ETH”、“SOL”）   |
| `style`     | 字符串 | 否  | "剥头皮交易" | 交易风格："剥头皮交易"、"日内交易" 或 "波段交易" |
| `marginUSD` | 数字  | 否  | 1000    | 以美元计的保证金                     |
| `leverage`  | 数字  | 否  | 10      | 杠杆倍数（最大：40）                  |
| `strategy`  | 字符串 | 否  | "最大收益"  | 策略类型（更多策略即将推出）               |

#### 示例请求

```bash
curl -X POST https://x402.minara.ai/x402/perp-trading-suggestion \\
  -H "x-payment-response: <payment_proof_token>" \\
  -H "Content-Type: application/json" \\
  -d '{
    "symbol": "BTC",
    "style": "日内交易",
    "marginUSD": 1000,
    "leverage": 10,
    "strategy": "最大收益"
  }'
```

#### 响应

**状态：** 201 已创建

```json
{
  "entryPrice": 98450,
  "side": "做多",
  "stopLossPrice": 96200,
  "takeProfitPrice": 102800,
  "confidence": 78,
  "reasons": [
    "BTC 在强劲成交量推动下突破了 97,500 美元关键阻力位",
    "RSI 位于 62，表明看涨动能存在但尚未超买",
    "MACD 在 4 小时周期显示看涨交叉",
    "成交量分布显示当前价位存在吸筹"
  ],
  "risks": [
    "在 100,000 美元这一心理阻力位附近可能回调",
    "临近即将召开的美联储会议，预计波动性较高",
    "主要交易所的资金费率呈上升趋势"
  ]
}
```

***

### Base 链预测市场分析

**端点：** `POST /x402/prediction-market-ask`

AI 驱动的预测市场分析。分析预测市场事件，并结合详细推理为每个结果给出概率估计。

#### 请求

**请求头：**

* `x-payment-response` （必需）- 来自 x402 协议的支付证明令牌
* `Content-Type: application/json`

**请求体参数：**

| 参数             | 类型  | 必需 | 默认    | 描述                             |
| -------------- | --- | -- | ----- | ------------------------------ |
| `link`         | 字符串 | 是  | -     | 预测市场页面链接（例如，Polymarket 事件 URL） |
| `mode`         | 字符串 | 是  | -     | 聊天模式："快速" 或 "专家"               |
| `only_result`  | 布尔值 | 否  | false | 仅返回预测概率，不提供推理                  |
| `customPrompt` | 字符串 | 否  | -     | 用于引导分析的自定义指令                   |

#### 示例请求

```bash
curl -X POST https://x402.minara.ai/x402/prediction-market-ask \\
  -H "x-payment-response: <payment_proof_token>" \\
  -H "Content-Type: application/json" \\
  -d '{
    "link": "https://polymarket.com/event/will-there-be-another-us-government-shutdown-by-january-31",
    "mode": "快速",
    "only_result": false,
    "customPrompt": "聚焦近期新闻和情绪分析。在概率估计上更保守一些。"
  }'
```

#### 响应

**状态：** 201 已创建

```json
{
  "predictions": [
    {
      "outcome": "唐纳德·特朗普",
      "yesProb": 0.65,
      "noProb": 0.35
    },
    {
      "outcome": "卡玛拉·哈里斯",
      "yesProb": 0.3,
      "noProb": 0.7
    }
  ],
  "reasoning": "基于近期民调数据和历史趋势，特朗普在关键摇摆州仍保持微弱领先。不过，竞选形势依然高度胶着，存在显著不确定性..."
}
```

***

### Polygon 链预测市场分析

**端点：** `POST /x402/polygon/prediction-market-ask`

Polygon 链上的 AI 驱动预测市场分析。功能与 Base 链端点相同。

#### 请求

**请求头：**

* `x-payment-response` （必需）- 来自 x402 协议的支付证明令牌
* `Content-Type: application/json`

**请求体参数：**

与上面的 Base 链端点相同。

#### 示例请求

```bash
curl -X POST https://x402.minara.ai/x402/polygon/prediction-market-ask \\
  -H "x-payment-response: <payment_proof_token>" \\
  -H "Content-Type: application/json" \\
  -d '{
    "link": "https://polymarket.com/event/will-there-be-another-us-government-shutdown-by-january-31",
    "mode": "快速",
    "only_result": false
  }'
```

#### 响应

**状态：** 201 已创建

与 Base 链端点相同的响应格式。

***

## 错误响应

### 402 需要支付

不带支付凭证的初始请求将返回：

```json
{
  "error": "payment_required",
  "message": "访问此资源需要支付",
  "paymentInstructions": {
    "amount": "0.20",
    "currency": "USDC",
    "recipient": "0x...",
    "chain": "base"
  }
}
```

### 401 未授权

无效或已过期的支付证明：

```json
{
  "error": "unauthorized",
  "message": "无效的支付响应令牌"
}
```

### 400 错误请求

无效的请求参数：

```json
{
  "error": "bad_request",
  "message": "缺少必需参数：userQuery"
}
```

***

## 速率限制

x402 端点按钱包地址限流：

* **AI 端点：** 每分钟 60 个请求
* **交易端点：** 每分钟 30 个请求

超出速率限制将返回：

```json
{
  "error": "rate_limit_exceeded",
  "message": "请求过多。请在 30 秒后重试。",
  "retryAfter": 30
}
```

***

## 备注

* 所有 x402 端点都需要 `x-payment-response` 在完成支付挑战后添加 header
* 价格可能会根据网络状况发生变化
* 有关 x402 协议的更多信息，请参阅 [x402 文档](https://x402scan.com/server)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://minara.ai/docs/minara-handbook/zh/jiao-yi/agent-api/api-reference-x402.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
