> ## Documentation Index
> Fetch the complete documentation index at: https://docs.viggle.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# 代码示例

> 各 V1 接口的 Go、JavaScript、Python 和 cURL 示例。

使用前先设置 `VIGGLE_API_KEY`，并将所有示例 ID 替换为自己账户返回的完整 ID。

## 积分 — `GET /v1/credits`

<CodeGroup>
  ```go Go theme={null}
  req, _ := http.NewRequest("GET", "https://apis.viggle.ai/v1/credits", nil)
  req.Header.Set("Authorization", "Bearer "+os.Getenv("VIGGLE_API_KEY")); resp, _ := http.DefaultClient.Do(req)
  ```

  ```javascript JavaScript theme={null}
  const resp = await fetch("https://apis.viggle.ai/v1/credits", {headers:{Authorization:`Bearer ${process.env.VIGGLE_API_KEY}`}});
  ```

  ```python Python theme={null}
  resp = requests.get("https://apis.viggle.ai/v1/credits", headers={"Authorization": f"Bearer {os.environ['VIGGLE_API_KEY']}"})
  ```

  ```bash cURL theme={null}
  curl "https://apis.viggle.ai/v1/credits" -H "Authorization: Bearer $VIGGLE_API_KEY"
  ```
</CodeGroup>

## 创建角色 — `POST /v1/characters`

<CodeGroup>
  ```go Go theme={null}
  body := &bytes.Buffer{}; w := multipart.NewWriter(body); f, _ := w.CreateFormFile("image", "character.png"); file, _ := os.Open("character.png"); io.Copy(f, file); w.WriteField("name", "Presenter"); w.Close()
  req, _ := http.NewRequest("POST", "https://apis.viggle.ai/v1/characters", body); req.Header.Set("Authorization", "Bearer "+os.Getenv("VIGGLE_API_KEY")); req.Header.Set("Content-Type", w.FormDataContentType()); resp, _ := http.DefaultClient.Do(req)
  ```

  ```javascript JavaScript theme={null}
  const form = new FormData(); form.append("image", imageFile); form.append("name", "Presenter");
  const resp = await fetch("https://apis.viggle.ai/v1/characters", {method:"POST", headers:{Authorization:`Bearer ${process.env.VIGGLE_API_KEY}`}, body:form});
  ```

  ```python Python theme={null}
  with open("character.png", "rb") as image:
      resp = requests.post("https://apis.viggle.ai/v1/characters", headers={"Authorization": f"Bearer {os.environ['VIGGLE_API_KEY']}"}, files={"image": image}, data={"name": "Presenter"})
  ```

  ```bash cURL theme={null}
  curl -X POST "https://apis.viggle.ai/v1/characters" -H "Authorization: Bearer $VIGGLE_API_KEY" -F "image=@character.png" -F "name=Presenter"
  ```
</CodeGroup>

添加 `-F "type=vsplat"` 提取 3D vsplat；同时保留渲染能力使用 `all`：

```bash cURL theme={null}
curl -X POST "https://apis.viggle.ai/v1/characters" -H "Authorization: Bearer $VIGGLE_API_KEY" -F "image=@character.png" -F "type=vsplat"
```

## 列出、获取、删除和导出角色

