Repository navigation
Examples: use the converters the API spec documents - #62
Merged
Merged
Conversation
The production API spec (https://v2.convertapi.com/info/openapi) has no web -> pdf and no any -> zip converter. convert_url_to_pdf.py now converts the URL with html -> pdf (same Url and FileName parameters) and links the html-to-pdf page. conversions_chaining.py passes from_format = 'file' to the ZIP step: without a source format the library sends every zip conversion to any -> zip. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Nov 9, 2026
There was a problem hiding this comment.
🟢 Approval recommended
There are no active review issues for the example updates to explicit HTML-to-PDF and file-to-ZIP converters.
No open issues 🎉
What changed in this PR
Updates two Python examples to use documented ConvertAPI converters without changing the library’s automatic format detection.
Changes:
- Uses explicit
html → pdfconversion for web page URLs and updates the documentation-link comment. - Uses explicit
file → zipconversion when archiving chained conversion results.
| File | Description |
|---|---|
examples/convert_url_to_pdf.py |
Sets from_format = 'html' and links to the HTML-to-PDF documentation. |
examples/conversions_chaining.py |
Sets from_format = 'file' for ZIP creation instead of relying on automatic detection. |
Review effort: Balanced
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Two examples call converters that the production API spec (https://v2.convertapi.com/info/openapi, 332 paths on 2026-11-09) does not list. Both still convert today, but developers copy these examples and the how-to guides on convertapi.com reuse them, so they should call documented converters. This is the Python part of what ConvertAPI/convertapi-library-dotnet#86 does for .NET.
convert_url_to_pdf.pyweb -> pdf, comment links /web-to-pdfhtml -> pdf(parameters), sameUrlandFileName; comment links https://www.convertapi.com/html-to-pdfconversions_chaining.pyany -> zip: with no source format the library sends everyzipconversion toanyfile -> zip(parameters):from_format = 'file', sameFileshttps://www.convertapi.com/web-to-pdf is not in the site's sitemap; https://www.convertapi.com/html-to-pdf is. The other examples already call documented converters; the
pdf -> extractstep of create_pdf_thumbnail.py goes away with #61.Verified against production (2026-11-09)
Python 3.15.2 in a venv with this branch installed (
pip install ., requests 2.34.2). Each example ran withpython <name>.pyfromexamples/, once onmain(58b93a2) and once on this branch, with the token inAPI_TOKEN. A wrapper logged each request's path;<tmp>istempfile.gettempdir().conversions_chaining.py, same output before and after:
Requests on
main:POST /upload,POST /convert/pdf/to/jpg,POST /convert/any/to/zip. On this branch:POST /upload,POST /convert/pdf/to/jpg,POST /convert/file/to/zip. All answered HTTP 200. Both runs saved a 775,249-bytetest.zipwithtest.jpgtotest-6.jpg; the JPGs are byte-identical before and after.convert_url_to_pdf.py, same output before and after:
Request on
main:POST /convert/web/to/pdf; on this branch:POST /convert/html/to/pdf; both HTTP 200. The PDF text: on this branch the PDF is the article (3 pages, 1,925 words, title "Data conversion"). Onmain, Wikimedia answered ConvertAPI's renderer with its "Too many requests" page (1 page, 62 words); that rate limiting comes and goes for both converters and is being looked at separately.Seen, not changed: the library itself still picks undocumented converters when no source format is given:
anyfor everyziptarget andwebwhen the parameters have aUrl(convertapi/task.py,__detect_format). The examples now pass the source format, so they do not depend on it.Same change in the other SDKs
🤖 Generated with Claude Code