### Verify API Key (GraphQL) Source: https://uthana.com/docs/api Test your API key by making a simple query to the GraphQL endpoint to ensure it's valid. ```APIDOC ## POST /graphql ### Description Verifies the provided API key by sending a basic GraphQL query. ### Method POST ### Endpoint `https://uthana.com/graphql` ### Parameters #### Headers - **Content-Type** (string) - Required - `application/json` - **Authorization** (string) - Required - `Basic ` ### Request Body - **query** (string) - Required - The GraphQL query string. Example: `{ __typename }` ### Request Example ```json { "query": "{ __typename }" } ``` ### Response #### Success Response (200) - **data** (object) - Contains the result of the GraphQL query. - **__typename** (string) - The type name of the query, expected to be "Query". #### Response Example ```json { "data": { "__typename": "Query" } } ``` ``` -------------------------------- ### Character Model Upload (Web UI) Source: https://uthana.com/docs/api Instructions for uploading a 3D character model using the Uthana Web UI. ```APIDOC ## Upload Character Model via Web UI ### Description Upload your 3D character model (FBX, glTF) using the Uthana Web UI. This is the recommended method for beginners. ### Steps 1. Navigate to the Uthana Web UI and sign in. 2. Click on the 'Character' button. 3. Upload your character model file (FBX, glTF, glb). 4. Verify the model by viewing existing motion or generating new motion. 5. Copy the character ID from the URL (e.g., `https://uthana.com/app//`). ### Auto-rigging If your character model is not rigged, Uthana will attempt to auto-rig it. This process may add 30-60 seconds to the upload time. Errors during auto-rigging will be detailed in the GraphQL response. ``` -------------------------------- ### Verify Uthana API Key with C# Source: https://uthana.com/docs/api This C# code demonstrates how to verify your Uthana API key using `HttpClient`. It sets up basic authentication headers and sends a JSON payload to the GraphQL endpoint. This example requires .NET Core or a compatible .NET version. The expected successful output is a JSON string: `{"data":{"__typename":"Query"}}`. ```csharp using System.Net.Http; using System.Text; using System.Text.Json; private const string ApiUrl = "https://uthana.com/graphql"; private readonly string _apiKey = "your-api-key"; var authValue = Convert.ToBase64String(Encoding.UTF8.GetBytes($"{_apiKey}:")); _httpClient.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Basic", authValue); var request = new { query = "{ __typename }" }; var json = JsonSerializer.Serialize(request); var content = new StringContent(json, Encoding.UTF8, "application/json"); var response = await _httpClient.PostAsync(ApiUrl, content); var responseJson = await response.Content.ReadAsStringAsync(); Console.WriteLine(responseJson); ``` -------------------------------- ### Download Motion Source: https://uthana.com/docs/api Allows downloading motion data for a specified character and motion ID. Supports different formats (FBX, GLB) and optional parameters like FPS and mesh inclusion. ```APIDOC ## GET /motion/file/motion_viewer/{CHARACTER_ID}/{MOTION_ID}/{format}/{CHARACTER_ID}-{MOTION_ID}.{format} ### Description Downloads motion data in the specified format (e.g., fbx, glb) for a given character and motion. ### Method GET ### Endpoint `/motion/file/motion_viewer/{CHARACTER_ID}/{MOTION_ID}/{format}/{CHARACTER_ID}-{MOTION_ID}.{format}` ### Parameters #### Path Parameters - **CHARACTER_ID** (string) - Required - The unique identifier for the character. - **MOTION_ID** (string) - Required - The unique identifier for the motion. - **format** (string) - Required - The desired format for the motion file (e.g., 'fbx', 'glb'). #### Query Parameters - **fps** (integer) - Optional - The desired frames per second for the motion (e.g., 24, 30, 60). - **no_mesh** (boolean) - Optional - If true, the mesh data will be excluded from the download. ### Request Example ```javascript // JavaScript Example const CHARACTER_ID = "cXi2eAP19XwQ"; const MOTION_ID = "your_motion_id"; async function downloadMotion(characterId, motionId, format, fps, noMesh) { let url = `https://uthana.com/motion/file/motion_viewer/${characterId}/${motionId}/${format}/${characterId}-${motionId}.${format}`; const params = new URLSearchParams(); if (fps) params.append("fps", fps.toString()); if (noMesh !== undefined) params.append("no_mesh", noMesh.toString()); if (params.toString()) url += `?${params.toString()}`; const response = await fetch(url, { headers: { Authorization: `Basic ${authString}`, }, }); if (!response.ok) { throw new Error(`Failed to download motion: ${response.statusText}`); } const blob = await response.blob(); return blob; } // Usage const fbxBlob = await downloadMotion(CHARACTER_ID, MOTION_ID, "fbx"); const motion30fps = await downloadMotion(CHARACTER_ID, MOTION_ID, "fbx", 30); ``` ```csharp // C# Example private const string CHARACTER_ID = "cXi2eAP19XwQ"; public async Task DownloadMotionAsync(string motionId, string format = "fbx", int? fps = null, bool? noMesh = null) { var downloadUrl = $"https://uthana.com/motion/file/motion_viewer/{CHARACTER_ID}/{motionId}/{format}/{CHARACTER_ID}-{motionId}.{format}"; var queryParams = new List(); if (fps.HasValue) queryParams.Add($"fps={fps.Value}"); if (noMesh.HasValue) queryParams.Add($"no_mesh={noMesh.Value.ToString().ToLower()}"); if (queryParams.Any()) downloadUrl += "?" + string.Join("&", queryParams); var response = await _httpClient.GetAsync(downloadUrl); response.EnsureSuccessStatusCode(); return await response.Content.ReadAsByteArrayAsync(); } // Usage var fbxData = await DownloadMotionAsync(motion.Id, "fbx"); var motion30fps = await DownloadMotionAsync(motion.Id, "fbx", fps: 30); ``` ### Response #### Success Response (200) - **response** (binary) - The motion data file in the requested format. ``` -------------------------------- ### Verify Uthana API Key with Python Source: https://uthana.com/docs/api This Python script verifies your Uthana API key by sending a request to the GraphQL endpoint. It uses the `requests` library and basic authentication. Ensure you have the `requests` library installed. The successful response will be a JSON object containing `{"data":{"__typename":"Query"}}`. ```python import requests API_URL = 'https://uthana.com/graphql' API_KEY = 'your-api-key' response = requests.post( API_URL, auth=(API_KEY, ''), json={'query': '{ __typename }'} ) print(response.json()) ``` -------------------------------- ### Download Motion Files (C#) Source: https://uthana.com/docs/api Provides asynchronous methods to download motion data in FBX or GLB format. Supports specifying FPS and an option to exclude the character mesh. Returns the motion data as a byte array. Requires an HttpClient instance. ```csharp using System; using System.Collections.Generic; using System.Linq; using System.Net.Http; using System.Threading.Tasks; public class UthanaMotionDownloader { private readonly HttpClient _httpClient; private const string CHARACTER_ID = "cXi2eAP19XwQ"; // Default character, or use your own public UthanaMotionDownloader(HttpClient httpClient) { _httpClient = httpClient; // Configure HttpClient with base address, default headers, etc. if needed } public async Task DownloadMotionAsync(string motionId, string format = "fbx", int? fps = null, bool? noMesh = null) { var downloadUrl = $"https://uthana.com/motion/file/motion_viewer/{CHARACTER_ID}/{motionId}/{format}/{CHARACTER_ID}-{motionId}.{format}"; var queryParams = new List(); if (fps.HasValue) queryParams.Add($"fps={fps.Value}"); if (noMesh.HasValue) queryParams.Add($"no_mesh={noMesh.Value.ToString().ToLower()}"); if (queryParams.Any()) downloadUrl += "?" + string.Join("&", queryParams); // Ensure authentication is handled, e.g., by setting default headers on _httpClient // _httpClient.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Basic", "YOUR_AUTH_STRING"); var response = await _httpClient.GetAsync(downloadUrl); response.EnsureSuccessStatusCode(); return await response.Content.ReadAsByteArrayAsync(); } public async Task DownloadMotionOnlyGlbAsync(string motionId, string filename = "motion") { var downloadUrl = $"https://uthana.com/motion/animation/motion_viewer/{CHARACTER_ID}/{motionId}/glb/{filename}.glb"; // Ensure authentication is handled var response = await _httpClient.GetAsync(downloadUrl); response.EnsureSuccessStatusCode(); return await response.Content.ReadAsByteArrayAsync(); } // Usage example (assuming 'motion.Id' is available and HttpClient is configured) /* public async Task ExampleUsage(string motionId) { var downloader = new UthanaMotionDownloader(new HttpClient()); // Or use an existing HttpClient instance var fbxData = await downloader.DownloadMotionAsync(motionId, "fbx"); var glbData = await downloader.DownloadMotionAsync(motionId, "glb"); var motion30fps = await downloader.DownloadMotionAsync(motionId, "fbx", fps: 30); var motionOnlyData = await downloader.DownloadMotionOnlyGlbAsync(motionId); } */ } ``` -------------------------------- ### Download Motion Animation via API Source: https://uthana.com/docs/api Downloads a generated motion animation in FBX or GLB format. Supports specifying frame rate (FPS) and downloading motion data only. Requires character ID, motion ID, and API key. ```shell CHARACTER_ID="cXi2eAP19XwQ" # Default character, or use your own MOTION_ID="" # Download the motion as FBX (includes character mesh, filename is customizable) curl -L "https://uthana.com/motion/file/motion_viewer/$CHARACTER_ID/$MOTION_ID/fbx/motion.fbx" \ -u your-api-key: \ -o motion.fbx # Download the motion as GLB (includes character mesh, filename is customizable) curl -L "https://uthana.com/motion/file/motion_viewer/$CHARACTER_ID/$MOTION_ID/glb/motion.glb" \ -u your-api-key: \ -o motion.glb # Download at 30 FPS curl -L "https://uthana.com/motion/file/motion_viewer/$CHARACTER_ID/$MOTION_ID/fbx/motion.fbx?fps=30" \ -u your-api-key: \ -o motion-30fps.fbx # Download the motion-only GLB (animation data without character mesh, filename is customizable) curl -L "https://uthana.com/motion/animation/motion_viewer/$CHARACTER_ID/$MOTION_ID/glb/motion.glb" \ -u your-api-key: \ -o motion-only.glb ``` ```python import requests API_KEY = "your-api-key" CHARACTER_ID = "cXi2eAP19XwQ" # Default character, or use your own MOTION_ID = "" # Download the motion as FBX (includes character mesh, filename is customizable) fbx_url = f'https://uthana.com/motion/file/motion_viewer/{CHARACTER_ID}/{MOTION_ID}/fbx/motion.fbx' response = requests.get(fbx_url, auth=(API_KEY, '')) with open('motion.fbx', 'wb') as f: f.write(response.content) # Download the motion as GLB (includes character mesh, filename is customizable) glB_url = f'https://uthana.com/motion/file/motion_viewer/{CHARACTER_ID}/{MOTION_ID}/glb/motion.glb' response = requests.get(glb_url, auth=(API_KEY, '')) with open('motion.glb', 'wb') as f: f.write(response.content) # Download at 30 FPS fbx_url_30fps = f'https://uthana.com/motion/file/motion_viewer/{CHARACTER_ID}/{MOTION_ID}/fbx/motion.fbx?fps=30' response = requests.get(fbx_url_30fps, auth=(API_KEY, '')) with open('motion-30fps.fbx', 'wb') as f: f.write(response.content) # Download the motion-only GLB (animation data without character mesh, filename is customizable) motion_only_glb_url = f'https://uthana.com/motion/animation/motion_viewer/{CHARACTER_ID}/{MOTION_ID}/glb/motion.glb' response = requests.get(motion_only_glb_url, auth=(API_KEY, '')) with open('motion-only.glb', 'wb') as f: f.write(response.content) ``` -------------------------------- ### Download Motion File API Source: https://uthana.com/docs/api Download generated motion files in various formats (FBX, GLB) with options to include the character mesh or download motion-only data, and specify FPS. ```APIDOC ## GET /motion/file/motion_viewer/{CHARACTER_ID}/{MOTION_ID}/{FORMAT}/{FILENAME} ### Description Downloads a motion file in the specified format (FBX or GLB). Optionally, you can specify the frames per second (FPS). ### Method GET ### Endpoint - `https://uthana.com/motion/file/motion_viewer/{CHARACTER_ID}/{MOTION_ID}/{FORMAT}/{FILENAME}` - `https://uthana.com/motion/animation/motion_viewer/{CHARACTER_ID}/{MOTION_ID}/{FORMAT}/{FILENAME}` (for motion-only GLB) ### Parameters #### Path Parameters - **CHARACTER_ID** (string) - Required - The ID of the character associated with the motion. - **MOTION_ID** (string) - Required - The ID of the motion to download. - **FORMAT** (string) - Required - The desired file format (e.g., `fbx`, `glb`). - **FILENAME** (string) - Required - The desired name for the downloaded file (e.g., `motion.fbx`). #### Query Parameters - **fps** (integer) - Optional - The desired frames per second for the downloaded motion. ### Request Example (Shell) ```bash # Download motion as FBX with character mesh curl -L "https://uthana.com/motion/file/motion_viewer/$CHARACTER_ID/$MOTION_ID/fbx/motion.fbx" -u your-api-key: -o motion.fbx # Download motion as GLB with character mesh curl -L "https://uthana.com/motion/file/motion_viewer/$CHARACTER_ID/$MOTION_ID/glb/motion.glb" -u your-api-key: -o motion.glb # Download motion as FBX at 30 FPS curl -L "https://uthana.com/motion/file/motion_viewer/$CHARACTER_ID/$MOTION_ID/fbx/motion.fbx?fps=30" -u your-api-key: -o motion-30fps.fbx # Download motion-only GLB (animation data without character mesh) curl -L "https://uthana.com/motion/animation/motion_viewer/$CHARACTER_ID/$MOTION_ID/glb/motion.glb" -u your-api-key: -o motion-only.glb ``` ### Response #### Success Response (200) The response will be the raw file content of the requested motion file. ``` -------------------------------- ### Bash Script for Text-to-Motion Job and Download Source: https://uthana.com/docs/api/examples/curl A complete bash script example that sets up API key and character ID variables, then proceeds to create a text-to-motion job and download the resulting motion as FBX and GLB files. ```bash #!/bin/bash set -eo pipefail # Set your API key and character ID for easy reuse UTHANA_APIKEY=your-api-key HOST="uthana.com" CHARACTER_ID= ``` -------------------------------- ### Generate Text-to-Motion Animation via API Source: https://uthana.com/docs/api Creates a new motion animation from a text prompt using a GraphQL mutation. Requires an API key for authentication. The response includes the ID and name of the created motion. ```shell curl 'https://uthana.com/graphql' \ -u your-api-key: \ -H "Content-Type: application/json" \ -d '{ "query": "mutation { create_text_to_motion(prompt: \"A person walking down the street\") { motion { id name } } }" }' ``` ```python import requests API_URL = "https://uthana.com/graphql" API_KEY = "your-api-key" query = ''' mutation { create_text_to_motion(prompt: "A person walking down the street") { motion { id name } } } ''' response = requests.post( API_URL, auth=(API_KEY, ''), json={'query': query} ) result = response.json() motion = result["data"]["create_text_to_motion"]["motion"] print(f"Created motion: {motion['id']} - {motion['name']}") ``` ```typescript const API_URL = "https://uthana.com/graphql"; const API_KEY = "your-api-key"; const authString = btoa(API_KEY + ":"); async function createMotion() { const response = await fetch(API_URL, { method: "POST", headers: { "Content-Type": "application/json", Authorization: `Basic ${authString}`, }, body: JSON.stringify({ query: ` mutation { create_text_to_motion(prompt: "A person walking down the street") { motion { id name } } }`, }), }); const json = await response.json(); const motion = json.data.create_text_to_motion.motion; console.log(`Created motion: ${motion.id} - ${motion.name}`); } createMotion(); ``` ```csharp using System; using System.Net.Http; using System.Text; using System.Text.Json; using System.Threading.Tasks; public class GraphQLResponse { public T Data { get; set; } } public class CreateTextToMotionData { public CreateTextToMotionResult CreateTextToMotion { get; set; } } public class CreateTextToMotionResult { public MotionData Motion { get; set; } } public class MotionData { public string Id { get; set; } public string Name { get; set; } } public class ApiClient { private readonly HttpClient _httpClient; private readonly string _apiUrl; public ApiClient(HttpClient httpClient, string apiUrl) { _httpClient = httpClient; _apiUrl = apiUrl; } public async Task CreateMotionAsync(string apiKey) { var query = @"\n mutation {\n create_text_to_motion(prompt: \"A person walking down the street\") {\n motion {\n id\n name\n }\n }\n }"; var request = new { query = query }; var json = JsonSerializer.Serialize(request); var content = new StringContent(json, Encoding.UTF8, "application/json"); // Assuming _httpClient is configured with the base address and authentication // For simplicity, we'll add the API key to the URL or headers if not using HttpClient.DefaultRequestHeaders // var response = await _httpClient.PostAsync(_apiUrl, content); // Example using a direct HttpClient instance for demonstration using (var client = new HttpClient()) { client.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Basic", Convert.ToBase64String(Encoding.ASCII.GetBytes(apiKey + ":"))); var response = await client.PostAsync(_apiUrl, content); response.EnsureSuccessStatusCode(); var responseJson = await response.Content.ReadAsStringAsync(); var result = JsonSerializer.Deserialize>(responseJson); var motion = result.Data.CreateTextToMotion.Motion; Console.WriteLine($"Created motion: {motion.Id} - {motion.Name}"); } } } // Example Usage: // var httpClient = new HttpClient(); // var apiClient = new ApiClient(httpClient, "https://uthana.com/graphql"); // await apiClient.CreateMotionAsync("your-api-key"); ``` -------------------------------- ### Download Motion Files (TypeScript) Source: https://uthana.com/docs/api Provides functions to download motion data in FBX or GLB format. Supports specifying FPS and an option to exclude the character mesh. Uses the Fetch API to make HTTP requests and returns a Blob object. ```typescript const CHARACTER_ID = "cXi2eAP19XwQ"; // Default character, or use your own const MOTION_ID = "YOUR_MOTION_ID"; const authString = "YOUR_AUTH_STRING"; // e.g., btoa("username:password") async function downloadMotion( characterId: string, motionId: string, format: "fbx" | "glb", fps?: 24 | 30 | 60, noMesh?: boolean, ) { let url = `https://uthana.com/motion/file/motion_viewer/${characterId}/${motionId}/${format}/${characterId}-${motionId}.${format}`; const params = new URLSearchParams(); if (fps) params.append("fps", fps.toString()); if (noMesh !== undefined) params.append("no_mesh", noMesh.toString()); if (params.toString()) url += `?${params.toString()}`; const response = await fetch(url, { headers: { Authorization: `Basic ${authString}`, }, }); if (!response.ok) { throw new Error(`Failed to download motion: ${response.statusText}`); } const blob = await response.blob(); return blob; } async function downloadMotionOnlyGlb(characterId: string, motionId: string, filename: string = "motion") { const url = `https://uthana.com/motion/animation/motion_viewer/${characterId}/${motionId}/glb/${filename}.glb`; const response = await fetch(url, { headers: { Authorization: `Basic ${authString}`, }, }); const blob = await response.blob(); return blob; } // Usage // const fbxBlob = await downloadMotion(CHARACTER_ID, MOTION_ID, "fbx"); // const glbBlob = await downloadMotion(CHARACTER_ID, MOTION_ID, "glb"); // const motion30fps = await downloadMotion(CHARACTER_ID, MOTION_ID, "fbx", 30); // const motionOnlyBlob = await downloadMotionOnlyGlb(CHARACTER_ID, MOTION_ID); ``` -------------------------------- ### Download Motion-Only GLB Files (C#) Source: https://uthana.com/docs/api/capabilities/downloading-motion Presents a C# example for downloading motion-only GLB files from the Uthana API using `HttpClient`. It demonstrates making a GET request and reading the response content as a byte array. ```csharp var motionOnlyUrl = $"https://uthana.com/motion/animation/motion_viewer/{CHARACTER_ID}/{motionId}/glb/motion.glb"; var response = await _httpClient.GetAsync(motionOnlyUrl); response.EnsureSuccessStatusCode(); var bytes = await response.Content.ReadAsByteArrayAsync(); ``` -------------------------------- ### Text-to-Motion Generation API Source: https://uthana.com/docs/api Generate a new text-to-motion animation by providing a text prompt. The API returns the motion ID and name upon successful creation. ```APIDOC ## POST /graphql ### Description Generates a new text-to-motion animation from a given text prompt. ### Method POST ### Endpoint https://uthana.com/graphql ### Parameters #### Request Body - **query** (string) - Required - The GraphQL mutation to create text-to-motion. - Example: `mutation { create_text_to_motion(prompt: "A person walking down the street") { motion { id name } } }` ### Request Example ```json { "query": "mutation { create_text_to_motion(prompt: \"A person walking down the street\") { motion { id name } } }" } ``` ### Response #### Success Response (200) - **data** (object) - Contains the result of the mutation. - **create_text_to_motion** (object) - The result of the text-to-motion creation. - **motion** (object) - Information about the created motion. - **id** (string) - The unique identifier for the generated motion. - **name** (string) - The name of the motion, typically derived from the prompt. #### Response Example ```json { "data": { "create_text_to_motion": { "motion": { "id": "", "name": "A person walking down the street" } } } } ``` #### Error Response Errors will be returned in a GraphQL `errors` array. ``` -------------------------------- ### GraphQL Queries Source: https://uthana.com/docs/api/examples/curl Examples of making GraphQL queries to retrieve data. ```APIDOC ## GraphQL Queries ### Description Send POST requests to the GraphQL endpoint with your query in the JSON body. ### Method POST ### Endpoint `https://uthana.com/graphql` ### Parameters #### Request Body - **query** (string) - Required - The GraphQL query string. - **variables** (object) - Optional - Variables to be used in the query. ### Request Example (Get motion details) ```bash curl -X POST https://uthana.com/graphql \ -u your-api-key: \ -H "Content-Type: application/json" \ -d '{ "query": "query GetMotion($id: String!) { motion(id: $id) { id name created } }", "variables": { "id": "m3G3XSJrjEJH" } }' ``` ### Request Example (Get org info) ```bash curl -X POST https://uthana.com/graphql \ -u your-api-key: \ -H "Content-Type: application/json" \ -d '{"query":"{ org { id name } }"}' ``` ``` -------------------------------- ### Error Handling Examples Source: https://uthana.com/docs/api/capabilities/stitch-loop-motions Code examples in Shell, Python, TypeScript, and C# demonstrating how to check for and handle API errors. ```Shell if echo "$RESPONSE" | jq -e '.errors' > /dev/null; then echo "Error occurred:" echo "$RESPONSE" | jq '.errors' fi ``` ```Python result = response.json() if "errors" in result: for error in result["errors"]: print(f"Error: {error['message']}") if "extensions" in error: print(f"Code: {error['extensions'].get('code', 'N/A')}") ``` ```TypeScript const json = await response.json(); if (json.errors) { json.errors.forEach((err: any) => { console.error(`Error: ${err.message}`); if (err.extensions) console.error(`Code: ${err.extensions.code || "N/A"}`); }); } ``` ```C# if (result.Errors != null && result.Errors.Length > 0) { foreach (var error in result.Errors) { Console.WriteLine($"Error: {error.Message}"); if (error.Extensions != null && error.Extensions.ContainsKey("code")) Console.WriteLine($"Code: {error.Extensions["code"]}"); } } ``` -------------------------------- ### Make GraphQL Queries with cURL Source: https://uthana.com/docs/api/examples/curl Provides examples of making POST requests to the Uthana GraphQL API to fetch data. It includes examples for retrieving motion details, organization information, and generating motion from text. ```bash curl -X POST https://uthana.com/graphql \ -u your-api-key: \ -H "Content-Type: application/json" \ -d '{ "query": "query GetMotion($id: String!) { motion(id: $id) { id name created } }", "variables": { "id": "m3G3XSJrjEJH" } }' ``` ```bash curl -X POST https://uthana.com/graphql \ -u your-api-key: \ -H "Content-Type: application/json" \ -d '{"query":"{ org { id name } }"}' ``` ```bash curl -X POST https://uthana.com/graphql \ -u your-api-key: \ -H "Content-Type: application/json" \ -d '{ "query": "mutation CreateTextToMotion($prompt: String!) { create_text_to_motion(prompt: $prompt) { motion { id name } } }", "variables": { "prompt": "walk casually" } }' ``` -------------------------------- ### GraphQL Mutations Source: https://uthana.com/docs/api/examples/curl Examples of making GraphQL mutations to modify data. ```APIDOC ## GraphQL Mutations ### Description Send POST requests to the GraphQL endpoint with your mutation in the JSON body. ### Method POST ### Endpoint `https://uthana.com/graphql` ### Parameters #### Request Body - **query** (string) - Required - The GraphQL mutation string. - **variables** (object) - Optional - Variables to be used in the mutation. ### Request Example (Generate motion from text) ```bash curl -X POST https://uthana.com/graphql \ -u your-api-key: \ -H "Content-Type: application/json" \ -d '{ "query": "mutation CreateTextToMotion($prompt: String!) { create_text_to_motion(prompt: $prompt) { motion { id name } } }", "variables": { "prompt": "walk casually" } }' ``` ``` -------------------------------- ### Download Motion-Only GLB (Python) Source: https://uthana.com/docs/api Downloads a GLB file containing only animation data, without the character mesh. The filename is customizable. This uses the 'requests' library to fetch the file content and save it locally. ```python import requests CHARACTER_ID = "YOUR_CHARACTER_ID" MOTION_ID = "YOUR_MOTION_ID" API_KEY = "YOUR_API_KEY" motion_only_url = f'https://uthana.com/motion/animation/motion_viewer/{CHARACTER_ID}/{MOTION_ID}/glb/motion.glb' response = requests.get(motion_only_url, auth=(API_KEY, '')) with open('motion-only.glb', 'wb') as f: f.write(response.content) ``` -------------------------------- ### Verify Uthana API Key with cURL Source: https://uthana.com/docs/api This snippet demonstrates how to verify your Uthana API key by making a simple query to the GraphQL endpoint using cURL. It requires your API key and the Uthana GraphQL endpoint URL. The expected output is a JSON object confirming the API's typename. ```shell API_KEY="your-api-key" curl 'https://uthana.com/graphql' \ -u $API_KEY: \ -H "Content-Type: application/json" \ -d '{"query": "{ __typename }"}' ``` -------------------------------- ### File Uploads (Multipart) Source: https://uthana.com/docs/api/examples/curl How to upload files using the GraphQL multipart request specification. ```APIDOC ## File Uploads (Multipart) ### Description Upload files for operations like `create_character` or `create_video_to_motion` using the GraphQL multipart request specification. ### Method POST ### Endpoint `https://uthana.com/graphql` ### Parameters #### Form Data - **operations** (string) - Required - JSON string containing the GraphQL query/mutation and variables. The file is represented by `null` in the variables. - **map** (string) - Required - JSON string mapping file keys in `operations` to form field names. - **[file_key]** (file) - Required - The actual file being uploaded. ### Request Example (Upload a character) ```bash curl -X POST https://uthana.com/graphql \ -u your-api-key: \ -F 'operations={ "query": "mutation ($file: Upload!, $name: String!) { create_character(file: $file, name: $name) { character {id name} } }", "variables": { "file": null, "name": "My Character" } }' \ -F 'map={ "0": ["variables.file"] }' \ -F '0=@/path/to/character.fbx' ``` ### Request Example (Disable auto-rigging during character creation) ```bash curl -X POST https://uthana.com/graphql \ -u your-api-key: \ -F 'operations={ "query": "mutation ($file: Upload!, $name: String!) { create_character(file: $file, name: $name, auto_rig: false) { character {id name} } }", "variables": { "file": null, "name": "My Character" } }' \ -F 'map={ "0": ["variables.file"] }' \ -F '0=@/path/to/character.fbx' ``` ``` -------------------------------- ### Verify Uthana API Key with TypeScript Source: https://uthana.com/docs/api This TypeScript code snippet verifies your Uthana API key using the `fetch` API. It constructs an Authorization header with basic authentication and sends a POST request to the GraphQL endpoint. This code is suitable for Node.js or browser environments. A successful response confirms the API key with `{"data":{"__typename":"Query"}}`. ```typescript const API_URL = "https://uthana.com/graphql"; const API_KEY = "your-api-key"; const authString = btoa(`${API_KEY}:`); const response = await fetch(API_URL, { method: "POST", headers: { "Content-Type": "application/json", Authorization: `Basic ${authString}`, }, body: JSON.stringify({ query: "{ __typename }", }), }); const json = await response.json(); console.log(json); ``` -------------------------------- ### Get Organization Information via GraphQL API (TypeScript) Source: https://uthana.com/docs/api/capabilities/account-and-organization This TypeScript example utilizes the `fetch` API to interact with the Uthana GraphQL endpoint. It demonstrates how to construct the request body, include authentication headers, and process the JSON response to display organization details. ```typescript const API_URL = "https://uthana.com/graphql"; const API_KEY = "YOUR_API_KEY"; const authString = btoa(API_KEY + ":"); async function getOrgInfo() { const response = await fetch(API_URL, { method: "POST", headers: { "Content-Type": "application/json", Authorization: `Basic ${authString}`, }, body: JSON.stringify({ query: ` query { org { id name motion_download_secs_per_month motion_download_secs_per_month_remaining characters_allowed characters_allowed_remaining users { id name email } } } `, }), }); const json = await response.json(); const org = json.data.org; console.log(`Organization: ${org.name}`); console.log(`Download allowance: ${org.motion_download_secs_per_month} seconds/month`); console.log(`Remaining: ${org.motion_download_secs_per_month_remaining} seconds`); console.log(`Characters: ${org.characters_allowed_remaining} of ${org.characters_allowed} remaining`); console.log(`Users: ${org.users.length}`); } getOrgInfo(); ``` -------------------------------- ### Download Motion File API Source: https://uthana.com/docs/api/capabilities/video-to-motion This section explains how to download the generated motion file once the job is completed. It provides examples in Shell, Python, TypeScript, and C#. ```APIDOC ## GET /motion/file/{format}/{character_id}/{motion_id} ### Description Downloads the generated motion file in the specified format. ### Method GET ### Endpoint https://uthana.com/motion/file/{format}/{character_id}/{motion_id} ### Parameters #### Path Parameters - **format** (String) - The desired file format (e.g., "fbx"). - **character_id** (String) - The ID of the character to associate with the motion. - **motion_id** (String) - The ID of the motion to download. ### Request Example ```bash curl -L "https://uthana.com/motion/file/fbx/cXi2eAP19XwQ/motion-abc/fbx/motion.fbx" -u YOUR_API_KEY: ``` ### Response #### Success Response (200) - The response will be the motion file in the requested format (e.g., `motion.fbx`). ``` -------------------------------- ### Upload Files using cURL (Multipart Form Data) Source: https://uthana.com/docs/api/examples/curl Illustrates how to upload files to the Uthana API using the GraphQL multipart request specification. Examples include uploading a character for creation. ```bash curl -X POST https://uthana.com/graphql \ -u your-api-key: \ -F 'operations={ "query": "mutation ($file: Upload!, $name: String!) { create_character(file: $file, name: $name) { character {id name} } }", "variables": { "file": null, "name": "My Character" } }' \ -F 'map={ "0": ["variables.file"] }' \ -F '0=@/path/to/character.fbx' ``` -------------------------------- ### Video to Motion API: Upload Video File Configuration Source: https://uthana.com/docs/api/capabilities/video-to-motion Configuration snippets for setting up API key and video file path for video-to-motion uploads. These examples show how to define essential variables before initiating an API call. ```shell # Set your API key and video file path API_KEY="your-api-key" VIDEO_FILE="/path/to/your/video.mp4" ``` ```python import requests API_URL = 'https://uthana.com/graphql' API_KEY = 'your-api-key' VIDEO_FILE = '/path/to/your/video.mp4' ``` ```typescript const API_URL = "https://uthana.com/graphql"; const API_KEY = "your-api-key"; // Example markup: const videoInput = document.querySelector("#videoFile"); const VIDEO_FILE = videoInput?.files?.[0]; if (!VIDEO_FILE) { throw new Error("Select a video file before uploading."); } ``` ```csharp private const string ApiUrl = "https://uthana.com/graphql"; private readonly string _apiKey = "your-api-key"; private readonly string _videoFile = "/path/to/your/video.mp4"; ``` -------------------------------- ### Download Character Bundle Source: https://uthana.com/docs/api/examples/curl Downloads a character bundle in FBX format, which includes the character mesh. ```APIDOC ## GET /motion/bundle/{CHARACTER_ID}/character.fbx ### Description Downloads the specified character as an FBX file, including its mesh. ### Method GET ### Endpoint /motion/bundle/{CHARACTER_ID}/character.fbx ### Parameters #### Path Parameters - **CHARACTER_ID** (String) - The ID of the character to download. ### Response #### Success Response (200) - The response body will be the FBX file content. ``` -------------------------------- ### Download FBX Motion Data with Different Configurations (Shell) Source: https://uthana.com/docs/api/capabilities/downloading-motion Demonstrates downloading FBX motion files from the Uthana API. The first example downloads at 30 FPS without the character mesh. The second example downloads at 30 FPS, in-place, with a Roblox-compatible FBX, requiring a specific character ID. ```shell curl -L "https://uthana.com/motion/file/motion_viewer/$CHARACTER_ID/$MOTION_ID/fbx/motion.fbx?fps=30&no_mesh=true" \ -u $API_KEY: \ -o motion-30fps-no-mesh.fbx CHARACTER_ID="cFB7NoFCUCvf" curl -L "https://uthana.com/motion/file/motion_viewer/$CHARACTER_ID/$MOTION_ID/fbx/motion.fbx?fps=30&no_mesh=false&in_place=true&roblox_compatible=true" \ -u $API_KEY: \ -o motion-30fps-roblox.fbx ``` -------------------------------- ### Download Motion File Source: https://uthana.com/docs/api/examples/curl Endpoints for downloading motion files in various formats. ```APIDOC ## Download Motion File ### Description Download motion files, with or without character meshes, in specified formats. ### Method GET ### Endpoint Structure `https://uthana.com/motion/file/motion_viewer/{character_id}/{motion_id}/{type}/{character_id}-{motion_id}.{type}` ### Parameters #### Path Parameters - **character_id** (string) - Required - The ID of the character. - **motion_id** (string) - Required - The ID of the motion. - **type** (string) - Required - The file format (`fbx`, `glb`). ### Request Example (Download motion as FBX with character mesh) ```bash curl -L "https://uthana.com/motion/file/motion_viewer///fbx/-.fbx" \ -u your-api-key: \ -o motion.fbx ``` ### Endpoint Structure (Motion-only GLB) `https://uthana.com/motion/animation/motion_viewer///glb/-.glb` ### Request Example (Download motion-only GLB) ```bash curl -L "https://uthana.com/motion/animation/motion_viewer///glb/-.glb" \ -u your-api-key: \ -o motion-only.glb ``` ### Notes - Replace `` and `` with your actual IDs. - The `-L` flag follows redirects. - The `-o` flag saves the file with the specified name. ``` -------------------------------- ### Create Text-to-Motion Job and Download Motion Source: https://uthana.com/docs/api/examples/curl This snippet demonstrates how to create a text-to-motion job using a GraphQL mutation and then download the generated motion in FBX and GLB formats. It utilizes `curl` for API requests and `jq` for parsing JSON responses. Ensure the `HOST` and `UTHANA_APIKEY` environment variables are set. ```bash MUTATION='{ "query": "mutation CreateTextToMotion($model: String!, $prompt: String!) { create_text_to_motion(model: $model, prompt: $prompt) { motion { id name } } }", "variables": {"model": "text-to-motion", "prompt": "a person runs in a circle"}, "operationName": "CreateTextToMotion" }' RES="$(curl -s "https://$HOST/graphql" \ -u $UTHANA_APIKEY: \ -H 'Accept: application/json' \ -H 'Content-Type: application/json' \ --data-raw "$MUTATION" )" echo $RES MOTION_ID="$(echo $RES | jq -r .data.create_text_to_motion.motion.id)" echo "motion_id: $MOTION_ID" # Download the motion as FBX (includes character mesh) curl -s --remote-name "https://$HOST/motion/file/motion_viewer/$CHARACTER_ID/$MOTION_ID/fbx/$CHARACTER_ID-$MOTION_ID.fbx" \ -u $UTHANA_APIKEY: # Download the motion as GLB (includes character mesh) curl -s --remote-name "https://$HOST/motion/file/motion_viewer/$CHARACTER_ID/$MOTION_ID/glb/$CHARACTER_ID-$MOTION_ID.glb" \ -u $UTHANA_APIKEY: # Download the motion-only GLB (animation data without character mesh) curl -s --remote-name "https://$HOST/motion/animation/motion_viewer/$CHARACTER_ID/$MOTION_ID/glb/$CHARACTER_ID-$MOTION_ID.glb" \ -u $UTHANA_APIKEY: # View the motion in the Uthana Web UI echo "https://$HOST/app/play/$CHARACTER_ID/$MOTION_ID" ``` -------------------------------- ### Stitch API: Pelvis State Input Example (JSON) Source: https://uthana.com/docs/api/capabilities/stitch-loop-motions An example of the 'PelvisStateInput' object structure required for the Stitch API. This object defines the character's pose at specific time points, including position, rotation, and facing direction. ```json { "pelvis_world_pos": { "x": 0.12, "y": 0.95, "z": 0.0 }, "pelvis_world_rot": { "x": 0, "y": 0, "z": 0, "w": 1 }, "hips_forward_facing_world_yaw": 0 } ``` -------------------------------- ### Authenticate Uthana API Request Source: https://uthana.com/docs/api/capabilities/text-to-motion Set up your API key for authenticating requests to the Uthana API. This is a prerequisite for all API interactions. Examples are provided for Shell, Python, TypeScript, and C#. ```shell # Set your API key API_KEY="your-api-key" ``` ```python import requests API_URL = 'https://uthana.com/graphql' API_KEY = 'your-api-key' ``` ```typescript const API_URL = "https://uthana.com/graphql"; const API_KEY = "your-api-key"; ``` ```csharp private const string ApiUrl = "https://uthana.com/graphql"; private readonly string _apiKey = "your-api-key"; ``` -------------------------------- ### Authenticate with Uthana API using cURL Source: https://uthana.com/docs/api/examples/curl Demonstrates various methods to authenticate API requests using cURL. This includes using the `-u` flag with an API key, the `Authorization` header with a base64-encoded key, and a query parameter. ```bash curl -s "https://uthana.com/graphql" \ -u YOUR_API_KEY: \ -H 'Accept: application/json' \ -H 'Content-Type: application/json' \ --data-raw '{}' ``` ```bash AUTH_STRING=$(echo -n "your-api-key:" | base64) curl -H "Authorization: Basic $AUTH_STRING" \ https://uthana.com/graphql ``` ```bash curl 'https://uthana.com/graphql?apikey=your-api-key' ```