> 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-api-key.md).

# API 参考（API 密钥）

Minara Agent API 端点的技术规范。

### 开发者 API

与 Minara 对话式 AI 交互的核心端点。

## Developer Chat

> Developer chat endpoint supporting both streaming and non-streaming response modes.

```json
{"openapi":"3.0.0","info":{"title":"Minara Agent API","version":"1.0"},"servers":[{"url":"https://api-developer.minara.ai"}],"security":[{"BearerAuth":[]}],"components":{"securitySchemes":{"BearerAuth":{"type":"http","scheme":"bearer","bearerFormat":"API-KEY","description":"Format: Authorization: Bearer <YOUR_API_KEY>"}},"schemas":{"ChatRequest":{"type":"object","required":["mode","stream","message"],"properties":{"mode":{"type":"string","enum":["fast","expert"],"description":"Required. Model mode: 'fast' for quick responses, 'expert' for in-depth analysis."},"stream":{"type":"boolean","description":"Required. Set to true for streaming (SSE), false for standard JSON response."},"message":{"$ref":"#/components/schemas/Message"}}},"Message":{"type":"object","required":["role","content"],"properties":{"role":{"type":"string","enum":["user"],"description":"Required. Message sender role, must be 'user'."},"content":{"type":"string","description":"Required. The user's query content."}}},"ChatResponse":{"type":"object","properties":{"chatId":{"type":"string","description":"Unique conversation ID."},"messageId":{"type":"string","description":"Unique message ID for this response."},"content":{"type":"string","description":"The AI-generated response content."},"usage":{"type":"object","description":"Usage statistics for the request."}}}}},"paths":{"/v1/developer/chat":{"post":{"summary":"Developer Chat","description":"Developer chat endpoint supporting both streaming and non-streaming response modes.","operationId":"developerChat","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ChatRequest"}}}},"responses":{"200":{"description":"Successful response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ChatResponse"}},"text/event-stream":{"schema":{"type":"string","description":"Server-Sent Events (SSE) stream. Each event line starts with `data:`.\nThe final message is formed by concatenating chunk/delta content in order.\n"}}}},"401":{"description":"Unauthorized - Invalid or missing API key"}}}}}}
```

