快速入門
跟著以下步驟,幾分鐘內就能開始使用 WayinVideo API。
1. 取得你的 API 金鑰
- 登入 WayinVideo API Dashboard
- 點擊 Create API Key 生成新的金鑰
- 複製並妥善保存你的 API 金鑰
重要: API 金鑰屬於機密資訊,請勿在前端程式碼或公開的程式碼庫中洩露。
2. 提交剪輯任務
傳送影片網址以提交一個 AI 剪輯任務:
curl -X POST https://wayinvideo-api.wayin.ai/api/v2/clips \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "x-wayinvideo-api-version: v2" \
-d '{
"video_url": "https://www.youtube.com/watch?v=example",
"enable_export": false
}'
回應:
{
"data": {
"id": "proj_abc123",
"name": "sample project name",
"status": "CREATED"
}
}
3. 輪詢取得結果
持續輪詢任務狀態,直到出現 SUCCEEDED。建議每 30 秒輪詢一次。
curl -X GET https://wayinvideo-api.wayin.ai/api/v2/clips/results/proj_abc123 \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "x-wayinvideo-api-version: v2"
處理完成後,回應中會包含你的剪輯片段:
{
"data": {
"id": "proj_abc123",
"name": "sample project name",
"status": "SUCCEEDED",
"clips": [
{
"idx": 0,
"title": "sample title",
"begin_ms": "15000",
"end_ms": "75000",
"thumbnail": "https://cdn.example.com/thumb/clip_001.jpg",
"tags": ["insight", "analysis"],
"desc": "sample description"
}
]
}
}
注意: 提交剪輯任務時,可以設定
enable_export = true,讓系統算圖並匯出影片,回應中會包含下載連結。由於算圖與匯出需要額外的處理時間,完成時間會比不開啟匯出時更長。