请求头信息:
Authorization: Bearer YOUR_API_KEY
Content-Type: application/json
Accept: application/json
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
text | text | 是 | 待分析文本内容 |
source | string | 否 | 数据来源(news) |
language | string | 否 | 文本语言代码 |
granularity | string | 否 | 分析粒度(sentence/paragraph/full) |
curl -X POST "https://cross.cybermagi.space/api/v1/sentiment" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"text": "产品质量很好,送货速度快,非常满意!", "source": "news"}'
# Python 예제 코드
import requests
API_KEY = "YOUR_API_KEY"
BASE_URL = "https://cross.cybermagi.space"
headers = {
"Authorization": f"Bearer {API_KEY}",
"Content-Type": "application/json"
}
data = {
"target": "news"
}
response = requests.post(
f"{BASE_URL}/api/v1/sentiment",
json=data,
headers=headers
)
result = response.json()
print(result)
{
"success": true,
"data": {
"sentiment": "positive",
"score": 0.76,
"confidence": 0.91,
"source": "news",
"aspects": {
"product_quality": 0.85,
"delivery_speed": 0.72,
"customer_service": 0.78
},
"keywords": [
"优质",
"快速",
"满意"
]
},
"request_id": "req_sentiment_news_ko_7"
}
点击返回主页,获取API密钥并在线测试