# Apify Tiktok Video Downloader (`paulwrsc/apify-tiktok-video-downloader`) Actor

- **URL**: https://apify.com/paulwrsc/apify-tiktok-video-downloader.md
- **Developed by:** [Paul Würschinger](https://apify.com/paulwrsc) (community)
- **Categories:** Social media, AI
- **Stats:** 1 total users, 0 monthly users, 0.0% runs succeeded, NaN bookmarks
- **User rating**: No ratings yet

## Pricing

from $10.00 / 1,000 results

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

## TikTok Video Scraper & Downloader — Apify Actor

A simple actor that collects metadata from public TikTok profiles and (optionally) saves video MP4 files to storage.

Use this actor to gather public video information from one or more TikTok profiles and — if enabled — to download the MP4 files for profiles you are allowed to access.

---

### Quick overview

- Input: one or more public TikTok profile URLs
- Output: dataset with one record per video (metadata). If downloads are enabled and succeed, each record will include a link to the saved MP4 file.
- Typical uses: data collection for research, archiving your own videos, or non-commercial analysis where you have the right to download content.

---

### How to run (Apify)

1. Open the actor in the Apify Console (or push it to your account).
2. Provide the input JSON (see example below).
3. Run the actor and inspect the dataset and key-value store results.

Example input (paste into the Apify run form):

```json
{
  "profileUrls": ["https://www.tiktok.com/@tiktok"],
  "limit": 5,
  "order": "desc",
  "downloadVideos": false
}
````

- `profileUrls`: required — list of public TikTok profile URLs
- `limit`: max number of videos to collect per profile (default: 10)
- `order`: `"desc"` (newest first) or `"asc"` (oldest first)
- `downloadVideos`: `true` or `false` — whether to save MP4 files

***

### Quick local run (for advanced users)

If you want to run the actor locally, you will need an environment with Node.js and the Apify CLI. Follow the project README or Apify documentation for local execution instructions.

***

### Output format

Each dataset record contains video metadata such as id, description, publish time, author, views/likes, and media info. When `downloadVideos` is enabled and an MP4 is successfully saved, the record includes:

- `storageKey`: internal key of the saved file
- `storageUrl`: direct link to the MP4 file in the actor's key-value store

Example (full):

```jsonc
{
  // Identifiers and text
  "id": "7380123456789012345",
  "text": "Check out this demo video! #example",
  "createTimeISO": "2024-04-25T10:30:00.000Z",

  // Author
  "author": {
    "name":   "tiktok",
    "avatar": "https://www.tiktok.com/@tiktok"   // channel URL, may be empty
  },

  // Statistics
  "playCount":    1234567,
  "diggCount":    54321,
  "commentCount": 987,
  "shareCount":   123,
  "collectCount": 0,            // always 0 (not provided by yt-dlp)

  // Video metadata
  "video": {
    "duration": 15,             // seconds
    "cover":    "https://p16-sign.tiktokcdn-us.com/cover/...",
    "width":    576,
    "height":   1024
  },

  // Music / sound
  "music": {
    "name":     "Original Sound",
    "author":   "tiktok",
    "original": true
  },

  // Page URL for the TikTok video (always present)
  "webVideoUrl": "https://www.tiktok.com/@tiktok/video/7380123456789012345",

  // ===== Fields added when downloadVideos === true and download succeeds =====
  "storageKey": "video-7380123456789012345.mp4",
  "storageUrl": "https://api.apify.com/v2/key-value-stores/<storeId>/records/video-7380123456789012345.mp4"
}
```

Notes about optional fields:

- `author.avatar`, `music.*`, and some numeric stats may be empty or zero if yt-dlp does not provide them for a particular video.
- `storageKey` and `storageUrl` appear only when `downloadVideos` is enabled and the MP4 download succeeded; otherwise those fields are omitted.
- Always validate presence of fields before using them in downstream processing.

***

### Policy (short)

Please read and follow these rules before using the actor:

- Respect TikTok's Terms of Service — automated scraping may violate their terms and can lead to bans or other penalties.
- Do not download or redistribute videos unless you have the rights or permission from the content owner.
- Use the actor only for lawful, ethical purposes (research, archiving your own content, or other permitted uses).

This actor is provided "as is". The maintainers are not responsible for legal consequences arising from misuse.

***

### Support & contributions

If you find issues or want to suggest improvements, open an issue or a pull request in the repository.

***

### License

MIT — see the `LICENSE` file for details.

# Actor input Schema

## `profileUrls` (type: `array`):

One or more TikTok profile URLs to scrape (e.g. https://www.tiktok.com/@username).

## `limit` (type: `integer`):

Maximum number of videos to retrieve per profile. Defaults to 10.

## `order` (type: `string`):

'desc' returns the newest videos first; 'asc' returns the oldest videos first. Defaults to 'desc'.

## `downloadVideos` (type: `boolean`):

When enabled, each MP4 is downloaded and saved to the Apify Key-Value Store. The public URL is added to the dataset record as 'storageUrl'.

## `tiktokSessionId` (type: `string`):

Your TikTok 'sessionid' cookie value. Required when running from datacenter IPs — without it TikTok may block video format requests. To get it: open TikTok in a browser → DevTools → Application → Cookies → copy the 'sessionid' value.

## Actor input object example

```json
{
  "profileUrls": [
    "https://www.tiktok.com/@tiktok"
  ],
  "limit": 10,
  "order": "desc",
  "downloadVideos": true
}
```

# Actor output Schema

## `dataset` (type: `string`):

Dataset containing one record per scraped TikTok video, including metadata and an optional MP4 download URL.

## `mp4Files` (type: `string`):

Key-Value Store entries for every video that was downloaded (only present when downloadVideos is enabled).

# 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 = {
    "profileUrls": [
        "https://www.tiktok.com/@tiktok"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("paulwrsc/apify-tiktok-video-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 = { "profileUrls": ["https://www.tiktok.com/@tiktok"] }

# Run the Actor and wait for it to finish
run = client.actor("paulwrsc/apify-tiktok-video-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 '{
  "profileUrls": [
    "https://www.tiktok.com/@tiktok"
  ]
}' |
apify call paulwrsc/apify-tiktok-video-downloader --silent --output-dataset

```

## MCP server setup

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

```

## OpenAPI specification

```json
{
    "openapi": "3.0.1",
    "info": {
        "title": "Apify Tiktok Video Downloader",
        "version": "0.0",
        "x-build-id": "4kPgpyrxdcUOF2ZWJ"
    },
    "servers": [
        {
            "url": "https://api.apify.com/v2"
        }
    ],
    "paths": {
        "/acts/paulwrsc~apify-tiktok-video-downloader/run-sync-get-dataset-items": {
            "post": {
                "operationId": "run-sync-get-dataset-items-paulwrsc-apify-tiktok-video-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/paulwrsc~apify-tiktok-video-downloader/runs": {
            "post": {
                "operationId": "runs-sync-paulwrsc-apify-tiktok-video-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/paulwrsc~apify-tiktok-video-downloader/run-sync": {
            "post": {
                "operationId": "run-sync-paulwrsc-apify-tiktok-video-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": [
                    "profileUrls"
                ],
                "properties": {
                    "profileUrls": {
                        "title": "TikTok Profile URLs",
                        "type": "array",
                        "description": "One or more TikTok profile URLs to scrape (e.g. https://www.tiktok.com/@username).",
                        "items": {
                            "type": "string"
                        }
                    },
                    "limit": {
                        "title": "Video Limit",
                        "minimum": 1,
                        "maximum": 100,
                        "type": "integer",
                        "description": "Maximum number of videos to retrieve per profile. Defaults to 10.",
                        "default": 10
                    },
                    "order": {
                        "title": "Sort Order",
                        "enum": [
                            "desc",
                            "asc"
                        ],
                        "type": "string",
                        "description": "'desc' returns the newest videos first; 'asc' returns the oldest videos first. Defaults to 'desc'.",
                        "default": "desc"
                    },
                    "downloadVideos": {
                        "title": "Download Videos",
                        "type": "boolean",
                        "description": "When enabled, each MP4 is downloaded and saved to the Apify Key-Value Store. The public URL is added to the dataset record as 'storageUrl'.",
                        "default": true
                    },
                    "tiktokSessionId": {
                        "title": "TikTok Session ID (optional)",
                        "type": "string",
                        "description": "Your TikTok 'sessionid' cookie value. Required when running from datacenter IPs — without it TikTok may block video format requests. To get it: open TikTok in a browser → DevTools → Application → Cookies → copy the 'sessionid' value."
                    }
                }
            },
            "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
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
```
