Repository navigation
Examples: use the converters the API spec documents - #125
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.js and get_result_file_stream.js now convert the URL with html -> pdf (same Url and FileName parameters) and link the html-to-pdf page. conversion_chaining.js passes 'file' as the source format of 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 documented ConvertAPI converters.
No open issues 🎉
What changed in this PR
Updates three Node.js examples to call documented ConvertAPI converters without changing their inputs or output handling. Library format detection remains unchanged.
Changes:
- Uses
htmlinstead ofwebfor both URL-to-PDF examples. - Updates their documentation comments to link to the HTML-to-PDF guide.
- Explicitly passes
fileas the source format for ZIP conversion in the chaining example.
| File | Description |
|---|---|
examples/get_result_file_stream.js |
Uses HTML-to-PDF and updates the guide link. |
examples/convert_url_to_pdf.js |
Uses HTML-to-PDF and updates the guide link. |
examples/conversion_chaining.js |
Explicitly selects the documented file-to-ZIP converter. |
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.
Three examples call converters that the production API spec (https://v2.convertapi.com/info/openapi, 332 paths on 2026-11-09) does not list. They 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 Node part of what ConvertAPI/convertapi-library-dotnet#86 does for .NET.
convert_url_to_pdf.jsweb -> pdf, comment links /web-to-pdfhtml -> pdf(parameters), sameUrlandFileName; comment links https://www.convertapi.com/html-to-pdfget_result_file_stream.jsconversion_chaining.jsany -> zip: with no source format the library sends everyzipconversion toanyfile -> zip(parameters):'file'passed as the source format, 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. CI runs the examples against staging, which served the same spec as production on 2026-11-09 (4,729,541 bytes).
Verified against production (2026-11-09)
Node 24.20.0,
npm ci && npm run build, thennode examples/<name>.jsfrom the repo root, once onmain(a402bd7) and once on this branch, with the token inAPI_TOKEN. The[trace]lines come from a--requirepreload that prints each request's path; they are not part of the examples' output.<tmp>isos.tmpdir().conversion_chaining.js on this branch:
On
mainthe output is the same except the third request,POST v2.convertapi.com/convert/any/to/zip. Both runs saved a 775,249-bytetest.zipwithtest.jpgtotest-6.jpg; the JPGs are byte-identical before and after.convert_url_to_pdf.js on this branch (on
mainthe request was/convert/web/to/pdf, the rest the same):get_result_file_stream.js on this branch (on
main:/convert/web/to/pdf, 91,412 bytes):The PDF text: on
mainand in both runs on this branch, Wikimedia answered ConvertAPI's renderer with its "Too many requests" page (1 page, 62 words), the same page the oldweb -> pdfgot. This does not depend on the converter: in the same hour the samehtml -> pdfcall rendered the article (3 pages, 1,925 words) from the Go, Python, PHP and Ruby examples. The demo URL is being looked at separately.Seen, not changed: the library itself still picks undocumented converters when no source format is given:
anyfor everyziptarget andurlwhen the parameters have aUrl(src/utils.js,detectFormat). The examples now pass the source format, so they do not depend on it.CI
The
test (Node 20/22/24)jobs ran every example against staging and passed on the first attempt; thereget_result_file_stream.jsdownloaded 286,113 bytes, the full article. Thebuildjob fails at "Audit the runtime dependencies":npm auditreports follow-redirects 1.16.0 - 1.16.1 (GHSA-mrwp-f3q8-3g9p), the same failuremainhas had since 2026-11-07 (https://github.com/ConvertAPI/convertapi-library-node/actions/runs/42359841164). It is not caused by this change.Same change in the other SDKs
🤖 Generated with Claude Code