> ## 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.

# Code examples

> Go, JavaScript, Python, and cURL examples for every V1 endpoint.

Set `VIGGLE_API_KEY` before using these examples. Replace all sample IDs with the complete IDs returned by your account.

## Credits — `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>

## Create Character — `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>

## List, get, and delete Characters

<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"
  ```
</CodeGroup>

For list, use `GET /v1/characters`; for deletion, change the request method to `DELETE`. See [Characters](/v1/api-reference/characters) for every request and response field.

## Create Motion — `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>

## Import Motion — `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>

## List, get, and delete Motions

<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"
  ```
</CodeGroup>

## Create, query, cancel, and download a Render

<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/renders/render_8f50b2c2c2b84ae0" -H "Authorization: Bearer $VIGGLE_API_KEY"
  curl -X DELETE "https://apis.viggle.ai/v1/renders/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>

For query, cancellation, and download, use the same authenticated request with `GET`, `DELETE`, or `GET` respectively. See [Renders](/v1/api-reference/renders) for parameter combinations and response fields.

## Create and query 3D Conversion

<CodeGroup>
  ```go Go theme={null}
  body := &bytes.Buffer{}; w := multipart.NewWriter(body); field, _ := w.CreateFormFile("image", "character.png"); file, _ := os.Open("character.png"); io.Copy(field, file); w.Close()
  req, _ := http.NewRequest("POST", base+"/avatars", body); req.Header.Set("Authorization", "Bearer "+apiKey); req.Header.Set("Content-Type", w.FormDataContentType()); avatar, _ := client.Do(req)
  ```

  ```javascript JavaScript theme={null}
  const avatarForm = new FormData(); avatarForm.append("image", imageFile);
  const createdAvatar = await fetch(`${base}/avatars`, {method:"POST", headers:{Authorization:`Bearer ${apiKey}`}, body:avatarForm});
  const avatar = await fetch(`https://apis.viggle.ai/v1/avatars/${avatarId}`, {headers:{Authorization:`Bearer ${process.env.VIGGLE_API_KEY}`}});
  const animation = await fetch(`https://apis.viggle.ai/v1/animations/${animationId}`, {headers:{Authorization:`Bearer ${process.env.VIGGLE_API_KEY}`}});
  ```

  ```python Python theme={null}
  with open("character.png", "rb") as image:
      created_avatar = requests.post(f"{base}/avatars", headers=headers, files={"image": image})
  avatar = requests.get(f"https://apis.viggle.ai/v1/avatars/{avatar_id}", headers={"Authorization": f"Bearer {os.environ['VIGGLE_API_KEY']}"})
  animation = requests.get(f"https://apis.viggle.ai/v1/animations/{animation_id}", headers={"Authorization": f"Bearer {os.environ['VIGGLE_API_KEY']}"})
  ```

  ```bash cURL theme={null}
  curl -X POST "https://apis.viggle.ai/v1/avatars" -H "Authorization: Bearer $VIGGLE_API_KEY" -F "image=@character.png"
  curl "https://apis.viggle.ai/v1/avatars/avatar_8f50b2c2c2b84ae0" -H "Authorization: Bearer $VIGGLE_API_KEY"
  curl -X POST "https://apis.viggle.ai/v1/animations" -H "Authorization: Bearer $VIGGLE_API_KEY" -F "video=@dance.mp4"
  curl "https://apis.viggle.ai/v1/animations/anim_8f50b2c2c2b84ae0" -H "Authorization: Bearer $VIGGLE_API_KEY"
  ```
</CodeGroup>

See [3D Conversion](/v1/api-reference/3d-outputs) for the required upload fields and full response schema.

## Endpoint-by-endpoint request examples

The following compact examples show the exact HTTP method, path, and request shape for every endpoint. In the Go snippets, `client` is an `http.Client`; in JavaScript, `apiKey` is your API key; in Python, `headers` is `{"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/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/renders/{render_id}`

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

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

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

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

### `DELETE /v1/renders/{render_id}`

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

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

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

  ```bash cURL theme={null}
  curl -X DELETE "$BASE/renders/$RENDER_ID" -H "Authorization: Bearer $VIGGLE_API_KEY"
  ```
</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>

### `GET /v1/avatars/{avatar_id}` and `GET /v1/animations/{animation_id}`

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

  ```javascript JavaScript theme={null}
  const avatar = await fetch(`${base}/avatars/${avatarId}`, {headers:{Authorization:`Bearer ${apiKey}`}});
  const animation = await fetch(`${base}/animations/${animationId}`, {headers:{Authorization:`Bearer ${apiKey}`}});
  ```

  ```python Python theme={null}
  avatar = requests.get(f"{base}/avatars/{avatar_id}", headers=headers)
  animation = requests.get(f"{base}/animations/{animation_id}", headers=headers)
  ```

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