Skip to content

Quickstart

Five minutes from a list of URLs to a folder of images, with a record of anything that couldn't be downloaded.

You need a file with image URLs in it. A CSV with a url column works; so do TSV, TXT (one URL per line), JSON, JSONL and Parquet. Machyon finds the URL column by its name (url, image_url, image_link, img_url, link, src, image, href, uri) or, failing that, by looking for values that start with http.

From Python

quickstart.py
import machyon

report = machyon.download("urls.csv", "images/")
print(report)                  # one-line summary
print(report.failure_reasons)  # e.g. {'http_404': 14, 'not_image': 6}

download() blocks until every row is finished, then returns a Report. A progress bar shows the rate, the current concurrency, retries and failures while it runs.

New to this? Build your first image dataset runs the same call on a small CSV and sorts the images into folders by category.

Your files are named {hash}{ext} by default: 16 hex characters derived from the URL, so the same URL always gets the same name, plus the image's real extension. To use your own columns:

quickstart_columns.py
import machyon

report = machyon.download(
    "products.csv", "images/",
    url_col="image_link",                  # optional: guessed when omitted
    names="{label}/{index}_{hash}{ext}",   # a folder per label
)
print(report.downloaded, report.skipped, report.failed)

More about filenames

The report is a plain dataclass, so the numbers are easy to use or store:

report_fields.py
import json

import machyon

report = machyon.download("urls.csv", "images/")
print(f"{report.downloaded} new, {report.skipped} already there, {report.failed} failed")
print(f"{report.rate:.0f} img/s, {report.mb_per_s:.1f} MB/s, p95 latency {report.latency_p95:.2f} s")
print(f"concurrency settled at {report.final_concurrency}, peak {report.peak_concurrency}")
print(json.dumps(report.to_dict(), default=str)[:80], "...")

In Jupyter, FastAPI or any async code

download() can't run inside an event loop that is already running. There, use report = await machyon.adownload("urls.csv", "images/"). Async apps

From the terminal

The same run, recorded against Machyon's test CDN. Eight of the 600 URLs can never succeed: six are gone (404) and two answer with an HTML page instead of an image.

Download, retry, resume
$ machyon urls.csv -o images/
2026-11-10 12:58:41,245 - machyon.engine - WARNING - http_404: HTTP 404 Not Found (http://cdn.example.test/img/131.jpg)
  -> The image no longer exists at that URL.

2026-11-10 12:58:41,508 - machyon.engine - WARNING - not_image: Content-Type text/html, body starts b'<html>not found</html>' (http://cdn.example.test/img/337.jpg)
  -> The server answered with something that isn't an image (an HTML error, login or bot-check page).

machyon: 100%|██████████| 600/600 [00:01<00:00, 353.95img/s,  0.38 MB/s | conc  64 | retry 20 | fail 8]
2026-11-10 12:58:42,751 - machyon - INFO - 592 downloaded, 0 already on disk, 8 failed in 1.7s (348.4 img/s, 7.11 MB/s) | failures: {'http_404': 6, 'not_image': 2}
2026-11-10 12:58:42,752 - machyon - INFO - Failures listed in images/failed_downloads.jsonl

⚠ 592 downloaded, 0 already on disk, 8 failed in 1.7s (348.2 img/s, 7.11 MB/s) | failures: {'http_404': 6, 'not_image': 2}
  http_404 (6x): HTTP 404 Not Found
      e.g. http://cdn.example.test/img/131.jpg
      -> The image no longer exists at that URL.
  not_image (2x): Content-Type text/html, body starts b'<html>not found</html>'
      e.g. http://cdn.example.test/img/337.jpg
      -> The server answered with something that isn't an image (an HTML error, login or bot-check page).
  Failures: images/failed_downloads.jsonl  (retry with: machyon retry -o images/)
$ machyon retry -o images/
2026-11-10 12:58:42,979 - machyon - INFO - No failed downloads to retry.

Nothing to retry.
  Still failing: 8 (see images/failed_downloads.jsonl)
$ machyon urls.csv -o images/
2026-11-10 12:58:43,230 - machyon - INFO - Warm start for cdn.example.test: concurrency 64

2026-11-10 12:58:43,268 - machyon.engine - WARNING - http_404: HTTP 404 Not Found (http://cdn.example.test/img/505.jpg)
  -> The image no longer exists at that URL.

2026-11-10 12:58:43,269 - machyon.engine - WARNING - not_image: Content-Type text/html, body starts b'<html>not found</html>' (http://cdn.example.test/img/337.jpg)
  -> The server answered with something that isn't an image (an HTML error, login or bot-check page).

machyon: 100%|██████████| 600/600 [00:00<00:00, 12802.02img/s]
2026-11-10 12:58:43,271 - machyon - INFO - 0 downloaded, 592 already on disk, 8 failed in 0.1s (0.0 img/s, 0.00 MB/s) | failures: {'http_404': 6, 'not_image': 2}
2026-11-10 12:58:43,271 - machyon - INFO - Failures listed in images/failed_downloads.jsonl

⚠ 0 downloaded, 592 already on disk, 8 failed in 0.1s (0.0 img/s, 0.00 MB/s) | failures: {'http_404': 6, 'not_image': 2}
  http_404 (6x): HTTP 404 Not Found
      e.g. http://cdn.example.test/img/505.jpg
      -> The image no longer exists at that URL.
  not_image (2x): Content-Type text/html, body starts b'<html>not found</html>'
      e.g. http://cdn.example.test/img/337.jpg
      -> The server answered with something that isn't an image (an HTML error, login or bot-check page).
  Failures: images/failed_downloads.jsonl  (retry with: machyon retry -o images/)

Recorded from Machyon 1.1.0 against the local test CDN (tools/record_casts.py).

Notice three things:

  1. The failures explain themselves. Each reason is shown once, with a real example and what to do about it.
  2. retry found nothing to retry. A 404 and an HTML page are permanent; retrying them would only cost time. Transient failures (timeouts, 503s, rate limits) are retried automatically before the run ends, and machyon retry exists for the ones that outlast that.
  3. Running again resumed. The second run skipped all 592 finished files in a tenth of a second and started at the concurrency it learned the first time.

What you have now

images/
├── 0f3c9a1e2b7d4c55.jpg
├── …                          592 complete images
├── failed_downloads.jsonl     one line per failed URL: url, names, reason, error
└── failed_downloads.txt       the same URLs, one per line

Every row in urls.csv is accounted for: it is a complete image in images/, or it is in failed_downloads.jsonl with a reason. That's the zero-lost contract. When nothing failed, neither ledger file exists.

Next