<CodeGroup>
  ```go Go theme={null}
  req, _ := http.NewRequest("GET", "https://apis.viggle.ai/v1/characters/char_550e8400-e29b-41d4-a716-446655440000", nil); req.Header.Set("Authorization", "Bearer "+os.Getenv("VIGGLE_API_KEY")); resp, _ := http.DefaultClient.Do(req)
  ```

  ```javascript JavaScript theme={null}
  const resp = await fetch(`https://apis.viggle.ai/v1/characters/${characterId}`, {headers:{Authorization:`Bearer ${process.env.VIGGLE_API_KEY}`}});
  ```

  ```python Python theme={null}
  resp = requests.get(f"https://apis.viggle.ai/v1/characters/{character_id}", headers={"Authorization": f"Bearer {os.environ['VIGGLE_API_KEY']}"})
  ```

  ```bash cURL theme={null}
  curl "https://apis.viggle.ai/v1/characters" -H "Authorization: Bearer $VIGGLE_API_KEY"
  curl "https://apis.viggle.ai/v1/characters/char_550e8400-e29b-41d4-a716-446655440000" -H "Authorization: Bearer $VIGGLE_API_KEY"
  curl -X DELETE "https://apis.viggle.ai/v1/characters/char_550e8400-e29b-41d4-a716-446655440000" -H "Authorization: Bearer $VIGGLE_API_KEY"
  curl "https://apis.viggle.ai/v1/characters/char_550e8400-e29b-41d4-a716-446655440000/export?download_type=vsplat" -H "Authorization: Bearer $VIGGLE_API_KEY"
  ```
</CodeGroup>

列表使用 `GET /v1/characters`；删除时将请求方法改为 `DELETE`。全部请求和响应字段见[角色](/zh/v1/api-reference/characters)。

## 从视频创建动作 — `POST /v1/motions`

<CodeGroup>
  ```go Go theme={null}
  body := &bytes.Buffer{}; w := multipart.NewWriter(body); f, _ := w.CreateFormFile("motion_video", "dance.mp4"); file, _ := os.Open("dance.mp4"); io.Copy(f, file); w.WriteField("name", "Dance"); w.Close()
  req, _ := http.NewRequest("POST", "https://apis.viggle.ai/v1/motions", body); req.Header.Set("Authorization", "Bearer "+os.Getenv("VIGGLE_API_KEY")); req.Header.Set("Content-Type", w.FormDataContentType()); resp, _ := http.DefaultClient.Do(req)
  ```

  ```javascript JavaScript theme={null}
  const form = new FormData(); form.append("motion_video", videoFile); form.append("name", "Dance");
  const resp = await fetch("https://apis.viggle.ai/v1/motions", {method:"POST", headers:{Authorization:`Bearer ${process.env.VIGGLE_API_KEY}`}, body:form});
  ```

  ```python Python theme={null}
  with open("dance.mp4", "rb") as video:
      resp = requests.post("https://apis.viggle.ai/v1/motions", headers={"Authorization": f"Bearer {os.environ['VIGGLE_API_KEY']}"}, files={"motion_video": video}, data={"name": "Dance"})
  ```

  ```bash cURL theme={null}
  curl -X POST "https://apis.viggle.ai/v1/motions" -H "Authorization: Bearer $VIGGLE_API_KEY" -F "motion_video=@dance.mp4" -F "name=Dance"
  ```
</CodeGroup>

添加 `-F "type=glb"` 提取 3D 动画。

## 从文本创建动作 — `POST /v1/motions`

接口路径相同，文本生成动作使用 `application/json`，视频输入使用 multipart。

<CodeGroup>
  ```javascript JavaScript theme={null}
  const resp = await fetch("https://apis.viggle.ai/v1/motions", {method:"POST", headers:{Authorization:`Bearer ${process.env.VIGGLE_API_KEY}`, "Content-Type":"application/json"}, body:JSON.stringify({text:"a person doing a cartwheel", duration_seconds:5})});
  ```

  ```python Python theme={null}
  resp = requests.post("https://apis.viggle.ai/v1/motions", headers={"Authorization": f"Bearer {os.environ['VIGGLE_API_KEY']}"}, json={"text":"a person doing a cartwheel", "duration_seconds":5})
  ```

  ```bash cURL theme={null}
  curl -X POST "https://apis.viggle.ai/v1/motions" -H "Authorization: Bearer $VIGGLE_API_KEY" -H "Content-Type: application/json" -d '{"text":"a person doing a cartwheel","duration_seconds":5}'
  ```
</CodeGroup>

## 导入动作 — `POST /v1/motions/import`

<CodeGroup>
  ```go Go theme={null}
  body := strings.NewReader(`{"template_id":"YOUR_TEMPLATE_ID","name":"Campaign dance"}`); req, _ := http.NewRequest("POST", "https://apis.viggle.ai/v1/motions/import", body); req.Header.Set("Authorization", "Bearer "+os.Getenv("VIGGLE_API_KEY")); req.Header.Set("Content-Type", "application/json"); resp, _ := http.DefaultClient.Do(req)
  ```

  ```javascript JavaScript theme={null}
  const resp = await fetch("https://apis.viggle.ai/v1/motions/import", {method:"POST", headers:{Authorization:`Bearer ${process.env.VIGGLE_API_KEY}`, "Content-Type":"application/json"}, body:JSON.stringify({template_id:"YOUR_TEMPLATE_ID", name:"Campaign dance"})});
  ```

  ```python Python theme={null}
  resp = requests.post("https://apis.viggle.ai/v1/motions/import", headers={"Authorization": f"Bearer {os.environ['VIGGLE_API_KEY']}"}, json={"template_id":"YOUR_TEMPLATE_ID", "name":"Campaign dance"})
  ```

  ```bash cURL theme={null}
  curl -X POST "https://apis.viggle.ai/v1/motions/import" -H "Authorization: Bearer $VIGGLE_API_KEY" -H "Content-Type: application/json" -d '{"template_id":"YOUR_TEMPLATE_ID","name":"Campaign dance"}'
  ```
</CodeGroup>

## 列出、获取、删除和导出动作

<CodeGroup>
  ```go Go theme={null}
  req, _ := http.NewRequest("GET", "https://apis.viggle.ai/v1/motions/mot_550e8400-e29b-41d4-a716-446655440000", nil); req.Header.Set("Authorization", "Bearer "+os.Getenv("VIGGLE_API_KEY")); resp, _ := http.DefaultClient.Do(req)
  ```

  ```javascript JavaScript theme={null}
  const resp = await fetch(`https://apis.viggle.ai/v1/motions/${motionId}`, {headers:{Authorization:`Bearer ${process.env.VIGGLE_API_KEY}`}});
  ```

  ```python Python theme={null}
  resp = requests.get(f"https://apis.viggle.ai/v1/motions/{motion_id}", headers={"Authorization": f"Bearer {os.environ['VIGGLE_API_KEY']}"})
  ```

  ```bash cURL theme={null}
  curl "https://apis.viggle.ai/v1/motions" -H "Authorization: Bearer $VIGGLE_API_KEY"
  curl "https://apis.viggle.ai/v1/motions/mot_550e8400-e29b-41d4-a716-446655440000" -H "Authorization: Bearer $VIGGLE_API_KEY"
  curl -X DELETE "https://apis.viggle.ai/v1/motions/mot_550e8400-e29b-41d4-a716-446655440000" -H "Authorization: Bearer $VIGGLE_API_KEY"
  curl "https://apis.viggle.ai/v1/motions/mot_550e8400-e29b-41d4-a716-446655440000/export?download_type=mixamo" -H "Authorization: Bearer $VIGGLE_API_KEY"
  ```
</CodeGroup>

## 创建、列出、获取和下载渲染任务

<CodeGroup>
  ```go Go theme={null}
  body := &bytes.Buffer{}; w := multipart.NewWriter(body); w.WriteField("character_id", "char_550e8400-e29b-41d4-a716-446655440000"); w.WriteField("motion_id", "mot_550e8400-e29b-41d4-a716-446655440000"); w.Close()
  req, _ := http.NewRequest("POST", "https://apis.viggle.ai/v1/renders", body); req.Header.Set("Authorization", "Bearer "+os.Getenv("VIGGLE_API_KEY")); req.Header.Set("Content-Type", w.FormDataContentType()); resp, _ := http.DefaultClient.Do(req)
  ```

  ```javascript JavaScript theme={null}
  const form = new FormData(); form.append("character_id", characterId); form.append("motion_id", motionId);
  const resp = await fetch("https://apis.viggle.ai/v1/renders", {method:"POST", headers:{Authorization:`Bearer ${process.env.VIGGLE_API_KEY}`}, body:form});
  ```

  ```python Python theme={null}
  resp = requests.post("https://apis.viggle.ai/v1/renders", headers={"Authorization": f"Bearer {os.environ['VIGGLE_API_KEY']}"}, data={"character_id": character_id, "motion_id": motion_id})
  ```

  ```bash cURL theme={null}
  curl -X POST "https://apis.viggle.ai/v1/renders" -H "Authorization: Bearer $VIGGLE_API_KEY" -F "character_id=char_550e8400-e29b-41d4-a716-446655440000" -F "motion_id=mot_550e8400-e29b-41d4-a716-446655440000"
  curl "https://apis.viggle.ai/v1/videos?status=ready&limit=20" -H "Authorization: Bearer $VIGGLE_API_KEY"
  curl "https://apis.viggle.ai/v1/videos/render_8f50b2c2c2b84ae0" -H "Authorization: Bearer $VIGGLE_API_KEY"
  curl -L "https://apis.viggle.ai/v1/renders/render_8f50b2c2c2b84ae0/download" -H "Authorization: Bearer $VIGGLE_API_KEY" -o output.mp4
  ```
</CodeGroup>

列表与状态查询使用 `GET /v1/videos` 和 `GET /v1/videos/{video_id}`，见[列出视频](/zh/v1/api-reference/videos/list)与[获取视频](/zh/v1/api-reference/videos/get)。旧 Render 查询接口已停用，返回 `405`。

没有取消接口。参数组合与响应字段见[渲染任务](/zh/v1/api-reference/renders)。

## 从准备好的草稿创建渲染

<CodeGroup>
  ```bash cURL theme={null}
  curl -X POST "https://apis.viggle.ai/v1/renders/prepare" \
    -H "Authorization: Bearer $VIGGLE_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{"character":{"kind":"asset","asset_id":"char_550e8400-e29b-41d4-a716-446655440000"},"motion":{"kind":"asset","asset_id":"mot_550e8400-e29b-41d4-a716-446655440000"}}'

  curl -X POST "https://apis.viggle.ai/v1/renders" \
    -H "Authorization: Bearer $VIGGLE_API_KEY" \
    -H "Content-Type: application/json" \
    -H "Idempotency-Key: $(uuidgen)" \
    -d '{"draft_id":"draft_abc123"}'
  ```

  ```python Python theme={null}
  import os, uuid, requests

  headers = {"Authorization": f"Bearer {os.environ['VIGGLE_API_KEY']}"}
  draft = requests.post(
      "https://apis.viggle.ai/v1/renders/prepare",
      headers=headers,
      json={
          "character": {"kind": "asset", "asset_id": "char_550e8400-e29b-41d4-a716-446655440000"},
          "motion": {"kind": "asset", "asset_id": "mot_550e8400-e29b-41d4-a716-446655440000"},
      },
  ).json()

  render = requests.post(
      "https://apis.viggle.ai/v1/renders",
      headers={**headers, "Idempotency-Key": str(uuid.uuid4())},
      json={"draft_id": draft["draft_id"]},
  )
  render.raise_for_status()
  ```
</CodeGroup>

任一来源为 `kind: "upload"` 时，先将原始字节 `PUT` 到 prepare 返回的各个 `uploads[].url`，再调用 `POST /v1/renders`。完整流程见[准备渲染](/zh/v1/api-reference/renders/prepare)。

## 通过 SSE 监听渲染

<CodeGroup>
  ```bash cURL theme={null}
  curl -N "https://apis.viggle.ai/v1/renders/render_8f50b2c2c2b84ae0/events" \
    -H "Authorization: Bearer $VIGGLE_API_KEY" \
    -H "Accept: text/event-stream"
  ```
</CodeGroup>

事件类型和重连方式见[监听渲染](/zh/v1/api-reference/renders/events)。

## 生成视频 — `POST /v1/videos`

文本、首帧、首尾帧、参考素材和角色动画生成共用此接口，实际模式由输入字段决定。

<CodeGroup>
  ```bash cURL（文本生成视频） theme={null}
  curl "https://apis.viggle.ai/v1/videos" \
    -H "Authorization: Bearer $VIGGLE_API_KEY" \
    -F prompt="a paper airplane gliding through a sunlit office" \
    -F quality=low \
    -F duration_s=5
  ```

  ```bash cURL（首帧生成视频） theme={null}
  curl "https://apis.viggle.ai/v1/videos" \
    -H "Authorization: Bearer $VIGGLE_API_KEY" \
    -F prompt="camera slowly zooms out" \
    -F quality=high \
    -F first_frame_image_url=https://example.test/first.png
  ```

  ```bash cURL（首尾帧生成视频） theme={null}
  curl "https://apis.viggle.ai/v1/videos" \
    -H "Authorization: Bearer $VIGGLE_API_KEY" \
    -F prompt="camera pans across the room" \
    -F quality=low \
    -F first_frame_image_url=https://example.test/first.png \
    -F last_frame_image_url=https://example.test/last.png
  ```

  ```bash cURL（参考视频或图片） theme={null}
  curl "https://apis.viggle.ai/v1/videos" \
    -H "Authorization: Bearer $VIGGLE_API_KEY" \
    -F prompt="keep the same outfit and walk forward" \
    -F quality=high \
    -F reference_video_url=https://example.test/reference.mp4 \
    -F reference_image_url=https://example.test/ref1.png
  ```

  ```bash cURL（角色动画） theme={null}
  curl "https://apis.viggle.ai/v1/videos" \
    -H "Authorization: Bearer $VIGGLE_API_KEY" \
    -F driving_video_url=https://example.test/driving.mp4 \
    -F character_image_url=https://example.test/char1.png
  ```

  ```python Python theme={null}
  import os, requests
  resp = requests.post(
      "https://apis.viggle.ai/v1/videos",
      headers={"Authorization": f"Bearer {os.environ['VIGGLE_API_KEY']}"},
      data={"prompt": "camera slowly zooms out", "quality": "high"},
      files={"first_frame_image": open("first.png", "rb")},
  )
  resp.raise_for_status()
  video = resp.json()
  ```
</CodeGroup>

五种模式都返回 `200` 和相同的受理结构 `{id, status, progress, created_at}`。完整字段与常见错误见[文本生成](/zh/v1/api-reference/videos/create-from-text)、[首帧生成](/zh/v1/api-reference/videos/create-from-first-frame)、[首尾帧生成](/zh/v1/api-reference/videos/create-from-first-last-frame)、[参考素材生成](/zh/v1/api-reference/videos/create-from-reference-video)和[使用 Viggle-Animate](/zh/v1/api-reference/videos/create-from-character-animation)。

## 各接口请求示例

以下示例展示各接口的 HTTP 方法、路径和请求结构。Go 中 `client` 为 `http.Client`；JavaScript 中 `apiKey` 为 API 密钥；Python 中 `headers` 为 `{"Authorization": "Bearer ..."}`。

### `GET /v1/characters`

<CodeGroup>
  ```go Go theme={null}
  req, _ := http.NewRequest("GET", base+"/characters", nil); req.Header.Set("Authorization", "Bearer "+apiKey); resp, _ := client.Do(req)
  ```

  ```javascript JavaScript theme={null}
  const resp = await fetch(`${base}/characters`, {headers:{Authorization:`Bearer ${apiKey}`}});
  ```

  ```python Python theme={null}
  resp = requests.get(f"{base}/characters", headers=headers)
  ```

  ```bash cURL theme={null}
  curl "$BASE/characters" -H "Authorization: Bearer $VIGGLE_API_KEY"
  ```
</CodeGroup>

### `GET /v1/characters/{character_id}`

<CodeGroup>
  ```go Go theme={null}
  req, _ := http.NewRequest("GET", base+"/characters/"+characterID, nil); req.Header.Set("Authorization", "Bearer "+apiKey); resp, _ := client.Do(req)
  ```

  ```javascript JavaScript theme={null}
  const resp = await fetch(`${base}/characters/${characterId}`, {headers:{Authorization:`Bearer ${apiKey}`}});
  ```

  ```python Python theme={null}
  resp = requests.get(f"{base}/characters/{character_id}", headers=headers)
  ```

  ```bash cURL theme={null}
  curl "$BASE/characters/$CHARACTER_ID" -H "Authorization: Bearer $VIGGLE_API_KEY"
  ```
</CodeGroup>

### `DELETE /v1/characters/{character_id}`

<CodeGroup>
  ```go Go theme={null}
  req, _ := http.NewRequest("DELETE", base+"/characters/"+characterID, nil); req.Header.Set("Authorization", "Bearer "+apiKey); resp, _ := client.Do(req)
  ```

  ```javascript JavaScript theme={null}
  const resp = await fetch(`${base}/characters/${characterId}`, {method:"DELETE", headers:{Authorization:`Bearer ${apiKey}`}});
  ```

  ```python Python theme={null}
  resp = requests.delete(f"{base}/characters/{character_id}", headers=headers)
  ```

  ```bash cURL theme={null}
  curl -X DELETE "$BASE/characters/$CHARACTER_ID" -H "Authorization: Bearer $VIGGLE_API_KEY"
  ```
</CodeGroup>

### `GET /v1/characters/{character_id}/export`

<CodeGroup>
  ```go Go theme={null}
  req, _ := http.NewRequest("GET", base+"/characters/"+characterID+"/export?download_type=vsplat", nil); req.Header.Set("Authorization", "Bearer "+apiKey); resp, _ := client.Do(req)
  ```

  ```javascript JavaScript theme={null}
  const resp = await fetch(`${base}/characters/${characterId}/export?download_type=vsplat`, {headers:{Authorization:`Bearer ${apiKey}`}});
  ```

  ```python Python theme={null}
  resp = requests.get(f"{base}/characters/{character_id}/export", params={"download_type": "vsplat"}, headers=headers)
  ```

  ```bash cURL theme={null}
  curl "$BASE/characters/$CHARACTER_ID/export?download_type=vsplat" -H "Authorization: Bearer $VIGGLE_API_KEY"
  ```
</CodeGroup>

### `GET /v1/motions`

<CodeGroup>
  ```go Go theme={null}
  req, _ := http.NewRequest("GET", base+"/motions", nil); req.Header.Set("Authorization", "Bearer "+apiKey); resp, _ := client.Do(req)
  ```

  ```javascript JavaScript theme={null}
  const resp = await fetch(`${base}/motions`, {headers:{Authorization:`Bearer ${apiKey}`}});
  ```

  ```python Python theme={null}
  resp = requests.get(f"{base}/motions", headers=headers)
  ```

  ```bash cURL theme={null}
  curl "$BASE/motions" -H "Authorization: Bearer $VIGGLE_API_KEY"
  ```
</CodeGroup>

### `GET /v1/motions/{motion_id}`

<CodeGroup>
  ```go Go theme={null}
  req, _ := http.NewRequest("GET", base+"/motions/"+motionID, nil); req.Header.Set("Authorization", "Bearer "+apiKey); resp, _ := client.Do(req)
  ```

  ```javascript JavaScript theme={null}
  const resp = await fetch(`${base}/motions/${motionId}`, {headers:{Authorization:`Bearer ${apiKey}`}});
  ```

  ```python Python theme={null}
  resp = requests.get(f"{base}/motions/{motion_id}", headers=headers)
  ```

  ```bash cURL theme={null}
  curl "$BASE/motions/$MOTION_ID" -H "Authorization: Bearer $VIGGLE_API_KEY"
  ```
</CodeGroup>

### `DELETE /v1/motions/{motion_id}`

<CodeGroup>
  ```go Go theme={null}
  req, _ := http.NewRequest("DELETE", base+"/motions/"+motionID, nil); req.Header.Set("Authorization", "Bearer "+apiKey); resp, _ := client.Do(req)
  ```

  ```javascript JavaScript theme={null}
  const resp = await fetch(`${base}/motions/${motionId}`, {method:"DELETE", headers:{Authorization:`Bearer ${apiKey}`}});
  ```

  ```python Python theme={null}
  resp = requests.delete(f"{base}/motions/{motion_id}", headers=headers)
  ```

  ```bash cURL theme={null}
  curl -X DELETE "$BASE/motions/$MOTION_ID" -H "Authorization: Bearer $VIGGLE_API_KEY"
  ```
</CodeGroup>

### `GET /v1/motions/{motion_id}/export`

<CodeGroup>
  ```go Go theme={null}
  req, _ := http.NewRequest("GET", base+"/motions/"+motionID+"/export?download_type=mixamo", nil); req.Header.Set("Authorization", "Bearer "+apiKey); resp, _ := client.Do(req)
  ```

  ```javascript JavaScript theme={null}
  const resp = await fetch(`${base}/motions/${motionId}/export?download_type=mixamo`, {headers:{Authorization:`Bearer ${apiKey}`}});
  ```

  ```python Python theme={null}
  resp = requests.get(f"{base}/motions/{motion_id}/export", params={"download_type": "mixamo"}, headers=headers)
  ```

  ```bash cURL theme={null}
  curl "$BASE/motions/$MOTION_ID/export?download_type=mixamo" -H "Authorization: Bearer $VIGGLE_API_KEY"
  ```
</CodeGroup>

### `GET /v1/videos`

替代已停用并返回 `405 Method Not Allowed` 的 `GET /v1/renders`，统一列出渲染及视频生成结果。

<CodeGroup>
  ```go Go theme={null}
  req, _ := http.NewRequest("GET", base+"/videos?status=ready&limit=20", nil); req.Header.Set("Authorization", "Bearer "+apiKey); resp, _ := client.Do(req)
  ```

  ```javascript JavaScript theme={null}
  const resp = await fetch(`${base}/videos?status=ready&limit=20`, {headers:{Authorization:`Bearer ${apiKey}`}});
  ```

  ```python Python theme={null}
  resp = requests.get(f"{base}/videos", params={"status": "ready", "limit": 20}, headers=headers)
  ```

  ```bash cURL theme={null}
  curl "$BASE/videos?status=ready&limit=20" -H "Authorization: Bearer $VIGGLE_API_KEY"
  ```
</CodeGroup>

### `GET /v1/videos/{video_id}`

替代已停用并返回 `405 Method Not Allowed` 的 `GET /v1/renders/{render_id}`。接受 `render_`、`vid_` 和 `anim_` 前缀 ID。

<CodeGroup>
  ```go Go theme={null}
  req, _ := http.NewRequest("GET", base+"/videos/"+videoID, nil); req.Header.Set("Authorization", "Bearer "+apiKey); resp, _ := client.Do(req)
  ```

  ```javascript JavaScript theme={null}
  const resp = await fetch(`${base}/videos/${videoId}`, {headers:{Authorization:`Bearer ${apiKey}`}});
  ```

  ```python Python theme={null}
  resp = requests.get(f"{base}/videos/{video_id}", headers=headers)
  ```

  ```bash cURL theme={null}
  curl "$BASE/videos/$VIDEO_ID" -H "Authorization: Bearer $VIGGLE_API_KEY"
  ```
</CodeGroup>

### `GET /v1/renders/{render_id}/events`

<CodeGroup>
  ```go Go theme={null}
  req, _ := http.NewRequest("GET", base+"/renders/"+renderID+"/events", nil); req.Header.Set("Authorization", "Bearer "+apiKey); req.Header.Set("Accept", "text/event-stream"); resp, _ := client.Do(req)
  ```

  ```bash cURL theme={null}
  curl -N "$BASE/renders/$RENDER_ID/events" -H "Authorization: Bearer $VIGGLE_API_KEY" -H "Accept: text/event-stream"
  ```
</CodeGroup>

### `GET /v1/renders/{render_id}/download`

<CodeGroup>
  ```go Go theme={null}
  req, _ := http.NewRequest("GET", base+"/renders/"+renderID+"/download", nil); req.Header.Set("Authorization", "Bearer "+apiKey); resp, _ := client.Do(req)
  ```

  ```javascript JavaScript theme={null}
  const resp = await fetch(`${base}/renders/${renderId}/download`, {headers:{Authorization:`Bearer ${apiKey}`}});
  ```

  ```python Python theme={null}
  resp = requests.get(f"{base}/renders/{render_id}/download", headers=headers, allow_redirects=True)
  ```

  ```bash cURL theme={null}
  curl -L "$BASE/renders/$RENDER_ID/download" -H "Authorization: Bearer $VIGGLE_API_KEY" -o output.mp4
  ```
</CodeGroup>
