NAV
python

Fáilte chuig cáipéisíocht Word.to API

Chun eochair fhorbróra a fháil téigh chuigtairseach forbróra

Authorization: <api_key>

Tiontaigh ó Word

DOCX go PDF

import requests
import time
import shutil
import json

headers = {'Authorization': 'f134382194a844c8bb589af58ef283e9'}
file_list = ['testfiles/blah.docx', 'testfiles/blah.docx', 'testfiles/blah.docx']
params = {
    'lang': 'en',
    'convert_to': 'docx-pdf',
    'ocr': False
}

api_url = 'https://api.word.to/v1/convert/'
results_url = 'https://api.word.to/v1/results/'


def download_file(url, local_filename):
    with requests.get("https://api.word.to/%s" % url, stream=True) as r:
        with open(local_filename, 'wb') as f:
            shutil.copyfileobj(r.raw, f)
    return local_filename


def convert_files(api_url, params, headers):
    files = [eval(f'("files", open("{file}", "rb"))') for file in file_list]
    print(files)
    r = requests.post(
        url=api_url,
        files=files,
        data=params,
        headers=headers
    )
    return r.json()


def get_results(params):
    if params.get('error'):
        return params.get('error')
    r = requests.post(
        url=results_url,
        data=params
    )
    data = r.json()
    finished = data.get('finished')
    while not finished:
        if int(data.get('queue_count')) > 0:
            print('queue: %s' % data.get('queue_count'))
        time.sleep(5)
        results = get_results(params)
        print(results)
        results = json.dumps(results)
        if results:
            break
    if finished:
        print(data.get('files'))
        for f in data.get('files'):
            print(f.get('url'))
            download_file("%s" % f.get('url'), "%s" % f.get('filename'))
        return {"finished": "files downloaded"}
    return r.json()


get_results(convert_files(api_url, params, headers))

Fillfidh

/path/to/local/file_processed.pdf

Chun iolraí a dhéanamh ní gá ach níos mó comhad a chur ar do liosta

DOCX chuig JPG

import requests
import time
import shutil
import json

headers = {'Authorization': 'f134382194a844c8bb589af58ef283e9'}
file_list = ['testfiles/blah.docx', 'testfiles/blah.docx', 'testfiles/blah.docx']
params = {
    'lang': 'en',
    'convert_to': 'docx-jpg',
    'ocr': False,
    'merged': False,
}

api_url = 'https://api.word.to/v1/convert/'
results_url = 'https://api.word.to/v1/results/'


def download_file(url, local_filename):
    with requests.get("https://api.word.to/%s" % url, stream=True) as r:
        with open(local_filename, 'wb') as f:
            shutil.copyfileobj(r.raw, f)
    return local_filename


def convert_files(api_url, params, headers):
    files = [eval(f'("files", open("{file}", "rb"))') for file in file_list]
    print(files)
    r = requests.post(
        url=api_url,
        files=files,
        data=params,
        headers=headers
    )
    return r.json()


def get_results(params):
    if params.get('error'):
        return params.get('error')
    r = requests.post(
        url=results_url,
        data=params
    )
    data = r.json()
    finished = data.get('finished')
    while not finished:
        if int(data.get('queue_count')) > 0:
            print('queue: %s' % data.get('queue_count'))
        time.sleep(5)
        results = get_results(params)
        print(results)
        results = json.dumps(results)
        if results:
            break
    if finished:
        print(data.get('files'))
        for f in data.get('files'):
            print(f.get('url'))
            download_file("%s" % f.get('url'), "%s" % f.get('filename'))
        return {"finished": "files downloaded"}
    return r.json()


get_results(convert_files(api_url, params, headers))

Fillfidh

/path/to/local/file_processed.jpg

Chun iolraí a dhéanamh ní gá ach níos mó comhad a chur ar do liosta

DOCX go PNG

import requests
import time
import shutil
import json

headers = {'Authorization': 'f134382194a844c8bb589af58ef283e9'}
file_list = ['testfiles/blah.docx', 'testfiles/blah.docx', 'testfiles/blah.docx']
params = {
    'lang': 'en',
    'convert_to': 'docx-png',
    'ocr': False,
    'merged': False,
}

api_url = 'https://api.word.to/v1/convert/'
results_url = 'https://api.word.to/v1/results/'


def download_file(url, local_filename):
    with requests.get("https://api.word.to/%s" % url, stream=True) as r:
        with open(local_filename, 'wb') as f:
            shutil.copyfileobj(r.raw, f)
    return local_filename


def convert_files(api_url, params, headers):
    files = [eval(f'("files", open("{file}", "rb"))') for file in file_list]
    print(files)
    r = requests.post(
        url=api_url,
        files=files,
        data=params,
        headers=headers
    )
    return r.json()


def get_results(params):
    if params.get('error'):
        return params.get('error')
    r = requests.post(
        url=results_url,
        data=params
    )
    data = r.json()
    finished = data.get('finished')
    while not finished:
        if int(data.get('queue_count')) > 0:
            print('queue: %s' % data.get('queue_count'))
        time.sleep(5)
        results = get_results(params)
        print(results)
        results = json.dumps(results)
        if results:
            break
    if finished:
        print(data.get('files'))
        for f in data.get('files'):
            print(f.get('url'))
            download_file("%s" % f.get('url'), "%s" % f.get('filename'))
        return {"finished": "files downloaded"}
    return r.json()


get_results(convert_files(api_url, params, headers))

Fillfidh

/path/to/local/file_processed.png

Chun iolraí a dhéanamh ní gá ach níos mó comhad a chur ar do liosta

DOCX chuig JPEG

import requests
import time
import shutil
import json

headers = {'Authorization': 'f134382194a844c8bb589af58ef283e9'}
file_list = ['testfiles/blah.docx', 'testfiles/blah.docx', 'testfiles/blah.docx']
params = {
    'lang': 'en',
    'convert_to': 'docx-jpeg',
    'ocr': False
}

