# Twitch Clip & Highlight MP4 Downloader (`xyrelith-data/twitch-clip-highlight-mp4-downloader`) Actor

Download Twitch clips and short highlights as MP4, or return signed source URLs with full clip metadata. Batch by clip URL, channel, category or highlight ID, filter by period, views and language, and cap quality or file size.

- **URL**: https://apify.com/xyrelith-data/twitch-clip-highlight-mp4-downloader.md
- **Developed by:** [Xyrelith Data](https://apify.com/xyrelith-data) (community)
- **Categories:** Social media, Videos, Automation
- **Features:** Limited permissions
- **Stats:** 1 total users, 0 monthly users, 0.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $0.49 / 1,000 results

This Actor is paid per event and usage. You are charged both the fixed price for specific events and for Apify platform usage.
Since this Actor supports Apify Store discounts, the price gets lower the higher subscription plan you have.

Learn more: https://docs.apify.com/actors/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

## Twitch Clip & Highlight MP4 Downloader

Save Twitch clips and short highlights as MP4 files, or collect their metadata and signed media URLs without downloading. Pick clips one by one, pull the top clips from whole channels or categories, and resolve highlight IDs — all without a Twitch login, API key or cookie.

Built for editors, stream teams, community managers and archivists who need a repeatable batch, not a one-off browser button.

### What you get

- **One row per clip or highlight** with title, channel, clipper, category, language, views, duration, creation date and source VOD details.
- **Signed MP4 or HLS URL** ready for your own downloader, plus its expiry time.
- **Optional MP4 download** into the run's key-value store, with a public download URL, file name and byte size.
- **Quality control** from source/1080p down to 360p, with an honest fallback flag when the exact tier is unavailable.
- **Size and duration guards** so a long highlight or oversized clip never silently blows up storage or bandwidth.
- **Clear error rows** for bad URLs, missing clips, unknown channels or categories, and non-highlight video IDs.

### Modes

| Mode | What it reads | Best for |
|---|---|---|
| Clip URLs or slugs | `clipUrls` | A known list of clips from a spreadsheet or another tool |
| Top clips from channels | `channelLogins` | Archiving a streamer's best recent clips |
| Top clips from categories | `categoryNames` | Finding what is popping in a game or category |
| Highlights by ID or URL | `highlightIds` | Saving a curated highlight reel |

Channel and category modes support **last 24 hours, 7 days, 30 days or all time**, **most viewed** or **trending** ordering, and client-side filters for minimum views, language and creation date. Pagination continues until `maxItems` or the source runs out.

### Input

| Field | Type | Default | Notes |
|---|---|---|---|
| `mode` | select | `byUrls` | `byUrls`, `byChannels`, `byCategories` or `byHighlightIds` |
| `clipUrls` | string list | empty | Twitch clip URLs, `clips.twitch.tv` links, or bare slugs |
| `channelLogins` | string list | empty | Channel logins or channel URLs |
| `categoryNames` | string list | empty | Category names, slugs or directory URLs |
| `highlightIds` | string list | empty | Numeric highlight IDs or `twitch.tv/videos/<id>` URLs |
| `quality` | select | `source` | `source`, `1080`, `720`, `480`, `360` |
| `saveToKeyValueStore` | boolean | `false` | Off = signed URLs and metadata; on = download MP4 |
| `maxFileSizeMB` | integer | `500` | Skip downloads above this size (1–2048) |
| `maxHighlightDurationSeconds` | integer | `600` | Skip highlights longer than this (1–3600) |
| `includeThumbnail` | boolean | `true` | Add a thumbnail image URL to each record |
| `period` | select | `LAST_WEEK` | Last day, week, month or all time |
| `sort` | select | `VIEWS_DESC` | Most viewed or trending |
| `language` | select | `(any)` | Broadcast language filter |
| `minViews` | integer | `0` | Drop clips below this view count |
| `createdAfter` / `createdBefore` | date | empty | Optional creation-date window |
| `maxItems` | integer | `20` | Stop after this many successful records (1–1000) |

### Output

| Field | Description |
|---|---|
| `recordType` | `clip`, `highlight` or `error` |
| `slug`, `clipId` | Twitch clip identifiers |
| `highlightId` | Numeric highlight/video identifier |
| `title`, `url`, `embedUrl` | Clip or highlight page links |
| `channelLogin`, `channelDisplayName` | Broadcaster |
| `creatorLogin`, `creatorDisplayName` | Clipper (clips only) |
| `gameId`, `gameName`, `gameSlug` | Category |
| `language`, `viewCount`, `durationSeconds`, `createdAt` | Core metadata |
| `sourceVideoId`, `sourceVideoTitle`, `sourceVideoBroadcastType`, `sourceVideoOffsetSeconds` | Source VOD details when Twitch still exposes them |
| `qualityRequested`, `quality`, `qualityLabel`, `resolution`, `frameRate`, `qualityFallback` | Delivered quality details |
| `availableQualities` | Tiers that were actually available |
| `sourceUrl`, `sourceUrlType`, `sourceUrlExpiresAt` | Signed MP4 (`mp4`) or HLS (`hls`) URL and expiry |
| `thumbnailUrl` | Thumbnail image URL when `includeThumbnail` is on |
| `fileSizeBytes` | Source size for clips; downloaded size when a file was saved |
| `estimatedFileSizeBytes` | Pre-download estimate for highlights |
| `downloadStatus` | `notRequested`, `downloaded`, `skipped` or `failed` |
| `downloadUrl`, `fileName` | Public key-value-store link and object key |
| `downloadSkippedReason`, `downloadError` | Why a download was skipped or failed |
| `errorType`, `errorMessage`, `input` | Error-row details |

Empty values are omitted. Zero views and `false` booleans are kept.

### Examples

#### Download three clips by URL

```json
{
  "mode": "byUrls",
  "clipUrls": [
    "https://www.twitch.tv/xqc/clip/EagerMagnificentOpossumRaccAttack-Z_1cH-jBbf9w3u7C",
    "https://clips.twitch.tv/TrustworthyDeterminedSnakeSuperVinlin-3AJn_BZG9QM87A9o"
  ],
  "quality": "720",
  "saveToKeyValueStore": true,
  "maxItems": 3
}
```

#### Collect a channel's most viewed clips from the last week

```json
{
  "mode": "byChannels",
  "channelLogins": ["xqc", "summit1g"],
  "period": "LAST_WEEK",
  "sort": "VIEWS_DESC",
  "minViews": 500,
  "language": "EN",
  "maxItems": 50
}
```

#### Collect trending clips from a category

```json
{
  "mode": "byCategories",
  "categoryNames": ["Just Chatting", "grand-theft-auto-v"],
  "period": "LAST_DAY",
  "sort": "TRENDING",
  "maxItems": 30
}
```

#### Save a short highlight as MP4

```json
{
  "mode": "byHighlightIds",
  "highlightIds": ["73558265"],
  "quality": "480",
  "saveToKeyValueStore": true,
  "maxHighlightDurationSeconds": 300,
  "maxFileSizeMB": 100
}
```

### How the media options work

- **Signed URL only (default).** Every record gets a `sourceUrl` that works without cookies. Clips are direct MP4 files; highlights are HLS playlists. The link expires in roughly 20 hours; `sourceUrlExpiresAt` tells you exactly when.
- **Save to key-value store.** The actor downloads the selected quality and stores it under `twitch-clips-<slug>.mp4` or `twitch-highlights-<videoId>.mp4`. `downloadUrl` is the public link. Downloads are sequential and bandwidth-heavy, so keep `maxItems` small.
- **Quality fallback.** If the requested tier is unavailable, the nearest available tier is delivered and `qualityFallback` is `true`. `availableQualities` lists the real options.
- **Size guard.** Clips above `maxFileSizeMB` are not downloaded; highlights are skipped when either the duration or the estimated file size exceeds your limits. The record still carries the metadata and signed URL.
- **Highlights only.** Past broadcasts, live streams and uploads are rejected with a clear error row. Highlights are short VODs and are converted to MP4 with remuxing, not re-encoding.

### Limits

- Twitch caps a channel or category clip ranking at about **1,000 clips per period**. Split by period for more, and use clip URLs for older individual clips.
- Twitch clip media tops out at **1080p** without a logged-in session. 1440p/2160p are not available to a cookieless actor.
- Signed URLs expire in about 20 hours; re-run the actor to mint fresh ones.
- Downloads use the run's key-value store, which follows Apify's run-storage retention (7 days for the default unnamed store). Download or copy the files if you need them longer.
- A deleted or region-blocked clip can disappear between the ranking request and the media request. It is returned as an error row or with `mediaStatus: unavailable`.
- Twitch can return a transient `service error` on trending queries; the actor retries with backoff before reporting a query failure.

### FAQ

**Do I need a Twitch account, client ID or cookie?** No. The actor uses Twitch's public web GraphQL and public media CDN. No credentials are read or stored.

**Can I get more than 1,000 clips from one channel?** Not from a single ranking. Use a shorter period or provide exact clip URLs for older clips.

**Why is my highlight download skipped?** Check `downloadSkippedReason`: `maxHighlightDuration` means the highlight is longer than your limit, and `maxFileSize` means it would exceed your size budget. The signed HLS URL is still returned.

**Why is the MP4 larger or smaller than the estimate?** Highlight estimates use the playlist bitrate; the final file size is measured after remuxing.

**Does this download live streams or full past broadcasts?** No. It downloads clips and highlights only.

### Data source and responsible use

Data comes from Twitch's public web endpoints. Download and use only content you own or are authorized to save, and follow Twitch's terms and the rights of streamers and clippers.

# Actor input Schema

## `mode` (type: `string`):

Choose clip URLs or slugs, channel top clips, category top clips, or highlight IDs. Each mode reads its own list field below.

## `clipUrls` (type: `array`):

Used by the clip URL mode. Paste twitch.tv/<channel>/clip/<slug>, clips.twitch.tv/<slug>, or bare slugs.

## `channelLogins` (type: `array`):

Used by the channel mode. Twitch channel logins or channel URLs; top clips are read for the selected period and sort order.

## `categoryNames` (type: `array`):

Used by the category mode. Examples: Just Chatting, grand-theft-auto-v, or a twitch.tv/directory/category/... URL.

## `highlightIds` (type: `array`):

Used by the highlight mode. Numeric highlight IDs or twitch.tv/videos/<id> URLs. Past broadcasts and uploads are rejected.

## `quality` (type: `string`):

Source picks the best available tier. Twitch clip sources top out at 1080p without login; if the exact tier is missing, the nearest available tier is used and marked as a fallback.

## `saveToKeyValueStore` (type: `boolean`):

Off by default: return signed source URLs and metadata only. On: download each clip or highlight as MP4 and add a public key-value-store download URL.

## `maxFileSizeMB` (type: `integer`):

Clips and highlights larger than this are not downloaded. Their metadata and signed source URL are still returned with a skipped status.

## `maxHighlightDurationSeconds` (type: `integer`):

Highlights longer than this are not downloaded; metadata and the signed HLS URL are still returned. Has no effect on clips.

## `includeThumbnail` (type: `boolean`):

Add a direct thumbnail image URL to every clip and highlight record.

## `period` (type: `string`):

Time window for channel and category rankings. Clip URL and highlight modes ignore it.

## `sort` (type: `string`):

Most viewed first, or Twitch's trending order. Applies to channel and category modes.

## `language` (type: `string`):

Keep only clips in this broadcast language. Leave on (any) for no language filter.

## `minViews` (type: `integer`):

Skip clips below this view count. Set to 0 to keep every clip.

## `createdAfter` (type: `string`):

Optional YYYY-MM-DD date. Older clips are skipped in channel and category modes.

## `createdBefore` (type: `string`):

Optional YYYY-MM-DD date. Newer clips are skipped in channel and category modes.

## `maxItems` (type: `integer`):

Stop after this many successful records (1-1000). Invalid inputs still produce error rows. Twitch caps channel and category rankings at about 1,000 clips per period.

## Actor input object example

```json
{
  "mode": "byUrls",
  "clipUrls": [
    "https://www.twitch.tv/xqc/clip/EagerMagnificentOpossumRaccAttack-Z_1cH-jBbf9w3u7C"
  ],
  "channelLogins": [],
  "categoryNames": [],
  "highlightIds": [],
  "quality": "source",
  "saveToKeyValueStore": false,
  "maxFileSizeMB": 500,
  "maxHighlightDurationSeconds": 600,
  "includeThumbnail": true,
  "period": "LAST_WEEK",
  "sort": "VIEWS_DESC",
  "language": "",
  "minViews": 0,
  "maxItems": 1
}
```

# Actor output Schema

## `clips` (type: `string`):

Dataset containing clip and highlight metadata, media URLs, and optional downloaded MP4 files.

# 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 = {
    "mode": "byUrls",
    "clipUrls": [
        "https://www.twitch.tv/xqc/clip/EagerMagnificentOpossumRaccAttack-Z_1cH-jBbf9w3u7C"
    ],
    "channelLogins": [],
    "categoryNames": [],
    "highlightIds": [],
    "quality": "source",
    "saveToKeyValueStore": false,
    "maxFileSizeMB": 500,
    "maxHighlightDurationSeconds": 600,
    "includeThumbnail": true,
    "period": "LAST_WEEK",
    "sort": "VIEWS_DESC",
    "language": "",
    "minViews": 0,
    "maxItems": 1
};

