# Torrent Downloader (`maximedupre/torrent-downloader`) Actor

Download files from magnet links and HTTP/HTTPS .torrent URLs. Save completed files to Apify storage with torrent name, info hash, file path, file size, and dataset links.

- **URL**: https://apify.com/maximedupre/torrent-downloader.md
- **Developed by:** [Maxime Dupré](https://apify.com/maximedupre) (community)
- **Categories:** Developer tools, Integrations
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

$4.50 / 1,000 downloaded 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/platform/actors/running/actors-in-store#pay-per-event

## What's an Apify Actor?

Actors are a software tools running on the Apify platform, for all kinds of web data extraction and automation use cases.
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.
Actors are written with capital "A".

## 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.
The best way to integrate Actors is as follows.

In JavaScript/TypeScript projects, use official [JavaScript/TypeScript client](https://docs.apify.com/api/client/js.md):

```bash
npm install apify-client
```

In Python projects, use official [Python client library](https://docs.apify.com/api/client/python.md):

```bash
pip install apify-client
```

In shell scripts, use [Apify CLI](https://docs.apify.com/cli/docs.md):

````bash
# MacOS / Linux
curl -fsSL https://apify.com/install-cli.sh | bash
# Windows
irm https://apify.com/install-cli.ps1 | iex
```bash

In AI frameworks, you might use the [Apify MCP server](https://docs.apify.com/platform/integrations/mcp.md).

If your project is in a different language, use the [REST API](https://docs.apify.com/api/v2.md).

For usage examples, see the [API](#api) section below.

For more details, see Apify documentation as [Markdown index](https://docs.apify.com/llms.txt) and [Markdown full-text](https://docs.apify.com/llms-full.txt).


# README

### 🧲 Torrent downloader for magnet links and .torrent URLs

Torrent Downloader downloads files from magnet links and direct HTTP/HTTPS `.torrent` URLs, saves completed files to Apify storage, and returns one clean dataset row per saved file. Each row includes the submitted target, torrent name, info hash, file name, file path, file size, and a `downloadUrl` you can use to retrieve the file from the run's key-value store.

Use this torrent downloader when you already have torrent targets and need a repeatable Apify workflow for downloading files, exporting a manifest, or connecting the result to the Apify API, schedules, webhooks, or integrations. Start with the prefilled [WebTorrent Sintel sample torrent](https://webtorrent.io/torrents/sintel.torrent), keep the default size caps, and inspect the output before running larger targets.

The Actor accepts public magnet links and public HTTP/HTTPS `.torrent` file URLs. It does not ask for cookies, a login, an API key, private tracker credentials, or user-provided proxy settings.

### ✅ What this Torrent Downloader does

- Accepts magnet links.
- Accepts direct HTTP and HTTPS `.torrent` file URLs.
- Processes multiple torrent targets in one run.
- Saves completed files to Apify key-value storage.
- Emits one dataset row per successfully saved file.
- Includes torrent provenance: submitted target, torrent name, and info hash when available.
- Includes file details: file name, file path inside the torrent, file size, and download URL.
- Lets you set a maximum size per torrent and a maximum total saved size for the run.
- Skips unsupported, unavailable, too-large, or incomplete targets without creating misleading result rows.
- Charges only for files that are successfully saved and emitted to the dataset.

This Actor is focused on downloading from known torrent targets. It does not search torrent sites, scrape torrent indexes, bypass private trackers, seed after download, or discover torrents for you.

### 📦 Data you can export

Each output row represents one saved torrent file.

| Field | Description |
| --- | --- |
| `target` | Magnet link or HTTP/HTTPS `.torrent` URL submitted in the input. |
| `torrentName` | Torrent display name when available. |
| `infoHash` | Torrent info hash when available. |
| `fileName` | Saved file name. |
| `filePath` | File path inside the torrent when available. |
| `fileSizeBytes` | File size in bytes when known. |
| `downloadUrl` | Apify storage URL for retrieving the saved file. |

You can open the dataset in Apify, export it as JSON, CSV, Excel, XML, RSS, or HTML, call it through the Apify API, schedule repeat runs, or connect it to webhooks and integrations. The downloaded files are stored separately in the run's key-value store and linked from each row through `downloadUrl`.

### 🚀 How to run

1. Open the Actor input.
2. Paste one or more magnet links or HTTP/HTTPS `.torrent` URLs in **Torrent targets**.
3. Keep **Maximum size per torrent** at `250 MB` for a small first run, or raise it when you expect larger torrents.
4. Keep **Maximum total size for this run** at `500 MB`, or lower it when testing.
5. Start the Actor and open the dataset.
6. Use each row's `downloadUrl` to retrieve the saved file.

For a first test, keep the prefilled Sintel torrent URL. It is a public sample torrent from WebTorrent and includes small subtitle files that are useful for checking the output shape.

### 🔧 Input

| Field | Required | Description |
| --- | --- | --- |
| `targets` | Yes | Magnet links or direct HTTP/HTTPS `.torrent` file URLs. |
| `maxTorrentSizeMb` | No | Skips a torrent when its declared total size is above this cap. Default is `250`. |
| `maxRunSizeMb` | No | Stops accepting more files when saved downloads reach this run cap. Default is `500`. |

Example input:

```json
{
  "targets": [
    "https://webtorrent.io/torrents/sintel.torrent",
    "magnet:?xt=urn:btih:08ada5a7a6183aae1e09d831df6748d566095a10&dn=Sintel"
  ],
  "maxTorrentSizeMb": 250,
  "maxRunSizeMb": 500
}
````

### 📄 Output example

```json
{
  "target": "https://webtorrent.io/torrents/sintel.torrent",
  "torrentName": "Sintel",
  "infoHash": "08ada5a7a6183aae1e09d831df6748d566095a10",
  "fileName": "Sintel.en.srt",
  "filePath": "Sintel/Sintel.en.srt",
  "fileSizeBytes": 1514,
  "downloadUrl": "https://api.apify.com/v2/key-value-stores/default/records/torrent-files__08ada5a7a6183aae1e09d831df6748d566095a10__0002-Sintel__Sintel.en.srt"
}
```

`torrentName`, `infoHash`, `filePath`, and `fileSizeBytes` can be `null` when the torrent metadata or saved file does not expose the value reliably.

### 💳 Pricing

This Actor uses pay-per-event pricing. You are charged $0.0045 for each torrent file successfully saved to Apify storage and emitted to the dataset.

Skipped targets, invalid inputs, unavailable torrents, too-large torrents, and files that cannot be saved do not create output rows and are not charged as downloaded files. Use the size caps to keep storage and run cost bounded before processing larger torrents.

### ⚠️ Limits and responsible use

- Use this Actor only for content you own, have permission to process, or are otherwise allowed to download in your jurisdiction and under the source site's terms.
- Torrent availability depends on peers, trackers, metadata, and the submitted target. Some torrents may be slow or unavailable at run time.
- The Actor does not seed after downloading.
- The Actor does not search torrent websites or discover torrent files.
- Private trackers, login-only torrents, invitation-only trackers, cookies, and user credentials are not supported.
- Download URLs point to files saved in Apify storage for that run.
- Very large torrents can use significant storage and compute. Keep the size caps low until you know the target size.

### ❓ FAQ

#### 🧲 Can I use magnet links?

Yes. Paste a magnet link in **Torrent targets**. The Actor waits for torrent metadata, applies the size caps, then saves files that can be downloaded within the run limits.

#### 📄 Can I use `.torrent` file URLs?

Yes. Paste a direct HTTP or HTTPS `.torrent` URL. The URL should point to the `.torrent` file itself, not a search page, listing page, or website download button.

#### 🔐 Do I need cookies, a login, or an API key?

No. The Actor is built for public torrent targets and does not ask for user credentials.

#### 🌱 Does this Actor seed files?

No. The Actor downloads and saves completed files. It does not expose a seeding option because Apify Actors are best suited to bounded runs, not long-running torrent seeding.

#### 🧩 Why did my torrent produce no rows?

The Actor saves rows only for files that are successfully downloaded and stored. A target can produce no rows when it is invalid, unsupported, larger than your cap, missing metadata, unavailable, or not reachable during the run.

### 📝 Changelog

- 0.1: Initial release.

### 🆘 Support

For issues, questions, or feature requests, [file a ticket](https://console.apify.com/actors/maximedupre~torrent-downloader/issues) and I'll fix or implement it in less than 24h 🫡

### 🔗 Other actors

- [YouTube Music Downloader ↗](https://apify.com/maximedupre/youtube-music-downloader) - Save audio files from direct YouTube Music and YouTube URLs.
- [TikTok Video Downloader ↗](https://apify.com/maximedupre/tiktok-video-downloader) - Download public TikTok video or audio files to Apify storage.
- [Pinterest Video Downloader ↗](https://apify.com/maximedupre/pinterest-video-downloader) - Extract Pinterest video and image media from public pin targets.
- [Streamable Video Downloader ↗](https://apify.com/maximedupre/streamable-video-downloader) - Get direct Streamable MP4 links, thumbnails, and source metadata.
- [RSS Feed Reader ↗](https://apify.com/maximedupre/rss-feed-reader) - Parse public RSS, Atom, RDF, and JSON Feed URLs into dataset rows.

**Made with ❤️ by Maxime Dupré**

# Actor input Schema

## `targets` (type: `array`):

Paste magnet links or direct HTTP/HTTPS `.torrent` file URLs.

## `maxTorrentSizeMb` (type: `integer`):

Skip a torrent when its declared total size is above this cap.

## `maxRunSizeMb` (type: `integer`):

Stop accepting more files when stored downloads reach this run cap.

## Actor input object example

```json
{
  "targets": [
    "https://fosstorrents.com/files/download.php?file=debian-live-13.5.0-amd64-standard.iso.torrent"
  ],
  "maxTorrentSizeMb": 2048,
  "maxRunSizeMb": 2048
}
```

# Actor output Schema

## `results` (type: `string`):

Open one row per saved torrent file, including the submitted target, torrent name, info hash, file path, file size, and download URL.

# 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 = {
    "targets": [
        "https://fosstorrents.com/files/download.php?file=debian-live-13.5.0-amd64-standard.iso.torrent"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("maximedupre/torrent-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 = { "targets": ["https://fosstorrents.com/files/download.php?file=debian-live-13.5.0-amd64-standard.iso.torrent"] }

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

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

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

```

## CLI example

```bash
echo '{
  "targets": [
    "https://fosstorrents.com/files/download.php?file=debian-live-13.5.0-amd64-standard.iso.torrent"
  ]
}' |
apify call maximedupre/torrent-downloader --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "command": "npx",
            "args": [
                "mcp-remote",
                "https://mcp.apify.com/?tools=maximedupre/torrent-downloader",
                "--header",
                "Authorization: Bearer <YOUR_API_TOKEN>"
            ]
        }
    }
}

```

## OpenAPI specification

```json
{
    "openapi": "3.0.1",
    "info": {
        "title": "Torrent Downloader",
        "description": "Download files from magnet links and HTTP/HTTPS .torrent URLs. Save completed files to Apify storage with torrent name, info hash, file path, file size, and dataset links.",
        "version": "0.1",
        "x-build-id": "BeLvtY8Qf335MVcd1"
    },
    "servers": [
        {
            "url": "https://api.apify.com/v2"
        }
    ],
    "paths": {
        "/acts/maximedupre~torrent-downloader/run-sync-get-dataset-items": {
            "post": {
                "operationId": "run-sync-get-dataset-items-maximedupre-torrent-downloader",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor, waits for its completion, and returns Actor's dataset items in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK"
                    }
                }
            }
        },
        "/acts/maximedupre~torrent-downloader/runs": {
            "post": {
                "operationId": "runs-sync-maximedupre-torrent-downloader",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor and returns information about the initiated run in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/runsResponseSchema"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/acts/maximedupre~torrent-downloader/run-sync": {
            "post": {
                "operationId": "run-sync-maximedupre-torrent-downloader",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor, waits for completion, and returns the OUTPUT from Key-value store in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK"
                    }
                }
            }
        }
    },
    "components": {
        "schemas": {
            "inputSchema": {
                "type": "object",
                "required": [
                    "targets"
                ],
                "properties": {
                    "targets": {
                        "title": "Torrent targets",
                        "minItems": 1,
                        "type": "array",
                        "description": "Paste magnet links or direct HTTP/HTTPS `.torrent` file URLs.",
                        "items": {
                            "type": "string",
                            "minLength": 1
                        }
                    },
                    "maxTorrentSizeMb": {
                        "title": "Maximum size per torrent",
                        "minimum": 1,
                        "maximum": 2048,
                        "type": "integer",
                        "description": "Skip a torrent when its declared total size is above this cap.",
                        "default": 2048
                    },
                    "maxRunSizeMb": {
                        "title": "Maximum total size for this run",
                        "minimum": 1,
                        "maximum": 4096,
                        "type": "integer",
                        "description": "Stop accepting more files when stored downloads reach this run cap.",
                        "default": 2048
                    }
                }
            },
            "runsResponseSchema": {
                "type": "object",
                "properties": {
                    "data": {
                        "type": "object",
                        "properties": {
                            "id": {
                                "type": "string"
                            },
                            "actId": {
                                "type": "string"
                            },
                            "userId": {
                                "type": "string"
                            },
                            "startedAt": {
                                "type": "string",
                                "format": "date-time",
                                "example": "2025-01-08T00:00:00.000Z"
                            },
                            "finishedAt": {
                                "type": "string",
                                "format": "date-time",
                                "example": "2025-01-08T00:00:00.000Z"
                            },
                            "status": {
                                "type": "string",
                                "example": "READY"
                            },
                            "meta": {
                                "type": "object",
                                "properties": {
                                    "origin": {
                                        "type": "string",
                                        "example": "API"
                                    },
                                    "userAgent": {
                                        "type": "string"
                                    }
                                }
                            },
                            "stats": {
                                "type": "object",
                                "properties": {
                                    "inputBodyLen": {
                                        "type": "integer",
                                        "example": 2000
                                    },
                                    "rebootCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "restartCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "resurrectCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "computeUnits": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            },
                            "options": {
                                "type": "object",
                                "properties": {
                                    "build": {
                                        "type": "string",
                                        "example": "latest"
                                    },
                                    "timeoutSecs": {
                                        "type": "integer",
                                        "example": 300
                                    },
                                    "memoryMbytes": {
                                        "type": "integer",
                                        "example": 1024
                                    },
                                    "diskMbytes": {
                                        "type": "integer",
                                        "example": 2048
                                    }
                                }
                            },
                            "buildId": {
                                "type": "string"
                            },
                            "defaultKeyValueStoreId": {
                                "type": "string"
                            },
                            "defaultDatasetId": {
                                "type": "string"
                            },
                            "defaultRequestQueueId": {
                                "type": "string"
                            },
                            "buildNumber": {
                                "type": "string",
                                "example": "1.0.0"
                            },
                            "containerUrl": {
                                "type": "string"
                            },
                            "usage": {
                                "type": "object",
                                "properties": {
                                    "ACTOR_COMPUTE_UNITS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_WRITES": {
                                        "type": "integer",
                                        "example": 1
                                    },
                                    "KEY_VALUE_STORE_LISTS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_INTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_EXTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_SERPS": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            },
                            "usageTotalUsd": {
                                "type": "number",
                                "example": 0.00005
                            },
                            "usageUsd": {
                                "type": "object",
                                "properties": {
                                    "ACTOR_COMPUTE_UNITS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_WRITES": {
                                        "type": "number",
                                        "example": 0.00005
                                    },
                                    "KEY_VALUE_STORE_LISTS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_INTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_EXTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_SERPS": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
```