api_url = 'https://api.word.to/v1/convert/'
results_url = 'https://api.word.to/v1/results/'


def download_file(url, local_filename):
    with requests.get("https://api.word.to/%s" % url, stream=True) as r:
        with open(local_filename, 'wb') as f:
            shutil.copyfileobj(r.raw, f)
    return local_filename


def convert_files(api_url, params, headers):
    files = [eval(f'("files", open("{file}", "rb"))') for file in file_list]
    print(files)
    r = requests.post(
        url=api_url,
        files=files,
        data=params,
        headers=headers
    )
    return r.json()


def get_results(params):
    if params.get('error'):
        return params.get('error')
    r = requests.post(
        url=results_url,
        data=params
    )
    data = r.json()
    finished = data.get('finished')
    while not finished:
        if int(data.get('queue_count')) > 0:
            print('queue: %s' % data.get('queue_count'))
        time.sleep(5)
        results = get_results(params)
        print(results)
        results = json.dumps(results)
        if results:
            break
    if finished:
        print(data.get('files'))
        for f in data.get('files'):
            print(f.get('url'))
            download_file("%s" % f.get('url'), "%s" % f.get('filename'))
        return {"finished": "files downloaded"}
    return r.json()


get_results(convert_files(api_url, params, headers))

Fillfidh

/path/to/local/file_processed.jpeg

Chun iolraí a dhéanamh ní gá ach níos mó comhad a chur ar do liosta

DOCX go XLS

import requests
import time
import shutil
import json

headers = {'Authorization': 'f134382194a844c8bb589af58ef283e9'}
file_list = ['testfiles/blah.docx', 'testfiles/blah.docx', 'testfiles/blah.docx']
params = {
    'lang': 'en',
    'convert_to': 'docx-xls',
    'ocr': False
}

api_url = 'https://api.word.to/v1/convert/'
results_url = 'https://api.word.to/v1/results/'


def download_file(url, local_filename):
    with requests.get("https://api.word.to/%s" % url, stream=True) as r:
        with open(local_filename, 'wb') as f:
            shutil.copyfileobj(r.raw, f)
    return local_filename


def convert_files(api_url, params, headers):
    files = [eval(f'("files", open("{file}", "rb"))') for file in file_list]
    print(files)
    r = requests.post(
        url=api_url,
        files=files,
        data=params,
        headers=headers
    )
    return r.json()


def get_results(params):
    if params.get('error'):
        return params.get('error')
    r = requests.post(
        url=results_url,
        data=params
    )
    data = r.json()
    finished = data.get('finished')
    while not finished:
        if int(data.get('queue_count')) > 0:
            print('queue: %s' % data.get('queue_count'))
        time.sleep(5)
        results = get_results(params)
        print(results)
        results = json.dumps(results)
        if results:
            break
    if finished:
        print(data.get('files'))
        for f in data.get('files'):
            print(f.get('url'))
            download_file("%s" % f.get('url'), "%s" % f.get('filename'))
        return {"finished": "files downloaded"}
    return r.json()


get_results(convert_files(api_url, params, headers))

Fillfidh

/path/to/local/file_processed.xls

Chun iolraí a dhéanamh ní gá ach níos mó comhad a chur ar do liosta

DOCX go XLSX

import requests
import time
import shutil
import json

headers = {'Authorization': 'f134382194a844c8bb589af58ef283e9'}
file_list = ['testfiles/blah.docx', 'testfiles/blah.docx', 'testfiles/blah.docx']
params = {
    'lang': 'en',
    'convert_to': 'docx-xlsx',
    'ocr': False
}

api_url = 'https://api.word.to/v1/convert/'
results_url = 'https://api.word.to/v1/results/'


def download_file(url, local_filename):
    with requests.get("https://api.word.to/%s" % url, stream=True) as r:
        with open(local_filename, 'wb') as f:
            shutil.copyfileobj(r.raw, f)
    return local_filename


def convert_files(api_url, params, headers):
    files = [eval(f'("files", open("{file}", "rb"))') for file in file_list]
    print(files)
    r = requests.post(
        url=api_url,
        files=files,
        data=params,
        headers=headers
    )
    return r.json()


def get_results(params):
    if params.get('error'):
        return params.get('error')
    r = requests.post(
        url=results_url,
        data=params
    )
    data = r.json()
    finished = data.get('finished')
    while not finished:
        if int(data.get('queue_count')) > 0:
            print('queue: %s' % data.get('queue_count'))
        time.sleep(5)
        results = get_results(params)
        print(results)
        results = json.dumps(results)
        if results:
            break
    if finished:
        print(data.get('files'))
        for f in data.get('files'):
            print(f.get('url'))
            download_file("%s" % f.get('url'), "%s" % f.get('filename'))
        return {"finished": "files downloaded"}
    return r.json()


get_results(convert_files(api_url, params, headers))

Fillfidh

/path/to/local/file_processed.xlsx

Chun iolraí a dhéanamh ní gá ach níos mó comhad a chur ar do liosta

Chun iolraí a dhéanamh ní gá ach níos mó comhad a chur ar do liosta

DOCX go PPTX

import requests
import time
import shutil
import json

headers = {'Authorization': 'f134382194a844c8bb589af58ef283e9'}
file_list = ['testfiles/blah.doc', 'testfiles/blah.doc', 'testfiles/blah.doc']
params = {
    'lang': 'en',
    'convert_to': 'doc-ppt',
    'ocr': False
}

api_url = 'https://api.word.to/v1/convert/'
results_url = 'https://api.word.to/v1/results/'


def download_file(url, local_filename):
    with requests.get("https://api.word.to/%s" % url, stream=True) as r:
        with open(local_filename, 'wb') as f:
            shutil.copyfileobj(r.raw, f)
    return local_filename


