Welcome to Word.to API documentation
To get a developer key please go todeveloper portal
Authorization: <api_key>
Convert from Word
DOCX to 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))
Will return
/path/to/local/file_processed.pdf
To make multiple simply put more files in your list
DOCX to 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))
Will return
/path/to/local/file_processed.jpg
To make multiple simply put more files in your list
DOCX to 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))
Will return
/path/to/local/file_processed.png
To make multiple simply put more files in your list
DOCX to 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))
Will return
/path/to/local/file_processed.jpeg
To make multiple simply put more files in your list
DOCX to 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))
Will return
/path/to/local/file_processed.xls
To make multiple simply put more files in your list
DOCX to 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))
Will return
/path/to/local/file_processed.xlsx
To make multiple simply put more files in your list
To make multiple simply put more files in your list
DOCX to 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))
Will return
/path/to/local/file_processed.ppt
To make multiple simply put more files in your list
DOCX to 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))
Will return
/path/to/local/file_processed.bmp
To make multiple simply put more files in your list
DOCX to 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))
Will return
/path/to/local/file_processed.html
To make multiple simply put more files in your list
DOCX to 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))
Will return
/path/to/local/file_processed.svg
To make multiple simply put more files in your list
DOCX to 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))
Will return
/path/to/local/file_processed.gif
To make multiple simply put more files in your list
DOCX to 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))
Will return
/path/to/local/file_processed.webp
To make multiple simply put more files in your list
DOCX to 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))
Will return
/path/to/local/file_processed.tiff
To make multiple simply put more files in your list
DOCX to 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))
Will return
/path/to/local/file_processed.psd
To make multiple simply put more files in your list
DOCX to 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))
Will return
/path/to/local/file_processed.epub
To make multiple simply put more files in your list
Convert to Word
PDF to 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))
Will return
/path/to/local/file_processed.docx
To make multiple simply put more files in your list
JPG to 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))
Will return
/path/to/local/file_processed.docx
To make multiple simply put more files in your list
PNG to 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))
Will return
/path/to/local/file_processed.docx
To make multiple simply put more files in your list
JPEG to 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))
Will return
/path/to/local/file_processed.docx
To make multiple simply put more files in your list
SVG to 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))
Will return
/path/to/local/file_processed.docx
To make multiple simply put more files in your list
BMP to 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))
Will return
/path/to/local/file_processed.docx
To make multiple simply put more files in your list
WebP to 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))
Will return
/path/to/local/file_processed.docx
To make multiple simply put more files in your list
GIF to 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))
Will return
/path/to/local/file_processed.docx
To make multiple simply put more files in your list
TIFF to 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))
Will return
/path/to/local/file_processed.docx
To make multiple simply put more files in your list
PSD to 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))
Will return
/path/to/local/file_processed.pdf
To make multiple simply put more files in your list
PDF to 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))
Will return
/path/to/local/file_processed.docx
To make multiple simply put more files in your list