Doc Converter Pro Web Rest API

How to call our API to convert documents from within your own application

Before you begin you need to have an account with our Doc Converter Pro Online Web App. If you have not done so please register for an account now. You can test the service for free but for production you will need to sign up for one of our paid plans.

Currently the Doc Converter Pro Web Rest API exposes the following API method:

https://api.docconverter.pro/api/converter/convertdoc - this API method will convert files sent via POST and will return or post back to a given URL the converted zip or html file.

The input parameters are:

  1. send a file in a FormData (JavaScript) or as MultipartFormDataContent (.NET C#), see the sample page or the C# code app for implementation details
  2. template - optionally specify a template name parameter, for instance: 'Convert to HTML5' . This template is used by default if a parameter is not specified. The template name has to be exactly as on Doc Converter Pro Online templates list, note you can create your own custom templates.
  3. returnJson - option to return json with list of converted output file URLs (attention: do not set returnHtml or returnData options if you use returnJson)
  4. returnHtml - option to return either a zip file (set it to false) with all the conversion files in it or a single output file (set it to true). By default it's set to 'false' - return a zip file. To return only a HTML file set this option to 'true'.
    Note 1: that if you set it to true then only the html file is returned, other files like images or CSS files are not sent. Only the zip file option contains all the converted files.
    Note 2: if you split document to pages or use split by tag feature in conversion template then API will return zip file anyway.
  5. returnData - option to return raw octet-stream data, default is 'false' and it returns url to converted file on the Doc Converter Pro Web API server
  6. backUrl - if specified WC API method will convert input files and will send them in zip or html file back via POST to that specified url.
Please note that you need a website or server to process these post request, please check out ASP.NET C# sample app that receives file sent via POST from that API method or this PHP sample code.

API Authorization Method

https://api.docconverter.pro/token - this API method will return access token valid for 14 days, method requires 3 parameters:

We recommmend storing token in some cache or database and reuse it for each conversion call. Please check sample code apps below how to get and use token.


Check out API test web page (Javascript/jQuery sample)...

We have created a sample page that demonstrates how the API conversion works: Doc Converter Pro Web API Test Page

How to use the sample page:

  1. enter your login credentials, the same login as your Doc Converter Pro Online account and click the Log In button. If you don't have a Doc Converter Pro Online account yet please Register for free.
  2. select the input document file that you want to convert
  3. optionally enter a template name
  4. optionally choose if you want to return a zip file with all output conversion files or just get the output file back
  5. optionally choose if you want to return json list of output file URLs, raw data or URL string to that data file located on WC server, using this raw data option with return html option is useful if you want to use only converted html right away after the server response
  6. also you can enable sending file back to given URL via POST, please specify your own working Post back URL

Please click here to download Javascript sample or view the HTML and PostJsCode.js file source code of test API page to see how you can use this API method in Javascript.

Example .NET Winforms C# app...

Please check out WebAPITestApp.zip sample .NET Winforms C# app that does the same as PostConvertReturn.html sample page. Based on that sample app C# code you can write code for ASP .NET MVC web applications as well.

Example PHP code ...

Please check out WebAPIPhpSample.zip sample PHP/HTML code that demos how to get API token and convert uploaded file. Extract zip to a php web server. Edit convert.php file and enter your Doc Converter Pro Online email and password on line 28. Set write permissions on upload/ folder if needed. Go to index.php in a browser, then select document to convert and click Start Converting button.

Example Java code ...

Please check out WebAPIJavaSample.zip sample Java code that demos how to get API token and convert uploaded file. Extract zip and edit WordCleanerWebApi.java file and enter your Doc Converter Pro Online email and password in GetAccessToken() method. Enter your doc file name and path and run.

Example Ruby code ...

Please check out WebAPIRubySample.zip sample Ruby code that demos how to get API token and convert sample doc file. Extract zip and edit dcp_web_api_sample.rb file and enter your Doc Converter Pro Online email and password on line 6 that gets api token. Make sure to install multipart-post gem: gem install multipart-post and then run this sample with: ruby dcp_web_api_sample.rb

Example Python code ...

Please check out WebAPIPythonSample.zip sample Pyton code that demos how to get API token and convert uploaded file to HTML5. Extract zip and edit docconverter_pro_api_sample.py file and enter your Doc Converter Pro Online email and password at 223 and 224 lines.

The Web API uses the same template files that you got on your Doc Converter Pro Online account; therefore, you can use the Doc Converter Pro Online version to prepare your template and preform any testing.

API Throttling

DCP Web API throttles requests per IP. You can convert maximum 2 documents per second, 40 documents per minute, 1000 per hour and 20000 per day. The best is to wait until conversion of given document is done then send another API conversion request. When converting lots of small documents we recommend to measure how many documents you convert per second/minute etc, otherwise you will get API quote exceeded error.

Questions? Contact us anytime.