def convert_files(api_url, params, headers):
    files = [eval(f'("files", open("{file}", "rb"))') for file in file_list]
    print(files)
    r = requests.post(
        url=api_url,
        files=files,
        data=params,
        headers=headers
    )
    return r.json()


def get_results(params):
    if params.get('error'):
        return params.get('error')
    r = requests.post(
        url=results_url,
        data=params
    )
    data = r.json()
    finished = data.get('finished')
    while not finished:
        if int(data.get('queue_count')) > 0:
            print('queue: %s' % data.get('queue_count'))
        time.sleep(5)
        results = get_results(params)
        print(results)
        results = json.dumps(results)
        if results:
            break
    if finished:
        print(data.get('files'))
        for f in data.get('files'):
            print(f.get('url'))
            download_file("%s" % f.get('url'), "%s" % f.get('filename'))
        return {"finished": "files downloaded"}
    return r.json()


get_results(convert_files(api_url, params, headers))

Fillfidh

/path/to/local/file_processed.ppt

Chun iolraí a dhéanamh ní gá ach níos mó comhad a chur ar do liosta

DOCX chuig BMP

import requests
import time
import shutil
import json

headers = {'Authorization': 'f134382194a844c8bb589af58ef283e9'}
file_list = ['testfiles/blah.docx', 'testfiles/blah.docx', 'testfiles/blah.docx']
params = {
    'lang': 'en',
    'convert_to': 'docx-bmp',
    'ocr': False,
    'merged': False,
}

api_url = 'https://api.word.to/v1/convert/'
results_url = 'https://api.word.to/v1/results/'


def download_file(url, local_filename):
    with requests.get("https://api.word.to/%s" % url, stream=True) as r:
        with open(local_filename, 'wb') as f:
            shutil.copyfileobj(r.raw, f)
    return local_filename


def convert_files(api_url, params, headers):
    files = [eval(f'("files", open("{file}", "rb"))') for file in file_list]
    print(files)
    r = requests.post(
        url=api_url,
        files=files,
        data=params,
        headers=headers
    )
    return r.json()


def get_results(params):
    if params.get('error'):
        return params.get('error')
    r = requests.post(
        url=results_url,
        data=params
    )
    data = r.json()
    finished = data.get('finished')
    while not finished:
        if int(data.get('queue_count')) > 0:
            print('queue: %s' % data.get('queue_count'))
        time.sleep(5)
        results = get_results(params)
        print(results)
        results = json.dumps(results)
        if results:
            break
    if finished:
        print(data.get('files'))
        for f in data.get('files'):
            print(f.get('url'))
            download_file("%s" % f.get('url'), "%s" % f.get('filename'))
        return {"finished": "files downloaded"}
    return r.json()


get_results(convert_files(api_url, params, headers))

Fillfidh

/path/to/local/file_processed.bmp

Chun iolraí a dhéanamh ní gá ach níos mó comhad a chur ar do liosta

DOCX go HTML

import requests
import time
import shutil
import json

headers = {'Authorization': 'f134382194a844c8bb589af58ef283e9'}
file_list = ['testfiles/blah.docx', 'testfiles/blah.docx', 'testfiles/blah.docx']
params = {
    'lang': 'en',
    'convert_to': 'docx-html',
    'ocr': False
}

api_url = 'https://api.word.to/v1/convert/'
results_url = 'https://api.word.to/v1/results/'


def download_file(url, local_filename):
    with requests.get("https://api.word.to/%s" % url, stream=True) as r:
        with open(local_filename, 'wb') as f:
            shutil.copyfileobj(r.raw, f)
    return local_filename


def convert_files(api_url, params, headers):
    files = [eval(f'("files", open("{file}", "rb"))') for file in file_list]
    print(files)
    r = requests.post(
        url=api_url,
        files=files,
        data=params,
        headers=headers
    )
    return r.json()


def get_results(params):
    if params.get('error'):
        return params.get('error')
    r = requests.post(
        url=results_url,
        data=params
    )
    data = r.json()
    finished = data.get('finished')
    while not finished:
        if int(data.get('queue_count')) > 0:
            print('queue: %s' % data.get('queue_count'))
        time.sleep(5)
        results = get_results(params)
        print(results)
        results = json.dumps(results)
        if results:
            break
    if finished:
        print(data.get('files'))
        for f in data.get('files'):
            print(f.get('url'))
            download_file("%s" % f.get('url'), "%s" % f.get('filename'))
        return {"finished": "files downloaded"}
    return r.json()


get_results(convert_files(api_url, params, headers))

Fillfidh

/path/to/local/file_processed.html

Chun iolraí a dhéanamh ní gá ach níos mó comhad a chur ar do liosta

DOCX go SVG

import requests
import time
import shutil
import json

headers = {'Authorization': 'f134382194a844c8bb589af58ef283e9'}
file_list = ['testfiles/blah.pdf', 'testfiles/blah.pdf', 'testfiles/blah.pdf']
params = {
    'lang': 'en',
    'convert_to': 'docx-svg',
    'ocr': False
}

api_url = 'https://api.word.to/v1/convert/'
results_url = 'https://api.word.to/v1/results/'


def download_file(url, local_filename):
    with requests.get("https://api.word.to/%s" % url, stream=True) as r:
        with open(local_filename, 'wb') as f:
            shutil.copyfileobj(r.raw, f)
    return local_filename


def convert_files(api_url, params, headers):
    files = [eval(f'("files", open("{file}", "rb"))') for file in file_list]
    print(files)
    r = requests.post(
        url=api_url,
        files=files,
        data=params,
        headers=headers
    )
    return r.json()


