---
title: "Media Downloader API — YouTube, TikTok, Instagram & 1000+ sites, from $0.004 | APIMODELS"
description: "API reference for pulling videos, images, audio and subtitles from YouTube, TikTok, Instagram, X, Bilibili, Douyin and 1000+ sites: four synchronous endpoints, paginated channels, YouTube downloads up to 1080p, error codes. Failed requests are not charged; from $0.004 per request. cURL/Python/Node."
canonical: https://apimodels.app/docs/media-downloader
markdown: https://apimodels.app/docs/media-downloader.md
language: en
source: "Generated from the HTML docs page at the canonical URL; the HTML page is the source of truth. Docs index: https://apimodels.app/llms.txt"
---

[Docs](https://apimodels.app/docs) · Media Downloader API

# Media Downloader API

Turn a public post link from YouTube, TikTok, Instagram, Facebook, X, Xiaohongshu, Bilibili, Weibo, Douyin and 1000+ other sites into structured JSON and direct links to its videos, images and audio. Four synchronous endpoints: single post, page-by-page listing, subtitles and proxied YouTube downloads. Results come back in the same HTTP response; only successful requests are charged, from $0.004 per request.

## Basics

- Host: https://api.apimodels.app (https://apimodels.app/api/v1/media/... works too)
- Auth: Authorization: Bearer YOUR_API_KEY — the same key as every other model on apimodels.app.
- Request: POST with a JSON body; the only required field is url (http / https, up to 2048 characters).
- Synchronous: the result is in the response, usually within a few seconds; playlist pages can take longer. Give your client a generous timeout (for example 150 seconds). There is no task_id, no polling and no callback.
- Optional header Accept-Language: zh returns 400 error messages in Chinese.

## Endpoints & pricing

| Endpoint                        | What it does                                 | Price            |
| ------------------------------- | -------------------------------------------- | ---------------- |
| POST /v1/media/extract          | Extract a single post                        | $0.004 / request |
| POST /v1/media/playlist         | List a channel, profile, playlist or hashtag | $0.02 / page     |
| POST /v1/media/subtitles        | Get subtitles (YouTube, Bilibili)            | $0.004 / request |
| POST /v1/media/youtube-download | YouTube download links (proxied)             | $0.012 / request |

Only successful requests are charged; failures (400 / 429 / 502 / 503 / 504) cost nothing. The playlist endpoint returns one page per call and bills per page. Downloading the returned files — YouTube proxy links included — is not billed again.

## Quick start

cURL: extract one post. Python: extract → pick the best quality → download with the media headers → merge separate audio and video with ffmpeg. Node.js: walk a profile page by page with next_cursor.

```bash
curl https://api.apimodels.app/v1/media/extract \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "url": "https://www.tiktok.com/@creator/video/VIDEO_ID" }'
```

```python
import subprocess
import requests

API = "https://api.apimodels.app/v1/media/extract"
HEADERS = {"Authorization": "Bearer YOUR_API_KEY"}

resp = requests.post(API, headers=HEADERS, timeout=150,
                     json={"url": "https://www.youtube.com/watch?v=VIDEO_ID"})
body = resp.json()
if resp.status_code != 200:
    raise SystemExit(f"{resp.status_code} {body.get('error_code')} {body.get('msg')}")
print("cost:", resp.headers.get("x-apimodels-cost"))  # e.g. 0.004

video = next(m for m in body["data"]["medias"] if m["media_type"] == "video")
dl_headers = video.get("headers") or {}  # e.g. Referer — send it with every download

def download(url, path):
    # links are short-lived: download right away
    with requests.get(url, headers=dl_headers, stream=True, timeout=600) as r:
        r.raise_for_status()
        with open(path, "wb") as f:
            for chunk in r.iter_content(1 << 20):
                f.write(chunk)

variants = video.get("variants") or []
best = max(variants, key=lambda v: v.get("quality") or 0) if variants else None
if best and best.get("audio_url"):
    # separate video and audio tracks: fetch both, merge without re-encoding
    v_path = "video." + best.get("video_ext", "mp4")
    a_path = "audio." + best.get("audio_ext", "m4a")
    download(best["video_url"], v_path)
    download(best["audio_url"], a_path)
    subprocess.run(["ffmpeg", "-y", "-i", v_path, "-i", a_path, "-c", "copy", "out.mp4"], check=True)
else:
    download(best["video_url"] if best else video["resource_url"], "out.mp4")
```

```javascript
const API = "https://api.apimodels.app/v1/media/playlist";
const headers = { "Authorization": "Bearer YOUR_API_KEY", "Content-Type": "application/json" };

const posts = [];
let cursor;
for (let page = 0; page < 5; page++) {          // every page is one billed request
  const res = await fetch(API, {
    method: "POST",
    headers,
    body: JSON.stringify({ url: "https://www.tiktok.com/@creator", ...(cursor ? { cursor } : {}) }),
  });
  const body = await res.json();
  if (!res.ok) throw new Error(`${res.status} ${body.error_code ?? ""} ${body.msg}`);
  posts.push(...body.data.posts);
  if (!body.data.has_more) break;
  cursor = body.data.next_cursor;
}
console.log(posts.length, "posts");
```

## Response envelope and headers

A success returns { "code": 200, "msg": "success", "data": { ... } }. data.model is always media-downloader and data.endpoint names the endpoint (post / playlist / subtitles / youtube); the remaining fields are listed per endpoint below.

| Field                  | Required | Type   | Description                                                                        |
| ---------------------- | -------- | ------ | ---------------------------------------------------------------------------------- |
| x-apimodels-request-id | Yes      | header | The id of this request. GET /v1/records/{id} returns what it was billed.           |
| x-apimodels-cost       | No       | header | On success, the USD amount deducted for this request (after any account discount). |

## 1. POST /v1/media/extract

Extract a single post · $0.004 per request

One public post from 1000+ sites (YouTube, TikTok, Instagram, Facebook, X, Xiaohongshu, Bilibili, Weibo, Douyin and more). Short links such as youtu.be and vt.tiktok.com work as-is. Returns the caption, author, stats and every media file with its available qualities.

### Request

| Field | Required | Type   | Description                                                                             |
| ----- | -------- | ------ | --------------------------------------------------------------------------------------- |
| url   | Yes      | string | Link to one post. Short links (youtu.be, vt.tiktok.com and similar) are accepted as-is. |

```bash
curl https://api.apimodels.app/v1/media/extract \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "url": "https://www.tiktok.com/@creator/video/VIDEO_ID" }'
```

### Response example

Structure from a real call, values and links replaced with placeholders; fields a post does not have are omitted.

```json
{
  "code": 200,
  "msg": "success",
  "data": {
    "model": "media-downloader",
    "endpoint": "post",
    "site": "youtube",
    "id": "VIDEO_ID",
    "title": "Video title",
    "text": "Caption or description of the post",
    "post_url": "https://www.youtube.com/watch?v=VIDEO_ID",
    "author": { "username": "creator", "display_name": "Creator Name" },
    "stats": { "view_count": 1024 },
    "medias": [
      {
        "media_type": "video",
        "resource_url": "https://...",
        "preview_url": "https://...",
        "duration": 19,
        "variants": [
          {
            "quality": 1080,
            "quality_label": "1080p",
            "video_url": "https://...",
            "video_ext": "mp4",
            "video_filesize": 5242880,
            "audio_url": "https://...",
            "audio_ext": "m4a"
          },
          {
            "quality": 360,
            "quality_label": "360p",
            "video_url": "https://...",
            "video_ext": "mp4",
            "is_default": true
          }
        ]
      },
      {
        "media_type": "audio",
        "resource_url": "https://...",
        "duration": 19
      }
    ]
  }
}
```

### Response fields (data)

| Field        | Required | Type   | Description                                                         |
| ------------ | -------- | ------ | ------------------------------------------------------------------- |
| site         | Yes      | string | The platform the post came from, e.g. youtube.                      |
| id           | No       | string | The post id on that platform.                                       |
| title / text | No       | string | Title and caption or description, when the platform has them.       |
| post_url     | No       | string | Canonical link to the post.                                         |
| created_at   | No       | string | Publish time as the platform reports it; the format varies by site. |
| author       | No       | object | username and display_name (sometimes id).                           |
| stats        | No       | object | Counts the platform exposes, e.g. view_count.                       |
| medias\[\]   | Yes      | array  | One entry per file in the post; fields below.                       |

### medias\[\]

| Field        | Required | Type   | Description                                                                                                                                                                                                            |       |      |      |
| ------------ | -------- | ------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----- | ---- | ---- |
| media_type   | Yes      | string | video \| image                                                                                                                                                                                                         | audio | live | file |
| resource_url | No       | string | Direct link to the file. Short-lived — download right away.                                                                                                                                                            |       |      |      |
| preview_url  | No       | string | Cover or thumbnail image.                                                                                                                                                                                              |       |      |      |
| duration     | No       | number | Length in seconds, for video and audio.                                                                                                                                                                                |       |      |      |
| headers      | No       | object | Request headers to send when downloading this file (for example Referer). Present only when needed.                                                                                                                    |       |      |      |
| variants\[\] | No       | array  | Available qualities: quality (number, e.g. 1080), quality_label (e.g. "1080p"), video_url, video_ext, video_filesize (bytes, when known), audio_url / audio_ext (only when the audio is a separate track), is_default. |       |      |      |

## 2. POST /v1/media/playlist

List a channel, profile, playlist or hashtag · $0.02 per page

One page per call. Pass next_cursor back as cursor for the next page and stop when has_more is false. Supported: YouTube channels, Shorts, playlists and hashtags; Instagram profiles and hashtags; X; TikTok profiles and hashtags; Douyin; Bilibili; Weibo.

### Request

| Field  | Required | Type   | Description                                                              |
| ------ | -------- | ------ | ------------------------------------------------------------------------ |
| url    | Yes      | string | Link to a profile, channel, playlist or hashtag.                         |
| cursor | No       | string | The next_cursor from the previous page. Leave it out for the first page. |

```bash
curl https://api.apimodels.app/v1/media/playlist \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "url": "https://www.youtube.com/@channel/videos" }'
# next page: add  "cursor": "<next_cursor from the previous response>"
```

### Response example

```json
{
  "code": 200,
  "msg": "success",
  "data": {
    "model": "media-downloader",
    "endpoint": "playlist",
    "site": "youtube",
    "profile": { "username": "@channel" },
    "posts": [
      {
        "id": "VIDEO_ID",
        "title": "Video title",
        "created_at": "3 days ago",
        "medias": [
          {
            "media_type": "video",
            "resource_url": "https://...",
            "preview_url": "https://...",
            "duration": 1215
          }
        ]
      }
    ],
    "has_more": true,
    "next_cursor": "NEXT_CURSOR"
  }
}
```

### Response fields (data)

| Field       | Required | Type    | Description                                                                                                                                                                     |
| ----------- | -------- | ------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| site        | Yes      | string  | The platform.                                                                                                                                                                   |
| posts\[\]   | Yes      | array   | The posts on this page, shaped like a single-post result but usually with fewer fields (for example no variants). For every quality of one entry, call /v1/media/extract on it. |
| has_more    | Yes      | boolean | Whether another page exists.                                                                                                                                                    |
| next_cursor | No       | string  | The cursor for the next page.                                                                                                                                                   |
| profile     | No       | object  | username, display_name, avatar_url, post_count — whichever the platform provides.                                                                                               |

Paging: send the same url again with cursor, until has_more is false. Every page is a $0.02 request, so a page limit in your loop doubles as a spending limit.

## 3. POST /v1/media/subtitles

Get subtitles (YouTube, Bilibili) · $0.004 per request

Every subtitle track on a YouTube or Bilibili video. YouTube offers srt, vtt and json3; Bilibili returns json (BCC). Auto-generated tracks say "(auto-generated)" in language_name. Links are short-lived (Bilibili about 30 minutes).

### Request

| Field | Required | Type   | Description                       |
| ----- | -------- | ------ | --------------------------------- |
| url   | Yes      | string | A YouTube or Bilibili video link. |

```bash
curl https://api.apimodels.app/v1/media/subtitles \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "url": "https://www.youtube.com/watch?v=VIDEO_ID" }'
```

### Response example

```json
{
  "code": 200,
  "msg": "success",
  "data": {
    "model": "media-downloader",
    "endpoint": "subtitles",
    "site": "youtube",
    "id": "VIDEO_ID",
    "title": "Video title",
    "duration": 19,
    "thumbnail_url": "https://...",
    "subtitles": [
      {
        "language_name": "English",
        "language_tag": "en",
        "urls": [
          { "format": "srt", "url": "https://..." },
          { "format": "vtt", "url": "https://..." },
          { "format": "json3", "url": "https://..." }
        ]
      }
    ]
  }
}
```

### Response fields (data)

| Field             | Required | Type   | Description                                                                                                                          |
| ----------------- | -------- | ------ | ------------------------------------------------------------------------------------------------------------------------------------ |
| site / id / title | No       | string | Platform, video id and title.                                                                                                        |
| duration          | No       | number | Video length in seconds.                                                                                                             |
| thumbnail_url     | No       | string | Thumbnail image.                                                                                                                     |
| subtitles\[\]     | Yes      | array  | One entry per track: language_name (auto-generated tracks say "(auto-generated)"), language_tag (e.g. en), urls\[\] { format, url }. |

Formats: YouTube offers srt, vtt and json3; Bilibili returns json (BCC). Subtitle links are short-lived — about 30 minutes on Bilibili — so fetch them right away.

## 4. POST /v1/media/youtube-download

YouTube download links (proxied) · $0.012 per request

YouTube files served through a temporary proxy: resource_proxy_url is a complete lower-quality file or the audio, variants carry video_proxy_url / audio_proxy_url up to 1080p (separate tracks to merge). Links last at most 1 hour and support HTTP Range, so downloads can resume. Not available for files over 3 GiB.

### Request

| Field | Required | Type   | Description                     |
| ----- | -------- | ------ | ------------------------------- |
| url   | Yes      | string | A youtube.com or youtu.be link. |

```bash
curl https://api.apimodels.app/v1/media/youtube-download \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "url": "https://youtu.be/VIDEO_ID" }'
```

### Response example

```json
{
  "code": 200,
  "msg": "success",
  "data": {
    "model": "media-downloader",
    "endpoint": "youtube",
    "site": "youtube",
    "id": "VIDEO_ID",
    "title": "Video title",
    "medias": [
      {
        "media_type": "video",
        "duration": 19,
        "resource_proxy_url": "https://...",
        "variants": [
          {
            "quality": 1080,
            "quality_label": "1080p",
            "video_ext": "mp4",
            "video_proxy_url": "https://...",
            "audio_ext": "m4a",
            "audio_proxy_url": "https://..."
          }
        ]
      }
    ]
  }
}
```

### What differs from extract

| Field                         | Required | Type   | Description                                                                  |
| ----------------------------- | -------- | ------ | ---------------------------------------------------------------------------- |
| medias\[\].resource_proxy_url | No       | string | A complete lower-quality file, or the audio.                                 |
| variants\[\].video_proxy_url  | No       | string | The video track for that quality, up to 1080p.                               |
| variants\[\].audio_proxy_url  | No       | string | The matching audio track; merge it with the video track for a complete file. |

- Proxy links last at most 1 hour and support HTTP Range, so interrupted downloads can resume; downloading them costs nothing extra.
- Files over 3 GiB are not available through the proxy.
- When no proxied file is available you get a 503 with error_code proxy_unavailable — not charged, and safe to retry.

## Errors

| HTTP            | Meaning                                                                                                                                                                 | Charged | What to do                                                     |
| --------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------- | -------------------------------------------------------------- |
| 400             | The content cannot be fetched or the request is wrong: error_code such as content_deleted, unsupported_site or invalid_url; a missing or non-http(s) url is also a 400. | No      | Check retryable: true means retry, false means change the link |
| 401             | Missing or invalid API key                                                                                                                                              | No      | Check the Authorization header                                 |
| 402             | Insufficient credits                                                                                                                                                    | No      | Top up and retry                                               |
| 429             | Rate limited                                                                                                                                                            | No      | Wait briefly and retry                                         |
| 502 / 503 / 504 | Temporary error or timeout (youtube-download’s proxy_unavailable is a 503 too)                                                                                          | No      | Retry                                                          |

A 400 body:

```json
{
  "code": 400,
  "msg": "This content has been deleted or doesn't exist.",
  "error_code": "content_deleted",
  "retryable": false
}
```

## Billing

- Failed requests are not charged — none of the errors above cost anything.
- Successful requests are billed per endpoint: extract $0.004 per request, subtitles $0.004 per request, playlist $0.02 per page, youtube-download $0.012 per request.
- Every response carries x-apimodels-request-id; GET /v1/records/{id} returns the exact amount billed for that request, for line-by-line reconciliation.
- Shares one balance and one API key with the 180+ other models on apimodels.app.

[Per-request billing lookup →](https://apimodels.app/docs/records)

## Download tips

- Links are short-lived: download right away, and store the files rather than the links.
- When a media item has headers (for example Referer), send them with the download — the file host may refuse the request otherwise.
- A variant with both video_url and audio_url has separate tracks: download both, then merge them without re-encoding:

```
ffmpeg -i video.mp4 -i audio.m4a -c copy out.mp4
```

Use the extensions from video_ext / audio_ext; if the video is webm, write out.mkv instead. A variant with only video_url is already a complete file and needs no merging.

## Usage policy

Only download content you own or have permission to use, and respect each platform's terms and copyright.

Related: [Model page](https://apimodels.app/models/media-downloader)[Per-request billing](https://apimodels.app/docs/records)[Account balance](https://apimodels.app/docs/account)

## FAQ

**How do I download a TikTok or YouTube video with an API?**

POST {"url": "<post link>"} to https://api.apimodels.app/v1/media/extract with Authorization: Bearer <API key>. The answer is synchronous: data.medias\[\] holds each file with a resource_url and, for videos, variants\[\] per quality. Download the file you want right away and send medias\[\].headers with it when present. For YouTube links up to 1080p that can resume after a dropped connection, call /v1/media/youtube-download instead ($0.012 per request); extract is $0.004 per request.

**How do I get every post from a channel or profile?**

Call /v1/media/playlist with the channel, profile, playlist or hashtag URL, then call it again with "cursor" set to next_cursor until has_more is false. Each call returns one page and costs $0.02. Page entries carry fewer fields than a single-post result, so call /v1/media/extract ($0.004) on a post when you need all of its qualities.

**How do I download YouTube subtitles as SRT through an API?**

POST the video link to /v1/media/subtitles ($0.004 per request). Each track in data.subtitles\[\] lists urls\[\] by format: srt, vtt or json3 on YouTube, json (BCC) on Bilibili. Auto-generated tracks say "(auto-generated)" in language_name. Fetch the file right away, because the links expire (about 30 minutes on Bilibili).

**Which errors are charged, and which ones should I retry?**

None of them are charged. A 400 carries an error_code (content_deleted, unsupported_site, invalid_url) and a retryable flag; retry only when retryable is true. 429 and 502 / 503 / 504 are temporary, so retry after a short wait, including a youtube-download 503 with error_code proxy_unavailable. 401 means the API key is missing or wrong, 402 means the balance is too low.
