File conversion examples using cURL
Using cURL, you can directly invoke ConvertAPI’s extensive document conversion and manipulation features from the command line or within scripts—no additional software or libraries required. By sending HTTP requests to the ConvertAPI endpoints, you’re able to perform operations like converting PDFs, merging documents, compressing images, or extracting data, all using familiar cURL commands. This approach makes it easy to automate conversions in shell scripts, integrate with CI/CD pipelines, and quickly test or debug new workflows.
With straightforward parameters for specifying files, formats, and advanced options (such as page ranges or image quality), cURL provides a lightweight, flexible way to tap into ConvertAPI’s robust capabilities from virtually any environment.
Basic Usage Examples
curl -X POST https://v2.convertapi.com/convert/web/to/pdf?auth=secret_or_token -F "Url=https://www.google.com" -F "StoreFile=true"
curl -X POST https://v2.convertapi.com/convert/xlsx/to/pdf?auth=secret_or_token -F "File=@/path/to/doc.xlsx" -F "StoreFile=true"
curl -X POST https://v2.convertapi.com/convert/docx/to/pdf \
-H "Authorization: Bearer secret_or_token" \
-F "File=https://cdn.convertapi.com/cara/testfiles/document.docx" \
-F "StoreFile=true"
Setting Additional Parameters
Every conversion endpoint accepts specific custom parameters. You can find these on the converter landing pages .
Convert a local PowerPoint to PNG with additional parameters
curl -X POST https://v2.convertapi.com/convert/pptx/to/png \
-H "Authorization: Bearer secret_or_token" \
-F "File=@/path/to/presentation.pptx" \
-F "StoreFile=true" \
-F "ImageResolutionH=500" \
-F "ImageResolutionV=500" \
-F "ScaleImage=true" \
-F "ScaleProportions=true"
Conversion Chaining Using cURL
You can create a conversion workflow by chaining multiple conversions with cURL. For instance, convert a PDF file into several JPG images and then compress the converted files into a single ZIP archive.
curl -X POST https://v2.convertapi.com/convert/pdf/to/jpg \
-H "Authorization: Bearer secret_or_token" \
-F "File=@/path/to/document.pdf" \
-F "ImageResolutionH=500" \
-F "ImageResolutionV=500" \
-F "ScaleImage=true" \
-F "StoreFile=true"
In this example we used a PDF document that consists of 3 pages which results in 3 separate JPG images. Now let's zip multiple converted files into a single archive:
curl -X POST https://v2.convertapi.com/convert/jpg/to/zip \
-H "Authorization: Bearer secret_or_token" \
-F "Files[0]=https://v2.convertapi.com/d/dda2ab19d23e7aaa4203b5ff1fa5a13b/document.jpg" \
-F "Files[1]=https://v2.convertapi.com/d/600e09f511ee90bbe5385ba32d791768/document-2.jpg" \
-F "Files[2]=https://v2.convertapi.com/d/8601b3e1ce2abad484cc58ef0c8f2a28/document-3.jpg"
-F "StoreFile=true"
In this example, the file URLs passed as the file array parameters are the converted files from a previous conversion step. You can use FileId instead if you wish, however you must store the files on our servers by setting the StoreFile=True to be able to chain multiple conversions.
It will be deleted automatically after a maximum period of 3 hours.
Conclusion
The ConvertAPI cURL integration offers a powerful and flexible way to access ConvertAPI’s extensive document conversion and manipulation capabilities directly from your terminal or within shell scripts. By leveraging the ubiquitous cURL tool, you can perform complex file transformations without the need for additional programming languages or SDKs.
For more details, updates, and deeper usage examples, explore the
ConvertAPI cURL GitHub repository.