def get_results(params):
    if params.get('error'):
        return params.get('error')
    r = requests.post(
        url=results_url,
        data=params
    )
    data = r.json()
    finished = data.get('finished')
    while not finished:
        if int(data.get('queue_count')) > 0:
            print('queue: %s' % data.get('queue_count'))
        time.sleep(5)
        results = get_results(params)
        print(results)
        results = json.dumps(results)
        if results:
            break
    if finished:
        print(data.get('files'))
        for f in data.get('files'):
            print(f.get('url'))
            download_file("%s" % f.get('url'), "%s" % f.get('filename'))
        return {"finished": "files downloaded"}
    return r.json()


get_results(convert_files(api_url, params, headers))

Fillfidh

/path/to/local/file_processed.svg

Chun iolraí a dhéanamh ní gá ach níos mó comhad a chur ar do liosta

DOCX a GIF

import requests
import time
import shutil
import json

headers = {'Authorization': 'f134382194a844c8bb589af58ef283e9'}
file_list = ['testfiles/blah.docx', 'testfiles/blah.docx', 'testfiles/blah.docx']
params = {
    'lang': 'en',
    'convert_to': 'docx-gif',
    'ocr': False
}

api_url = 'https://api.word.to/v1/convert/'
results_url = 'https://api.word.to/v1/results/'


def download_file(url, local_filename):
    with requests.get("https://api.word.to/%s" % url, stream=True) as r:
        with open(local_filename, 'wb') as f:
            shutil.copyfileobj(r.raw, f)
    return local_filename


def convert_files(api_url, params, headers):
    files = [eval(f'("files", open("{file}", "rb"))') for file in file_list]
    print(files)
    r = requests.post(
        url=api_url,
        files=files,
        data=params,
        headers=headers
    )
    return r.json()


def get_results(params):
    if params.get('error'):
        return params.get('error')
    r = requests.post(
        url=results_url,
        data=params
    )
    data = r.json()
    finished = data.get('finished')
    while not finished:
        if int(data.get('queue_count')) > 0:
            print('queue: %s' % data.get('queue_count'))
        time.sleep(5)
        results = get_results(params)
        print(results)
        results = json.dumps(results)
        if results:
            break
    if finished:
        print(data.get('files'))
        for f in data.get('files'):
            print(f.get('url'))
            download_file("%s" % f.get('url'), "%s" % f.get('filename'))
        return {"finished": "files downloaded"}
    return r.json()


get_results(convert_files(api_url, params, headers))

Fillfidh

/path/to/local/file_processed.gif

Chun iolraí a dhéanamh ní gá ach níos mó comhad a chur ar do liosta

DOCX chuig WebP

import requests
import time
import shutil
import json

headers = {'Authorization': 'f134382194a844c8bb589af58ef283e9'}
file_list = ['testfiles/blah.docx', 'testfiles/blah.docx', 'testfiles/blah.docx']
params = {
    'lang': 'en',
    'convert_to': 'docx-webp',
    'ocr': False,
    'merged': False,
}

api_url = 'https://api.word.to/v1/convert/'
results_url = 'https://api.word.to/v1/results/'


def download_file(url, local_filename):
    with requests.get("https://api.word.to/%s" % url, stream=True) as r:
        with open(local_filename, 'wb') as f:
            shutil.copyfileobj(r.raw, f)
    return local_filename


def convert_files(api_url, params, headers):
    files = [eval(f'("files", open("{file}", "rb"))') for file in file_list]
    print(files)
    r = requests.post(
        url=api_url,
        files=files,
        data=params,
        headers=headers
    )
    return r.json()


def get_results(params):
    if params.get('error'):
        return params.get('error')
    r = requests.post(
        url=results_url,
        data=params
    )
    data = r.json()
    finished = data.get('finished')
    while not finished:
        if int(data.get('queue_count')) > 0:
            print('queue: %s' % data.get('queue_count'))
        time.sleep(5)
        results = get_results(params)
        print(results)
        results = json.dumps(results)
        if results:
            break
    if finished:
        print(data.get('files'))
        for f in data.get('files'):
            print(f.get('url'))
            download_file("%s" % f.get('url'), "%s" % f.get('filename'))
        return {"finished": "files downloaded"}
    return r.json()


get_results(convert_files(api_url, params, headers))

Fillfidh

/path/to/local/file_processed.webp

Chun iolraí a dhéanamh ní gá ach níos mó comhad a chur ar do liosta

DOCX go TIFF

import requests
import time
import shutil
import json

headers = {'Authorization': 'f134382194a844c8bb589af58ef283e9'}
file_list = ['testfiles/blah.docx', 'testfiles/blah.docx', 'testfiles/blah.docx']
params = {
    'lang': 'en',
    'convert_to': 'docx-tiff',
    'ocr': False
}

api_url = 'https://api.word.to/v1/convert/'
results_url = 'https://api.word.to/v1/results/'


def download_file(url, local_filename):
    with requests.get("https://api.word.to/%s" % url, stream=True) as r:
        with open(local_filename, 'wb') as f:
            shutil.copyfileobj(r.raw, f)
    return local_filename


def convert_files(api_url, params, headers):
    files = [eval(f'("files", open("{file}", "rb"))') for file in file_list]
    print(files)
    r = requests.post(
        url=api_url,
        files=files,
        data=params,
        headers=headers
    )
    return r.json()


def get_results(params):
    if params.get('error'):
        return params.get('error')
    r = requests.post(
        url=results_url,
        data=params
    )
    data = r.json()
    finished = data.get('finished')
    while not finished:
        if int(data.get('queue_count')) > 0:
            print('queue: %s' % data.get('queue_count'))
        time.sleep(5)
        results = get_results(params)
        print(results)
        results = json.dumps(results)
        if results:
            break
    if finished:
        print(data.get('files'))
        for f in data.get('files'):
            print(f.get('url'))
            download_file("%s" % f.get('url'), "%s" % f.get('filename'))
        return {"finished": "files downloaded"}
    return r.json()


get_results(convert_files(api_url, params, headers))