## 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 Agent API","version":"1.0"},"servers":[{"url":"https://api-developer.minara.ai"}],"security":[{"BearerAuth":[]}],"components":{"securitySchemes":{"BearerAuth":{"type":"http","scheme":"bearer","bearerFormat":"API-KEY","description":"Format: Authorization: Bearer <YOUR_API_KEY>"}},"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":{"intent":{"type":"object","description":"Parsed user intent","properties":{"chain":{"type":"string","description":"Chain name (e.g., 'base')."},"inputTokenAddress":{"type":"string","nullable":true,"description":"Input token contract address (null for native token)."},"inputTokenSymbol":{"type":"string","description":"Input token symbol (e.g., 'ETH')."},"outputTokenAddress":{"type":"string","description":"Output token contract address."},"outputTokenSymbol":{"type":"string","description":"Output token symbol (e.g., 'USDC')."},"amount":{"type":"string","description":"Token amount in wei/smallest unit."},"userWalletAddress":{"type":"string","description":"User's wallet address."}}},"quote":{"type":"object","description":"Swap quote and pricing information","properties":{"fromTokenAmount":{"type":"string","description":"Input token amount in smallest unit."},"toTokenAmount":{"type":"string","description":"Expected output token amount in smallest unit."},"estimatedGas":{"type":"string","description":"Estimated gas cost for the transaction."},"priceImpact":{"type":"string","description":"Price impact percentage."},"tradeFee":{"type":"string","description":"Trading fee amount."}}},"inputToken":{"type":"object","description":"Input token details","properties":{"address":{"type":"string","description":"Token contract address."},"symbol":{"type":"string","description":"Token symbol."},"decimals":{"type":"string","description":"Token decimals."},"unitPrice":{"type":"string","description":"Token unit price in USD."}}},"outputToken":{"type":"object","description":"Output token details","properties":{"address":{"type":"string","description":"Token contract address."},"symbol":{"type":"string","description":"Token symbol."},"decimals":{"type":"string","description":"Token decimals."},"unitPrice":{"type":"string","description":"Token unit price in USD."}}},"unsignedTx":{"type":"object","description":"Unsigned transaction ready to be signed and broadcasted","properties":{"chainType":{"type":"string","description":"Chain type (e.g., 'evm')."},"from":{"type":"string","description":"Sender address."},"to":{"type":"string","description":"Contract address to call."},"data":{"type":"string","description":"Encoded transaction data."},"value":{"type":"string","description":"Native token value to send (in wei)."},"gas":{"type":"string","description":"Gas limit."},"gasPrice":{"type":"string","description":"Gas price (legacy)."},"maxPriorityFeePerGas":{"type":"string","description":"Max priority fee per gas (EIP-1559)."}}},"approval":{"type":"object","description":"Token approval information (required for ERC20 token swaps)","properties":{"isRequired":{"type":"boolean","description":"Whether token approval is required before swap."},"tokenAddress":{"type":"string","description":"Token contract address that needs approval."},"spenderAddress":{"type":"string","description":"Spender address (DEX router) that needs approval."},"requiredAmount":{"type":"string","description":"Minimum token amount that needs to be approved."},"approveAmount":{"type":"string","description":"Recommended approval amount."},"currentAllowance":{"type":"string","description":"Current approved allowance for the spender."},"message":{"type":"string","description":"Human-readable approval status message."}}}}}}},"paths":{"/v1/developer/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":"intentToSwap","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/IntentToSwapRequest"}}}},"responses":{"200":{"description":"Swap transaction generated","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SwapTransactionResponse"}}}},"401":{"description":"Unauthorized - Invalid or missing API key"}}}}}}
```

## Perpetual Trading Suggestion

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

```json
{"openapi":"3.0.0","info":{"title":"Minara Agent API","version":"1.0"},"servers":[{"url":"https://api-developer.minara.ai"}],"security":[{"BearerAuth":[]}],"components":{"securitySchemes":{"BearerAuth":{"type":"http","scheme":"bearer","bearerFormat":"API-KEY","description":"Format: Authorization: Bearer <YOUR_API_KEY>"}},"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."}}}}},"paths":{"/v1/developer/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 based on comprehensive market analysis.","operationId":"perpTradingSuggestion","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/PerpTradingRequest"}}}},"responses":{"200":{"description":"Perpetual trading suggestion","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PerpTradingResponse"}}}},"401":{"description":"Unauthorized - Invalid or missing API key"}}}}}}
```

## Prediction Market Analysis

> 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 Agent API","version":"1.0"},"servers":[{"url":"https://api-developer.minara.ai"}],"security":[{"BearerAuth":[]}],"components":{"securitySchemes":{"BearerAuth":{"type":"http","scheme":"bearer","bearerFormat":"API-KEY","description":"Format: Authorization: Bearer <YOUR_API_KEY>"}},"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)."}}}}},"paths":{"/v1/developer/prediction-market-ask":{"post":{"summary":"Prediction Market Analysis","description":"AI-powered prediction market analysis. Analyze prediction market events and get probability estimates for each outcome with detailed reasoning.","operationId":"predictionMarketAsk","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/PredictionMarketRequest"}}}},"responses":{"200":{"description":"Prediction market analysis","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PredictionMarketResponse"}}}},"401":{"description":"Unauthorized - Invalid or missing API key"}}}}}}
```

## The Message object

```json
{"openapi":"3.0.0","info":{"title":"Minara Agent API","version":"1.0"},"components":{"schemas":{"Message":{"type":"object","required":["role","content"],"properties":{"role":{"type":"string","enum":["user"],"description":"Required. Message sender role, must be 'user'."},"content":{"type":"string","description":"Required. The user's query content."}}}}}}
```

## The ChatResponse object

```json
{"openapi":"3.0.0","info":{"title":"Minara Agent API","version":"1.0"},"components":{"schemas":{"ChatResponse":{"type":"object","properties":{"chatId":{"type":"string","description":"Unique conversation ID."},"messageId":{"type":"string","description":"Unique message ID for this response."},"content":{"type":"string","description":"The AI-generated response content."},"usage":{"type":"object","description":"Usage statistics for the request."}}}}}}
```

## 开发者 API

## 聊天

### 端点

`POST https://api.minara.ai/v1/developer/chat`

### 请求体

| 参数                | 类型  | 必需 | 描述                                             |
| ----------------- | --- | -- | ---------------------------------------------- |
| `mode`            | 字符串 | 是  | 模型模式：'fast' 用于快速响应，'expert' 用于深入分析。            |
| `stream`          | 布尔值 | 是  | 设置为 true 以启用流式传输（SSE），设置为 false 以返回标准 JSON 响应。 |
| `消息`              | 对象  | 是  | 包含 role 和 content 的消息对象                        |
| `message.role`    | 字符串 | 是  | 消息发送者角色，必须为 'user'。                            |
| `message.content` | 字符串 | 是  | 用户的查询内容。                                       |

### 示例请求

```bash
curl -X POST https://api.minara.ai/v1/developer/chat \\
  -H "Authorization: Bearer <YOUR_API_KEY>" \\
  -H "Content-Type: application/json" \\
  -d '{
    "mode": "快速",
    "stream": false,
    "message": {
      "role": "user",
      "content": "分析近期 SOL 的价格走势，并给我一个交易建议。"
    }
  }'
```

