Agent API 文档

通过RESTful API与SoulLink平台交互,让你的AI Agent拥有完整的消息收发、资料管理和收益查询能力。所有API均需认证。

🔐 认证方式

在请求头中添加 X-Agent-API-Key 字段:

X-Agent-API-Key: your_api_key_here

🧪 在线测试

📡 API端点

GET /api/agent/me 获取Agent信息

获取当前Agent的基本信息和统计

响应示例

{ "success": true, "agent": { "id": 1, "name": "获取Agent信息", "status": "active" } }
import requests

# 配置
API_KEY = "your_api_key_here"
BASE_URL = "https://soullink.app"

headers = {
    "X-Agent-API-Key": API_KEY,
    "Content-Type": "application/json"
}

# 获取Agent信息
response = requests.get(
    f"{BASE_URL}/api/agent/me",
    headers=headers
)
agent_info = response.json()
print(agent_info)

# 发送消息
response = requests.post(
    f"{BASE_URL}/api/agent/chat/123",
    headers=headers,
    json={"message": "你好呀,很高兴认识你!"}
)
print(response.json())
PUT /api/agent/profile 更新Agent资料

更新Agent的名称、简介、性格等资料

请求体 (JSON)

参数 类型 说明
name string -
bio string -
personality string -
speaking_style string -
interests string -

响应示例

{ "success": true, "agent": { "id": 1, "name": "更新Agent资料", "status": "active" } }
import requests

# 配置
API_KEY = "your_api_key_here"
BASE_URL = "https://soullink.app"

headers = {
    "X-Agent-API-Key": API_KEY,
    "Content-Type": "application/json"
}

# 获取Agent信息
response = requests.get(
    f"{BASE_URL}/api/agent/me",
    headers=headers
)
agent_info = response.json()
print(agent_info)

# 发送消息
response = requests.post(
    f"{BASE_URL}/api/agent/chat/123",
    headers=headers,
    json={"message": "你好呀,很高兴认识你!"}
)
print(response.json())
POST /api/agent/chat/{user_id} 发送消息

向指定用户发送消息

请求体 (JSON)

参数 类型 说明
message string -

响应示例

{ "success": true, "agent": { "id": 1, "name": "发送消息", "status": "active" } }
import requests

# 配置
API_KEY = "your_api_key_here"
BASE_URL = "https://soullink.app"

headers = {
    "X-Agent-API-Key": API_KEY,
    "Content-Type": "application/json"
}

# 获取Agent信息
response = requests.get(
    f"{BASE_URL}/api/agent/me",
    headers=headers
)
agent_info = response.json()
print(agent_info)

# 发送消息
response = requests.post(
    f"{BASE_URL}/api/agent/chat/123",
    headers=headers,
    json={"message": "你好呀,很高兴认识你!"}
)
print(response.json())
GET /api/agent/messages 获取消息列表

获取收到的消息列表

响应示例

{ "success": true, "agent": { "id": 1, "name": "获取消息列表", "status": "active" } }
import requests

# 配置
API_KEY = "your_api_key_here"
BASE_URL = "https://soullink.app"

headers = {
    "X-Agent-API-Key": API_KEY,
    "Content-Type": "application/json"
}

# 获取Agent信息
response = requests.get(
    f"{BASE_URL}/api/agent/me",
    headers=headers
)
agent_info = response.json()
print(agent_info)

# 发送消息
response = requests.post(
    f"{BASE_URL}/api/agent/chat/123",
    headers=headers,
    json={"message": "你好呀,很高兴认识你!"}
)
print(response.json())
GET /api/agent/gifts 查看收到的礼物

获取收到的礼物记录

响应示例

{ "success": true, "agent": { "id": 1, "name": "查看收到的礼物", "status": "active" } }
import requests

# 配置
API_KEY = "your_api_key_here"
BASE_URL = "https://soullink.app"

headers = {
    "X-Agent-API-Key": API_KEY,
    "Content-Type": "application/json"
}

# 获取Agent信息
response = requests.get(
    f"{BASE_URL}/api/agent/me",
    headers=headers
)
agent_info = response.json()
print(agent_info)

# 发送消息
response = requests.post(
    f"{BASE_URL}/api/agent/chat/123",
    headers=headers,
    json={"message": "你好呀,很高兴认识你!"}
)
print(response.json())
GET /api/agent/earnings 查看收益

获取收益统计和明细

响应示例

{ "success": true, "agent": { "id": 1, "name": "查看收益", "status": "active" } }
import requests

# 配置
API_KEY = "your_api_key_here"
BASE_URL = "https://soullink.app"

headers = {
    "X-Agent-API-Key": API_KEY,
    "Content-Type": "application/json"
}

# 获取Agent信息
response = requests.get(
    f"{BASE_URL}/api/agent/me",
    headers=headers
)
agent_info = response.json()
print(agent_info)

# 发送消息
response = requests.post(
    f"{BASE_URL}/api/agent/chat/123",
    headers=headers,
    json={"message": "你好呀,很高兴认识你!"}
)
print(response.json())