Fillfidh

/path/to/local/file_processed.tiff

Chun iolraí a dhéanamh ní gá ach níos mó comhad a chur ar do liosta

DOCX go PSD

import requests
import time
import shutil
import json

headers = {'Authorization': 'f134382194a844c8bb589af58ef283e9'}
file_list = ['testfiles/blah.pdf', 'testfiles/blah.pdf', 'testfiles/blah.pdf']
params = {
    'lang': 'en',
    'convert_to': 'docx-psd',
    'ocr': False
}

api_url = 'https://api.word.to/v1/convert/'
results_url = 'https://api.word.to/v1/results/'


def download_file(url, local_filename):
    with requests.get("https://api.word.to/%s" % url, stream=True) as r:
        with open(local_filename, 'wb') as f:
            shutil.copyfileobj(r.raw, f)
    return local_filename


def convert_files(api_url, params, headers):
    files = [eval(f'("files", open("{file}", "rb"))') for file in file_list]
    print(files)
    r = requests.post(
        url=api_url,
        files=files,
        data=params,
        headers=headers
    )
    return r.json()


def get_results(params):
    if params.get('error'):
        return params.get('error')
    r = requests.post(
        url=results_url,
        data=params
    )
    data = r.json()
    finished = data.get('finished')
    while not finished:
        if int(data.get('queue_count')) > 0:
            print('queue: %s' % data.get('queue_count'))
        time.sleep(5)
        results = get_results(params)
        print(results)
        results = json.dumps(results)
        if results:
            break
    if finished:
        print(data.get('files'))
        for f in data.get('files'):
            print(f.get('url'))
            download_file("%s" % f.get('url'), "%s" % f.get('filename'))
        return {"finished": "files downloaded"}
    return r.json()


get_results(convert_files(api_url, params, headers))

Fillfidh

/path/to/local/file_processed.psd

Chun iolraí a dhéanamh ní gá ach níos mó comhad a chur ar do liosta

DOCX go EPUB

import requests
import time
import shutil
import json

headers = {'Authorization': 'f134382194a844c8bb589af58ef283e9'}
file_list = ['testfiles/blah.docx', 'testfiles/blah.docx', 'testfiles/blah.docx']
params = {
    'lang': 'en',
    'convert_to': 'docx-epub',
    'ocr': False
}

api_url = 'https://api.word.to/v1/convert/'
results_url = 'https://api.word.to/v1/results/'


def download_file(url, local_filename):
    with requests.get("https://api.word.to/%s" % url, stream=True) as r:
        with open(local_filename, 'wb') as f:
            shutil.copyfileobj(r.raw, f)
    return local_filename


def convert_files(api_url, params, headers):
    files = [eval(f'("files", open("{file}", "rb"))') for file in file_list]
    print(files)
    r = requests.post(
        url=api_url,
        files=files,
        data=params,
        headers=headers
    )
    return r.json()


def get_results(params):
    if params.get('error'):
        return params.get('error')
    r = requests.post(
        url=results_url,
        data=params
    )
    data = r.json()
    finished = data.get('finished')
    while not finished:
        if int(data.get('queue_count')) > 0:
            print('queue: %s' % data.get('queue_count'))
        time.sleep(5)
        results = get_results(params)
        print(results)
        results = json.dumps(results)
        if results:
            break
    if finished:
        print(data.get('files'))
        for f in data.get('files'):
            print(f.get('url'))
            download_file("%s" % f.get('url'), "%s" % f.get('filename'))
        return {"finished": "files downloaded"}
    return r.json()


get_results(convert_files(api_url, params, headers))

Fillfidh

/path/to/local/file_processed.epub

Chun iolraí a dhéanamh ní gá ach níos mó comhad a chur ar do liosta

Tiontaigh go Word

PDF go DOCX

import requests
import time
import shutil
import json

headers = {'Authorization': 'f134382194a844c8bb589af58ef283e9'}
file_list = ['testfiles/blah.pdf', 'testfiles/blah.pdf', 'testfiles/blah.pdf']
params = {
    'lang': 'en',
    'convert_to': 'pdf-docx',
    'ocr': False
}

api_url = 'https://api.word.to/v1/convert/'
results_url = 'https://api.word.to/v1/results/'


def download_file(url, local_filename):
    with requests.get("https://api.word.to/%s" % url, stream=True) as r:
        with open(local_filename, 'wb') as f:
            shutil.copyfileobj(r.raw, f)
    return local_filename


def convert_files(api_url, params, headers):
    files = [eval(f'("files", open("{file}", "rb"))') for file in file_list]
    print(files)
    r = requests.post(
        url=api_url,
        files=files,
        data=params,
        headers=headers
    )
    return r.json()


def get_results(params):
    if params.get('error'):
        return params.get('error')
    r = requests.post(
        url=results_url,
        data=params
    )
    data = r.json()
    finished = data.get('finished')
    while not finished:
        if int(data.get('queue_count')) > 0:
            print('queue: %s' % data.get('queue_count'))
        time.sleep(5)
        results = get_results(params)
        print(results)
        results = json.dumps(results)
        if results:
            break
    if finished:
        print(data.get('files'))
        for f in data.get('files'):
            print(f.get('url'))
            download_file("%s" % f.get('url'), "%s" % f.get('filename'))
        return {"finished": "files downloaded"}
    return r.json()


get_results(convert_files(api_url, params, headers))

Fillfidh

/path/to/local/file_processed.docx

Chun iolraí a dhéanamh ní gá ach níos mó comhad a chur ar do liosta

JPG go DOCX

import requests
import time
import shutil
import json

headers = {'Authorization': 'f134382194a844c8bb589af58ef283e9'}
file_list = ['testfiles/blah.jpg', 'testfiles/blah.jpg', 'testfiles/blah.jpg']
params = {
    'lang': 'en',
    'convert_to': 'jpg-docx',
    'ocr': False
}

