File Conversion REST API

A very simple API

Every conversion is a two part process. First import the files, then export in the desired format.

Authentication

All API calls must include the Authorization header in the format of "Token key value", like this example; where XXXXXXXX is the token issues by any2web.

curl \
	--header "Authorization: Token XXXXXXXX" \
	...

All other examples of authenticated API calls assume that this header will be present and it's been left out of the following examples to reduce noise.

Conversion Sources

The orignal documents/files are specified using the source parameter.

This can be a file uploaded via POST, or a link to a document

Uploading a file source

curl \
	--form source="@Some File.doc" \
	http://any2web.io/api/convert/pdf \
	>output.pdf

We can pull from a link too, we will detect the file type

curl \
	--form source="http://your.example.com/convert-queue/source.doc" \
	http://any2web.io/api/convert/pdf \
	>output.pdf

You can pass Auth or Query String parameters too, and SSL works but your certificates must be signed by a well know authority.

curl \
	--form source="https://user:pass@your.server/secret?key=123456" \
	http://any2web.io/api/convert/pdf \
	>output.pdf

Output Formats

The output format can be specified with the POST parameters. If only output is provided the output MIME type will be guessed. An explicit MIME type can be specified by output-mime. If the format cannot be guessed and no MIME type was specified the response will be PDF.

curl \
	--form output="pdf"
	http://any2web.io/api/convert \

This one would be sent back as an HTTP PUT.

curl \
	--form output="http://user:pass@your.server/output/file.pdf"
	http://any2web.io/api/convert \

This one would be sent as an email attachment:

curl \
	--form output="mailto:user@example.com"
	--form output-mime="application/pdf"
	http://any2web.io/api/convert \

Example Calls

Converting to PDF

curl \
	--header "Authorization: Token ABC" \
	--form source="@Some File.doc" \
	http://any2web.io/api/convert/pdf \
	> Output.pdf

Converting to PNG+ZIP

The output.zip file contains multiple PNG images.

curl \
	--header "Authorization: Token ABC" \
	--form source="@Some File.doc" \
	http://any2web.io/api/convert/png \
	> output.zip

Converting to SVG+ZIP

The output.zip file contains multiple SVG images.

curl \
	--header "Authorization: Token ABC" \
	--form source="@Some File.doc" \
	http://any2web.io/api/convert/svg \
	> output.zip