Skip to main content

Python REST API wrapper for

Project description


This is the official Python SDK v2 for the Online UniConverter API v2.


 pip install Online-UniConverter-python

Creating API Client

  import mediaio

  mediaio.configure(api_key = 'API_KEY')

Or set the environment variable MEDIAIO_API_KEY and use:

  import mediaio



You have tow way to use UniConvert SDK.

1.Facade mode

### init convert env
import os
import mediaio

config = {
    'api_key' : 'api_key',
    'endpoint': '',


# test convert video from mov to mp4

file_info = mediaio.convertFile('56.mp4', 'mp4', 'mov')['url'], os.path.join('output' , file_info['filename'])

# convert mp4 to mp3
file_info = mediaio.convertFile('56.mp4', 'mp4', 'mp3')['url'], os.path.join('output' , file_info['filename'])

# convert png to bmp 
file_info = mediaio.convertFile('56.png', 'png', 'bmp')['url'], os.path.join('output' , file_info['filename'])

# compress video

file_info = mediaio.compressVideo('11.mp4', 'mp4', ratio=0.9)
print(file_info)['url'], os.path.join('output' , file_info['filename']))

# compress audio
file_info = mediaio.compressAudio('2.mp3', 'mp3', bitrate=96)
print(file_info)['url'], os.path.join('output', file_info['filename']))

# compress png
file_info = mediaio.compressImage('13.png', 'png')
print(file_info)['url'], os.path.join('output', file_info['filename']))

# need progress
def convertCallback(step, progress):
    print(step, progress)

file_info = mediaio.convertFile('56.mp4', 'mp4', 'mov')['url'], os.path.join('output' , file_info['filename'], progress=convertCallback)

## advanceParams
advanceParams = {
        'enable': True,
        'enable': True,
        'encode': 'AC-3',
        'bitrate': '96kbps'
file_info = mediaio.convertFile('56.mp4', 'mp4', 'mp4', advanceParams=advanceParams)['url'], os.path.join('output' , file_info['filename'])

2. DIY mode

Uploading Files

Uploads to UniConvert are done via import/upload tasks (see the docs). This SDK offers a convenient upload method:

import os
from mediaio.task import Task

config = {
    'api_key' : 'api_key',
    'endpoint': '',


task = Task.create(operation='import/upload')
if task['code'] >0: raise Exception(task['msg'])   
result = Task.upload(file_name=urlOrFile, task=task) 

Convert File

UniConvert can convert file after you uploaded file for using convert tasks. You can use Task.wait wait for task is finish.

payload ={
    'input': result['data']['id'],
    'input_format': input_format,
    'output_format': output_format,
if advanceParams: 
task = Task.create(operation='convert', payload=payload) 
if (task['code'] > 0): raise Exception(task['msg'])   
result = Task.wait(task['data']['id'])   

Compress File

UniConvert can convert file after you uploaded file for using compress tasks. You can use Task.wait wait for task is finish.

payload = {
    'input': task_id,
    'input_format': input_format,
    'output_format': input_format,
    'ratio': 0.2 

task = Task.create(operation='compress', payload=payload) 
if (task['code'] > 0): raise Exception(task['msg'])   
return Task.wait(task['data']['id'])     

Downloading Files

UniConvert can generate public URLs for using export/url tasks. You can use the SDK to download the output files when the task is finished.

from mediaio.task import Task
task_id = '{task_id}'
task = Task.create(operation='export/url', payload={'input': task_id})
result = Task.wait(task['data']['id'])          
fileInfo = result['data']['result']['files'][0] 


Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

Online-UniConverter-python- (10.5 kB view hashes)

Uploaded source

Built Distribution

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page