api_url = 'https://api.word.to/v1/convert/'
results_url = 'https://api.word.to/v1/results/'


def download_file(url, local_filename):
    with requests.get("https://api.word.to/%s" % url, stream=True) as r:
        with open(local_filename, 'wb') as f:
            shutil.copyfileobj(r.raw, f)
    return local_filename


def convert_files(api_url, params, headers):
    files = [eval(f'("files", open("{file}", "rb"))') for file in file_list]
    print(files)
    r = requests.post(
        url=api_url,
        files=files,
        data=params,
        headers=headers
    )
    return r.json()


def get_results(params):
    if params.get('error'):
        return params.get('error')
    r = requests.post(
        url=results_url,
        data=params
    )
    data = r.json()
    finished = data.get('finished')
    while not finished:
        if int(data.get('queue_count')) > 0:
            print('queue: %s' % data.get('queue_count'))
        time.sleep(5)
        results = get_results(params)
        print(results)
        results = json.dumps(results)
        if results:
            break
    if finished:
        print(data.get('files'))
        for f in data.get('files'):
            print(f.get('url'))
            download_file("%s" % f.get('url'), "%s" % f.get('filename'))
        return {"finished": "files downloaded"}
    return r.json()


get_results(convert_files(api_url, params, headers))

Fillfidh

/path/to/local/file_processed.docx

Chun iolraí a dhéanamh ní gá ach níos mó comhad a chur ar do liosta

PNG go DOCX

import requests
import time
import shutil
import json

headers = {'Authorization': 'f134382194a844c8bb589af58ef283e9'}
file_list = ['testfiles/blah.pdf', 'testfiles/blah.pdf', 'testfiles/blah.pdf']
params = {
    'lang': 'en',
    'convert_to': 'png-docx',
    'ocr': False
}

api_url = 'https://api.word.to/v1/convert/'
results_url = 'https://api.word.to/v1/results/'


def download_file(url, local_filename):
    with requests.get("https://api.word.to/%s" % url, stream=True) as r:
        with open(local_filename, 'wb') as f:
            shutil.copyfileobj(r.raw, f)
    return local_filename


def convert_files(api_url, params, headers):
    files = [eval(f'("files", open("{file}", "rb"))') for file in file_list]
    print(files)
    r = requests.post(
        url=api_url,
        files=files,
        data=params,
        headers=headers
    )
    return r.json()


def get_results(params):
    if params.get('error'):
        return params.get('error')
    r = requests.post(
        url=results_url,
        data=params
    )
    data = r.json()
    finished = data.get('finished')
    while not finished:
        if int(data.get('queue_count')) > 0:
            print('queue: %s' % data.get('queue_count'))
        time.sleep(5)
        results = get_results(params)
        print(results)
        results = json.dumps(results)
        if results:
            break
    if finished:
        print(data.get('files'))
        for f in data.get('files'):
            print(f.get('url'))
            download_file("%s" % f.get('url'), "%s" % f.get('filename'))
        return {"finished": "files downloaded"}
    return r.json()


get_results(convert_files(api_url, params, headers))

Fillfidh

/path/to/local/file_processed.docx

Chun iolraí a dhéanamh ní gá ach níos mó comhad a chur ar do liosta

JPEG go DOCX

import requests
import time
import shutil
import json

headers = {'Authorization': 'f134382194a844c8bb589af58ef283e9'}
file_list = ['testfiles/blah.jpeg', 'testfiles/blah.jpeg', 'testfiles/blah.jpeg']
params = {
    'lang': 'en',
    'convert_to': 'jpeg-docx',
    'ocr': False
}

api_url = 'https://api.word.to/v1/convert/'
results_url = 'https://api.word.to/v1/results/'


def download_file(url, local_filename):
    with requests.get("https://api.word.to/%s" % url, stream=True) as r:
        with open(local_filename, 'wb') as f:
            shutil.copyfileobj(r.raw, f)
    return local_filename


def convert_files(api_url, params, headers):
    files = [eval(f'("files", open("{file}", "rb"))') for file in file_list]
    print(files)
    r = requests.post(
        url=api_url,
        files=files,
        data=params,
        headers=headers
    )
    return r.json()


def get_results(params):
    if params.get('error'):
        return params.get('error')
    r = requests.post(
        url=results_url,
        data=params
    )
    data = r.json()
    finished = data.get('finished')
    while not finished:
        if int(data.get('queue_count')) > 0:
            print('queue: %s' % data.get('queue_count'))
        time.sleep(5)
        results = get_results(params)
        print(results)
        results = json.dumps(results)
        if results:
            break
    if finished:
        print(data.get('files'))
        for f in data.get('files'):
            print(f.get('url'))
            download_file("%s" % f.get('url'), "%s" % f.get('filename'))
        return {"finished": "files downloaded"}
    return r.json()


get_results(convert_files(api_url, params, headers))

Fillfidh

/path/to/local/file_processed.docx

Chun iolraí a dhéanamh ní gá ach níos mó comhad a chur ar do liosta

SVG go DOCX

import requests
import time
import shutil
import json

headers = {'Authorization': 'f134382194a844c8bb589af58ef283e9'}
file_list = ['testfiles/blah.svg', 'testfiles/blah.svg', 'testfiles/blah.svg']
params = {
    'lang': 'en',
    'convert_to': 'svg-docx',
    'ocr': False
}

api_url = 'https://api.word.to/v1/convert/'
results_url = 'https://api.word.to/v1/results/'


def download_file(url, local_filename):
    with requests.get("https://api.word.to/%s" % url, stream=True) as r:
        with open(local_filename, 'wb') as f:
            shutil.copyfileobj(r.raw, f)
    return local_filename