// Run the Actor and wait for it to finish
const run = await client.actor("xyrelith-data/twitch-clip-highlight-mp4-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 = {
    "mode": "byUrls",
    "clipUrls": ["https://www.twitch.tv/xqc/clip/EagerMagnificentOpossumRaccAttack-Z_1cH-jBbf9w3u7C"],
    "channelLogins": [],
    "categoryNames": [],
    "highlightIds": [],
    "quality": "source",
    "saveToKeyValueStore": False,
    "maxFileSizeMB": 500,
    "maxHighlightDurationSeconds": 600,
    "includeThumbnail": True,
    "period": "LAST_WEEK",
    "sort": "VIEWS_DESC",
    "language": "",
    "minViews": 0,
    "maxItems": 1,
}

# Run the Actor and wait for it to finish
run = client.actor("xyrelith-data/twitch-clip-highlight-mp4-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 '{
  "mode": "byUrls",
  "clipUrls": [
    "https://www.twitch.tv/xqc/clip/EagerMagnificentOpossumRaccAttack-Z_1cH-jBbf9w3u7C"
  ],
  "channelLogins": [],
  "categoryNames": [],
  "highlightIds": [],
  "quality": "source",
  "saveToKeyValueStore": false,
  "maxFileSizeMB": 500,
  "maxHighlightDurationSeconds": 600,
  "includeThumbnail": true,
  "period": "LAST_WEEK",
  "sort": "VIEWS_DESC",
  "language": "",
  "minViews": 0,
  "maxItems": 1
}' |
apify call xyrelith-data/twitch-clip-highlight-mp4-downloader --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,xyrelith-data/twitch-clip-highlight-mp4-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/XtdHFubJRRIccMx6c/builds/7MucuI4BLsegk8aKi/openapi.json
