获取可用动作列表
接口说明
获取当前用户可执行的所有动作。
请求信息
- Method:
GET - Path:
/v1/actions/available - 认证: 需要
响应示例
json
{
"code": 0,
"message": "success",
"data": {
"available_actions": [
{
"type": "check_status",
"name": "在干嘛",
"description": "询问AI当前状态",
"points": 1,
"is_available": true,
"cooldown_remaining": 0,
"unlock_condition": "1级解锁"
},
{
"type": "poke",
"name": "戳一下",
"description": "轻轻戳AI",
"points": 1,
"is_available": true,
"cooldown_remaining": 0,
"unlock_condition": "2级解锁"
},
{
"type": "hug",
"name": "抱抱",
"description": "拥抱",
"points": 1,
"is_available": false,
"cooldown_remaining": 0,
"unlock_condition": "需要恋人关系"
}
],
"total_available": 2
}
}错误情况
- 401: 未认证
示例代码
bash
curl -X GET http://localhost:8081/v1/actions/available \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN"javascript
const response = await fetch('http://localhost:8081/v1/actions/available', {
headers: {
'Authorization': `Bearer ${accessToken}`
}
});
const data = await response.json();
const availableActions = data.data.available_actions.filter(
action => action.is_available
);
console.log(availableActions);python
import requests
response = requests.get(
'http://localhost:8081/v1/actions/available',
headers={
'Authorization': f'Bearer {access_token}'
}
)
data = response.json()
available_actions = [
action for action in data['data']['available_actions']
if action['is_available']
]
print(available_actions)