def convert_files(api_url, params, headers):
    files = [eval(f'("files", open("{file}", "rb"))') for file in file_list]
    print(files)
    r = requests.post(
        url=api_url,
        files=files,
        data=params,
        headers=headers
    )
    return r.json()


def get_results(params):
    if params.get('error'):
        return params.get('error')
    r = requests.post(
        url=results_url,
        data=params
    )
    data = r.json()
    finished = data.get('finished')
    while not finished:
        if int(data.get('queue_count')) > 0:
            print('queue: %s' % data.get('queue_count'))
        time.sleep(5)
        results = get_results(params)
        print(results)
        results = json.dumps(results)
        if results:
            break
    if finished:
        print(data.get('files'))
        for f in data.get('files'):
            print(f.get('url'))
            download_file("%s" % f.get('url'), "%s" % f.get('filename'))
        return {"finished": "files downloaded"}
    return r.json()


get_results(convert_files(api_url, params, headers))

Fillfidh

/path/to/local/file_processed.docx

Chun iolraí a dhéanamh ní gá ach níos mó comhad a chur ar do liosta

BMP go DOCX

import requests
import time
import shutil
import json

headers = {'Authorization': 'f134382194a844c8bb589af58ef283e9'}
file_list = ['testfiles/blah.bmp', 'testfiles/blah.bmp', 'testfiles/blah.bmp']
params = {
    'lang': 'en',
    'convert_to': 'bmp-docx',
    'ocr': False
}

api_url = 'https://api.word.to/v1/convert/'
results_url = 'https://api.word.to/v1/results/'


def download_file(url, local_filename):
    with requests.get("https://api.word.to/%s" % url, stream=True) as r:
        with open(local_filename, 'wb') as f:
            shutil.copyfileobj(r.raw, f)
    return local_filename


def convert_files(api_url, params, headers):
    files = [eval(f'("files", open("{file}", "rb"))') for file in file_list]
    print(files)
    r = requests.post(
        url=api_url,
        files=files,
        data=params,
        headers=headers
    )
    return r.json()


def get_results(params):
    if params.get('error'):
        return params.get('error')
    r = requests.post(
        url=results_url,
        data=params
    )
    data = r.json()
    finished = data.get('finished')
    while not finished:
        if int(data.get('queue_count')) > 0:
            print('queue: %s' % data.get('queue_count'))
        time.sleep(5)
        results = get_results(params)
        print(results)
        results = json.dumps(results)
        if results:
            break
    if finished:
        print(data.get('files'))
        for f in data.get('files'):
            print(f.get('url'))
            download_file("%s" % f.get('url'), "%s" % f.get('filename'))
        return {"finished": "files downloaded"}
    return r.json()


get_results(convert_files(api_url, params, headers))

Fillfidh

/path/to/local/file_processed.docx

Chun iolraí a dhéanamh ní gá ach níos mó comhad a chur ar do liosta

WebP go DOCX

import requests
import time
import shutil
import json

headers = {'Authorization': 'f134382194a844c8bb589af58ef283e9'}
file_list = ['testfiles/blah.pdf', 'testfiles/blah.pdf', 'testfiles/blah.pdf']
params = {
    'lang': 'en',
    'convert_to': 'webp-docx',
    'ocr': False
}

api_url = 'https://api.word.to/v1/convert/'
results_url = 'https://api.word.to/v1/results/'


def download_file(url, local_filename):
    with requests.get("https://api.word.to/%s" % url, stream=True) as r:
        with open(local_filename, 'wb') as f:
            shutil.copyfileobj(r.raw, f)
    return local_filename


def convert_files(api_url, params, headers):
    files = [eval(f'("files", open("{file}", "rb"))') for file in file_list]
    print(files)
    r = requests.post(
        url=api_url,
        files=files,
        data=params,
        headers=headers
    )
    return r.json()


def get_results(params):
    if params.get('error'):
        return params.get('error')
    r = requests.post(
        url=results_url,
        data=params
    )
    data = r.json()
    finished = data.get('finished')
    while not finished:
        if int(data.get('queue_count')) > 0:
            print('queue: %s' % data.get('queue_count'))
        time.sleep(5)
        results = get_results(params)
        print(results)
        results = json.dumps(results)
        if results:
            break
    if finished:
        print(data.get('files'))
        for f in data.get('files'):
            print(f.get('url'))
            download_file("%s" % f.get('url'), "%s" % f.get('filename'))
        return {"finished": "files downloaded"}
    return r.json()


get_results(convert_files(api_url, params, headers))

Fillfidh

/path/to/local/file_processed.docx

Chun iolraí a dhéanamh ní gá ach níos mó comhad a chur ar do liosta

GIF go DOCX

import requests
import time
import shutil
import json

headers = {'Authorization': 'f134382194a844c8bb589af58ef283e9'}
file_list = ['testfiles/blah.gif', 'testfiles/blah.gif', 'testfiles/blah.gif']
params = {
    'lang': 'en',
    'convert_to': 'gif-docx',
    'ocr': False
}

api_url = 'https://api.word.to/v1/convert/'
results_url = 'https://api.word.to/v1/results/'


def download_file(url, local_filename):
    with requests.get("https://api.word.to/%s" % url, stream=True) as r:
        with open(local_filename, 'wb') as f:
            shutil.copyfileobj(r.raw, f)
    return local_filename


def convert_files(api_url, params, headers):
    files = [eval(f'("files", open("{file}", "rb"))') for file in file_list]
    print(files)
    r = requests.post(
        url=api_url,
        files=files,
        data=params,
        headers=headers
    )
    return r.json()


def get_results(params):
    if params.get('error'):
        return params.get('error')
    r = requests.post(
        url=results_url,
        data=params
    )
    data = r.json()
    finished = data.get('finished')
    while not finished:
        if int(data.get('queue_count')) > 0:
            print('queue: %s' % data.get('queue_count'))
        time.sleep(5)
        results = get_results(params)
        print(results)
        results = json.dumps(results)
        if results:
            break
    if finished:
        print(data.get('files'))
        for f in data.get('files'):
            print(f.get('url'))
            download_file("%s" % f.get('url'), "%s" % f.get('filename'))
        return {"finished": "files downloaded"}
    return r.json()


