Upload asset
August 8, 2024
Table of contents
Runway Assets.
https://api.useapi.net/v1/runwayml/assets/?…
Request Headers
Authorization: Bearer {API token}
Content-Type: select from the table below
API token
is required, see Setup useapi.net for details.Content-Type
is required, select from the table below:
Content-Type | File Extension |
---|---|
image/png | png |
image/jpeg | jpeg |
image/gif | gif |
video/mp4 | mp4 |
video/quicktime | mov |
video/3gpp | 3gp |
video/x-matroska | mkv |
video/x-flv | flv |
video/mpeg | mpeg |
video/MP2T | ts |
video/x-msvideo | avi |
video/x-motion-jpeg | mjpeg |
video/webm | webm |
video/ogg | ogv |
audio/wav | wav |
audio/wave | wav |
audio/mpeg | mp3 |
audio/flac | flac |
audio/ogg | ogg |
audio/webm | webm |
Query Parameters
email
is optional when only one account configured. However, if you have multiple accounts configured, this parameter becomes required.name
is required. Specify the name of the asset.
Request Body
Provide content of the uploaded file as a binary data.
Responses
-
{ "assetId": "user:user_id-runwayml:account_email-asset:asset_uuid", "id": "<asset uuid>", "user": { "id": 1234567, "username": "<user name>", "firstName": "<first name>", "lastName": "<last name>", "picture": null, "teamName": "<team name>", "teamPicture": null }, "createdAt": "2024-08-01T01:02:03.456Z", "updatedAt": "2024-08-01T01:02:03.456Z", "name": "<asset name>", "description": "", "type": { "name": "image", "type": "image", "isDirectory": false }, "size": 123456789, "url": "<asset url>", "previewUrls": ["<asset preview url>"], "fileCount": 1, "private": true, "permissions": { "read": true, "write": true, "admin": true }, "annotated": false, "isUserUpload": true, "sourceApplication": "web", "createdBy": { "id": 1234567, "username": "<user name>", "firstName": "<first name>", "lastName": "<last name>", "picture": null, "teamName": "<team name>", "teamPicture": null }, "favorite": false }
-
{ "error": "<Error message>", "code": 400 }
-
{ "error": "Unauthorized", "code": 401 }
Model
{ // TypeScript, all fields are optional
assetId: string,
id: string,
user: {
id: number,
username: string,
firstName: string,
lastName: string,
picture: string,
teamName: string,
teamPicture: string,
},
createdAt: string,
updatedAt: string,
name: string,
description: string,
type: {
name: string,
type: string,
isDirectory: boolean,
},
size: number,
url: string,
previewUrls: string[],
fileCount: number,
private: boolean,
permissions: {
read: boolean,
write: boolean,
admin: boolean,
},
annotated: boolean,
isUserUpload: boolean,
sourceApplication: string,
createdBy: {
id: number,
username: string,
firstName: string,
lastName: string,
picture: string,
teamName: string,
teamPicture: string,
},
favorite: boolean
}
Examples
-
curl -X POST "https://api.useapi.net/v1/runwayml/assets/?name=your_file_name" \ -H "Authorization: Bearer …" \ -H "Content-Type: image/jpeg" \ --data-binary /path/to/your/image_or_video_or_audio_file.jpeg
-
const token = "API token"; const name = "asset name"; const apiUrl = `https://api.useapi.net/v1/runwayml/assets/?name=${name}`; let blob; /* // Example 1: Fetch image from URL const imageUrl = "https://upload.wikimedia.org/wikipedia/commons/7/7d/Mona_Lisa_color_restoration.jpg"; const responseImage = await fetch(imageUrl); blob = await responseImage.blob(); */ /* // Example 2: Load image from local file (Blob) const fsp = require('fs').promises; const imageFileName = "./cat.png"; blob = new Blob([await fsp.readFile(imageFileName)]); */ /* // Example 3: Load from input file html element // <input id="image-file" type="file"> const imageFile = document.getElementById(`image-file`); if (imageFile.files[0]) blob = imageFile.files[0]); */ const response = await fetch(apiUrl, { method: "POST" headers: { "Authorization": `Bearer ${token}`, }, body: blob }); const result = await response.json(); console.log("response", {response, result});
-
import requests token = "API token" name = "asset name" email = "email" api_url = f"https://api.useapi.net/v1/runwayml/assets/?name={name}&email={email}" headers = { 'Authorization': f'Bearer {token}', 'Content-Type': 'image/jpeg' } # # Example 1: Fetch image from URL # image_url = "https://upload.wikimedia.org/wikipedia/commons/7/7d/Mona_Lisa_color_restoration.jpg" # response_image = requests.get(image_url) # file_content = response_image.content # # Example 2: Load image from local file # image_file_path = "./image.jpg" # with open(image_file_path, 'rb') as image_file: # file_content = image_file.read() response = requests.post(api_url, headers=headers, data=file_content) print(response, response.json())