# Bulk File Downloader \[USD 1/1K files] (`usefulapi/bulk-file-downloader`) Actor

Download files in bulk from a list of links: PDF, Office, ZIP, CSV, images, audio, video. Real type read from the first bytes (an HTML error page served as .pdf is caught), size cap, optional SHA-256 check, retries, every file saved with a ready ZIP link.

- **URL**: https://apify.com/usefulapi/bulk-file-downloader.md
- **Developed by:** [Useful API](https://apify.com/usefulapi) (community)
- **Categories:** Developer tools, Automation, Other
- **Features:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $1.00 / 1,000 files

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.

Learn more: https://docs.apify.com/actors/running/actors-in-store.md#pay-per-event

## What's an Apify Actor?

An Actor is a serverless cloud program that runs on the Apify platform. It has two run modes.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.

Apify vocabulary and the platform model are defined once, in the agent quickstart at https://apify.com/agents.md.

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.

Do not guess an integration path. Every one of them is in the agent quickstart at https://apify.com/agents.md: the Apify MCP server, Agent Skills with the Apify CLI, the JavaScript and Python clients, the REST API, and the account-free path for an agent with no human to sign in. It also carries the rule on stating cost before the first paid run.

For examples already wired to this Actor's own input schema, see the [API](#api) section below.

Each client library has reference documentation the quickstart does not restate: [JavaScript/TypeScript](https://docs.apify.com/api/client/js/docs.md) (`npm install apify-client`) and [Python](https://docs.apify.com/api/client/python/docs.md) (`pip install apify-client`).

# README

## Bulk File Downloader

Download files in bulk from a list of links: PDFs, Word, Excel and PowerPoint files, ZIP and other archives, CSV, JSON,
images, audio and video. Every file is checked by its **real type, read from its first bytes**, so an HTML error page
or login page served at a `.pdf` link is reported as `wrong_type` instead of being saved as a broken PDF. You get one
row per link, every file in a store of its own, and a ready **ZIP link** to download them all at once.

### What it does

- **Type from the bytes**: PDF, DOCX, XLSX, PPTX, ODT/ODS/ODP, EPUB, legacy Office, ZIP, GZ, BZ2, XZ, ZST, 7Z, RAR, TAR,
  JPEG, PNG, GIF, WebP, AVIF, HEIC, SVG, BMP, TIFF, ICO, MP3, AAC, M4A, WAV, FLAC, OGG, MP4, MOV, WebM, AVI, CSV, TSV,
  JSON, XML, TXT, HTML and more. The type is compared with what the link promises (its extension, the name in
  `Content-Disposition`, or a file `Content-Type` such as `application/pdf`).
- **HTML pages are not files**: unless you allow them, an HTML answer is `wrong_type`, not saved and not billed as a file.
- **Size cap** checked from `Content-Length` before the download, and enforced while downloading when the server does not
  say (or says wrong). Up to 1,000 MB per file.
- **Optional SHA-256 check** per file, and SHA-256 of every file in its row. Duplicates (same bytes) are saved once.
- **File names** from your own `filename`, else `Content-Disposition`, else the link; the right extension is added when it
  is missing; a taken name gets part of the SHA-256.
- **Retries with backoff** after no answer, a server error, a 429 or a too slow transfer (not after a 404 or 403).
- **One row per link, never a failed run** because of one bad link.
- **ZIP of everything**: Apify serves the saved files as one ZIP from the link in the run's OUTPUT (and in every row).

### Input examples

Plain list:

```json
{ "urls": ["https://www.irs.gov/pub/irs-pdf/fw9.pdf", "https://calibre-ebook.com/downloads/demos/demo.docx"] }
```

With names, a checksum and an expected type:

```json
{
  "files": [
    { "url": "https://www.irs.gov/pub/irs-pdf/fw9.pdf", "filename": "irs-form-w9.pdf" },
    { "url": "https://go.microsoft.com/fwlink/?LinkID=521962", "type": "xlsx" },
    { "url": "https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf", "sha256": "3df79d34abbca99308e79cb94461c1893582604d68329a41fd4bec1885e6adb4" }
  ],
  "allowedTypes": ["documents", "archives"],
  "maxFileSizeMb": 200
}
```

`allowedTypes` takes types (`pdf`, `docx`, `csv`, `jpeg` ...) or groups: `documents`, `office`, `archives`, `images`,
`audio`, `video`, `data`. `allowedExtensions` and `allowedContentTypes` (`application/pdf`, `image/*`) are checked before
the download starts. Turn `storeFiles` off to check links (type, size, SHA-256, headers) without saving anything.

### Output

One row per link (dataset views "Files" and "All fields"):

```json
{
  "status": "ok",
  "url": "https://www.irs.gov/pub/irs-pdf/f1040s3.pdf",
  "fileName": "f1040s3.pdf",
  "key": "files__f1040s3.pdf",
  "fileUrl": "https://api.apify.com/v2/key-value-stores/Lw0wiXfc1e2xhqz7u/records/files__f1040s3.pdf?signature=...",
  "detectedType": "pdf",
  "detectedMime": "application/pdf",
  "expectedType": "pdf",
  "contentTypeHeader": "application/pdf",
  "contentTypeMatches": true,
  "bytes": 69852,
  "sha256": "008cfd3fe3ebd0860452069b90fd0a3d53dda6dd8a5d870278370aa899a63f82",
  "lastModified": "Fri, 02 Jan 2026 17:10:40 GMT",
  "redirects": 0,
  "attempts": 1,
  "billedAs": { "event": "file", "megabytes": 0 },
  "filesStoreId": "Lw0wiXfc1e2xhqz7u",
  "zipUrl": "https://api.apify.com/v2/key-value-stores/Lw0wiXfc1e2xhqz7u/records?prefix=files__&signature=..."
}
```

Statuses: `ok`, `not_found`, `forbidden`, `rate_limited`, `server_error`, `http_error`, `wrong_type`, `too_large`,
`too_slow`, `timeout`, `unreachable`, `dns_not_found`, `checksum_mismatch`, `duplicate`, `empty`, `private_address`,
`blocked_port`, `invalid_input`, `store_failed`, `cost_limit`.

The run's **OUTPUT** record has the totals, `filesStoreId` and `zipUrl`.

### Where the files are, and for how long

Files are saved in a key-value store created for your run (not the run's default store, so the links never expose your
input). Each row's `fileUrl` and the `zipUrl` are signed: they open without an API token. The ZIP link is valid for 7
days. The store is unnamed, so Apify deletes it after your plan's data retention period (7 days on most plans):
download the ZIP or copy the files before then.

### Pricing (pay per event)

| Event | Price |
|---|---|
| Run start | USD 0.005 |
| File saved (or checked, with saving off) | **USD 0.001 (USD 1 per 1,000)** |
| Each started MB beyond a file's first MB | USD 0.0002 (USD 0.20 per GB) |
| Link without a new file (404, wrong type, too large, duplicate, no answer ...) | USD 0.0002 |

The megabyte event counts every byte received for a link, including retries and downloads stopped part way (too slow,
over your size cap, your cost limit), so one link bills at most (retries + 1) x your size cap in megabytes. A download
stopped by the per-file time cap (`maxSecondsPerFile`) is not retried.

Measured on Apify: 80 IRS PDFs (29 MB) took 29 seconds. Set a maximum cost per run and the Actor stops cleanly before it,
keeping every row it saved.

### Good to know

- Links are fetched as you give them (no robots.txt check for direct file links). Redirects are followed, at most 5.
- Private, loopback and cloud metadata addresses are refused on every hop, also after a redirect. Ports other than 80,
  443, 8080 and 8443 are followed only when your own link names them.
- At most 2 downloads at a time go to one host, with a short pause between them. A host that fails 3 times in a row is
  skipped for the rest of the run.
- Speed rule: after a 15 s allowance a server must keep sending at least 200 KB per second on average, or the file stops
  as `too_slow` (and is retried). A file stopped by the per-file time cap is not retried.
- User agent: `Mozilla/5.0 (compatible; UsefulApiBot/1.0; +https://apify.com/usefulapi)` for every request. Hosts that
  refuse bots are reported in the row's status, not worked around.
- Only download files you have the right to download and keep.

# Actor input Schema

## `urls` (type: `array`):

One link per line, up to 20,000 per run. Each link is fetched as given (redirects followed, at most 5).

## `files` (type: `array`):

Optional, instead of or with the list above: objects with url and, if you like, filename (the name to save under), sha256 (the file is kept only when its SHA-256 matches) and type (the type you expect, for example pdf).

## `allowedTypes` (type: `array`):

Keep only these types, read from the file's first bytes: pdf, docx, xlsx, pptx, zip, gz, csv, json, xml, txt, jpeg, png, mp3, mp4 and more, or groups: documents, office, archives, images, audio, video, data. Empty: any type except HTML pages.

## `allowHtml` (type: `boolean`):

Off: an HTML answer (an error, login or landing page where a file was expected) is reported as wrong_type and not saved or billed as a file.

## `checkExtension` (type: `boolean`):

Report wrong_type when the bytes contradict what the link promises: its extension (.pdf), the name in Content-Disposition, or a file Content-Type header such as application/pdf. Similar formats pass (a .jpg that is a WebP, a .docx read as ZIP).

## `allowedExtensions` (type: `array`):

Optional: keep only files whose name (from Content-Disposition or the link) ends in one of these, for example pdf, docx. Checked before the download.

## `allowedContentTypes` (type: `array`):

Optional: keep only answers with one of these Content-Type headers, for example application/pdf or image/\*. Checked before the download.

## `maxFileSizeMb` (type: `integer`):

Larger files are skipped: checked from the Content-Length header before the download, and cut while downloading when the server does not say.

## `maxSecondsPerFile` (type: `integer`):

A file that takes longer is stopped (status timeout, not retried). Separately, after a 15 s allowance a server must keep sending at least 200 KB per second on average, or the file stops as too_slow (and is retried).

## `retries` (type: `integer`):

Extra tries after no answer, a server error, a 429 or a too slow transfer (waits 2 s, 6 s, 12 s, 20 s, 30 s). Not after a 404 or 403. Not after the per-file time cap. Every retry's bytes count toward the megabyte event.

## `storeFiles` (type: `boolean`):

Off: check only (type, size, SHA-256, headers), nothing saved. Files are still downloaded to be checked.

## `dedupe` (type: `boolean`):

A file with the same bytes (SHA-256) as one already saved in this run is not saved again; its row points to the first copy.

## `concurrency` (type: `integer`):

Downloads at the same time across all hosts. At most 2 at a time go to one host, with a short pause between them, whatever this number.

## Actor input object example

```json
{
  "urls": [
    "https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf",
    "https://calibre-ebook.com/downloads/demos/demo.docx"
  ],
  "files": [
    {
      "url": "https://www.irs.gov/pub/irs-pdf/fw9.pdf",
      "filename": "irs-form-w9.pdf"
    }
  ],
  "allowHtml": false,
  "checkExtension": true,
  "maxFileSizeMb": 100,
  "maxSecondsPerFile": 300,
  "retries": 2,
  "storeFiles": true,
  "dedupe": true,
  "concurrency": 10
}
```

# Actor output Schema

## `files` (type: `string`):

No description

## `details` (type: `string`):

No description

## `summary` (type: `string`):

No description

## `store` (type: `string`):

No description

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "urls": [
        "https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf",
        "https://calibre-ebook.com/downloads/demos/demo.docx"
    ],
    "files": [
        {
            "url": "https://www.irs.gov/pub/irs-pdf/fw9.pdf",
            "filename": "irs-form-w9.pdf"
        }
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("usefulapi/bulk-file-downloader").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = {
    "urls": [
        "https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf",
        "https://calibre-ebook.com/downloads/demos/demo.docx",
    ],
    "files": [{
            "url": "https://www.irs.gov/pub/irs-pdf/fw9.pdf",
            "filename": "irs-form-w9.pdf",
        }],
}

# Run the Actor and wait for it to finish
run = client.actor("usefulapi/bulk-file-downloader").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "urls": [
    "https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf",
    "https://calibre-ebook.com/downloads/demos/demo.docx"
  ],
  "files": [
    {
      "url": "https://www.irs.gov/pub/irs-pdf/fw9.pdf",
      "filename": "irs-form-w9.pdf"
    }
  ]
}' |
apify call usefulapi/bulk-file-downloader --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,usefulapi/bulk-file-downloader"
        }
    }
}
```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/LlViIA7rAvjsmiNO4/builds/egx8Ls956GkJ3dVRc/openapi.json
