Vizard now offers an API service, with the same abilities as the web app.
Quickstart
Step 1: Generate your API key
Navigate to your Workspace-Account-API Key
Click the "Generate API Key" button. Your unique API key will be displayed within seconds. Note: This feature requires a Pro plan.
Important: Treat your API key like a password. Keep it confidential and do not share it with anyone.
Step 2: Post a long video
Request
URL
Method
POST
Rate limits
3 requests per minute
Headers
Name of Header | Value | Required |
Content-Type | application/json | YES |
VIZARDAI_API_KEY | Vizard ai api key | YES |
Body (Raw json)
Name | Data Type | Required | Description |
lang | string | YES | Language code of video. |
videoUrl | string | YES | The URL of the remote video should start with either http or https and must be downloadable. |
ext | string | YES | The extension of the video file. mp4 3gp avi mov |
preferLength | array | YES | The duration of the clipped video. 0, auto; 1, less than 30s; 2, 30s to 60s; 3, 60s to 90s; 4, 90s to 3min |
projectName | string | NO | The name of the long video. |
subtitleSwitch | int | NO | Subtitle switch. 0, off; 1, on; (default value) |
headlineSwitch | int | NO | Headline switch. 0, off; 1, on; (default value) |
Response
Content-Type
application/json
Body
Data Name | Data Type | Description |
code | int | 2000, created succeeded; 4001, invalid api key; 4002, created failed; 4003, requests exceeded the limit; 4004, Unsupported video format; 4005, invalid video url. 4006, illegal parameter |
projectId | string | Used for polling short clips generation |
Step 3: Polling short clips
Request
URL
Method
GET
Headers
Name of Header | Value | Required |
VIZARDAI_API_KEY | Vizard ai api key | YES |
Parameters
Name | Data Type | Required | Description |
projectId | Long | YES | Get the video export result by projectId. Please append it to https request url, behind β/query/β. |
Response
Content-Type
application/json
Body
Data Name | Data Type | Description |
code | int | 1000, processing; 2000, clipping succeeded; 4001, invalid api key; 4002, clipping failed. 4003, requests exceeded the limit; 4004, Unsupported video format; 4005, invalid video url. 4006, illegal parameter |
videos | array | A list of URLs for video clips. The video URL is valid for 3 hours. Please ensure that you complete the download within this time frame. If the 3-hour period expires, you can query again to obtain a new valid video URL. It is important to note that after 7 days, the video will be permanently deleted. |
Video
videoUrl | string | Video download url. |
videoMsDuration | long | Video duration in milliseconds. |
title | string | Video title. |
viralReason | string | Ai clip reason. |
viralScore | float | Ai clip score. |
transcript | string | Video text content. |
relatedTopic | array | Video related topics. |
Appendix
Supported video languages
Language Code | Language Name |
ar | Arabic |
nl | Dutch |
en | English |
fr | French |
de | German |
hi | Hindi |
id | Indonesian |
it | Italian |
ja | Japanese |
ko | Korean |
zh | Mandarin |
zh-TW | Mandarin |
pt | Portuguese |
ru | Russian |
es | Spanish |
tr | Turkish |
uk | Ukrainian |
vi | Vietnamese |
Supported file types
mp4, 3gp, avi, mov
Maximum video length
2 hours
Maximum file size
8GB
Clip resolution
720p
Video storage
7 days
Upload minutes
300 minutes per month
Sample Code
Python
import requests
import time
VIZARDAI_API_KEY = "YOUR VIZARD AI API KEY"
PROJECT_NAME = "api-vizard-sample"
VIDEO_URL = "https://dlany1hql2ufi.cloudfront.net/0-test/WhyHiking-1920x1080-60s.mp4"
VIDEO_FILE_EXT = "mp4"
LANG = "en"
PREFER_LENGTH = "[1,2]"
SUBTITLE_SWITCH = 0
HEADLINE_SWITCH = 1
headers = {
"Content-Type": "application/json",
"VIZARDAI_API_KEY": VIZARDAI_API_KEY
}
def create_project():
create_data = {
'projectName': PROJECT_NAME,
'videoUrl': VIDEO_URL,
'ext': VIDEO_FILE_EXT,
'lang': LANG,
'preferLength': PREFER_LENGTH,
'subtitleSwitch': SUBTITLE_SWITCH,
'headlineSwitch': HEADLINE_SWITCH,
}
create_url = "https://elb-api.vizard.ai/hvizard-server-front/open-api/v1/project/create"
print('creating project')
response = requests.post(create_url, headers=headers, json=create_data)
create_result = response.json()
if response.status_code == 200:
print(create_result)
if create_result["code"] == 2000:
project_id = create_result["projectId"]
else:
print("create error:", create_result)
project_id = ""
else:
print('create request failed: ', create_result)
project_id = ""
return project_id
def query_videos(project_id):
query_url = "https://elb-api.vizard.ai/hvizard-server-front/open-api/v1/project/query/" + str(project_id)
while (True):
print('querying videos')
response = requests.get(query_url, headers=headers)
if response.status_code == 200:
query_result = response.json()
if query_result["code"] == 2000:
print('clipping succeeded.')
print(query_result)
break
elif query_result["code"] == 1000:
time.sleep(5)
continue
else:
print(query_result)
print("clipping error:")
print(query_result['msg'])
break
else:
print('query request failed: ', response.json)
break
def main():
project_id = create_project()
if (project_id != ""):
query_videos(project_id)
if __name__ == "__main__":
main()