Skip to main content
Use AmzDownloader to extract product-gallery videos and save their metadata with Node.js. You can then download one direct MP4 or explicitly request conversion of one supported Amazon HLS playlist. The example keeps extraction and conversion as separate credit-consuming operations.

Prepare the example

You need Node.js 20 or newer, an API key, and permission to use the media. Clone the runnable files:
Without --convert, the script saves metadata and downloads a direct MP4 if one is available. If Amazon exposes only HLS playlists, it saves the metadata without charging for conversion. To authorize conversion of one playlist, add the explicit flag:
Keep the same operation ID when retrying the identical extraction. Use a new ID for a different product or extraction settings. This tutorial limits the ID to 80 characters so the separate :mp4 conversion suffix also fits the API’s idempotency header limit.

Run the complete workflow

The bundled client.mjs sends credentials only to AmzDownloader, rejects redirects and applies request timeouts. The extraction call enables productVideos and disables the other groups. It accepts either an immediate completed response or a queued job, with at most 20 polls separated by three seconds.
download-videos.mjs
The script writes media-result.json before attempting a download. A successful selected download is saved as video-001.mp4; that file is not overwritten. The 64 MB download limit and polling budget belong to this example. They are not promises about maximum source-video size or extraction latency.

Understand the media response

Read data.media.productVideos for the requested product-gallery group. Each item can include title, cover, src, duration, group, contentType and optional creator metadata. Read data.source.asin, data.source.marketplace, data.source.fetchedAt, data.counts and data.warnings alongside it. Related, customer-review and creator videos can be classified separately. This example does not request related or creator groups. To include them, deliberately change the request flags and inspect each video’s group; do not assume that every returned video depicts the selected product.

Keep conversion and download separate

A supported .m3u8 conversion request uses POST /videos/convert. Its MP4 download location is the response’s top-level url, not data.url. A direct MP4 source does not need conversion. Download the returned URL without an AmzDownloader authorization header. One successful extraction costs one credit, including a cache hit. One successful conversion costs one additional credit, including a cached conversion. Polling, owned result reads, failures and identical idempotent replays add no credits. If a download fails after the API succeeded, use the saved metadata before requesting more work. If polling ends locally, retain the printed job ID and check its status later. Do not submit a new extraction simply to check progress. See the conversion API overview, conversion guide, errors, the video API overview and the public examples repository.