get_results(convert_files(api_url, params, headers))

Fillfidh

/path/to/local/file_processed.docx

Chun iolraí a dhéanamh ní gá ach níos mó comhad a chur ar do liosta

TIFF go DOCX

import requests
import time
import shutil
import json

headers = {'Authorization': 'f134382194a844c8bb589af58ef283e9'}
file_list = ['testfiles/blah.tiff', 'testfiles/blah.tiff', 'testfiles/blah.tiff']
params = {
    'lang': 'en',
    'convert_to': 'tiff-docx',
    'ocr': False
}

api_url = 'https://api.word.to/v1/convert/'
results_url = 'https://api.word.to/v1/results/'


def download_file(url, local_filename):
    with requests.get("https://api.word.to/%s" % url, stream=True) as r:
        with open(local_filename, 'wb') as f:
            shutil.copyfileobj(r.raw, f)
    return local_filename


def convert_files(api_url, params, headers):
    files = [eval(f'("files", open("{file}", "rb"))') for file in file_list]
    print(files)
    r = requests.post(
        url=api_url,
        files=files,
        data=params,
        headers=headers
    )
    return r.json()


def get_results(params):
    if params.get('error'):
        return params.get('error')
    r = requests.post(
        url=results_url,
        data=params
    )
    data = r.json()
    finished = data.get('finished')
    while not finished:
        if int(data.get('queue_count')) > 0:
            print('queue: %s' % data.get('queue_count'))
        time.sleep(5)
        results = get_results(params)
        print(results)
        results = json.dumps(results)
        if results:
            break
    if finished:
        print(data.get('files'))
        for f in data.get('files'):
            print(f.get('url'))
            download_file("%s" % f.get('url'), "%s" % f.get('filename'))
        return {"finished": "files downloaded"}
    return r.json()


get_results(convert_files(api_url, params, headers))

Fillfidh

/path/to/local/file_processed.docx

Chun iolraí a dhéanamh ní gá ach níos mó comhad a chur ar do liosta

PSD go DOCX

import requests
import time
import shutil
import json

headers = {'Authorization': 'f134382194a844c8bb589af58ef283e9'}
file_list = ['testfiles/blah.psd', 'testfiles/blah.psd', 'testfiles/blah.psd']
params = {
    'lang': 'en',
    'convert_to': 'psd-docx',
    'ocr': False
}

api_url = 'https://api.word.to/v1/convert/'
results_url = 'https://api.word.to/v1/results/'


def download_file(url, local_filename):
    with requests.get("https://api.word.to/%s" % url, stream=True) as r:
        with open(local_filename, 'wb') as f:
            shutil.copyfileobj(r.raw, f)
    return local_filename


def convert_files(api_url, params, headers):
    files = [eval(f'("files", open("{file}", "rb"))') for file in file_list]
    print(files)
    r = requests.post(
        url=api_url,
        files=files,
        data=params,
        headers=headers
    )
    return r.json()


def get_results(params):
    if params.get('error'):
        return params.get('error')
    r = requests.post(
        url=results_url,
        data=params
    )
    data = r.json()
    finished = data.get('finished')
    while not finished:
        if int(data.get('queue_count')) > 0:
            print('queue: %s' % data.get('queue_count'))
        time.sleep(5)
        results = get_results(params)
        print(results)
        results = json.dumps(results)
        if results:
            break
    if finished:
        print(data.get('files'))
        for f in data.get('files'):
            print(f.get('url'))
            download_file("%s" % f.get('url'), "%s" % f.get('filename'))
        return {"finished": "files downloaded"}
    return r.json()


get_results(convert_files(api_url, params, headers))

Fillfidh

/path/to/local/file_processed.pdf

Chun iolraí a dhéanamh ní gá ach níos mó comhad a chur ar do liosta

PDF go DOCX

import requests
import time
import shutil
import json

headers = {'Authorization': 'f134382194a844c8bb589af58ef283e9'}
file_list = ['testfiles/blah.pdf', 'testfiles/blah.pdf', 'testfiles/blah.pdf']
params = {
    'lang': 'en',
    'convert_to': 'pdf-docx',
    'ocr': False
}

api_url = 'https://api.word.to/v1/convert/'
results_url = 'https://api.word.to/v1/results/'


def download_file(url, local_filename):
    with requests.get("https://api.word.to/%s" % url, stream=True) as r:
        with open(local_filename, 'wb') as f:
            shutil.copyfileobj(r.raw, f)
    return local_filename


def convert_files(api_url, params, headers):
    files = [eval(f'("files", open("{file}", "rb"))') for file in file_list]
    print(files)
    r = requests.post(
        url=api_url,
        files=files,
        data=params,
        headers=headers
    )
    return r.json()


def get_results(params):
    if params.get('error'):
        return params.get('error')
    r = requests.post(
        url=results_url,
        data=params
    )
    data = r.json()
    finished = data.get('finished')
    while not finished:
        if int(data.get('queue_count')) > 0:
            print('queue: %s' % data.get('queue_count'))
        time.sleep(5)
        results = get_results(params)
        print(results)
        results = json.dumps(results)
        if results:
            break
    if finished:
        print(data.get('files'))
        for f in data.get('files'):
            print(f.get('url'))
            download_file("%s" % f.get('url'), "%s" % f.get('filename'))
        return {"finished": "files downloaded"}
    return r.json()


get_results(convert_files(api_url, params, headers))

Fillfidh

/path/to/local/file_processed.docx

Chun iolraí a dhéanamh ní gá ach níos mó comhad a chur ar do liosta