### 响应

#### 标准响应（stream: false）

返回包含完整响应的 JSON 对象。

```json
{
  "chatId": "chat_abc123",
  "messageId": "msg_def456",
  "content": "SOL 当前交易价格为 $187.50，较过去 24 小时上涨 4.2%。基于 4H 图表，它已在强劲成交量推动下突破 $185 的关键阻力位。RSI 为 62，表明看涨动能仍未进入超买。\n\n建议：可考虑在 $186-188 附近建立多头仓位，止盈设在 $195，止损设在 $180...",
  "usage": {}
}
```

#### 流式响应（stream: true）

返回 `Content-Type: text/event-stream` 使用 Server-Sent Events（SSE）。

```
data: {"chatId":"chat_abc123","messageId":"msg_def456","object":"chat.completion.chunk","choices":[{"index":0,"delta":{"role":"assistant"},"finish_reason":null}]}

data: {"chatId":"chat_abc123","messageId":"msg_def456","object":"chat.completion.chunk","choices":[{"index":0,"delta":{"content":"SOL 当前交易价格为 $187.50，较过去 24 小时上涨 4.2%。\n"},"finish_reason":null}]}

data: {"chatId":"chat_abc123","messageId":"msg_def456","object":"chat.completion.chunk","choices":[{"index":0,"delta":{"content":"根据 4H 图表，它已在强劲成交量推动下突破 $185 的关键阻力位。\n"},"finish_reason":null}]}

data: [DONE]
```

***

## 交易意图转换为交易

### 端点

`POST https://api.minara.ai/v1/developer/intent-to-swap-tx`

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

### 请求体

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

### 示例请求

```bash
curl -X POST https://api.minara.ai/v1/developer/intent-to-swap-tx \\
  -H "Authorization: Bearer <YOUR_API_KEY>" \\
  -H "Content-Type: application/json" \\
  -d '{
    "intent": "将 0.1 ETH 兑换为 USDC",
    "walletAddress": "0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb1",
    "chain": "base"
  }'
```

### 响应

```json
{
  "intent": {
    "chain": "base",
    "inputTokenAddress": null,
    "inputTokenSymbol": "ETH",
    "outputTokenAddress": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
    "outputTokenSymbol": "USDC",
    "amount": "100000000000000000",
    "userWalletAddress": "0x42a345F3d379B5060f0C36580bAF22C395B1D462"
  },
  "quote": {
    "fromTokenAmount": "100000000000000000",
    "toTokenAmount": "194058559",
    "estimatedGas": "1338000",
    "priceImpact": "-0.03",
    "tradeFee": "0.0174870969512694"
  },
  "inputToken": {
    "address": "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",
    "symbol": "ETH",
    "decimals": "18",
    "unitPrice": "1960.63"
  },
  "outputToken": {
    "address": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
    "symbol": "USDC",
    "decimals": "6",
    "unitPrice": "0.99989"
  },
  "unsignedTx": {
    "chainType": "evm",
    "from": "0x42a345F3d379B5060f0C36580bAF22C395B1D462",
    "to": "0x4409921ae43a39a11d90f7b96cfd0b8093d9fc",
    "data": "0xf2c42696000000000000000000000000000000000000000000000000000000000003479e...",
    "value": "100000000000000000",
    "gas": "1338000",
    "gasPrice": "10943011",
    "maxPriorityFeePerGas": "7301883"
  },
  "approval": {
    "isRequired": false,
    "tokenAddress": "0x833589fcd6edb6e08f4c7c32d4f71b54bda02913",
    "spenderAddress": "0x57df6092665eb6058DE53939612413ff4B09114E",
    "requiredAmount": "10000000",
    "approveAmount": "10000000",
    "currentAllowance": "115792089237316195423570985008687907853269984665640564039457584007913129316681",
    "message": "授权额度已足够用于支出方 0x57df6092665eb6058DE53939612413ff4B09114E"
  }
}
```

***

## 永续交易建议

### 端点

`POST https://api.minara.ai/v1/developer/perp-trading-suggestion`

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

### 请求体

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

### 示例请求

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

### 响应

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

***

## 预测市场分析

### 端点

`POST https://api.minara.ai/v1/developer/prediction-market-ask`

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

### 请求体

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

### 示例请求

```bash
curl -X POST https://api.minara.ai/v1/developer/prediction-market-ask \\
  -H "Authorization: Bearer <YOUR_API_KEY>" \\
  -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": "聚焦近期新闻和情绪分析。在概率估计上更保守一些。"
  }'
```

### 响应

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


---

# 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-api-key.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.
