The `convertapi` Python Client provides an interface to ConvertAPI's file conversion and manipulation services. It allows users to convert documents, images, videos, and more between various formats programmatically. The current version is 2.0.0, and the library is actively maintained with releases addressing features and breaking changes.
pip install convertapiVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to initialize the ConvertAPI client with your API secret and perform a simple file conversion from a URL. It converts a DOC file to PDF and saves the output locally. Error handling for API-specific and general exceptions is included.
Ensure your client library is updated to v2.0.0 or later. No explicit code change is usually required if you set `convertapi.api_secret`, as the library handles the header internally.
Review your conversion calls and remove any parameters that specified an 'alternative converter'. Test existing conversions thoroughly as the default converter might behave differently or lack certain features.
For critical operations, consider explicitly setting timeouts. You can configure `convertapi.default_timeout` or pass `timeout` parameter to `convertapi.convert` for individual calls.
Always ensure the value passed to the `File` parameter matches the expected input type for your specific conversion scenario. For local files, ensure the path is accessible; for URLs, ensure it's a valid and publicly accessible link.
Double-check your `convertapi.api_secret` value. Ensure it matches the secret found on your ConvertAPI dashboard (https://www.convertapi.com/a/dashboard). Make sure environment variable `CONVERTAPI_SECRET` is set if you are loading it from there.
The correct attribute to set the API secret is `convertapi.api_secret`. Change `convertapi.secret = '...'` or `convertapi.api_key = '...'` to `convertapi.api_secret = '...'`.
Ensure that the `parameters` dictionary passed to `convertapi.convert()` includes a key named 'File' with the path, URL, or bytes of the file you intend to convert, e.g., `{'File': 'path/to/file.docx'}`.